-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueue.List.h
202 lines (151 loc) · 4.13 KB
/
Queue.List.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/**
* QueueList Declaration
* ------------------------------------------------------------------
* Copyright (c) Chi-Tai Dang
*
* @author Chi-Tai Dang
* @version 1.0
* @remarks
*
* This file is part of the Environs framework developed at the
* Lab for Human Centered Multimedia of the University of Augsburg.
* http://hcm-lab.de/environs
*
* Environ is free software; you can redistribute it and/or modify
* it under the terms of the Eclipse Public License v1.0.
* A copy of the license may be obtained at:
* http://www.eclipse.org/org/documents/epl-v10.html
* --------------------------------------------------------------------
*/
#pragma once
#ifndef INCLUDE_HCM_ENVIRONS_IMPLEMENTATION_QUEUELIST_H
#define INCLUDE_HCM_ENVIRONS_IMPLEMENTATION_QUEUELIST_H
#ifndef CLI_CPP
//#define ENABLE_VECTOR_LIST
namespace environs
{
namespace lib
{
class IQueueItem
{
friend class QueueList;
private:
IQueueItem * next;
};
/**
* QueueList
*
*/
class QueueList
{
public:
/** Constructor */
QueueList ();
~QueueList ();
/**
* Append the item at the end of the queue.
*
* @param position
*/
bool push ( IQueueItem * obj );
/**
* Removes and returns the first object in the queue.
*
* @param position
*
* @ return The first object in the queue.
*/
void * pop ();
/**
* Query empty state of the queue.
*
* @param empty state
*
* @ return The first object in the queue.
*/
bool empty ();
#ifndef NDEBUG
bool remove ( IQueueItem * obj );
#endif
/**
* Get the size of the list.
*
* @return size of the list
*/
size_t size ();
size_t size_;
private:
IQueueItem * front;
IQueueItem * end;
};
#ifdef ENABLE_VECTOR_LIST
template <class T>
class VectorListSPProxy
{
public:
VectorListSPProxy () : next ( 0 )
{};
T item;
VectorListSPProxy * next;
};
template <class T>
class VectorListSP {
public:
/** Constructor */
VectorListSP ();
~VectorListSP ();
/**
* Append the item at the end of the queue.
*
* @param position
*/
bool push_back ( const T & obj );
/**
* Query empty state of the queue.
*
* @param empty state
*
* @ return The first object in the queue.
*/
bool empty ();
/**
* Get the size of the list.
*
* @return size of the list
*/
size_t size ();
size_t size_;
private:
VectorListSPProxy<T> ** items;
size_t capacity;
size_t next;
size_t end;
size_t sizeArray;
VectorListSPProxy<T> * root;
VectorListSPProxy<T> * last;
/**
* Append the item at the end of the queue.
*
* @param position
*/
bool push ( const T & obj );
/**
* Removes and returns the first object in the queue.
*
* @param position
*
* @ return The first object in the queue.
*/
VectorListSPProxy<T> * front ();
/**
* Allocate new proxies.
*
* @ return success.
*/
bool alloc ( size_t start, size_t count );
};
#endif
}
}
#endif
#endif /// -> INCLUDE_HCM_ENVIRONS_IMPLEMENTATION_QUEUELIST_H