#include <itkSmartPointerVectorContainer.h>
difference: we handle smart pointers
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface. This is a full-fleged Object, so there is modification time, debug, and reference count information.
Template parameters for SmartPointerVectorContainer:
TElementIdentifier = An INTEGRAL type for use in indexing the vector.
TElement = The element type stored in the container.
Definition at line 60 of file itkSmartPointerVectorContainer.h.
typedef const TElement itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::ConstElement |
Definition at line 74 of file itkSmartPointerVectorContainer.h.
typedef const itk::SmartPointer<const Element> itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::ConstElementPointer |
Definition at line 76 of file itkSmartPointerVectorContainer.h.
typedef SmartPointer<const Self> itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::ConstPointer |
Definition at line 69 of file itkSmartPointerVectorContainer.h.
typedef TElement itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Element |
Definition at line 73 of file itkSmartPointerVectorContainer.h.
typedef TElementIdentifier itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::ElementIdentifier |
Save the template parameters.
Definition at line 72 of file itkSmartPointerVectorContainer.h.
typedef itk::SmartPointer<Element> itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::ElementPointer |
Definition at line 75 of file itkSmartPointerVectorContainer.h.
typedef SmartPointer<Self> itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Pointer |
Definition at line 68 of file itkSmartPointerVectorContainer.h.
typedef SmartPointerVectorContainer itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Self |
Standard class typedefs.
Definition at line 66 of file itkSmartPointerVectorContainer.h.
typedef VectorType itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::STLContainerType |
This type is provided to Adapt this container as an STL container
Definition at line 104 of file itkSmartPointerVectorContainer.h.
typedef Object itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Superclass |
Definition at line 67 of file itkSmartPointerVectorContainer.h.
itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::SmartPointerVectorContainer | ( | ) | [inline, protected] |
Provide pass-through constructors corresponding to all the STL vector constructors. These are for internal use only since this is also an Object which must be constructed through the "New()" routine.
Definition at line 89 of file itkSmartPointerVectorContainer.h.
: Object(), VectorType() {}
itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::SmartPointerVectorContainer | ( | size_type | n ) | [inline, protected] |
Definition at line 91 of file itkSmartPointerVectorContainer.h.
: Object(), VectorType(n) {}
itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::SmartPointerVectorContainer | ( | size_type | n, |
const Element & | x | ||
) | [inline, protected] |
Definition at line 93 of file itkSmartPointerVectorContainer.h.
: Object(), VectorType(n, x) {}
itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::SmartPointerVectorContainer | ( | const Self & | r ) | [inline, protected] |
Definition at line 95 of file itkSmartPointerVectorContainer.h.
: Object(), VectorType(r) {}
itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::SmartPointerVectorContainer | ( | InputIterator | first, |
InputIterator | last | ||
) | [inline, protected] |
Definition at line 98 of file itkSmartPointerVectorContainer.h.
: Object(), VectorType(first, last) {}
SmartPointerVectorContainer< TElementIdentifier, TElement >::ConstIterator itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Begin | ( | void | ) | const |
Get a begin const iterator for the vector.
Definition at line 215 of file itkSmartPointerVectorContainer.txx.
{ return ConstIterator(0, this, this->VectorType::begin()); }
SmartPointerVectorContainer< TElementIdentifier, TElement >::Iterator itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Begin | ( | void | ) |
Get a begin iterator for the vector.
Definition at line 239 of file itkSmartPointerVectorContainer.txx.
{ return Iterator(0, this, this->VectorType::begin()); }
const STLContainerType& itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::CastToSTLConstContainer | ( | ) | const [inline] |
Cast the container to a const STL container type
Definition at line 121 of file itkSmartPointerVectorContainer.h.
{ return dynamic_cast<const STLContainerType &>(*this); }
STLContainerType& itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::CastToSTLContainer | ( | ) | [inline] |
Cast the container to a STL container type
Definition at line 117 of file itkSmartPointerVectorContainer.h.
{ return dynamic_cast<STLContainerType &>(*this); }
SmartPointerVectorContainer< TElementIdentifier, TElement >::ElementPointer & itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::CreateElementAt | ( | ElementIdentifier | id ) |
Get a reference to the element at the given index. If the element location does not exist, it will be created with a default element value.
It is assumed that the value of the element is modified through the reference.
Definition at line 69 of file itkSmartPointerVectorContainer.txx.
{ if(id >= this->VectorType::size()) { this->CreateIndex(id); } this->Modified(); return this->VectorType::operator[](id); }
void itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::CreateIndex | ( | ElementIdentifier | id ) |
Make sure that the index range of the STL vector is large enough to allow the given index, expanding it if necessary. The index will contain the default element regardless of whether expansion occured.
The vector must be expanded to fit the new id.
No expansion was necessary. Just overwrite the index's entry with the default element.
Definition at line 172 of file itkSmartPointerVectorContainer.txx.
{ if(id >= static_cast<ElementIdentifier>(this->VectorType::size())) { this->VectorType::resize(id+1); this->Modified(); } else if(id > 0) { this->VectorType::operator[](id) = NULL; this->Modified(); } }
void itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::DeleteIndex | ( | ElementIdentifier | id ) |
It doesn't make sense to delete a vector index. Instead, just overwrite the index with the default element.
Definition at line 202 of file itkSmartPointerVectorContainer.txx.
{
this->VectorType::operator[](id) = NULL;
this->Modified();
}
SmartPointerVectorContainer< TElementIdentifier, TElement >::ElementPointer & itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::ElementAt | ( | ElementIdentifier | id ) |
Declare the public interface routines.
Get a reference to the element at the given index. It is assumed that the index exists, and it will not automatically be created.
It is assumed that the value of the element is modified through the reference.
Definition at line 37 of file itkSmartPointerVectorContainer.txx.
{ this->Modified(); return this->VectorType::operator[](id); }
const SmartPointerVectorContainer< TElementIdentifier, TElement >::ConstElementPointer itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::ElementAt | ( | ElementIdentifier | id ) | const |
Get a reference to the element at the given index. It is assumed that the index exists, and it will not automatically be created.
Definition at line 52 of file itkSmartPointerVectorContainer.txx.
{ return ConstElementPointer(this->VectorType::operator[](id)); }
SmartPointerVectorContainer< TElementIdentifier, TElement >::ConstIterator itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::End | ( | void | ) | const |
Get an end const iterator for the vector.
Definition at line 227 of file itkSmartPointerVectorContainer.txx.
{ return ConstIterator(this->VectorType::size()-1, this, this->VectorType::end()); }
SmartPointerVectorContainer< TElementIdentifier, TElement >::Iterator itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::End | ( | void | ) |
Get an end iterator for the vector.
Definition at line 251 of file itkSmartPointerVectorContainer.txx.
{ return Iterator(this->VectorType::size()-1, this, this->VectorType::end()); }
virtual const char* itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::GetClassName | ( | ) | const [virtual] |
Standard part of every itk Object.
const SmartPointerVectorContainer< TElementIdentifier, TElement >::ConstElementPointer itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::GetElement | ( | ElementIdentifier | id ) | const |
Read the element from the given index. It is assumed that the index exists.
Definition at line 87 of file itkSmartPointerVectorContainer.txx.
{ return ConstElementPointer(this->VectorType::operator[](id).GetPointer()); }
bool itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::GetElementIfIndexExists | ( | ElementIdentifier | id, |
Element ** | element | ||
) | const |
Check if the given index is in range of the STL vector. If it is not, return false. Otherwise, set the element through the pointer (if it isn't NULL), and return true.
Definition at line 149 of file itkSmartPointerVectorContainer.txx.
{ if (NumericTraits<ElementIdentifier>::IsNonnegative(id) && (id < this->VectorType::size())) { if(element) { *element = this->VectorType::operator[](id).GetPointer(); } return true; } return false; }
bool itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::IndexExists | ( | ElementIdentifier | id ) | const |
Check if the index range of the STL vector is large enough to allow the given index without expansion.
Definition at line 133 of file itkSmartPointerVectorContainer.txx.
{ return (NumericTraits<ElementIdentifier>::IsNonnegative(id) && (id < this->VectorType::size())); }
void itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Initialize | ( | void | ) |
Clear the elements. The final size will be zero.
Definition at line 275 of file itkSmartPointerVectorContainer.txx.
{ this->VectorType::clear(); }
void itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::InsertElement | ( | ElementIdentifier | id, |
Element * | element | ||
) |
Set the element value at the given index. If the element location does not exist, it will be created with a default element value.
Definition at line 115 of file itkSmartPointerVectorContainer.txx.
{ if(id >= static_cast<ElementIdentifier>(this->VectorType::size())) { this->CreateIndex(id); } this->VectorType::operator[](id) = element; this->Modified(); }
static Pointer itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::New | ( | ) | [static] |
Method for creation through the object factory.
void itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Reserve | ( | ElementIdentifier | size ) |
Tell the container to allocate enough memory to allow at least as many elements as the size given to be stored. This is NOT guaranteed to actually allocate any memory, but is useful if the implementation of the container allocates contiguous storage.
Definition at line 291 of file itkSmartPointerVectorContainer.txx.
{ this->CreateIndex(size-1); }
void itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::SetElement | ( | ElementIdentifier | id, |
Element * | element | ||
) |
Set the element value at the given index. It is assumed that the index exists.
Definition at line 100 of file itkSmartPointerVectorContainer.txx.
{
this->VectorType::operator[](id) = element;
this->Modified();
}
unsigned long itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Size | ( | void | ) | const |
Get the number of elements currently stored in the vector.
Definition at line 263 of file itkSmartPointerVectorContainer.txx.
{ return static_cast<unsigned long>( this->VectorType::size() ); }
void itk::SmartPointerVectorContainer< TElementIdentifier, TElement >::Squeeze | ( | void | ) |
Tell the container to try to minimize its memory usage for storage of the current number of elements. This is NOT guaranteed to decrease memory usage.
Definition at line 305 of file itkSmartPointerVectorContainer.txx.
{ }
friend class ConstIterator [friend] |
Definition at line 126 of file itkSmartPointerVectorContainer.h.
friend class Iterator [friend] |
Friends to this class.
Definition at line 125 of file itkSmartPointerVectorContainer.h.