|
Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
21 #ifndef ELM_DATA_VECTORQUEUE_H
22 #define ELM_DATA_VECTORQUEUE_H
24 #include <elm/assert.h>
30 template <
class T,
class E = Equiv<T> >
40 inline int size(
void)
const;
41 inline bool isEmpty(
void)
const;
44 for(
int i = hd; i != tl; i = (i + 1) & (cap - 1))
51 inline const T&
get(
void);
52 inline T&
head(
void)
const;
53 inline void reset(
void);
56 inline operator bool(
void)
const;
63 template <
class T,
class E>
void VectorQueue<T, E>::enlarge(
void) {
64 int new_cap = cap * 2, off = 0;
65 T *new_buffer =
new T[new_cap];
68 for(
int i = 0; i < off; i++)
69 new_buffer[i] = buffer[hd + i];
72 for(
int i = hd; i < tl; i++)
73 new_buffer[off + i - hd] = buffer[i];
81 : hd(0), tl(0), cap(1 << capacity), buffer(new T[cap]) {
82 ASSERTP(cap >= 0,
"capacity must be positive");
97 return (cap - hd) + tl;
105 int new_tl = (tl + 1) & (cap - 1);
115 ASSERTP(hd != tl,
"queue empty");
117 hd = (hd + 1) & (cap - 1);
122 ASSERTP(hd != tl,
"queue empty");
145 #endif // ELM_DATA_VECTORQUEUE_H
T & head(void) const
Definition: VectorQueue.h:121
const T & get(void)
Definition: VectorQueue.h:114
bool isEmpty(void) const
Definition: VectorQueue.h:100
bool equals(const C1 &c1, const C2 &c2)
Definition: util.h:107
void reset(void)
Definition: VectorQueue.h:126
void put(const T &value)
Definition: VectorQueue.h:104
T * operator->(void) const
Definition: VectorQueue.h:135
Definition: VectorQueue.h:31
Content & operator*(Content &c)
Definition: xom_dtd.cpp:1185
int size(void) const
Definition: VectorQueue.h:93
uint64 size
Definition: arch.h:35
bool contains(const T &val) const
Definition: VectorQueue.h:43
void put(var< T > &x, in< T > v)
Definition: type_info.h:287
T & operator*(void) const
Definition: VectorQueue.h:139
VectorQueue(int capacity=4)
Definition: VectorQueue.h:80
int capacity(void) const
Definition: VectorQueue.h:89
ret< T > get(const var< T > &v)
Definition: type_info.h:288
~VectorQueue(void)
Definition: VectorQueue.h:85