HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TIL_HoldingQueue.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: TIL_HoldingQueue.C (TIL Library, C++)
7  *
8  * COMMENTS:
9  * Queue with constant time head addition, tail removal and
10  * internal removal.
11  */
12 #ifndef TIL_HOLDING_QUEUE_H
13 #define TIL_HOLDING_QUEUE_H
14 
15 #include "TIL_API.h"
16 class TIL_HoldingQueue;
17 
19 {
20 public:
21  TIL_HoldingNode() : myPrev(0), myNext(0), myQueue(0) { }
22 
23  TIL_HoldingNode *&prev() { return myPrev; }
24  TIL_HoldingNode *&next() { return myNext; }
25 
26  TIL_HoldingNode *prev() const { return myPrev; }
27  TIL_HoldingNode *next() const { return myNext; }
28 
29  void setQueue(TIL_HoldingQueue *q, bool update_queues=true);
30  TIL_HoldingQueue *queue() const { return myQueue; }
31 
32 private:
33  TIL_HoldingNode *myPrev;
34  TIL_HoldingNode *myNext;
35  TIL_HoldingQueue *myQueue;
36 };
37 
38 
40 {
41 public:
42  TIL_HoldingQueue() : myHead(0), myTail(0), myEntries(0) {}
44 
45  // adds to head.
46  void add(TIL_HoldingNode *newtile);
47 
48  // removes an arbitrary tile.
49  void remove(TIL_HoldingNode *tile);
50 
51  // returns the last node off at the tail & removes it from the queue.
52  TIL_HoldingNode * pop();
53 
54  // queries.
55  TIL_HoldingNode * head() { return myHead; }
56  bool isEmpty() const { return myHead == 0; }
57  unsigned int entries() const { return myEntries; }
58 
59  // clears out the queue and deletes the holding nodes if delete_nodes is
60  // true.
61  void empty(bool delete_nodes = true);
62 
63  int traverse(int (*tfunc)(TIL_HoldingNode *, void *),
64  void *data);
65 private:
66  TIL_HoldingNode *myHead;
67  TIL_HoldingNode *myTail;
68  unsigned int myEntries;
69 };
70 
71 
72 #endif
73 
TIL_HoldingNode *& next()
TIL_HoldingNode * next() const
TIL_HoldingNode *& prev()
TIL_HoldingQueue * queue() const
TIL_HoldingNode * head()
GLboolean * data
Definition: glcorearb.h:130
unsigned int entries() const
TIL_HoldingNode * prev() const
#define TIL_API
Definition: TIL_API.h:10
bool isEmpty() const