18 #ifndef NDB_VECTOR_HPP
19 #define NDB_VECTOR_HPP
21 #include <ndb_global.h>
22 #include <portlib/NdbMutex.h>
30 T& operator[](
unsigned i);
31 const T& operator[](
unsigned i)
const;
32 unsigned size()
const {
return m_size; };
34 int push_back(
const T &);
35 void push(
const T&,
unsigned pos);
36 T&
set(T&,
unsigned pos, T& fill_obj);
39 void erase(
unsigned index);
43 int fill(
unsigned new_size, T & obj);
54 int assign(
const T*,
unsigned cnt);
55 int assign(
const Vector<T>& obj) {
return assign(obj.getBase(), obj.size());}
57 T* getBase() {
return m_items;}
58 const T* getBase()
const {
return m_items;}
84 m_items(new T[src.m_size]),
86 m_incSize(src.m_incSize),
87 m_arraySize(src.m_size)
90 if (unlikely(m_items == NULL)){
97 for(
unsigned i = 0; i < m_size; i++){
98 m_items[
i] = src.m_items[
i];
130 return (*
this)[m_size - 1];
136 if(m_size == m_arraySize){
137 T * tmp =
new T [m_arraySize + m_incSize];
143 for (
unsigned k = 0; k < m_size; k++)
147 m_arraySize = m_arraySize + m_incSize;
159 if (pos < m_size - 1)
161 for(
unsigned i = m_size - 1; i > pos; i--)
163 m_items[
i] = m_items[i-1];
174 T&
ret = m_items[pos];
185 for (
unsigned k = i; k + 1 < m_size; k++)
186 m_items[k] = m_items[k + 1];
199 while(m_size <= new_size)
210 for(
unsigned i = 0; i<obj.size(); i++){
222 for (
unsigned i = 0; i<cnt; i++)
225 if ((ret = push_back(src[i])))
235 if (
size() != obj.size())
238 return memcmp(getBase(), obj.getBase(),
size() *
sizeof(T)) == 0;
247 T& operator[](
unsigned i);
248 const T& operator[](
unsigned i)
const;
249 unsigned size()
const {
return m_size; };
251 int push_back(
const T &);
252 int push_back(
const T &,
bool lockMutex);
255 void erase(
unsigned index);
256 void erase(
unsigned index,
bool lockMutex);
259 void clear(
bool lockMutex);
261 int fill(
unsigned new_size, T & obj);
266 unsigned m_arraySize;
313 return (*
this)[m_size - 1];
320 if(m_size == m_arraySize){
321 T * tmp =
new T [m_arraySize + m_incSize];
328 for (
unsigned k = 0; k < m_size; k++)
332 m_arraySize = m_arraySize + m_incSize;
345 if(m_size == m_arraySize){
346 T * tmp =
new T [m_arraySize + m_incSize];
354 for (
unsigned k = 0; k < m_size; k++)
358 m_arraySize = m_arraySize + m_incSize;
374 for (
unsigned k = i; k + 1 < m_size; k++)
375 m_items[k] = m_items[k + 1];
388 for (
unsigned k = i; k + 1 < m_size; k++)
389 m_items[k] = m_items[k + 1];
414 while(m_size <= new_size)