C++ main module for gpm Package  1.0
CORE_Array.hpp
Go to the documentation of this file.
1 #ifndef CORE_Array_CPP
2 #define CORE_Array_CPP
3 
4 #include <CORE_Array.h>
5 #include <vector>
6 #include "CORE_Integer.h"
7 #include "CORE_String.h"
8 #include "CORE_Vector.h"
9 #include "CORE_Exception.h"
10 
11 using namespace std;
12 
13 
14 
15 template<class T>
17  mStartIndex=0;
18  mSize=n;
19  mCapacity=n;
20  mCapacityFactor=1;
21  mVector=new T[mCapacity];
22  mCVector=mVector;
23  if (mVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(mCapacity),"CORE_Array.hpp",21,"constructor(...)");
24  mHasToBeDeleted=true;
25 
26  //cout << "create an empty array to "<<getIdentityString()<<"\n";
27 }
28 template<class T>
30  mSize=0;
31  mStartIndex=0;
32  mCapacity=10;
33  mCapacityFactor=1;
34  mVector=new T[mCapacity];
35  mCVector=mVector;
36  mHasToBeDeleted=true;
37  if (mVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(mCapacity),"CORE_Array.hpp",34,"constructor(...)");
38 
39  //cout << "create an empty array to "<<getIdentityString()<<"\n";
40 }
41 template<class T >
42 template<class Q>
43 CORE_Array<T>::CORE_Array(const std::vector<Q>& values):CORE_List() {
44  mSize=values.size();
45  mStartIndex=0;
46  mCapacity=mSize;
47  mCapacityFactor=1;
48  mVector=new T[mCapacity];
49  mCVector=mVector;
50  mHasToBeDeleted=true;
51  if (mVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(mCapacity),"CORE_Array.hpp",48,"constructor(...)");
52  for (int i=0;i<mSize;i++) mVector[i]=(T) values[i];
53  //cout << "create an empty array to "<<getIdentityString()<<"\n";
54 }
55 
56 template<class T>
58  clear();
59  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
60 
61 }
62 
63 template<class T>
65  int cap=v.getCapacity();
66  int s=0;
67  setValues(cap,v.getCompleteValues(s),0);
68  mSize=v.getSize();
69  mStartIndex=v.getStartIndex();
70  mCapacityFactor=v.getCapacityFactor();
71  mCVector=&mVector[mStartIndex];
72 }
73 
74 
75 template<class T>
76 void CORE_Array<T>::setCapacity(const int& dim) {
77  if ((dim>=INT_MAX)||(dim<0))
78  throw CORE_Exception("common/core","CORE_Array::setCapacity","capacity too big !"+CORE_Integer::toString(dim));
79 
80  //capacity is ok
81  if (dim==mCapacity) return;
82 
83  // create a new array
84  T *newVector=new T[dim];
85  if (newVector==null)
86  throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(dim),"CORE_Array.hpp",81,"setCapacity(cont& int&)");
87 
88  // copy the old value
89  // last index of the usefull value
90  int p=mSize+mStartIndex;
91  int n=(p<dim)?p:dim;
92  // copy all the values [0,p]
93  for (int i=0;i<n;i++) newVector[i]=mVector[i];
94 
95  // free memory
96  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
97 
98  // affect the new allocated vector
99  mVector=newVector;
100  mCVector=&mVector[mStartIndex];
101 
102  // set the memeory allocation of the new vector
103  mCapacity=dim;
104 }
105 
106 template<class T>
108  if ((mSize==mCapacity) && (mStartIndex==0)) return;
109  if ((mSize>=INT_MAX) || (mSize<0))throw CORE_Exception("common/core","CORE_Array::resize","capacity too big !"+CORE_Integer::toString(mSize));
110  T *newVector=new T[mSize];
111  if (newVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(mSize),"CORE_Array.hpp",107,"resize()");
112  for (int i=0;i<mSize;i++)
113  newVector[i]=mCVector[i];
114  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
115  mVector=newVector;
116  mCVector=mVector;
117  mCapacity=mSize;
118  mStartIndex=0;
119 }
120 
121 template<class T>
122 void CORE_Array<T>::resize(const int& n) {
123  if ((n==mCapacity) && (mStartIndex==0)) {
124  mSize=n;
125  return;
126  }
127  if ((n>=INT_MAX)|| (n<0)) throw CORE_Exception("common/core","CORE_Array::resize","capacity too big !"+CORE_Integer::toString(n));
128  T *newVector=new T[n];
129  if (newVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(n),"CORE_Array.hpp",124,"resize(const int&)");
130  for (int i=0;i<n;i++)
131  newVector[i]=mCVector[i];
132  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
133  mVector=newVector;
134  mCVector=mVector;
135  mSize=n;
136  mCapacity=n;
137  mStartIndex=0;
138 
139 }
140 template<class T>
141 void CORE_Array<T>::setSize(const int& n) {
142  // the size is ok
143  if (mSize==n) return;
144  // compute the capacacity needed by the array (the size value is from the start index)
145  int dim=mStartIndex+n;
146  // set the size
147  if (dim<=mCapacity) mSize=n;
148  else {
149  // update the capacity
150  setCapacity(dim);
151  // set the size
152  mSize=n;
153  }
154 }
155 
156 template<class T>
157 void CORE_Array<T>::add(const T& obj) {
158  int dim=mSize+mStartIndex;
159  if (mCapacity<=dim) {
160  mCapacity=mStartIndex+(mSize+1)*mCapacityFactor;
161  if ((mCapacity>=INT_MAX)|| (mCapacity<0)) throw CORE_Exception("common/core","CORE_Array::resize","capacity too big !"+CORE_Integer::toString(mCapacity));
162  T *newVector=new T[mCapacity];
163  if (newVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(mCapacity),"CORE_Array.hpp",157,"add(const T&)");
164 
165  for (int i=0;i<dim;i++) newVector[i]=mVector[i];
166  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
167  mVector=newVector;
168  mCVector=&mVector[mStartIndex];
169  }
170  mVector[dim]=obj;
171  mSize++;
172 }
173 
174 template<class T>
175 void CORE_Array<T>::setValues(const tString& v,const int& fromIndex) {
176 
177  if ((v[0]!='[') && (v[0]!='(')) return;
178  SP::CORE_String str=CORE_String::New(v.substr(1,v.length()-2));
179  str->tokenize(",");
180  str->begin();
181  int n=str->getTokensCount();
182  int newDim=n+fromIndex;
183  // verify the capacity is sufficent
184  if (newDim>mCapacity) setCapacity(newDim);
185 
186  // set the start index
187  setStartIndex(fromIndex);
188 
189  // set the size
190  setSize(n);
191 
192  T value;
193  int k=0;
194  while (str->hasNextToken()) {
195  CORE_String::parse(str->nextToken(),value);
196  mCVector[k]=value;
197  k++;
198  }
199 }
200 template<class T>
202  const int& fromIndex) {
203 
204  // size of the array to copy
205  int narray=array.getSize();
206 
207  // new dimension of the array
208  int newDim=narray+fromIndex;
209 
210  // verify if the capacity is sufficent
211  if (newDim>mCapacity) setCapacity(newDim);
212 
213  // set the start index
214  setStartIndex(fromIndex);
215 
216  // set the size
217  setSize(narray);
218 
219  // copy the array
220  for (int i=0;i<narray;i++) mCVector[i]=array[i];
221 }
222 
223 template<class T>
224 void CORE_Array<T>::setValues(const int& n,const T* values,const int& fromIndex) {
225  int narray=n;
226  int newDim=narray+fromIndex;
227 
228  // verify the capacity is sufficent
229  if (newDim>mCapacity) setCapacity(newDim);
230 
231  // set the start index
232  setStartIndex(fromIndex);
233 
234  // set the size
235  setSize(narray);
236 
237  // copy the array
238  for (int i=0;i<narray;i++) mCVector[i]=values[i];
239 }
240 template<class T>
241 void CORE_Array<T>::setValues(const vector<T>& values,const int& fromIndex) {
242  int narray=values.size();
243  int newDim=narray+fromIndex;
244 
245  // verify the capacity is sufficent
246  if (newDim>mCapacity) setCapacity(newDim);
247 
248  // set the start index
249  setStartIndex(fromIndex);
250 
251  // set the size
252  setSize(narray);
253 
254  // copy the array
255  for (int i=0;i<narray;i++) mCVector[i]=values[i];
256 }
257 
258 
259 template<class T>
261 
262  tBoolean hasExisted=false;
263  int k=0;
264  T val;
265  for (int i=0;i<mSize;i++) {
266  val=mCVector[i];
267  if (val!=obj) {
268  mCVector[k]=val;
269  k++;
270  }
271  }
272  hasExisted=(mSize!=k);
273  mSize=k;
274  return hasExisted;
275 }
276 
277 template<class T>
279  if (index>=size()) return false;
280  if (index<0) return false;
281  int n=mSize-1;
282  for (int i=index;i<n;i++)
283  mCVector[i]=mCVector[i+1];
284 
285  mSize--;
286  return true;
287 }
288 template<class T>
290  if (n>=mSize) return;
291  mCapacity=n+mStartIndex;
292  if ((mCapacity>=INT_MAX) || (mCapacity<0)) throw CORE_Exception("common/core","CORE_Array::contractToLastElement(const int& n)","capacity too big !"+CORE_Integer::toString(mCapacity));
293  T *newVector=new T[mCapacity];
294  if (newVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(mCapacity),"CORE_Array.hpp",287,"contractToLastElement(const int&)");
295 
296  int k=mSize-1+mStartIndex;
297  for (int i=mCapacity-1;i>=0;i--) {
298  newVector[i]=mVector[k];
299  k--;
300  }
301  mSize=n;
302  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
303  mVector=newVector;
304  mCVector=&mVector[mStartIndex];
305 }
306 
307 template<class T>
308 int CORE_Array<T>::insert(const int& index,const T& obj) {
309  int dim=mSize+mStartIndex;
310  if (dim<mCapacity) {
311  for (int i=mSize;i>index;i--)
312  mCVector[i]=mCVector[i-1];
313  mCVector[index]=obj;
314 
315  } else {
316  int n=index+mStartIndex;
317  mCapacity+=mCapacityFactor*mSize;
318  if ((mCapacity>=INT_MAX)|| (mCapacity<0)) throw CORE_Exception("common/core","CORE_Array::insert(const int& index,const T& obj)","capacity too big !"+CORE_Integer::toString(mCapacity));
319  T *newVector=new T[mCapacity];
320  if (newVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(mCapacity),"CORE_Array.hpp",312,"insert(const int&,const T&)");
321 
322  // copy the vector from [0,index+mStartIndex[
323  for (int i=0;i<n;i++) newVector[i]=mVector[i];
324  // insert the obj at index
325  newVector[n]=obj;
326  // copy the vector from [index+mStartIndex,dim]
327  for (int i=n+1;i<=dim;i++)
328  newVector[i]=mVector[i-1];
329  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
330  mVector=newVector;
331  mCVector=&mVector[mStartIndex];
332  }
333  mSize++;
334  return index;
335 }
336 template<class T>
338  const tBoolean& evenIfEqual) {
339  int si=0;
340  int sf=mSize-1;
341  if (sf<0) {
342  add(obj);
343  return 0;
344  }
345  if (obj<mCVector[0]) {
346  insert(0,obj);
347  return 0;
348  } else if (obj==mCVector[0]) {
349  if (evenIfEqual) return insert(0,obj);
350  else return 0;
351  }
352  if (obj>mCVector[sf]) {
353  add(obj);
354  return mSize;
355  } else if (obj==mCVector[sf]) {
356  if (evenIfEqual) return insert(mSize-1,obj);
357  return mSize-1;
358  };
359  int i=0;
360  while (sf-si>1) {
361  i=(si+sf)/2;
362  if (obj>mCVector[i]) si=i;
363  else if (obj==mCVector[i]) {
364  if (evenIfEqual) return insert(i,obj);
365  return i;
366  }
367  else sf=i;
368  }
369  if (obj==mCVector[sf]) {
370  if (evenIfEqual) return insert(sf,obj);
371  return sf;
372  }
373  if (obj==mCVector[si]) {
374  if (evenIfEqual) return insert(si,obj);
375  return si;
376  }
377  return insert(sf,obj);
378 }
379 template<class T>
380 int CORE_Array<T>::getIndex(const T& obj) const {
381  int si=0;
382  int sf=mSize-1;
383  if (sf<0) {
384  return -1;
385  }
386  if (obj<mCVector[si]) {
387  return -1;
388  }
389  if (obj>mCVector[sf]) {
390  return -1;
391  }
392  int i=0;
393  while (sf-si>1) {
394  i=(si+sf)/2;
395  if (obj>mCVector[i]) si=i;
396  else if (obj==mCVector[i]) return i;
397  else sf=i;
398  }
399  if (mCVector[sf]==obj) return sf;
400  if (mCVector[si]==obj) return si;
401  return -1;
402 }
403 template<class T>
404 int CORE_Array<T>::getInfIndex(const T& obj) const {
405  int si=0;
406  int sf=mSize-1;
407  if (sf<0) {
408  return -1;
409  }
410  if (obj<mCVector[si]) {
411  return -1;
412  }
413  if (obj==mCVector[si]) {
414  return 0;
415  }
416  if (obj>=mCVector[sf]) {
417  return sf;
418  }
419  int i=0;
420  while (sf-si>1) {
421  i=(si+sf)/2;
422  if (obj>mCVector[i]) si=i;
423  else if (obj==mCVector[i]) {
424  // possibility of egality
425  for (int k=i-1;k>=0;k--)
426  if (obj!=mCVector[k]) return k+1;
427  return sf;
428  }
429  else sf=i;
430  }
431  if (mCVector[sf]==obj) {
432  for (int k=sf-1;k>=0;k--)
433  if (obj!=mCVector[k]) return k+1;
434  return sf;
435  }
436  if (mCVector[si]==obj) {
437  for (int k=si-1;k>=0;k--)
438  if (obj!=mCVector[k]) return k+1;
439  return si;
440  }
441  for (int k=si-1;k>=0;k--)
442  if (obj!=mCVector[k]) return k+1;
443  return si;
444 }
445 
446 template<class T>
447 int CORE_Array<T>::getSupIndex(const T& obj) const {
448  int n=mSize;
449  int si=0;
450  int sf=n-1;
451  if (sf<0) {
452  return -1;
453  }
454  if (obj<mCVector[0]) {
455  return -1;
456  }
457  if (obj==mCVector[0]) {
458  for (int k=1;k<n;k++)
459  if (obj!=mCVector[k]) return k-1;
460  return 0;
461  }
462  if (obj>=mCVector[sf]) {
463  return sf;
464  }
465  int i=0;
466  while (sf-si>1) {
467  i=(si+sf)/2;
468  if (obj>mCVector[i]) si=i;
469  else if (obj==mCVector[i]) {
470  // possibility of egality
471  for (int k=i+1;k<n;k++)
472  if (obj!=mCVector[k]) return k-1;
473 
474  return sf;
475  }
476  else sf=i;
477  }
478  if (mCVector[sf]==obj) {
479  for (int k=sf+1;k<n;k++)
480  if (obj!=mCVector[k]) return k-1;
481  return sf;
482  }
483  if (mCVector[si]==obj) {
484  for (int k=si+1;k<n;k++)
485  if (obj!=mCVector[k]) return k-1;
486  return si;
487  }
488  for (int k=sf+1;k<n;k++)
489  if (obj!=mCVector[k]) return k-1;
490  return sf;
491 }
492 
493 template<class T>
495  T old;
496  int mid=mSize/2;
497  int j=mSize-1;
498  for (int i=0;i<mid;i++) {
499  old=mCVector[i];
500  mCVector[i]=mCVector[j];
501  mCVector[j]=old;
502  j--;
503  }
504 }
505 
506 template<class T>
508  // size of array to merge
509  int n=array.getSize();
510 
511  // size of this array after merging
512  int newSize=mSize+n;
513  int newDim=mStartIndex+newSize;
514 
515  if (newDim<mCapacity) {
516  int k=0;
517  for (int i=mSize;i<newSize;i++) {
518  mCVector[i]=array[k];
519  k++;
520  }
521  } else {
522  // increase capacity
523  mCapacity=mStartIndex+newSize*mCapacityFactor;
524  if ((mCapacity>=INT_MAX)|| (mCapacity<0)) throw CORE_Exception("common/core","CORE_Array::merge(const CORE_Array<T>& obj)","capacity too big !"+CORE_Integer::toString(mCapacity));
525  T *newVector=new T[mCapacity];
526  if (newVector==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(mCapacity),"CORE_Array.hpp",517,"merge(const CORE_Array<T>&)");
527 
528  // copy the this vector
529  for (int i=mStartIndex+mSize-1;i>=0;i--) newVector[i]=mVector[i];
530  // add the array
531  int k=0;
532  for (int i=mStartIndex+mSize;i<newDim;i++) {
533  newVector[i]=array[k];
534  k++;
535  }
536 
537  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
538  mVector=newVector;
539  mCVector=&mVector[mStartIndex];
540  }
541  mSize=newSize;
542 }
543 template<class T>
545  tString str("");
546  int dim=mSize;
547  str+="size:"+CORE_Integer::toString(mSize)+"\n";
548  for (int i=0;i<dim;i++) {
549  str+=CORE_Integer::toString(i)+":";
550  str+=CORE_String::toString(mCVector[i]);
551  str+="\t";
552 
553 
554  }
555  return str;
556 }
557 template<class T>
558 void CORE_Array<T>::addAfterIndex(const int& index,const T& v) {
559  int dim=mSize+1;
560  setSize(dim);
561  for (int i=dim-1;i>index+1;i--) {
562  mCVector[i]=mCVector[i-1];
563  }
564  mCVector[index+1]=v;
565 }
566 
567 template<class T>
570 
571  int nIndices=indices.getSize();
572  int nValues=values.getSize();
573  int nValuesToAdd=0;
574  for (int i=0;i<nValues;i++)
575  nValuesToAdd+=values[i]->getSize();
576 
577  // resize the new dimension
578  int dim=mStartIndex+mSize+nValuesToAdd;
579  if ((dim>=INT_MAX)|| (dim<0)) throw CORE_Exception("common/core","CORE_Array::addAfterIndices(...)","capacity too big !"+CORE_Integer::toString(dim));
580  T* newValues=new T[dim];
581  if (newValues==null) throw CORE_Exception("common/core","impossible to allocate memory of size "+CORE_Integer::toString(dim),"CORE_Array.hpp",571,"addAfterIndices(...)");
582  // set the current cursors
583  int cur_newValues=dim-1;
584  int cur_indices=nIndices-1;
585  int cur_mVector=mStartIndex+mSize-1;
586 
587  int insertIndex=-1;
588  while (cur_indices>-1) {
589  insertIndex=indices[cur_indices]+mStartIndex;
590  //cout << "insert index:"<< insertIndex<<"\n";
591  // copy the values of mVector in newValues
592  //cout << "copy the values from "<<cur_mVector<<" to "<<(insertIndex+1)<<"\n";
593  for (int i=cur_mVector;i>insertIndex;i--) {
594  newValues[cur_newValues]=mVector[i];
595  //cout << "newValues["<<cur_newValues<<"]="<<mVector[i]<<"\n";
596  cur_newValues--;
597  }
598  cur_mVector=insertIndex;
599 
600  // insert the new values
601  //cout << "insert the new values \n";
602  CORE_Array<T> &vals=*values[cur_indices].get();
603  int nVals=vals.getSize();
604  for (int i=nVals-1;i>=0;i--) {
605  newValues[cur_newValues]=vals[i];
606  //cout << "newValues["<<cur_newValues<<"]="<<vals[i]<<"\n";
607  cur_newValues--;
608  }
609 
610  // insert at new index
611  cur_indices--;
612  }
613 
614  // copy the last values
615  //cout << "copy the last values from "<<cur_mVector<<" to 0 \n";
616  for (int i=cur_mVector;i>=mStartIndex;i--) {
617  newValues[cur_newValues]=mVector[i];
618  //cout << "newValues["<<cur_newValues<<"]="<<mVector[i]<<"\n";
619  cur_newValues--;
620  }
621 
622  // set the new dimension
623  mCapacity=dim;
624  mSize=dim-mStartIndex;
625 
626  // free memories
627  if ((mVector!=null) && (mHasToBeDeleted)) delete[] mVector;
628  mVector=newValues;
629  mCVector=&mVector[mStartIndex];
630 
631 }
634 template<class T>
635 void CORE_Array<T>::sort(T*& items,const int& N,
636  const tString& order) {
637 
638  int h=1;
639  int i,j;
640  T v;
641  do h=3*h+1;
642  while (h<=N);
643  do {
644  h/=3;
645  for (i=h;i<N;++i) {
646  if (compare(items[i],
647  items[i-h],
648  order)) {
649  v=items[i];
650  j=i;
651  do {
652  items[j]=items[j-h];
653  j=j-h;
654  }
655  while ((j>=h) && (!compare(items[j-h],
656  v,
657  order)));
658  items[j]=v;
659  }
660  }
661  }
662  while (h>1);
663 
664 }
665 template<class T>
666 int CORE_Array<T>::search(const T* values,const int& n,
667  const T& obj,
668  const tString& order){
669 
670  int si=0;
671  int sf=n-1;
672  if (sf<0) {
673  return -1;
674  }
675  // min
676  if (compare(obj,values[0],order)) {
677  return -1;
678  }
679 
680  // max
681  if (compare(values[sf],obj,order)) {
682  return -1;
683  }
684 
685  //eq
686  if (compare(values[0],obj,"=")) {
687  return 0;
688  }
689  if (compare(values[sf],obj,"=")) {
690  return sf;
691  }
692 
693 
694 
695  int i=0;
696  while (sf-si>1) {
697  i=(si+sf)/2;
698  if (compare(values[i],obj,"=")) {
699  return i;
700  } else if (compare(values[i],obj,order)) {
701  si=i;
702  }
703  else sf=i;
704  }
705  if (compare(obj,values[sf],"=")) {
706  return sf;
707  }
708  if (compare(obj,values[si],"=")) {
709  return si;
710  }
711  return -1;
712 }
713 #endif
void addAfterIndex(const int &index, const T &v)
add an element after index
Definition: CORE_Array.hpp:558
tString toString() const
return the string associated to the string
Definition: CORE_String.h:150
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
int getCapacity() const
return the memory allocation size of the array
Definition: CORE_Array.h:229
this class describes a list
Definition: CORE_List.h:12
int getSupIndex(const T &v) const
get the sup index of value return -1 if no value less than v
Definition: CORE_Array.hpp:447
int getCapacityFactor() const
get the capacity factor
Definition: CORE_Array.h:216
#define tBoolean
Definition: types.h:35
#define null
Definition: types.h:13
const T * getCompleteValues(int &s) const
get the values of the complete vector
Definition: CORE_Array.h:396
void reverse()
reverse the vector
Definition: CORE_Array.hpp:494
static void parse(const tString &str, unsigned char &c)
parse unsigned char c in str
Definition: CORE_String.h:418
const T & get(const int &i) const
get the value at index i Assert in (i>-1) Assert in (i
Definition: CORE_Array.h:181
void add(const T &obj)
add an element at the end re-allocate the array if capacity too small
Definition: CORE_Array.hpp:157
static int search(const T *values, const int &n, const T &value, const tString &order)
search the value in values array ordered in order
Definition: CORE_Array.hpp:666
void setSize(const int &n)
set the size of the array
Definition: CORE_Array.hpp:141
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
tBoolean remove()
remove the last element
Definition: CORE_Array.h:486
virtual ~CORE_Array()
destroy an array of T*
Definition: CORE_Array.hpp:57
this class describes an array
Definition: CORE_Array.h:18
int insertInOrder(const T &obj, const tBoolean &evenIfEqual)
insert the object in increasing order
Definition: CORE_Array.hpp:337
int getStartIndex() const
get start index
Definition: CORE_Array.h:220
int getSize() const
return the size of the array
Definition: CORE_Array.h:226
void sort()
sort the array in an increasing order
Definition: CORE_Array.h:540
void copy(const CORE_Array< T > &src)
void copy
Definition: CORE_Array.hpp:64
CORE_Array()
build an array of T*
Definition: CORE_Array.hpp:29
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:142
int getInfIndex(const T &v) const
get the inf index of value return -1 if no value less than v
Definition: CORE_Array.hpp:404
tString toString() const
turn the array into string
Definition: CORE_Array.hpp:544
int insert(const int &i, const T &obj)
insert the object at index i re-allocate the array if capacity too small
Definition: CORE_Array.hpp:308
#define tString
Definition: types.h:36
void merge(const CORE_Array< T > &array)
merge the array in this
Definition: CORE_Array.hpp:507
static SP::CORE_String New()
create a class String
Definition: CORE_String.h:96
void resize()
resize the array to the util size
Definition: CORE_Array.hpp:107
int getIndex(const T &v) const
get the index of value return -1 if no value in index
Definition: CORE_Array.hpp:380
void setCapacity(const int &c)
set the capacity of the vector
Definition: CORE_Array.hpp:76
void setValues(const CORE_Array< T > &array, const int &fromIndex)
Definition: CORE_Array.hpp:201
void contractToLastElements(const int &n)
keep only the last n elements of the array and set its capacity also to n
Definition: CORE_Array.hpp:289
tBoolean removeAtIndex(const int &i)
Definition: CORE_Array.hpp:278
void addAfterIndices(const CORE_Array< int > &indices, CORE_SharedPointersList< CORE_Array< T > > &values)
add alements after indices
Definition: CORE_Array.hpp:568