Vector< T > Class Template Reference
[Collections]

A dynamically sized vector template. More...

#include <Vector.h>

Inheritance diagram for Vector< T >:
IEnumerable< T > IMemoryValidate

List of all members.

Classes

class  Iterator

Public Member Functions

 Vector (int count=10)
 constructor.
 Vector (const Vector &v)
Vectoroperator= (const Vector &v)
Iterator Begin () const
void Add (T item)
 Add an item.
void AddRange (const Array< T > &a, const int offset, const int len)
void AddRange (const Array< T > &a, const int len)
void AddRange (const Array< T > &a)
void AddRange (const Vector< T > &v)
void AddRangeWithPad (const Array< T > &a, int count)
void AddRangeWithLeadingPad (Array< T > &a, int count)
void SetElementAt (T item, int pos)
 Set an element of the array.
void Insert (T item, int pos)
 Insert an item into the array.
ElementAt (const int pos) const
 Get an element.
T & ElementAtRef (const int pos) const
 Get a reference to an element.
RemoveAt (const int pos)
 Remove the element at the index.
T & operator[] (const int idx) const
void Remove (const T &item)
 Remove the specified item.
Pop ()
 Removes that last (highest index) element.
Peek () const
 Returns that last (highest index) element.
T & PeekRef () const
 Returns that last (highest index) element.
void Clear ()
 Resets the vector count to zero.
int Count () const
 Number of elements in the vector.
Vector< T > * Copy () const
 Shallow copy of the vector.
T * Data ()
 Internal data pointer.
void EnsureElementTo (int size)
 Ensure the vector has a minimum number of elements.
void SetCount (int cnt)
RefCountPtr< Array< T > > ToArray () const
RefCountPtr< Array< T > > ToArray (int count) const
void CheckMem () const
void ValidateMem () const

Protected Member Functions

virtual RefCountPtr< IIterator
< T > > 
IteratorPtr ()
void ExtendTo (int index)
void Extend (int newlen)

Protected Attributes

T * m_data
int m_pos
int m_size

Detailed Description

template<typename T>
class Vector< T >

A dynamically sized vector template.

Both native and class types (with copy constructors) can be used.

Definition at line 41 of file Vector.h.


Constructor & Destructor Documentation

template<typename T>
Vector< T >::Vector ( int  count = 10  )  [inline]

constructor.

Definition at line 103 of file Vector.h.


Member Function Documentation

template<typename T>
void Vector< T >::Add ( item  )  [inline]

Add an item.

Parameters:
item[in] of type T
Exceptions:
OutOfMemoryException 

Definition at line 164 of file Vector.h.

Referenced by Vector< Decimal >::Copy(), Uri::Parse(), CommandLine::Parse(), and XPathLex::Tokenize().

template<typename T>
void Vector< T >::Clear (  )  [inline]

Resets the vector count to zero.

Does not deallocate or clear any vector elements.

Definition at line 393 of file Vector.h.

Referenced by XPathLex::Tokenize().

template<typename T>
Vector<T>* Vector< T >::Copy (  )  const [inline]

Shallow copy of the vector.

Exceptions:
OutOfMemoryException 

Definition at line 410 of file Vector.h.

template<typename T>
int Vector< T >::Count (  )  const [inline]

Number of elements in the vector.

Definition at line 401 of file Vector.h.

Referenced by Vector< Decimal >::Copy(), Vector< Decimal >::EnsureElementTo(), and Vector< Decimal >::Remove().

template<typename T>
T* Vector< T >::Data (  )  [inline]

Internal data pointer.

Definition at line 424 of file Vector.h.

template<typename T>
T Vector< T >::ElementAt ( const int  pos  )  const [inline]

Get an element.

Parameters:
pos[in] Index in the vector.
Returns:
T

Definition at line 277 of file Vector.h.

Referenced by Vector< Decimal >::Copy(), Vector< Decimal >::Remove(), and Vector< Decimal >::RemoveAt().

template<typename T>
T& Vector< T >::ElementAtRef ( const int  pos  )  const [inline]

Get a reference to an element.

Parameters:
pos[in] Index in the vector.
Returns:
T

Definition at line 294 of file Vector.h.

template<typename T>
void Vector< T >::EnsureElementTo ( int  size  )  [inline]

Ensure the vector has a minimum number of elements.

Parameters:
size[in] The minimum number of elements.

Definition at line 430 of file Vector.h.

template<typename T>
void Vector< T >::Insert ( item,
int  pos 
) [inline]

Insert an item into the array.

If necessary, the vector is automatically extended. All existing items are preserved.

Parameters:
item[in] of type T.
pos[in] Index in the vector.
Exceptions:
OutOfMemoryException 

Definition at line 259 of file Vector.h.

template<typename T>
T Vector< T >::Peek (  )  const [inline]

Returns that last (highest index) element.

Definition at line 366 of file Vector.h.

template<typename T>
T& Vector< T >::PeekRef (  )  const [inline]

Returns that last (highest index) element.

Definition at line 379 of file Vector.h.

template<typename T>
T Vector< T >::Pop (  )  [inline]

Removes that last (highest index) element.

Definition at line 353 of file Vector.h.

template<typename T>
void Vector< T >::Remove ( const T &  item  )  [inline]

Remove the specified item.

Search for item and remove it. No error if item is not in the vector.

Parameters:
item[in] The item to remove.

Definition at line 337 of file Vector.h.

template<typename T>
T Vector< T >::RemoveAt ( const int  pos  )  [inline]

Remove the element at the index.

No error if pos is greater than the vector length.

Parameters:
pos[in] Vector index.

Definition at line 311 of file Vector.h.

Referenced by Vector< Decimal >::Remove().

template<typename T>
void Vector< T >::SetElementAt ( item,
int  pos 
) [inline]

Set an element of the array.

If necessary, the vector is automatically extended.

Parameters:
item[in] of type T.
pos[in] The index to set.
Exceptions:
OutOfMemoryException 

Definition at line 239 of file Vector.h.


Member Data Documentation

template<typename T>
int Vector< T >::m_pos [protected]
template<typename T>
int Vector< T >::m_size [protected]

The documentation for this class was generated from the following file: