-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessageQueueSorter.h
40 lines (32 loc) · 1.04 KB
/
MessageQueueSorter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef MessageQueueSorter_h
#define MessageQueueSorter_h
#include "MessageQueueItem.h"
class MessageQueueSorter
{
public:
MessageQueueSorter();
void init(MessageQueueItem * queue);
/*
* Sets item to point to the next available item
* Returns true on succes
*
*/
bool getUnusedItem(MessageQueueItem ** item);
/*
* moves inactive items to the back
* must be called after destroy() on any of the MessageQueueItems in this queue
*
*/
MessageQueueItem ** reorder();
MessageQueueItem ** getSortedQueue() {return m_sorted;};
private:
int m_length;
MessageQueueItem * m_original;
MessageQueueItem * m_buf1[MAXMESSAGECOUNT]; //Sorted list with items removed
MessageQueueItem * m_buf2[MAXMESSAGECOUNT]; //List to transfer active items into front to back and inactive items back to front
MessageQueueItem ** m_sorted; //points to the current state
MessageQueueItem ** m_from; //points to the current state
MessageQueueItem ** m_to; //points to the current state
int m_firstUnusedItemIndex;
};
#endif