28 #include "dabc/defines.h"
40 template<
class T,
bool canexpand = false>
46 friend class Queue<T,canexpand>;
143 memcpy((
void *)tgt, (
const void *)
fTail, sz *
sizeof(T));
144 memcpy((
void *) (tgt + sz), (
const void *)
fQueue, (
fHead -
fQueue) *
sizeof(T));
154 if (newcapacity < 16) newcapacity = 16;
155 T* q =
new T [newcapacity];
156 if (q==0)
return false;
172 if (
Size()==0)
return false;
177 if (*i_src != value) {
178 if (i_tgt!=i_src) *i_tgt = *i_src;
183 }
while (i_src !=
fHead);
187 return i_tgt != i_src;
192 if (indx>=
fSize)
return false;
194 T* tgt =
fTail + indx;
200 if (src==
fHead)
break;
222 EOUT(
"No more space in fixed queue size = %d",
fSize);
235 EOUT(
"No more space in fixed queue size = %d",
fSize);
247 EOUT(
"No more space in fixed queue size = %d",
fSize);
261 #ifdef DABC_EXTRA_CHECKS
272 #ifdef DABC_EXTRA_CHECKS
282 #ifdef DABC_EXTRA_CHECKS
284 EOUT(
"Wrong item index %u", indx);
286 T* item =
fTail + indx;
293 #ifdef DABC_EXTRA_CHECKS
295 EOUT(
"Wrong item index %u", indx);
299 T* item =
fTail + indx;
306 #ifdef DABC_EXTRA_CHECKS
346 if (size()==0)
return 0;
354 for (
unsigned n=0; n<size(); n++)
355 if (at(n)==item)
return true;
361 if (n>=size())
return false;
368 for (iterator iter = begin(); iter!=end(); iter++)
401 template<
class T,
bool canexpand = true>
433 for (
unsigned n=0; n<
Size(); n++)
444 for (
unsigned n=0;n<
Size();n++)
453 for (
unsigned n=0;n<
Size();n++) {
455 if (item->id()==
id)
return item;
Specialized vector with pointers.
bool remove_at(unsigned n)
bool has_ptr(void *item) const
Queue< T, canexpand > * prnt
bool operator==(const Iterator &src) const
bool operator!=(const Iterator &src) const
Iterator(const Iterator &src)
Iterator(Queue< T, canexpand > *_prnt, T *_item, unsigned _loop)
Iterator & operator=(const Iterator &src)
Template of circular queue.
bool Expand(unsigned newcapacity=0)
void Init(unsigned capacity)
bool RemoveItem(unsigned indx)
void PushRef(const T &val)
T * ItemPtr(unsigned indx) const
unsigned fInitSize
original size of the queue, restored then Reset() method is called
virtual void CopyTo(T *tgt)
Method can be used to copy content of the queue into externally allocated array.
unsigned Capacity() const
T * QueueItem(unsigned n)
void Allocate(unsigned capacity)
T & Item(unsigned indx) const
Template of queue with complex objects.
T * FindItemWithId(DDD id)
Queue< T, canexpand > Parent
virtual void CopyTo(T *tgt)
Method can be used to copy content of the queue into externally allocated array.
void AllocateRecs(unsigned rec_capacity)
Helper methods to preallocate memory in each record in the queue.
unsigned Capacity() const
RecordsQueue(unsigned capacity)
void Allocate(unsigned capacity)
T & Item(unsigned n) const