Public Member Functions | Private Member Functions | Private Attributes | Friends

alize::RefVector< T > Class Template Reference

#include <RefVector.h>

Inheritance diagram for alize::RefVector< T >:
Inheritance graph
[legend]
Collaboration diagram for alize::RefVector< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RefVector (unsigned long capacity=1)
 RefVector (const RefVector< T > &v)
const RefVector< T > & operator= (const RefVector< T > &v)
virtual ~RefVector ()
void clear ()
void setCapacity (unsigned long newCapacity)
unsigned long size () const
bool isEmpty () const
unsigned long addObject (T &o)
unsigned long addObject (T &o, unsigned long i)
void setObject (T &o, unsigned long index) const
T & getObject (unsigned long index) const
T & operator[] (unsigned long index)
const T & operator[] (unsigned long index) const
unsigned long getObjectIndex (const T &o) const
void removeObjects (unsigned long first, unsigned long last, DeleteFlag fl=DO_NOT_DELETE)
T & removeObject (unsigned long i)
const T & removeObject (const T &o)
T ** getArray () const
void deleteAllObjects (unsigned long first=0)
virtual String getClassName () const

Private Member Functions

T ** createArray ()

Private Attributes

unsigned long _size
unsigned long _capacity
T ** _array

Friends

class TestRefVector

Detailed Description

template<class T>
class alize::RefVector< T >

This class implements a growable template array of objects. Note that the array just store pointers on the elements. If you delete the array, the pointed objects are not deleted. To delete all the pointed objects, call deleteAllObjects()

Author:
Frederic Wils frederic.wils@lia.univ-avignon.fr
Version:
1.0
Date:
2006

Definition at line 91 of file RefVector.h.


Constructor & Destructor Documentation

template<class T>
alize::RefVector< T >::RefVector ( unsigned long  capacity = 1 ) [inline, explicit]

Create an RefVector object.

Parameters:
capacitymaximum number of elements in the array
The capacity will automatically grow when the size will overtake the capacity
reservewhen the capacity grow, a number of locations equals to this value is added to the vector.

Definition at line 104 of file RefVector.h.

template<class T>
alize::RefVector< T >::RefVector ( const RefVector< T > &  v ) [inline]

Definition at line 108 of file RefVector.h.

template<class T>
virtual alize::RefVector< T >::~RefVector (  ) [inline, virtual]

Definition at line 130 of file RefVector.h.


Member Function Documentation

template<class T>
unsigned long alize::RefVector< T >::addObject ( T &  o ) [inline]
template<class T>
unsigned long alize::RefVector< T >::addObject ( T &  o,
unsigned long  i 
) [inline]

Inserts an object at a specified place

Parameters:
othe object to add
iindex
Returns:
the index of the added object

Definition at line 178 of file RefVector.h.

template<class T>
void alize::RefVector< T >::clear (  ) [inline]

Definition at line 132 of file RefVector.h.

template<class T>
T** alize::RefVector< T >::createArray (  ) [inline, private]

Definition at line 322 of file RefVector.h.

template<class T>
void alize::RefVector< T >::deleteAllObjects ( unsigned long  first = 0 ) [inline]
template<class T>
T** alize::RefVector< T >::getArray (  ) const [inline]

Use this method to access directly to the internal vector

Returns:
a pointer on the first element
Warning:
Fast but dangerous ! Use preferably set and get.

Definition at line 303 of file RefVector.h.

template<class T>
virtual String alize::RefVector< T >::getClassName (  ) const [inline, virtual]

Returns the name of the class

Returns:
the name of the class of the object as a String

Implements alize::Object.

Definition at line 314 of file RefVector.h.

template<class T>
T& alize::RefVector< T >::getObject ( unsigned long  index ) const [inline]
template<class T>
unsigned long alize::RefVector< T >::getObjectIndex ( const T &  o ) const [inline]

Returns the index of the object (the first found)

Parameters:
othe object
Returns:
the index of the object
Exceptions:
Exceptionif the object cannot be found

Definition at line 233 of file RefVector.h.

template<class T>
bool alize::RefVector< T >::isEmpty (  ) const [inline]

Definition at line 151 of file RefVector.h.

template<class T>
const RefVector<T>& alize::RefVector< T >::operator= ( const RefVector< T > &  v ) [inline]

Definition at line 113 of file RefVector.h.

template<class T>
T& alize::RefVector< T >::operator[] ( unsigned long  index ) [inline]

Definition at line 215 of file RefVector.h.

template<class T>
const T& alize::RefVector< T >::operator[] ( unsigned long  index ) const [inline]

Definition at line 221 of file RefVector.h.

template<class T>
const T& alize::RefVector< T >::removeObject ( const T &  o ) [inline]

Remove the first occurence of an object

Parameters:
othe object to remove
Returns:
the removed object (same as o)
Exceptions:
Exceptionif the object is not referenced in the vector

Definition at line 284 of file RefVector.h.

template<class T>
T& alize::RefVector< T >::removeObject ( unsigned long  i ) [inline]

Removes an object from the array.

Parameters:
iindex of the object to remove
Returns:
the removed object

Definition at line 269 of file RefVector.h.

Referenced by alize::XLine::deleteElement(), alize::SegServer::remove(), and alize::SegAbstract::removeOwner().

template<class T>
void alize::RefVector< T >::removeObjects ( unsigned long  first,
unsigned long  last,
DeleteFlag  fl = DO_NOT_DELETE 
) [inline]

Removes a set of objects from the array.

Parameters:
firstindex of the first object to remove
lastindex of the last object to remove
flDELETE = remove and delete the objects
DO_NOT_DELETE = remove but do not delete the objects

Definition at line 248 of file RefVector.h.

template<class T>
void alize::RefVector< T >::setCapacity ( unsigned long  newCapacity ) [inline]

Adjusts the size of the internal array Take care of consequences if the new capacity is smaller than the actual capacity

Parameters:
cnew capacity

Definition at line 139 of file RefVector.h.

template<class T>
void alize::RefVector< T >::setObject ( T &  o,
unsigned long  index 
) const [inline]

Set an object at a specified location in the vector. Note that the previous object inside this location is not destroyed.

Parameters:
othe object to store
indexan index into this vector
Exceptions:
IndexOutOfBoundsException

Definition at line 196 of file RefVector.h.

Referenced by alize::LabelServer::setLabel().

template<class T>
unsigned long alize::RefVector< T >::size (  ) const [inline]

Friends And Related Function Documentation

template<class T>
friend class TestRefVector [friend]

Definition at line 93 of file RefVector.h.


Member Data Documentation

template<class T>
T** alize::RefVector< T >::_array [private]
template<class T>
unsigned long alize::RefVector< T >::_capacity [private]

Definition at line 319 of file RefVector.h.

template<class T>
unsigned long alize::RefVector< T >::_size [private]

Definition at line 318 of file RefVector.h.

Referenced by alize::RefVector< SegCluster >::operator=().


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