MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DtSortedList Class Reference

A DtSortedList is a list of elements of arbitrary type. More...

+ Inheritance diagram for DtSortedList:
+ Collaboration diagram for DtSortedList:

Public Member Functions

 DtSortedList (DtSortOrder sortOrderVal=DtSortOrderAscending)
 Constructor.
virtual ~DtSortedList ()
 Destructor - does NOT free memory of data associated with the items.
 DtSortedList (const DtSortedList &orig)
 Copy constructor.
DtSortedListoperator= (const DtSortedList &orig)
 Assignment operator.
virtual void setSortOrder (DtSortOrder sortOrderValue)
 Set/Get sort order.
virtual DtSortOrder sortOrder () const
virtual DtSortedListItemfirst () const
 Return first and last item on the list.
virtual DtSortedListItemlast () const
unsigned count () const
 Returns the number of elements in the list.
virtual bool compareItems (const DtSortedListItem &firstItem, const DtSortedListItem &secondItem) const
 Compare the two items based on sort order and return true if first comes first in order to second.
virtual DtSortedListItemadd (void *data)
 Add element to the list in sorted order.
virtual void * remove (DtSortedListItem *item)
 Remove an element from the list.
virtual void removeAll ()
 Calls remove for all elements in the list.
virtual DtSortedListItemitemLookup (void *data) const
 Returns the DtSortedListItem envelope object containing the indicated data element.
virtual void reverseSortOrder ()
 Reverses sort order of list.
virtual void printData (DtSortOrder order=DtSortOrderAscending)
 Print the list.

Protected Member Functions

virtual DtSortedListItemnewItem (void *data)
 Create a new sorted list item envelope for the data to be inserted into the list.
virtual void addToList (DtSortedListItem *item, DtSortedListItem *before)
 Add first item to the list before second.
virtual void removeFromList (DtSortedListItem *item)
 Remove item from the list. Does NOT delete the data contained in item.
virtual void reposition (DtSortedListItem *item)
 An item's data for sorting has changed. Reposition it within the list.
virtual void repositionForward (DtSortedListItem *item, DtSortedListItem *positionItem)
 An item's data for sorting has changed.
virtual void repositionBackward (DtSortedListItem *item, DtSortedListItem *positionItem)
 An item's data for sorting has changed.
virtual void insertBefore (DtSortedListItem *item, DtSortedListItem *positionItem)
 Insert the first item before the second.
virtual void insertAfter (DtSortedListItem *item, DtSortedListItem *positionItem)
 Insert the first item after the second.

Protected Attributes

DtSortedListItemmyFirst
DtSortedListItemmyLast
unsigned myCount
DtSortOrder mySortOrder

Detailed Description

A DtSortedList is a list of elements of arbitrary type.

Data elements are added to, and extracted from a DtSortedList as void*. DtSortedList encloses each element in a DtSortedListItem object. You can iterate through the elements in a DtSortedList like this Example:

for (DtSortedListItem* item = list.first(); item; item = item->next())
{
void* dataElement = item->data();
}

Constructor & Destructor Documentation

DtSortedList::DtSortedList ( DtSortOrder  sortOrderVal = DtSortOrderAscending)

Constructor.

DtSortedList::~DtSortedList ( )
virtual

Destructor - does NOT free memory of data associated with the items.

It only frees the items.

References myFirst, DtSortedListItem::myNext, and NULL.

DtSortedList::DtSortedList ( const DtSortedList orig)

Copy constructor.

Shallow copy. Copies the pointers you've added to the list, but not the items that are pointed to.

References add(), DtSortedListItem::data(), first(), DtSortedListItem::next(), and NULL.

Member Function Documentation

DtSortedListItem * DtSortedList::add ( void *  data)
virtual

Add element to the list in sorted order.

Returns the DtSortedListItem envelope object that contains the new element.

Reimplemented in DtRtiMsgQueue, and DtRetractInfoList.

References addToList(), compareItems(), first(), newItem(), and DtSortedListItem::next().

Referenced by DtRetractInfoList::add(), DtSortedList(), and operator=().

void DtSortedList::addToList ( DtSortedListItem item,
DtSortedListItem before 
)
protectedvirtual

Add first item to the list before second.

If second item is NULL, item is added to end of list.

References myCount, myFirst, myLast, DtSortedListItem::myNext, DtSortedListItem::myPrev, and NULL.

Referenced by add(), and reverseSortOrder().

bool DtSortedList::compareItems ( const DtSortedListItem firstItem,
const DtSortedListItem secondItem 
) const
inlinevirtual

Compare the two items based on sort order and return true if first comes first in order to second.

References DtSortOrderAscending, and mySortOrder.

Referenced by add(), reposition(), repositionBackward(), and repositionForward().

unsigned DtSortedList::count ( ) const
inline

Returns the number of elements in the list.

References myCount.

DtSortedListItem * DtSortedList::first ( ) const
inlinevirtual
void DtSortedList::insertAfter ( DtSortedListItem item,
DtSortedListItem positionItem 
)
protectedvirtual

Insert the first item after the second.

If second item is NULL, first item is placed at end of list.

References myCount, myFirst, myLast, DtSortedListItem::myNext, DtSortedListItem::myPrev, and NULL.

Referenced by repositionBackward(), and repositionForward().

void DtSortedList::insertBefore ( DtSortedListItem item,
DtSortedListItem positionItem 
)
protectedvirtual

Insert the first item before the second.

If second item is NULL, first item is placed at beginning of list.

References myCount, myFirst, myLast, DtSortedListItem::myNext, DtSortedListItem::myPrev, and NULL.

Referenced by repositionBackward(), and repositionForward().

DtSortedListItem * DtSortedList::itemLookup ( void *  data) const
virtual

Returns the DtSortedListItem envelope object containing the indicated data element.

References DtSortedListItem::data(), myFirst, and DtSortedListItem::myNext.

DtSortedListItem * DtSortedList::last ( ) const
inlinevirtual
DtSortedListItem * DtSortedList::newItem ( void *  data)
protectedvirtual

Create a new sorted list item envelope for the data to be inserted into the list.

Reimplemented in DtRetractInfoList, and DtRtiMsgQueue.

Referenced by add().

DtSortedList & DtSortedList::operator= ( const DtSortedList orig)

Assignment operator.

Shallow copy. Copies the pointers you've added to the list, but not the items that are pointed to. Old list items are removed from the list, and the elements they contain are not deleted.

References add(), DtSortedListItem::data(), first(), mySortOrder, DtSortedListItem::next(), NULL, and removeAll().

void DtSortedList::printData ( DtSortOrder  order = DtSortOrderAscending)
virtual
void * DtSortedList::remove ( DtSortedListItem item)
virtual

Remove an element from the list.

Item is the envelope containing the data element you would like to remove. Note: remove does not free memory of data associated with the item. It only frees the item. The data is returned to the caller for deletion if required.

Reimplemented in DtRetractInfoList.

References DtSortedListItem::myData, NULL, and removeFromList().

void DtSortedList::removeAll ( )
virtual

Calls remove for all elements in the list.

It does NOT delete the data in the list. Merely removes the data from the list.

Reimplemented in DtRetractInfoList.

References first(), DtSortedListItem::next(), and NULL.

Referenced by operator=().

void DtSortedList::removeFromList ( DtSortedListItem item)
protectedvirtual

Remove item from the list. Does NOT delete the data contained in item.

References myCount, myFirst, myLast, DtSortedListItem::myNext, and DtSortedListItem::myPrev.

Referenced by remove(), repositionBackward(), and repositionForward().

void DtSortedList::reposition ( DtSortedListItem item)
protectedvirtual

An item's data for sorting has changed. Reposition it within the list.

References compareItems(), DtSortedListItem::next(), DtSortedListItem::prev(), repositionBackward(), and repositionForward().

void DtSortedList::repositionBackward ( DtSortedListItem item,
DtSortedListItem positionItem 
)
protectedvirtual

An item's data for sorting has changed.

Reposition it backward within the list relative to position of the second item. If the second item is NULL, start at last()

References compareItems(), insertAfter(), insertBefore(), DtSortedListItem::prev(), and removeFromList().

Referenced by reposition().

void DtSortedList::repositionForward ( DtSortedListItem item,
DtSortedListItem positionItem 
)
protectedvirtual

An item's data for sorting has changed.

Reposition it forward within the list relative to position of the second item. If the second item is NULL, start at first()

References compareItems(), insertAfter(), insertBefore(), DtSortedListItem::next(), and removeFromList().

Referenced by reposition().

void DtSortedList::reverseSortOrder ( )
virtual

Reverses sort order of list.

References addToList(), DtSortOrderAscending, DtSortOrderDescending, first(), last(), and mySortOrder.

Referenced by setSortOrder().

void DtSortedList::setSortOrder ( DtSortOrder  sortOrderValue)
virtual

Set/Get sort order.

Changing the sort order will result in a reordering of the list elements.

References mySortOrder, and reverseSortOrder().

DtSortOrder DtSortedList::sortOrder ( ) const
inlinevirtual

References mySortOrder.

Member Data Documentation

unsigned DtSortedList::myCount
protected
DtSortedListItem* DtSortedList::myFirst
protected
DtSortedListItem* DtSortedList::myLast
protected
DtSortOrder DtSortedList::mySortOrder
protected

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

Document ID: Generated on Wed Mar 11 20:26:49 EDT 2015 from SVN revision 150939
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)