MAK RTIspy API Documentation for HLA 1.3
sortedList.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1997 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: sortedList.h,v $ $Revision: 1.4 $ $State: Exp $
00007 *********************************************************************/
00008 
00011 
00012 #ifndef DtSortedList_H_
00013 #define DtSortedList_H_
00014 
00015 #include "rtiMsConfig.h"
00016 #include <stddef.h>
00017 #include <vlutil/vlMachineTypes.h>
00018 
00024 class DT_DLL_RTIUTIL DtSortedListItem
00025 {
00026 public:
00027 
00028    friend class DtSortedList;
00029 
00030 public:
00031 
00033    virtual ~DtSortedListItem();
00034 
00037    DtSortedListItem* prev() const;
00038    DtSortedListItem* next() const;
00039 
00041    void* data() const;
00042 
00044    virtual bool operator<= (const DtSortedListItem&) const;
00045    virtual bool operator<  (const DtSortedListItem&) const;
00046    virtual bool operator>= (const DtSortedListItem&) const;
00047    virtual bool operator>  (const DtSortedListItem&) const;
00048    virtual bool operator== (const DtSortedListItem&) const;
00049 
00051    virtual void printData();
00052 
00053 protected:
00054 
00056    DtSortedListItem(void* d);
00057 
00058 protected:
00059 
00060    DtSortedListItem* myPrev;
00061    DtSortedListItem* myNext;
00062    void* myData;
00063 };
00064 
00065 inline void* DtSortedListItem::data() const
00066 {
00067    return myData;
00068 }
00069 
00070 inline DtSortedListItem* DtSortedListItem::prev() const
00071 {
00072    return myPrev;
00073 }
00074 
00075 inline DtSortedListItem* DtSortedListItem::next() const
00076 {
00077    return myNext;
00078 }
00079 
00080 enum DtSortOrder
00081 {
00082    DtSortOrderAscending,
00083    DtSortOrderDescending
00084 };
00085 
00097 
00098 class DT_DLL_RTIUTIL DtSortedList
00099 {
00100 
00101 public:
00102 
00104    DtSortedList(DtSortOrder sortOrderVal=DtSortOrderAscending);
00105 
00108    virtual ~DtSortedList();
00109 
00112    DtSortedList(const DtSortedList& orig);
00113 
00118    DtSortedList& operator=(const DtSortedList& orig);
00119 
00122    virtual void setSortOrder(DtSortOrder sortOrderValue);
00123    virtual DtSortOrder sortOrder() const;
00124 
00127    virtual DtSortedListItem* first() const;
00128    virtual DtSortedListItem* last() const;
00129 
00131    unsigned count() const;
00132 
00135    virtual bool compareItems(const DtSortedListItem& firstItem,
00136       const DtSortedListItem& secondItem) const;
00137 
00140    virtual DtSortedListItem* add(void* data);
00141 
00147    virtual void* remove(DtSortedListItem* item);
00148 
00151    virtual void removeAll();
00152     
00155    virtual DtSortedListItem* itemLookup(void* data) const;
00156 
00158    virtual void reverseSortOrder();
00159 
00161    virtual void printData(DtSortOrder order=DtSortOrderAscending);
00162 
00163 protected:
00164 
00167    virtual DtSortedListItem* newItem(void* data);
00168 
00171    virtual void addToList(DtSortedListItem* item, DtSortedListItem* before);
00172 
00174    virtual void removeFromList(DtSortedListItem* item);
00175 
00177    virtual void reposition(DtSortedListItem* item);
00178 
00182    virtual void repositionForward(DtSortedListItem* item,
00183       DtSortedListItem* positionItem);
00184 
00188    virtual void repositionBackward(DtSortedListItem* item,
00189       DtSortedListItem* positionItem);
00190 
00193    virtual void insertBefore(DtSortedListItem* item,
00194       DtSortedListItem* positionItem);
00195 
00198    virtual void insertAfter(DtSortedListItem* item,
00199       DtSortedListItem* positionItem);
00200 
00201 protected:
00202 
00203    DtSortedListItem* myFirst;
00204    DtSortedListItem* myLast;
00205    unsigned  myCount;
00206    DtSortOrder mySortOrder;
00207 };
00208 
00209 inline DtSortOrder DtSortedList::sortOrder() const
00210 {
00211    return mySortOrder;
00212 }
00213 
00214 inline bool DtSortedList::compareItems(const DtSortedListItem& firstItem,
00215    const DtSortedListItem& secondItem) const
00216 {
00217    return (mySortOrder == DtSortOrderAscending)
00218       ? (firstItem <= secondItem) : (firstItem >= secondItem);
00219 }
00220 
00221 inline DtSortedListItem* DtSortedList::first() const
00222 {
00223    return myFirst;
00224 }
00225 
00226 inline DtSortedListItem* DtSortedList::last() const
00227 {
00228    return myLast;
00229 }
00230 
00231 inline unsigned DtSortedList::count() const
00232 {
00233    return myCount;
00234 }
00235 
00236 #endif

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)