Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::genstruct::Vector< T > Class Template Reference

#include <elm/genstruct/Vector.h>

Classes

class  Iterator
 

Public Member Functions

 Vector (int _cap=8)
 
 Vector (const Vector< T > &vec)
 
 ~Vector (void)
 
int count (void) const
 
int length (void) const
 
int capacity (void) const
 
bool isEmpty (void) const
 
const T & get (int index) const
 
T & item (int index)
 
void set (int index, const T value)
 
T & operator[] (int index)
 
const T & operator[] (int index) const
 
bool contains (const T &value) const
 
template<template< class _ > class C>
bool containsAll (const C< T > &items)
 
int indexOf (const T &value, int start=0) const
 
int lastIndexOf (const T &value, int start=-1) const
 
 operator bool (void) const
 
bool operator== (const Vector< T > &v) const
 
bool operator!= (const Vector< T > &v) const
 
const T & first (void) const
 
const T & last (void) const
 
Iterator find (const T &item)
 
Iterator find (const T &item, const Iterator &start)
 
const T & top (void) const
 
void add (void)
 
void add (const T &value)
 
template<template< class _ > class C>
void addAll (const C< T > &items)
 
void removeAt (int index)
 
void remove (const T &value)
 
void remove (const Iterator &iter)
 
template<template< class _ > class C>
void removeAll (const C< T > &items)
 
void insert (int index, const T &value)
 
void clear (void)
 
void grow (int new_cap)
 
void setLength (int new_length)
 
table< T > detach (void)
 
void copy (const Vector &vec)
 
Vector< T > & operator= (const Vector &vec)
 
void swallow (Vector< T > &v)
 
void insert (const T &item)
 
void push (const T &value)
 
const T pop (void)
 
void addFirst (const T &item)
 
void addLast (const T &item)
 
void removeFirst (void)
 
void removeLast (void)
 
void set (const Iterator &pos, const T &item)
 
void addAfter (const Iterator &pos, const T &item)
 
void addBefore (const Iterator &pos, const T &item)
 

Detailed Description

template<class T>
class elm::genstruct::Vector< T >

A vector is an array of items whose size grows dynamically.

Implemented concepts
Parameters
TType of stored items.

Constructor & Destructor Documentation

template<class T>
elm::genstruct::Vector< T >::Vector ( int  _cap = 8)

Build a new vector.

Parameters
_capCapacity represents the initial and growing size of the fector.
template<class T>
elm::genstruct::Vector< T >::Vector ( const Vector< T > &  vec)

Build a vector by copying an existing one.

Parameters
vecVector to copy.
template<class T>
elm::genstruct::Vector< T >::~Vector ( void  )

Delete the vector and all its contained items.

Member Function Documentation

template<class T>
void elm::genstruct::Vector< T >::add ( const T &  value)

References elm::value().

template<class T>
void elm::genstruct::Vector< T >::addAfter ( const Iterator pos,
const T &  item 
)
template<class T>
template<template< class _ > class C>
void elm::genstruct::Vector< T >::addAll ( const C< T > &  items)
template<class T>
void elm::genstruct::Vector< T >::addBefore ( const Iterator pos,
const T &  item 
)
template<class T>
void elm::genstruct::Vector< T >::addFirst ( const T &  item)
template<class T>
void elm::genstruct::Vector< T >::addLast ( const T &  item)
template<class T >
int elm::genstruct::Vector< T >::capacity ( void  ) const

Get the capacity of the vector.

Returns
Vector capacity.
template<class T>
void elm::genstruct::Vector< T >::clear ( void  )

Remove all items from the vector.

Referenced by elm::xom::Nodes::operator=().

template<class T>
bool elm::genstruct::Vector< T >::contains ( const T &  value) const

Test if the given value is already in the vector.

Parameters
valueValue to look for.
Returns
True if the value is int he vector, false else.

Referenced by elm::xom::Nodes::contains(), and elm::genstruct::Vector< elm::xom::Node * >::containsAll().

template<class T>
template<template< class _ > class C>
bool elm::genstruct::Vector< T >::containsAll ( const C< T > &  items)
template<class T >
void elm::genstruct::Vector< T >::copy ( const Vector< T > &  vec)

Copy the given vector in the current one.

Parameters
vecVector to copy.

Referenced by elm::genstruct::Vector< elm::xom::Node * >::operator=(), and elm::genstruct::Vector< elm::xom::Node * >::Vector().

template<class T >
table< T > elm::genstruct::Vector< T >::detach ( void  )
template<class T>
Iterator elm::genstruct::Vector< T >::find ( const T &  item)
template<class T>
Iterator elm::genstruct::Vector< T >::find ( const T &  item,
const Iterator start 
)
template<class T>
const T& elm::genstruct::Vector< T >::first ( void  ) const
template<class T >
T elm::genstruct::Vector< T >::get ( int  index) const

Get an item from the vector.

Parameters
indexIndex of the item to get.
Returns
Item at the given index.
Attention
It is an error to give an index higher or equal than the vector length().
template<class T >
void elm::genstruct::Vector< T >::grow ( int  new_cap)

Enlarge the vector with the given capacity.

Parameters
new_capSize for enlarging the vector.
template<class T>
int elm::genstruct::Vector< T >::indexOf ( const T &  value,
int  start = 0 
) const

Compute the first index of the value in the vector.

Parameters
valueValue to look for.
startStart index for looking the value for.
Returns
Index of the value in the vector or -1.
Attention
It is an error to give an index higher or equal than the vector length().

Referenced by elm::genstruct::Vector< elm::xom::Node * >::remove().

template<class T>
void elm::genstruct::Vector< T >::insert ( const T &  item)
template<class T>
bool elm::genstruct::Vector< T >::isEmpty ( void  ) const

Test if vector is empty.

Returns
True if vector is empty, false else.
template<class T >
T & elm::genstruct::Vector< T >::item ( int  index)

Get a reference to an item in the vector, allowing to change the item.

Parameters
indexIndex of the item to get.
Returns
Reference to the item at the given index.
Attention
It is an error to give an index higher or equal than the vector length().

Referenced by elm::genstruct::Vector< elm::xom::Node * >::addAll(), elm::genstruct::Vector< elm::xom::Node * >::containsAll(), elm::genstruct::Vector< elm::xom::Node * >::operator[](), elm::genstruct::Vector< elm::xom::Node * >::removeAll(), and elm::genstruct::Vector< elm::xom::Node * >::set().

template<class T>
const T& elm::genstruct::Vector< T >::last ( void  ) const
template<class T>
int elm::genstruct::Vector< T >::lastIndexOf ( const T &  value,
int  start = -1 
) const

Compute the last index of the value in the vector.

Parameters
valueValue to look for.
startStart index for looking the value for.
Returns
Index of the value in the vector or -1.
Attention
It is an error to give an index higher or equal than the vector length().
template<class T>
int elm::genstruct::Vector< T >::length ( void  ) const

Get the number of items in the vector.

Returns
Items number.

Referenced by elm::genstruct::Vector< elm::xom::Node * >::operator==(), and elm::AbstractBlockAllocatorWithGC::totalCount().

template<class T>
elm::genstruct::Vector< T >::operator bool ( void  ) const

Same as isEmpty().

template<class T>
bool elm::genstruct::Vector< T >::operator!= ( const Vector< T > &  v) const
template<class T>
Vector< T > & elm::genstruct::Vector< T >::operator= ( const Vector< T > &  vec)

Shortcut to copy().

template<class T>
bool elm::genstruct::Vector< T >::operator== ( const Vector< T > &  v) const
template<class T>
T & elm::genstruct::Vector< T >::operator[] ( int  index)

Same as item(int).

template<class T>
T elm::genstruct::Vector< T >::operator[] ( int  index) const

Same as item(int) const.

template<class T>
void elm::genstruct::Vector< T >::remove ( const T &  value)

Referenced by elm::xom::Nodes::remove().

template<class T>
void elm::genstruct::Vector< T >::remove ( const Iterator iter)
template<class T>
template<template< class _ > class C>
void elm::genstruct::Vector< T >::removeAll ( const C< T > &  items)
template<class T >
void elm::genstruct::Vector< T >::removeAt ( int  index)

Remove the value at the given index. Values past the index are shifted to the left.

Parameters
indexIndex of the value to remove.
Attention
It is an error to give an index higher or equal than the vector length().

Referenced by elm::genstruct::Vector< elm::xom::Node * >::remove(), elm::genstruct::Vector< elm::xom::Node * >::removeFirst(), and elm::genstruct::Vector< elm::xom::Node * >::removeLast().

template<class T>
void elm::genstruct::Vector< T >::removeFirst ( void  )
template<class T>
void elm::genstruct::Vector< T >::removeLast ( void  )
template<class T>
void elm::genstruct::Vector< T >::set ( int  index,
const T  value 
)

Change the value of the item at the given index.

Parameters
indexIndex of item to set.
valueValue to replace the item.
Attention
It is an error to give an index higher or equal than the vector length().

References elm::value().

template<class T>
void elm::genstruct::Vector< T >::set ( const Iterator pos,
const T &  item 
)
template<class T >
void elm::genstruct::Vector< T >::setLength ( int  new_length)

Set the length of the vector.

Parameters
new_lengthNew length of the vector (must be less or equal to the current length of the vector).
template<class T>
void elm::genstruct::Vector< T >::swallow ( Vector< T > &  v)
template<class T>
const T elm::genstruct::Vector< T >::top ( void  ) const

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