#include <orderedlist.h>
Public Member Functions | |
virtual | ~OrderedList () |
Destructor. | |
void | append (Entity *entity) |
Add an Entity to the end of the list. | |
void | insertBefore (Entity *entity) |
Inserts the new Entity relative to the list cursor. | |
virtual ostream & | renderState (ostream &os) const |
Write the state of an Object for debugging and demonstration. | |
virtual const Info * | typeInfo () const |
Return the instance of Object::Info that describes the class of this object. | |
virtual Object * | clone (bool deepCopy=false) const =0 |
A polymorphic copy constructor. | |
Static Public Attributes | |
static const Info *const | TYPE_INFO = Object::typeInfoFactory("OrderedList") |
Protected Member Functions | |
OrderedList () | |
OrderedList (const OrderedList &pattern) | |
virtual void | append_impl (Entity *entity)=0 |
Called by a template method. | |
virtual void | insertBefore_impl (Entity *entity)=0 |
Called by a template method. | |
Private Member Functions | |
void | setCount (int c) |
Hide from sub-classes. | |
void | incCount () |
Hide from sub-classes. | |
void | decCount () |
Hide from sub-classes. |
An OrderedList maintains an order but no sorting is performed or enforced. It is left to the user of the class to order the list as desired with the provided mutators.
container::OrderedList::OrderedList | ( | const OrderedList & | pattern | ) | [protected] |
void container::OrderedList::append | ( | Entity * | entity | ) |
Add an Entity to the end of the list.
No copy of the Entity is made; the list takes on the responsibility of deleting the Entity. The list relinquishes the responsibility to delete the Entity only if it is extracted from the list using extractCurrentEntity().
This method is a template function that enforces the correct value for count. Concrete sub-classes must implement append_impl(Entity*) to do the work of adding an Entity.
00058 { 00059 append_impl(entity); 00060 incCount(); 00061 }
virtual void container::OrderedList::append_impl | ( | Entity * | entity | ) | [protected, pure virtual] |
Called by a template method.
Implemented in container::OrderedArrayList, and container::OrderedLinkedList.
virtual Object* container::OrderedList::clone | ( | bool | deepCopy = false |
) | const [pure virtual] |
A polymorphic copy constructor.
Implements container::List.
Implemented in container::OrderedArrayList, and container::OrderedLinkedList.
void container::OrderedList::decCount | ( | ) | [inline, private] |
Hide from sub-classes.
Reimplemented from container::Container.
00136 { 00137 Container::decCount(); 00138 }
void container::OrderedList::incCount | ( | ) | [inline, private] |
Hide from sub-classes.
Reimplemented from container::Container.
00129 { 00130 Container::incCount(); 00131 }
void container::OrderedList::insertBefore | ( | Entity * | entity | ) |
Inserts the new Entity relative to the list cursor.
The cursor remains unchanged, pointing to the same, pre-existing Entity or to the tail of the list
00063 { 00064 insertBefore_impl(entity); 00065 incCount(); 00066 }
virtual void container::OrderedList::insertBefore_impl | ( | Entity * | entity | ) | [protected, pure virtual] |
Called by a template method.
Implemented in container::OrderedArrayList, and container::OrderedLinkedList.
ostream & container::OrderedList::renderState | ( | ostream & | os | ) | const [virtual] |
Write the state of an Object for debugging and demonstration.
This method must not change the state of an Object; adding or removing debug statements should not change the behavior of a class. The implementation must be robust, e.g., NULL safe, etc. and work without an unrecoverable error for any state, excluding an Object's time of construction and destruction. It is not required for the implementation to be thread safe.
Reimplemented from container::List.
Reimplemented in container::OrderedArrayList, and container::OrderedLinkedList.
00070 { 00071 return this->List::renderState(os); 00072 }
void container::OrderedList::setCount | ( | int | c | ) | [inline, private] |
Hide from sub-classes.
Reimplemented from container::Container.
00122 { 00123 Container::setCount(c); 00124 }
const Object::Info * container::OrderedList::typeInfo | ( | ) | const [virtual] |
Return the instance of Object::Info that describes the class of this object.
Instantiation of Object::Info is controlled by the protected method Object::typeInfoFactory(const string&). Each sub-class of Object should create one and only one instance of Object::Info.
Reimplemented from container::List.
Reimplemented in container::OrderedArrayList, and container::OrderedLinkedList.
00074 { 00075 return TYPE_INFO; 00076 }
const Object::Info *const container::OrderedList::TYPE_INFO = Object::typeInfoFactory("OrderedList") [static] |
Reimplemented from container::List.
Reimplemented in container::OrderedArrayList, and container::OrderedLinkedList.