Go to the documentation of this file.
21 #ifndef GNASH_SAFESTACK_H
22 #define GNASH_SAFESTACK_H
44 typedef std::vector<T*> StackType;
59 return _data[offset >> _chunkShift][offset & _chunkMod];
71 return _data[offset >> _chunkShift][offset & _chunkMod];
82 return _data[offset >> _chunkShift][offset & _chunkMod];
95 return _data[offset >> _chunkShift][offset & _chunkMod];
105 return _data[offset >> _chunkShift][offset & _chunkMod];
113 return _data[offset >> _chunkShift][offset & _chunkMod];
122 _data[offset >> _chunkShift][offset & _chunkMod] = val;
157 StackSize available = (1 << _chunkShift) * _data.size() - _end + 1;
159 while (available <
n)
162 _data.push_back(
new T[1 << _chunkShift]);
163 available += 1 << _chunkShift;
186 _downstop = _end - 1;
209 _downstop = downstop;
218 for (
auto& elem : _data)
delete [] elem;
228 static const StackSize _chunkMod = (1 << _chunkShift) - 1;
T & value(StackSize i)
Definition: SafeStack.h:100
StackSize fixDownstop()
Definition: SafeStack.h:183
@ T
Definition: GnashKey.h:132
@ i
Definition: GnashKey.h:155
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
bool empty() const
Is the stack empty to us? (Check totalSize() != for actually empty)
Definition: SafeStack.h:178
const T & value(StackSize i) const
Definition: SafeStack.h:108
@ n
Definition: GnashKey.h:160
T & pop()
Pop the top of the stack.
Definition: SafeStack.h:147
T & top(StackSize i)
From the top of the stack, get the i'th value down.
Definition: SafeStack.h:66
@ t
Definition: GnashKey.h:166
SafeStack()
Default constructor.
Definition: SafeStack.h:213
Definition: SafeStack.h:29
StackSize size() const
Alias for getDownstop()
Definition: SafeStack.h:175
void push(const T &t)
Definition: SafeStack.h:141
void setDownstop(StackSize i)
Definition: SafeStack.h:192
StackSize totalSize() const
Return the complete stack size, including non-accessible elements.
Definition: SafeStack.h:202
StackSize getDownstop() const
Gives the size of the stack which is currently accessible.
Definition: SafeStack.h:169
void clear()
Drop all stack elements reguardless of the "downstop".
Definition: SafeStack.h:134
void drop(StackSize i)
Definition: SafeStack.h:128
StackType::size_type StackSize
Definition: SafeStack.h:49
void setAllSizes(StackSize total, StackSize downstop)
Definition: SafeStack.h:206
const T & at(StackSize i) const
From the top of the stack, get the i'th value down.
Definition: SafeStack.h:77
T & at(StackSize i)
From the top of the stack, get the i'th value down.
Definition: SafeStack.h:90
const T & top(StackSize i) const
From the top of the stack, get the i'th value down.
Definition: SafeStack.h:54
void assign(StackSize i, T val)
Assign a value to given index counting from bottom.
Definition: SafeStack.h:117
void grow(StackSize i)
Definition: SafeStack.h:155
~SafeStack()
Delete the allocated data.
Definition: SafeStack.h:216
Definition: SafeStack.h:42