#include <sortedlinkedlist.h>
Public Member Functions | |
SortedLinkedList () | |
SortedLinkedList (const SortedLinkedList &pattern) | |
virtual | ~SortedLinkedList () |
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 |
A polymorphic copy constructor. | |
Static Public Attributes | |
static const Info *const | TYPE_INFO |
Protected Member Functions | |
virtual bool | insertSorted_impl (Entity *entity) |
Called by a template method. | |
virtual bool | add_impl (Entity *entity) |
Called by a template method. |
container::SortedLinkedList::SortedLinkedList | ( | const SortedLinkedList & | pattern | ) |
bool container::SortedLinkedList::add_impl | ( | Entity * | entity | ) | [protected, virtual] |
Called by a template method.
Implements container::List.
00078 { 00079 return insertSorted_impl(entity); 00080 }
Object * container::SortedLinkedList::clone | ( | bool | deepCopy = false |
) | const [virtual] |
bool container::SortedLinkedList::insertSorted_impl | ( | Entity * | entity | ) | [protected, virtual] |
Called by a template method.
Implements container::SortedList.
00056 { 00057 Entity& newEntity = *entity; 00058 for (struct Node* node = head->next; node != tail; node = node->next) { 00059 Entity& existingEntity = *node->entity; 00060 int delta = newEntity.compareKeyTo(existingEntity); 00061 00062 if (delta < 0) { 00063 new Node(entity, node); 00064 return true; 00065 } 00066 00067 if (delta == 0) { 00068 return false; 00069 } 00070 } 00071 00072 new Node(entity, tail); 00073 return true; 00074 }
ostream & container::SortedLinkedList::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::LinkedList.
00084 { 00085 return this->LinkedList::renderState(os); 00086 }
const Object::Info * container::SortedLinkedList::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::LinkedList.
00088 { 00089 return TYPE_INFO; 00090 }
const Object::Info *const container::SortedLinkedList::TYPE_INFO [static] |
Initial value:
Object::typeInfoFactory("SortedLinkedList")
Reimplemented from container::LinkedList.