43 #ifndef __EST_TBUFFER_H__
44 #define __EST_TBUFFER_H__
49 #define TBUFFER_N_OLD (10)
52 #define TBUFFER_DEFAULT_SIZE 0
55 #define TBUFFER_DEFAULT_STEP 100
63 extern struct old_tbuffer EST_old_buffers[TBUFFER_N_OLD];
98 void init(
unsigned int size,
int step);
100 void expand_to(
unsigned int req_size,
bool cpy);
102 void expand_to(
unsigned int req_size,
const TYPE &set_to,
int howmany);
113 EST_TBuffer(
unsigned int size=TBUFFER_DEFAULT_SIZE,
int step=TBUFFER_DEFAULT_STEP);
119 unsigned int length(
void)
const {
return p_size;}
122 void set(
const TYPE &set_to,
int howmany=-1);
129 {
if (req_size > p_size) expand_to(req_size, (
bool)TRUE);}
132 void ensure(
unsigned int req_size,
bool copy)
133 {
if (req_size > p_size) expand_to(req_size, copy,-1);}
136 void ensure(
unsigned int req_size,
const TYPE &set_to,
int howmany=-1)
137 {
if (req_size > p_size) expand_to(req_size, set_to, howmany);}
144 TYPE *
b(
void) {
return p_buffer;}
146 const TYPE *
b(
void)
const {
return p_buffer;}
149 const TYPE &
operator() (
unsigned int i)
const {
return p_buffer[i];}
151 TYPE &operator[] (
unsigned int i) {
return p_buffer[i];}
152 const TYPE &operator[] (
unsigned int i)
const {
return p_buffer[i];}
TYPE * b(void)
Simple access as a pointer.
void ensure(unsigned int req_size, bool copy)
Make sure there is enough space, copying if requested.
void ensure(unsigned int req_size)
Extend if needed, copying existing data.
void ensure(unsigned int req_size, const TYPE &set_to, int howmany=-1)
Make sure there is enough space, setting to a known value.
const TYPE * b(void) const
Read-only access when the EST_TBuffer is a constant.
~EST_TBuffer(void)
Destructor. Places the memory in EST_old_buffers[] for re-use if there is room.
const TYPE & operator()(unsigned int i) const
operator () is simple access
unsigned int length(void) const
Current available space.
void set(const TYPE &set_to, int howmany=-1)
Set to the given value. By default sets all values.
EST_TBuffer(unsigned int size=TBUFFER_DEFAULT_SIZE, int step=TBUFFER_DEFAULT_STEP)