12 template<
class T,
bool canexpand = false>
19 friend class Queue<T,canexpand>;
49 if (++item == prnt->fBorder) { item = prnt->fQueue; loop++; }
56 if (++item == prnt->fBorder) { item = prnt->fQueue; loop++; }
141 memcpy((
void *) tgt,
fTail, sz *
sizeof(T));
150 if (!canexpand)
return false;
154 if (newcapacity < 16) newcapacity = 16;
155 T* q =
new T [newcapacity];
156 if (q==0)
return false;
173 if (
size()==0)
return false;
178 if (*i_src != value) {
179 if (i_tgt!=i_src) *i_tgt = *i_src;
184 }
while (i_src !=
fHead);
188 return i_tgt != i_src;
194 if (indx>=
fSize)
return false;
196 T* tgt =
fTail + indx;
202 if (src==
fHead)
break;
226 throw std::runtime_error(
"No more space in fixed-size queue");
240 throw std::runtime_error(
"No more space in fixed queue size");
256 #ifdef DABC_EXTRA_CHECKS
257 if (
fSize==0) EOUT((
"Queue is empty"));
268 #ifdef DABC_EXTRA_CHECKS
269 if (
fSize==0) EOUT((
"Queue is empty"));
277 #ifdef DABC_EXTRA_CHECKS
279 EOUT((
"Wrong item index %u", indx));
281 T* _item =
fTail + indx;
289 #ifdef DABC_EXTRA_CHECKS
291 EOUT((
"Wrong item index %u", indx));
295 T* _item =
fTail + indx;
303 #ifdef DABC_EXTRA_CHECKS
304 if (
fSize==0) EOUT((
"Queue is empty"));
355 template<
class T,
bool canexpand = true>
406 while (cnt-->0)
pop();
416 for (
unsigned n=0;n<
size();n++)
iterator over raw data messages
Definition: Iterator.h:10
iterator over queue elements
Definition: Queue.h:17
Iterator(const Iterator &src)
constructor
Definition: Queue.h:33
Iterator & operator++()
prefix ++iter
Definition: Queue.h:47
bool operator!=(const Iterator &src) const
compare operator
Definition: Queue.h:41
bool operator==(const Iterator &src) const
compare operator
Definition: Queue.h:39
Iterator()
constructor
Definition: Queue.h:31
void operator++(int)
postfix iter++
Definition: Queue.h:54
T * operator()() const
get current item
Definition: Queue.h:36
Iterator & operator=(const Iterator &src)
assign operator
Definition: Queue.h:44
queue class
Definition: Queue.h:13
Iterator begin()
begin iterator
Definition: Queue.h:330
T * fTail
tail
Definition: Queue.h:69
bool Expand(unsigned newcapacity=0)
increase capacity of queue without lost of content
Definition: Queue.h:148
void clear()
clear queue
Definition: Queue.h:310
void push(const T &val)
push value
Definition: Queue.h:219
Queue(unsigned _capacity)
constructor with capacity
Definition: Queue.h:86
T * item_ptr(unsigned indx) const
provide item pointer
Definition: Queue.h:287
T * PushEmpty()
push empty, return pointer on place
Definition: Queue.h:231
T pop_front()
pop front element
Definition: Queue.h:254
T & item(unsigned indx) const
access arbitrary item
Definition: Queue.h:275
virtual ~Queue()
destructor
Definition: Queue.h:99
unsigned fCapacity
capacity
Definition: Queue.h:66
T * fQueue
queue
Definition: Queue.h:64
bool Remove(T value)
remove value from queue
Definition: Queue.h:171
Iterator end()
end iterator
Definition: Queue.h:332
T * fBorder
maximum pointer value
Definition: Queue.h:65
T & back() const
access back element
Definition: Queue.h:301
void Init(unsigned _capacity)
init queue
Definition: Queue.h:106
unsigned size() const
return queue size
Definition: Queue.h:321
unsigned fSize
size
Definition: Queue.h:67
void Allocate(unsigned _capacity)
allocate queue
Definition: Queue.h:113
bool erase_item(unsigned indx)
erase item with index
Definition: Queue.h:192
unsigned fInitSize
original size of the queue, restored then clear() method is called
Definition: Queue.h:70
T * fHead
head
Definition: Queue.h:68
virtual void CopyTo(T *tgt)
Method can be used to copy content of the queue into externally allocated array.
Definition: Queue.h:134
void pop()
pop element
Definition: Queue.h:245
bool MakePlaceForNext()
create place for next entry
Definition: Queue.h:213
unsigned capacity() const
return queue capacity
Definition: Queue.h:318
bool full() const
is queue full
Definition: Queue.h:324
T & front() const
access front element
Definition: Queue.h:266
bool empty() const
is queue empty
Definition: Queue.h:327
Special case of the queue when structure or class is used as entry of the queue.
Definition: Queue.h:356
unsigned size() const
size
Definition: Queue.h:375
T * item_ptr(unsigned indx) const
item pointer
Definition: Queue.h:387
RecordsQueue()
default constructor
Definition: Queue.h:360
T & back() const
back element
Definition: Queue.h:369
bool erase_item(unsigned indx)
erase item
Definition: Queue.h:423
RecordsQueue(unsigned _capacity)
construct queue with given capacity
Definition: Queue.h:363
bool empty() const
is queue empty
Definition: Queue.h:381
unsigned capacity() const
capacity
Definition: Queue.h:372
void pop_items(unsigned cnt)
pop several items
Definition: Queue.h:401
T pop_front()
pop item and return it
Definition: Queue.h:393
T & item(unsigned indx) const
item reference
Definition: Queue.h:384
T & front() const
front element
Definition: Queue.h:366
void clear()
clear queue
Definition: Queue.h:411
bool full() const
is queue full
Definition: Queue.h:378
void pop()
pop item
Definition: Queue.h:390