-
c_collection( void )
This is the default constructor. It does nothing.
-
c_collection( const c_collection& that )
This is a copy constructor, it only invokes operator=()
(hopefuly) on the derived collection class.
-
virtual ~c_collection( void )
This is the default destructor. It does nothing.
-
virtual int get_count( void ) const
This is a pure virtual function, so it must be implemented
by the derived collection class, and is meant to return
a count of the elements in the collection.
-
virtual int add( const T& elm )
This is a generic function used for adding elements
to the collection. It is pure virtual in c_collection.
-
virtual int remove_all( void )
In the derived classes, this fucntion should remove all
the elements from the collection, and free all associated
memory.
-
virtual c_collection_iter* prepare_iter( const collection_sorting_order ord = raw_order ) const
This is how you obtain an iterator pointer when you want to
iterate (step) through all of the elements in a collection.
This function is pure virtual in c_collection.
-
virtual int first( c_collection_iter*, T& ) const
virtual int next( c_collection_iter*, T& ) const
virtual int prev( c_collection_iter*, T& ) const
virtual int last( c_collection_iter*, T& ) const
These functions are used to iterate through a collection. The only
thing you have to watch out for during an iteration is that elements
are not removed from the collection you are iterating through, or the
iterator pointer can be come invalid. If you are aware that this
condion has occured, you can deallocate the iterator without fear
of derefrencing a bad pointer, otherwise it's behavior is undefined.
To obtain the first element in the collection, use first(), and use
last() to obtain the last element in the collection. Please note
that weather or not the iteration follows any kind of logical
order is dependant on the dervied collection object.
next() returns the next element in the iteration, it is equivalent
to first() if first has not yet been called, while prev() returns
the previous element in the collection.
-
virtual int complete_iter( c_collection_iter* ) const
This function needs to be called once for each invocation of
prepare_iter(). prepare_iter() allocates memory, and complete_iter()
must be called to clean it up.
|