92 p_buffer =
new T[size];
101 if (req_size > p_size)
103 unsigned int new_size = p_size;
105 while(new_size < req_size)
109 new_size = (
int)(new_size*(
float)(-p_step)/100.0);
111 T * new_buffer =
new T[new_size];
114 memcpy(new_buffer, p_buffer, p_size*
sizeof(T));
117 p_buffer = new_buffer;
125 if (req_size > p_size)
127 unsigned int new_size = p_size;
129 while(new_size < req_size)
133 new_size = (
int)(new_size*(
float)(-p_step)/100.0);
135 T * new_buffer =
new T[new_size];
139 for(
int i=0; i<howmany; i++)
140 new_buffer[i] = set_to;
143 p_buffer = new_buffer;
154 for(
int i=0; i<howmany; i++)
155 p_buffer[i] = set_to;
struct old_tbuffer EST_old_buffers[TBUFFER_N_OLD]
Memory of old buffers.
#define TBUFFER_N_OLD
How many chunks of memory to keep around for re-use.
EST_TVector< T > & copy(EST_TVector< T > a, const EST_TList< T > &in)
void set(const T &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)
~EST_TBuffer(void)
Destructor. Places the memory in EST_old_buffers[] for re-use if there is room.