|
Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
21 #ifndef ELM_DATA_STATICSTACK_H_
22 #define ELM_DATA_STATICSTACK_H_
24 #include <elm/array.h>
25 #include <elm/assert.h>
26 #include <elm/PreIterator.h>
30 template <
class T,
int N>
38 {
copy(s);
return *
this; }
41 inline bool isEmpty(
void)
const {
return _t == 0; }
42 inline const T&
top(
void)
const {
return _s[_t - 1]; }
43 inline const T&
pop(
void) { ASSERTP(_t != 0,
"empty stack"); _t--;
return _s[_t]; }
44 inline void push(
const T& v) { ASSERTP(_t != N,
"stack full"); _s[_t] = v; _t++; }
45 inline void reset(
void) { _t = 0; }
51 inline bool ended(
void)
const {
return _i >= _s._t; }
52 inline const T&
item(
void)
const {
return _s._s[_i]; }
53 inline void next(
void) { _i++; }
60 inline int count(
void)
const {
return _t; }
62 {
for(
int i = _t; i >= 0; i--)
if(_s[i] == v)
return true;
return false; }
65 {
for(
typename C::Iter i(coll); i; i++)
if(!
contains(*i))
return false;
return true; }
67 inline Iter
begin(
void)
const {
return Iter(*
this); }
68 inline Iter
end(
void)
const {
return Iter(*
this, _t); }
72 {
if(_t != s._t)
return false;
for(
int i = 0; i < _t; i++)
if(_s[i] != s._s[i])
return false;
return true; }
74 {
for(
int i = 0; i < s._t; i++)
if(!
contains(s._s[i]))
return false;
return true; }
bool operator>=(const StaticStack< T, N > &s) const
Definition: StaticStack.h:78
void copy(T *target, const T *source, int size)
Definition: array.h:70
void next(void)
Definition: StaticStack.h:53
bool operator==(const StaticStack< T, N > &s) const
Definition: StaticStack.h:75
void copy(const StaticStack< T, N > &s)
Definition: StaticStack.h:35
Definition: StaticStack.h:48
bool isEmpty(void) const
Definition: StaticStack.h:41
const T & pop(void)
Definition: StaticStack.h:43
bool contains(const T &v)
Definition: StaticStack.h:61
bool operator<(const StaticStack< T, N > &s) const
Definition: StaticStack.h:79
bool ended(void) const
Definition: StaticStack.h:51
const T & item(void) const
Definition: StaticStack.h:52
bool operator<=(const StaticStack< T, N > &s) const
Definition: StaticStack.h:77
void reset(void)
Definition: StaticStack.h:45
Definition: StaticStack.h:31
bool operator>(const StaticStack< T, N > &s) const
Definition: StaticStack.h:80
int count(void) const
Definition: StaticStack.h:60
Iter items(void) const
Definition: StaticStack.h:69
StaticStack(void)
Definition: StaticStack.h:33
Iter begin(void) const
Definition: StaticStack.h:67
bool contains(const StaticStack< T, N > &s) const
Definition: StaticStack.h:73
bool operator!=(const StaticStack< T, N > &s) const
Definition: StaticStack.h:76
Iter operator*(void) const
Definition: StaticStack.h:70
Iter end(void) const
Definition: StaticStack.h:68
StaticStack(const StaticStack< T, N > &s)
Definition: StaticStack.h:34
Iter(const StaticStack &s, int i=0)
Definition: StaticStack.h:50
bool containsAll(const C &coll)
Definition: StaticStack.h:64
StaticStack< T, N > & operator=(const StaticStack< T, N > &s)
Definition: StaticStack.h:37
void push(const T &v)
Definition: StaticStack.h:44
const T & top(void) const
Definition: StaticStack.h:42
bool equals(const StaticStack< T, N > &s) const
Definition: StaticStack.h:71