52 : m_buffer_size(1000), m_current_buffer_size(0), m_nb_in_buffer(0),m_current_buffer(0)
56 : m_buffer_size(buf_size), m_current_buffer_size(0), m_nb_in_buffer(0),m_current_buffer(0)
61 : m_buffer_size(ref.m_buffer_size), m_current_buffer_size(0), m_nb_in_buffer(0), m_current_buffer(0)
66 _freeAllocatedBuffers();
75 m_buffer_size = ref.m_buffer_size;
81 if (!m_current_buffer)
82 _allocateCurrentBuffer();
83 T* v = &(*m_current_buffer)[m_nb_in_buffer];
85 if (m_nb_in_buffer==m_current_buffer_size)
94 if (n>m_current_buffer_size){
95 BufferType* bt =
new BufferType(n);
96 m_allocated_buffers.add(bt);
99 if (!m_current_buffer)
100 _allocateCurrentBuffer();
103 if ((m_nb_in_buffer+n)>=m_current_buffer_size)
104 _allocateCurrentBuffer();
105 T* v = &(*m_current_buffer)[m_nb_in_buffer];
107 if (m_nb_in_buffer==m_current_buffer_size)
108 m_current_buffer = 0;
114 m_current_buffer = 0;
115 m_current_buffer_size = 0;
116 _freeAllocatedBuffers();
119 Integer nbAllocatedBuffer() {
return m_allocated_buffers.size(); }
120 Integer bufferSize()
const {
return m_current_buffer_size; }
123 void _freeAllocatedBuffers()
125 for( Integer i=0, s=m_allocated_buffers.size(); i<s; ++i )
126 delete m_allocated_buffers[i];
127 m_allocated_buffers.clear();
133 BufferType* m_current_buffer;
134 UniqueArray< BufferType* > m_allocated_buffers;
136 void _allocateCurrentBuffer()
138 m_current_buffer =
new BufferType(m_buffer_size);
139 m_current_buffer_size = m_buffer_size;
140 m_allocated_buffers.add(m_current_buffer);