21 mVector=
new T[mCapacity];
26 "CORE_Array.hpp",21,
"constructor(...)");
37 mVector=
new T[mCapacity];
43 "CORE_Array.hpp",34,
"constructor(...)");
54 mVector=
new T[mCapacity];
59 "CORE_Array.hpp",48,
"constructor(...)");
60 for (
tArrayIndex i=0;i<mSize;i++) mVector[i]=(T) values[i];
67 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
79 mCVector=&mVector[mStartIndex];
89 if (dim==mCapacity)
return;
92 T *newVector=
new T[dim];
101 for (i=0;i<n;i++) newVector[i]=mVector[i];
104 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
108 mCVector=&mVector[mStartIndex];
116 if ((mSize==mCapacity) && (mStartIndex==0))
return;
118 T *newVector=
new T[mSize];
121 newVector[i]=mCVector[i];
122 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
131 if ((n==mCapacity) && (mStartIndex==0)) {
136 T *newVector=
new T[n];
139 newVector[i]=mCVector[i];
140 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
151 if (mSize==n)
return;
155 if (dim<=mCapacity) mSize=n;
167 if (mCapacity<=dim) {
168 mCapacity=mStartIndex+(mSize+1)*mCapacityFactor;
172 T *newVector=
new T[mCapacity];
176 "CORE_Array.hpp",157,
"add(const T&)");
178 for (i=0;i<dim;i++) newVector[i]=mVector[i];
179 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
181 mCVector=&mVector[mStartIndex];
190 if ((v[0]!=
'[') && (v[0]!=
'('))
return;
194 unsigned int n=str->getTokensCount();
195 unsigned int newDim=n+fromIndex;
197 if (newDim>mCapacity) setCapacity(newDim);
200 setStartIndex(fromIndex);
207 while (str->hasNextToken()) {
224 if (newDim>mCapacity) setCapacity(newDim);
227 setStartIndex(fromIndex);
233 for (i=0;i<narray;i++) mCVector[i]=array[i];
242 if (newDim>mCapacity) setCapacity(newDim);
245 setStartIndex(fromIndex);
251 for (i=0;i<narray;i++) mCVector[i]=values[i];
259 if (newDim>mCapacity) setCapacity(newDim);
262 setStartIndex(fromIndex);
268 for (i=0;i<narray;i++) mCVector[i]=values[i];
285 hasExisted=(mSize!=k);
292 if (index>=size())
return false;
293 if (index<0)
return false;
295 if (n==0)
return false;
297 for (i=index-1;i<n;i++)
298 mCVector[i]=mCVector[i+1];
305 if (n>=mSize)
return;
306 mCapacity=n+mStartIndex;
308 T *newVector=
new T[mCapacity];
312 for (i=mCapacity;i>0;) {
314 newVector[i]=mVector[k];
318 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
320 mCVector=&mVector[mStartIndex];
327 for (i=mSize;i>index;i--)
328 mCVector[i]=mCVector[i-1];
333 mCapacity+=mCapacityFactor*mSize;
335 T *newVector=
new T[mCapacity];
339 for (i=0;i<n;i++) newVector[i]=mVector[i];
343 for (i=n+1;i<=dim;i++)
344 newVector[i]=mVector[i-1];
345 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
347 mCVector=&mVector[mStartIndex];
364 if (obj<mCVector[0]) {
367 }
else if (obj==mCVector[0]) {
368 if (evenIfEqual)
return insert(0,obj);
372 if (obj>mCVector[sf]) {
375 }
else if (obj==mCVector[sf]) {
376 if (evenIfEqual)
return insert(mSize-1,obj);
383 if (obj>mCVector[i]) si=i;
384 else if (obj==mCVector[i]) {
385 if (evenIfEqual)
return insert(i,obj);
391 if (obj==mCVector[sf]) {
392 if (evenIfEqual)
return insert(sf,obj);
395 if (obj==mCVector[si]) {
396 if (evenIfEqual)
return insert(si,obj);
399 return insert(sf,obj);
413 if (obj<mCVector[si]) {
416 if (obj>mCVector[sf]) {
422 if (obj>mCVector[i]) si=i;
423 else if (obj==mCVector[i]) {
429 if (mCVector[sf]==obj) {
433 if (mCVector[si]==obj) {
450 if (obj<mCVector[si]) {
453 if (obj==mCVector[si]) {
456 if (obj>=mCVector[sf]) {
463 if (obj>mCVector[i]) si=i;
464 else if (obj==mCVector[i]) {
468 if (obj!=mCVector[k]) {
478 if (mCVector[sf]==obj) {
481 if (obj!=mCVector[k]) {
489 if (mCVector[si]==obj) {
492 if (obj!=mCVector[k]) {
503 if (obj!=mCVector[k]) {
523 if (obj<mCVector[0]) {
526 if (obj==mCVector[0]) {
528 if (obj!=mCVector[k]) {
536 if (obj>=mCVector[sf]) {
543 if (obj>mCVector[i]) si=i;
544 else if (obj==mCVector[i]) {
546 for (k=i+1;k<n;k++) {
547 if (obj!=mCVector[k]) {
558 if (mCVector[sf]==obj) {
559 for (k=sf+1;k<n;k++) {
560 if (obj!=mCVector[k]) {
568 if (mCVector[si]==obj) {
569 for (k=si+1;k<n;k++) {
570 if (obj!=mCVector[k]) {
578 for (k=sf+1;k<n;k++) {
579 if (obj!=mCVector[k]) {
591 if (mSize==0)
return;
595 for (i=0;i<mid;i++) {
597 mCVector[i]=mCVector[j];
612 if (newDim<mCapacity) {
614 for (i=mSize;i<newSize;i++) {
615 mCVector[i]=array[k];
620 mCapacity=mStartIndex+newSize*mCapacityFactor;
623 "CORE_Array::merge(const CORE_Array<T>& obj)",
625 T *newVector=
new T[mCapacity];
629 "CORE_Array.hpp",517,
"merge(const CORE_Array<T>&)");
632 for (i=mStartIndex+mSize;i>0;) {
634 newVector[i]=mVector[i];
638 for (i=mStartIndex+mSize;i<newDim;i++) {
639 newVector[i]=array[k];
643 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
645 mCVector=&mVector[mStartIndex];
655 for (i=0;i<dim;i++) {
668 for (i=dim-1;i>index+1;i--) {
669 mCVector[i]=mCVector[i-1];
681 for (i=0;i<nValues;i++)
682 nValuesToAdd+=values[i]->getSize();
688 "CORE_Array::addAfterIndices(...)",
690 T* newValues=
new T[dim];
694 "CORE_Array.hpp",571,
"addAfterIndices(...)");
696 long long int cur_newValues=dim-1;
697 long long int cur_indices=nIndices-1;
698 long long int cur_mVector=mStartIndex+mSize-1;
700 long long int insertIndex=-1;
701 while (cur_indices>-1) {
702 insertIndex=indices[cur_indices]+mStartIndex;
706 for (j=cur_mVector;j>insertIndex;j--) {
707 newValues[cur_newValues]=mVector[j];
711 cur_mVector=insertIndex;
717 for (j=nVals-1;j>=0;j--) {
718 newValues[cur_newValues]=vals[j];
729 for (j=cur_mVector;j>=(
long long int)mStartIndex;j--) {
730 newValues[cur_newValues]=mVector[j];
737 mSize=dim-mStartIndex;
740 if ((mVector!=
null) && (mHasToBeDeleted))
delete[] mVector;
742 mCVector=&mVector[mStartIndex];
760 if (compare(items[i],
769 while ((j>=h) && (!compare(items[j-h],
794 if (compare(obj,values[0],order)) {
799 if (compare(values[sf],obj,order)) {
804 if (compare(values[0],obj,
"=")) {
807 if (compare(values[sf],obj,
"=")) {
817 if (compare(values[i],obj,
"=")) {
820 }
else if (compare(values[i],obj,order)) {
825 if (compare(obj,values[sf],
"=")) {
829 if (compare(obj,values[si],
"=")) {
const T * getCompleteValues(tArrayIndex &s) const
get the values of the complete vector
Definition: CORE_Array.h:396
void setCapacity(const tArrayIndex &c)
set the capacity of the vector
Definition: CORE_Array.hpp:84
tString toString() const
return the string associated to the string
Definition: CORE_String.h:150
#define tArrayIndex
Definition: types.h:39
tBoolean getSupIndex(const T &v, tArrayIndex &index) const
get the sup index of value return false if no value less than v
Definition: CORE_Array.hpp:513
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
void addAfterIndex(const tArrayIndex &index, const T &v)
add an element after index
Definition: CORE_Array.hpp:665
this class describes a list
Definition: CORE_List.h:12
#define tBoolean
Definition: types.h:48
#define null
Definition: types.h:13
void reverse()
reverse the vector
Definition: CORE_Array.hpp:589
void contractToLastElements(const tArrayIndex &n)
keep only the last n elements of the array and set its capacity also to n
Definition: CORE_Array.hpp:304
static void parse(const tString &str, unsigned char &c)
parse unsigned char c in str
Definition: CORE_String.h:418
tArrayIndex insertInOrder(const T &obj, const tBoolean &evenIfEqual)
insert the object in increasing order
Definition: CORE_Array.hpp:353
tBoolean removeAtIndex(const tArrayIndex &i)
Definition: CORE_Array.hpp:291
void add(const T &obj)
add an element at the end re-allocate the array if capacity too small
Definition: CORE_Array.hpp:165
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
static tBoolean search(const T *values, const tArrayIndex &n, const T &value, const tString &order, tArrayIndex &index)
search the value in values array ordered in order
Definition: CORE_Array.hpp:780
tBoolean remove()
remove the last element
Definition: CORE_Array.h:486
#define tArrayIndexMax
Definition: types.h:40
const T & get(const tArrayIndex &i) const
get the value at index i Assert in (i>-1) Assert in (i
Definition: CORE_Array.h:179
virtual ~CORE_Array()
destroy an array of T*
Definition: CORE_Array.hpp:65
this class describes an array
Definition: CORE_Array.h:18
tArrayIndex insert(const tArrayIndex &i, const T &obj)
insert the object at index i re-allocate the array if capacity too small
Definition: CORE_Array.hpp:324
tBoolean getInfIndex(const T &v, tArrayIndex &index) const
get the inf index of value return false if no value less than v
Definition: CORE_Array.hpp:441
void setSize(const tArrayIndex &n)
set the size of the array
Definition: CORE_Array.hpp:149
void sort()
sort the array in an increasing order
Definition: CORE_Array.h:546
void copy(const CORE_Array< T > &src)
void copy
Definition: CORE_Array.hpp:72
CORE_Array()
build an array of T*
Definition: CORE_Array.hpp:32
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:142
tString toString() const
turn the array into string
Definition: CORE_Array.hpp:651
void setValues(const CORE_Array< T > &array, const tArrayIndex &fromIndex)
Definition: CORE_Array.hpp:214
#define tString
Definition: types.h:49
void merge(const CORE_Array< T > &array)
merge the array in this
Definition: CORE_Array.hpp:604
static SP::CORE_String New()
create a class String
Definition: CORE_String.h:96
const tArrayIndex & getStartIndex() const
get start index
Definition: CORE_Array.h:217
const tFlag & getCapacityFactor() const
get the capacity factor
Definition: CORE_Array.h:213
void resize()
resize the array to the util size
Definition: CORE_Array.hpp:115
const tArrayIndex & getSize() const
return the size of the array
Definition: CORE_Array.h:223
const tArrayIndex & getCapacity() const
return the memory allocation size of the array
Definition: CORE_Array.h:226
void addAfterIndices(const CORE_Array< tArrayIndex > &indices, CORE_SharedPointersList< CORE_Array< T > > &values)
add alements after indices
Definition: CORE_Array.hpp:675
tBoolean getIndex(const T &v, tArrayIndex &index) const
get the index of value return false if no value in index
Definition: CORE_Array.hpp:404