#include <sortedlist.h>
Public Member Functions | |
virtual | ~SortedList () |
bool | insertSorted (Entity *entity) |
Insert an Entity into the List maintaining a sorted order. | |
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("SortedList") |
Protected Member Functions | |
SortedList () | |
SortedList (const SortedList &orig) | |
virtual bool | insertSorted_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. |
Does not allow duplicate Entity objects.
container::SortedList::SortedList | ( | const SortedList & | orig | ) | [protected] |
virtual Object* container::SortedList::clone | ( | bool | deepCopy = false |
) | const [pure virtual] |
A polymorphic copy constructor.
Implements container::List.
Implemented in container::SortedArrayList, and container::SortedLinkedList.
void container::SortedList::decCount | ( | ) | [inline, private] |
Hide from sub-classes.
Reimplemented from container::Container.
00119 { 00120 Container::decCount(); 00121 }
void container::SortedList::incCount | ( | ) | [inline, private] |
Hide from sub-classes.
Reimplemented from container::Container.
00112 { 00113 Container::incCount(); 00114 }
bool container::SortedList::insertSorted | ( | Entity * | entity | ) |
Insert an Entity into the List maintaining a sorted order.
The position of entity will be determined by the Entity class' implementation of compareKeyTo(const Entity&). Duplicate keys will be rejected, i.e., if Entity::compareKeyTo(const Entity&) returns 0 for any item in the SortedList the insertion will not take place.
The List is sorted and does not contain duplicate entries
The cursor remains unchanged, pointing to the same, pre-existing Entity or to the tail of the list
00055 { 00056 if (insertSorted_impl(entity)) { 00057 incCount(); 00058 return true; 00059 } 00060 00061 return false; 00062 }
virtual bool container::SortedList::insertSorted_impl | ( | Entity * | entity | ) | [protected, pure virtual] |
Called by a template method.
Implemented in container::SortedArrayList, and container::SortedLinkedList.
ostream & container::SortedList::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::SortedArrayList, and container::SortedLinkedList.
00066 { 00067 return this->List::renderState(os); 00068 }
void container::SortedList::setCount | ( | int | c | ) | [inline, private] |
Hide from sub-classes.
Reimplemented from container::Container.
00105 { 00106 Container::setCount(c); 00107 }
const Object::Info * container::SortedList::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::SortedArrayList, and container::SortedLinkedList.
00070 { 00071 return TYPE_INFO; 00072 }
const Object::Info *const container::SortedList::TYPE_INFO = Object::typeInfoFactory("SortedList") [static] |
Reimplemented from container::List.
Reimplemented in container::SortedArrayList, and container::SortedLinkedList.