OOFILE  1.9
ooflist.h
Go to the documentation of this file.
1 // COPYRIGHT 1994 A.D. Software, All rights reserved
2 #ifndef H_OOFLIST
3 #define H_OOFLIST
4 
5 #ifndef H_OOF0
6  #include "oof0.h"
7 #endif
8 
9 #ifdef OOF_DEBUG
10  #include <assert.h>
11 #endif
12 
33 class OOF_ListBase {
34  public:
36  mCount(0) {}; // initialize the list
37 // use default copy ctor
38  virtual ~OOF_ListBase() {
39 #ifdef OOF_DEBUG
40  assert(!mCount); // make sure there are no elements
41 #endif
42  }; // It's our descendant's responsibility !
43 
44  bool isEmpty() { return (mCount==0); }; // is the list empty?
45 
46  unsigned long count() { return mCount; }; // Return the number of items
47 
48  virtual unsigned long remove() = 0;
49 
50  protected:
51  unsigned long mCount; // number of items
52 };
53 
54 
60  public:
61  OOF_ListElement(unsigned long theItem):
62  mNext(0),
63  mItem(theItem) {}; // initialize a list element
64 // use default copy ctor
66 
67  OOF_ListElement *mNext; // next element on list,
68  // NULL if this is the last
69  unsigned long mItem; // item on the list
70 };
71 
72 
77 class OOF_List : public OOF_ListBase {
78  public:
80  OOF_ListBase(),
81  mFirst(0),
82  mLast(0) {}; // initialize the list
83 // use default copy ctor
84  virtual ~OOF_List() { while (mCount) remove(); };
85 
86  void prepend(unsigned long theItem);
87  void append(unsigned long theItem);
88  virtual unsigned long remove();
89 
90  bool member(unsigned long theItem) const;
91 
92  void sortedInsert(unsigned long theItem);
93  void sortedInsertNoDups(unsigned long theItem);
94 
95  private:
96  OOF_ListElement *mFirst;
97  OOF_ListElement *mLast;
98 };
99 
100 
107  public:
108  OOF_ULSorterElement(unsigned long theItem, unsigned long theData):
109  mNext(0),
110  mItem(theItem),
111  mData(theData) {}; // initialize a list element
112 // use default copy ctor
114 
115  OOF_ULSorterElement *mNext; // next element on list,
116  // NULL if this is the last
117  unsigned long mItem; // item on the list
118  unsigned long mData; // 4-byte list container
119 };
120 
121 
126 class OOF_ULSorter : public OOF_ListBase {
127  public:
129  OOF_ListBase(),
130  mFirst(0),
131  mLast(0),
132  mLastInsertEqual(0),
133  mEqualInserted(0) {}; // initialize the list
134 // use default copy ctor
135  virtual ~OOF_ULSorter() { while (mCount) remove(); };
136 
137  virtual unsigned long remove();
138 
140  void sortedInsert(unsigned long theItem, unsigned long theData);
141  void sortedInsertReverse(unsigned long theItem, unsigned long theData);
143 
144  // Special Members for the string sorting stuff !
145  bool lastEqual() { return mLastInsertEqual; };
146  inline OOF_ULSorterElement *theEqual() { return mEqualInserted; };
147  void exchange(OOF_ULSorterElement *theItem);
148 
149  private:
150  OOF_ULSorterElement *mFirst; // Head of the list, NULL if list is empty // owned - special case as linked list of owned items
151  OOF_ULSorterElement *mLast; // Last element of list
152 
153  // Special Members for the string sorting stuff !
154  bool mLastInsertEqual;
155  OOF_ULSorterElement *mEqualInserted;
156 };
157 
158 
159 
165  public:
166  OOF_LSorterElement(long theItem, unsigned long theData):
167  mNext(0),
168  mItem(theItem),
169  mData(theData) {}; // initialize a list element
170 // use default copy ctor
172 
173  OOF_LSorterElement *mNext; // next element on list,
174  // NULL if this is the last
175  long mItem; // item on the list
176  unsigned long mData; // 4-byte list container
177 };
178 
179 
184 class OOF_LSorter : public OOF_ListBase {
185  public:
187  OOF_ListBase(),
188  mFirst(0),
189  mLast(0) {}; // initialize the list
190 // use default copy ctor
191  virtual ~OOF_LSorter() { while (mCount) remove(); };
192 
193  virtual unsigned long remove(); // Take item off the front of the list
194  // NOTE: This now returns the container data and not the Key
195 
196  void sortedInsert(long theItem, unsigned long theData);
197  void sortedInsertReverse(long theItem, unsigned long theData);
198  // Put item into list sorted
199 
200  private:
201  OOF_LSorterElement *mFirst; // Head of the list, NULL if list is empty // owned - special case as linked list of owned items
202  OOF_LSorterElement *mLast; // Last element of list
203 };
204 
205 
211  public:
212  OOF_DSorterElement(double theItem, unsigned long theData):
213  mNext(0),
214  mItem(theItem),
215  mData(theData) {}; // initialize a list element
216 // use default copy ctor
218 
219  OOF_DSorterElement *mNext; // next element on list,
220  // NULL if this is the last
221  double mItem; // item on the list
222  unsigned long mData; // 4-byte list container
223 };
224 
225 
230 class OOF_DSorter : public OOF_ListBase {
231  public:
233  OOF_ListBase(),
234  mFirst(0),
235  mLast(0) {}; // initialize the list
236 // use default copy ctor
237  virtual ~OOF_DSorter() { while (mCount) remove(); };
238 
239  virtual unsigned long remove(); // Take item off the front of the list
240  // NOTE: This now returns the container data and not the Key
241 
242  void sortedInsert(double theItem, unsigned long theData);
243  void sortedInsertReverse(double theItem, unsigned long theData);
244  // Put item into list sorted
245 
246  private:
247  OOF_DSorterElement *mFirst; // Head of the list, NULL if list is empty // owned - special case as linked list of owned items
248  OOF_DSorterElement *mLast; // Last element of list
249 };
250 
251 
252 //--- Partitioning Sorters to cope with nested sorts ---//
253 
259  public:
260  OOF_ULPSorterElement(unsigned long theItem, unsigned long theData):
261  mNext(0),
262  mItem(theItem),
263  mData(theData),
264  mPart(0) {}; // initialize a list element
265 // use default copy ctor
267 
268  OOF_ULPSorterElement *mNext; // next element on list,
269  // NULL if this is the last
270  unsigned long mItem; // item on the list
271  unsigned long mData; // 4-byte list container
272  unsigned short mPart; // Partition Counter
273 };
274 
275 
280 class OOF_ULPSorter : public OOF_ListBase {
281  public:
283  OOF_ListBase(),
284  mFirst(0),
285  mLast(0),
286  mLastInsertEqual(0),
287  mEqualInserted(0) {}; // initialize the list
288 // use default copy ctor
289  virtual ~OOF_ULPSorter() { while (mCount) remove(); };
290 
291  virtual unsigned long remove(); // Take item off the front of the list
292  // NOTE: This now returns the container data and not the Key
293 
294  void sortedInsert(unsigned long theItem, unsigned long theData);
295  void sortedInsertReverse(unsigned long theItem, unsigned long theData);
296  // Put item into list sorted
297 
298  // Special Members for the string sorting stuff !
299  bool lastEqual() { return mLastInsertEqual; };
300  inline OOF_ULPSorterElement *theEqual() { return mEqualInserted; };
301  inline OOF_ULPSorterElement *theFirst() { return mFirst; };
302  void exchange(OOF_ULPSorterElement *theItem);
303 
304  private:
305  OOF_ULPSorterElement *mFirst; // Head of the list, NULL if list is empty // owned - special case as linked list of owned items
306  OOF_ULPSorterElement *mLast; // Last element of list
307 
308  // Special Members for the string sorting stuff !
309  bool mLastInsertEqual;
310  OOF_ULPSorterElement *mEqualInserted;
311 };
312 
313 
314 
320  public:
321  OOF_LPSorterElement(long theItem, unsigned long theData):
322  mNext(0),
323  mItem(theItem),
324  mData(theData),
325  mPart(0) {}; // initialize a list element
326 // use default copy ctor
328 
329  OOF_LPSorterElement *mNext; // next element on list,
330  // NULL if this is the last
331  long mItem; // item on the list
332  unsigned long mData; // 4-byte list container
333  unsigned short mPart; // Partition Counter
334 };
335 
336 
341 class OOF_LPSorter : public OOF_ListBase {
342  public:
344  OOF_ListBase(),
345  mFirst(0),
346  mLast(0) {}; // initialize the list
347 // use default copy ctor
348  virtual ~OOF_LPSorter() { while (mCount) remove(); };
349 
350  virtual unsigned long remove(); // Take item off the front of the list
351  // NOTE: This now returns the container data and not the Key
352  inline OOF_LPSorterElement *theFirst() { return mFirst; };
353 
354  void sortedInsert(long theItem, unsigned long theData);
355  void sortedInsertReverse(long theItem, unsigned long theData);
356  // Put item into list sorted
357 
358  private:
359  OOF_LPSorterElement *mFirst; // Head of the list, NULL if list is empty // owned - special case as linked list of owned items
360  OOF_LPSorterElement *mLast; // Last element of list
361 };
362 
363 
364 
372  public:
373  OOF_DPSorterElement(double theItem, unsigned long theData):
374  mNext(0),
375  mItem(theItem),
376  mData(theData),
377  mPart(0) {}; // initialize a list element
378 // use default copy ctor
380 
381  OOF_DPSorterElement *mNext; // next element on list,
382  // NULL if this is the last
383  double mItem; // item on the list
384  unsigned long mData; // 4-byte list container
385  unsigned short mPart; // Partition Counter
386 };
387 
388 
393 class OOF_DPSorter : public OOF_ListBase {
394  public:
396  OOF_ListBase(),
397  mFirst(0),
398  mLast(0) {}; // initialize the list
399 // use default copy ctor
400  virtual ~OOF_DPSorter() { while (mCount) remove(); };
401 
402  virtual unsigned long remove(); // Take item off the front of the list
403  // NOTE: This now returns the container data and not the Key
404  inline OOF_DPSorterElement *theFirst() { return mFirst; };
405 
406  void sortedInsert(double theItem, unsigned long theData);
407  void sortedInsertReverse(double theItem, unsigned long theData);
408  // Put item into list sorted
409 
410  private:
411  OOF_DPSorterElement *mFirst; // Head of the list, NULL if list is empty // owned - special case as linked list of owned items
412  OOF_DPSorterElement *mLast; // Last element of list
413 };
414 
415 #endif
416 
417 
OOF_ULSorterElement(unsigned long theItem, unsigned long theData)
Definition: ooflist.h:108
unsigned long mData
Definition: ooflist.h:118
void sortedInsert(double theItem, unsigned long theData)
Definition: ooflist.cpp:509
virtual ~OOF_ULSorter()
Definition: ooflist.h:135
virtual ~OOF_LSorter()
Definition: ooflist.h:191
OOF_LSorter()
Definition: ooflist.h:186
virtual ~OOF_List()
Definition: ooflist.h:84
unsigned long mData
Definition: ooflist.h:332
Sortable list of doubles.
Definition: ooflist.h:230
void sortedInsertReverse(unsigned long theItem, unsigned long theData)
Put item into list sorted.
Definition: ooflist.cpp:318
bool member(unsigned long theItem) const
Is theItem in the list.
Definition: ooflist.cpp:115
void sortedInsertReverse(long theItem, unsigned long theData)
Definition: ooflist.cpp:818
virtual ~OOF_DPSorter()
Definition: ooflist.h:400
Declare macros used by most of OOFILE.
OOF_LSorterElement(long theItem, unsigned long theData)
Definition: ooflist.h:166
bool isEmpty()
Definition: ooflist.h:44
void sortedInsert(unsigned long theItem, unsigned long theData)
Definition: ooflist.cpp:263
unsigned long mData
Definition: ooflist.h:384
OOF_ListBase()
Definition: ooflist.h:35
void sortedInsertReverse(unsigned long theItem, unsigned long theData)
Definition: ooflist.cpp:674
Default list.
Definition: ooflist.h:77
unsigned long mData
Definition: ooflist.h:271
unsigned long mItem
Definition: ooflist.h:69
virtual ~OOF_LPSorter()
Definition: ooflist.h:348
virtual ~OOF_ListBase()
Definition: ooflist.h:38
OOF_LPSorterElement * theFirst()
Definition: ooflist.h:352
Sortable list of doubles with partitioning for nested sorts.
Definition: ooflist.h:393
bool lastEqual()
Definition: ooflist.h:145
OOF_ULPSorterElement(unsigned long theItem, unsigned long theData)
Definition: ooflist.h:260
unsigned short mPart
Definition: ooflist.h:333
virtual ~OOF_DSorter()
Definition: ooflist.h:237
Sortable list element for one unsigned long.
Definition: ooflist.h:106
OOF_LPSorterElement * mNext
Definition: ooflist.h:327
bool lastEqual()
Definition: ooflist.h:299
void append(unsigned long theItem)
Put item at the end of the list.
Definition: ooflist.cpp:42
void sortedInsert(long theItem, unsigned long theData)
Definition: ooflist.cpp:415
virtual ~OOF_ULPSorter()
Definition: ooflist.h:289
void sortedInsert(unsigned long theItem, unsigned long theData)
Definition: ooflist.cpp:617
OOF_DPSorterElement * mNext
Definition: ooflist.h:379
unsigned long mData
Definition: ooflist.h:176
Element for partitionable, sortable list of longs.
Definition: ooflist.h:319
OOF_DPSorterElement(double theItem, unsigned long theData)
Definition: ooflist.h:373
Element for sortable list of longs.
Definition: ooflist.h:164
OOF_ULSorterElement * mNext
Definition: ooflist.h:113
void exchange(OOF_ULPSorterElement *theItem)
Definition: ooflist.cpp:720
OOF_List()
Definition: ooflist.h:79
Sortable list of unsigned longs with partitioning for nested sorts.
Definition: ooflist.h:280
OOF_ULSorterElement * theEqual()
Definition: ooflist.h:146
unsigned long mCount
Definition: ooflist.h:51
unsigned short mPart
Definition: ooflist.h:385
OOF_DPSorterElement * theFirst()
Definition: ooflist.h:404
OOF_ULPSorterElement * theFirst()
Definition: ooflist.h:301
OOF_DSorterElement * mNext
Definition: ooflist.h:217
void sortedInsert(long theItem, unsigned long theData)
Definition: ooflist.cpp:776
unsigned short mPart
Definition: ooflist.h:272
Element for partitionable, sortable list of unsigned longs.
Definition: ooflist.h:258
OOF_LPSorter()
Definition: ooflist.h:343
Sortable list of longs.
Definition: ooflist.h:184
unsigned long mItem
Definition: ooflist.h:117
Sortable list of longs with partitioning for nested sorts.
Definition: ooflist.h:341
void sortedInsertNoDups(unsigned long theItem)
Put item into list sorted only if not already there.
Definition: ooflist.cpp:179
Elements used in OOF_ListBase.
Definition: ooflist.h:59
unsigned long mItem
Definition: ooflist.h:270
OOF_DSorter()
Definition: ooflist.h:232
unsigned long mData
Definition: ooflist.h:222
OOF_ULPSorterElement * theEqual()
Definition: ooflist.h:300
OOF_LSorterElement * mNext
Definition: ooflist.h:171
void prepend(unsigned long theItem)
Put item at the beginning of the list.
Definition: ooflist.cpp:68
void sortedInsert(unsigned long theItem)
Put item into list sorted.
Definition: ooflist.cpp:139
OOF_ULPSorterElement * mNext
Definition: ooflist.h:266
~OOF_ListElement()
Definition: ooflist.h:65
Sortable list of unsigned longs.
Definition: ooflist.h:126
Defines a singly linked list of list elements.
Definition: ooflist.h:33
OOF_ULSorter()
Definition: ooflist.h:128
OOF_ListElement(unsigned long theItem)
Definition: ooflist.h:61
OOF_ListElement * mNext
Definition: ooflist.h:65
OOF_LPSorterElement(long theItem, unsigned long theData)
Definition: ooflist.h:321
void exchange(OOF_ULSorterElement *theItem)
Definition: ooflist.cpp:362
Element for sortable list of doubles.
Definition: ooflist.h:210
OOF_DPSorter()
Definition: ooflist.h:395
unsigned long count()
Definition: ooflist.h:46
OOF_DSorterElement(double theItem, unsigned long theData)
Definition: ooflist.h:212
void sortedInsertReverse(double theItem, unsigned long theData)
Definition: ooflist.cpp:543
Sortable list of doubles with partitioning for nested sorts.
Definition: ooflist.h:371
void sortedInsertReverse(long theItem, unsigned long theData)
Definition: ooflist.cpp:449
void sortedInsert(double theItem, unsigned long theData)
Definition: ooflist.cpp:886
void sortedInsertReverse(double theItem, unsigned long theData)
Definition: ooflist.cpp:928