HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_PriorityQueue.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.h (TIL Library, C++)
7  *
8  * COMMENTS:
9  * A 'queue' with multiple queues inside, each of which bucket a
10  * priority range.
11  */
12 #ifndef TIL_PRIORITY_QUEUE_H
13 #define TIL_PRIORITY_QUEUE_H
14 
15 #include "TIL_API.h"
16 #include "TIL_HoldingQueue.h"
17 
19 
20 
22 {
23 public:
24 
25  // sorts nodes into 'nbuckets' queues, each of which cover
26  // consequetive priority ranges of 'bucket_range'
27  // if any bucket other than the lowest overflows the 'max_per_bucket',
28  // it will be passed down to a lower bucket.
29 
30  TIL_PriorityQueue(unsigned int nbuckets,
31  unsigned int bucket_range,
32  unsigned int max_entries);
34 
35 
36  void add(TIL_PNode *node, unsigned int priority);
37  void remove(TIL_PNode *node);
38 
39  // returns the last node in the lowest priority non-empty queue
40  TIL_PNode *pop();
41 
42  bool isEmpty() const;
43 
44  void empty(bool delete_nodes = true);
45 
46  // both of these only set the values; they only affect funture additions.
47  void setPriorityRange(unsigned int bucket_range);
48  unsigned int getPriorityRange() const { return myBucketPriority; }
49 
50  // sets the max # of elements assumed to be in the cache, so that the
51  // bucket sizes can be assigned appropriately.
52  void setMaxSize(unsigned int size);
53  unsigned int getMaxBucketSize(int bn) const { return myMaxBucketSize[bn]; }
54 
55  unsigned int getNumBuckets() const { return myNumBuckets; }
56  unsigned int getBucketSize(int bucket) const;
57 
58  int traverse(int (*tfunc)(TIL_PNode *, void *), void *data);
59 
60 private:
61  TIL_HoldingQueue *myBuckets;
62  unsigned int *myMaxBucketSize;
63  unsigned int myNumBuckets;
64  unsigned int myBucketPriority;
65 };
66 
67 #endif
unsigned int getNumBuckets() const
unsigned int getPriorityRange() const
GLsizeiptr size
Definition: glcorearb.h:663
unsigned int getMaxBucketSize(int bn) const
GLboolean * data
Definition: glcorearb.h:130
TIL_HoldingNode TIL_PNode
#define TIL_API
Definition: TIL_API.h:10