1 #ifndef CORE_Vector_CPP
2 #define CORE_Vector_CPP
26 for (
int i=0;i<n;i++) {
41 if (obj==
null)
return false;
42 typename vector<T >::iterator p;
46 p=find(mVector.begin(),mVector.end(),obj);
47 found=(p!=mVector.end());
57 if (index>=size())
return false;
58 if (index<0)
return false;
59 typename vector<T >::iterator p=mVector.begin()+index;
67 mVector[i]=mVector[j];
74 if (((
int)mVector.size())==index) add(obj);
77 if (index<0)
return false;
78 typename vector<T >::iterator p=mVector.begin()+i;
79 if (i>size())
return false;
80 mVector.insert(p,obj);
95 }
else if (obj==mVector[0]) {
96 if (evenIfEqual)
return insert(0,evenIfEqual);
99 if (obj>mVector[sf]) {
102 }
else if (obj==mVector[sf]) {
103 if (evenIfEqual)
return insert(sf,evenIfEqual);
109 if (obj>mVector[i]) si=i;
110 else if (obj==mVector[i]) {
111 if (evenIfEqual)
return insert(i,evenIfEqual);
116 if (obj==mVector[sf]) {
117 if (evenIfEqual)
return insert(sf,evenIfEqual);
120 if (obj==mVector[si]) {
121 if (evenIfEqual)
return insert(si,evenIfEqual);
124 return insert(sf,obj);
134 int sf=values.size()-1;
139 if (compare(obj,values[0],order)) {
144 if (compare(values[sf],obj,order)) {
149 if (compare(values[0],obj,
"=")) {
152 if (compare(values[sf],obj,
"=")) {
161 if (compare(values[i],obj,
"=")) {
163 }
else if (compare(values[i],obj,order)) {
168 if (compare(obj,values[sf],
"=")) {
171 if (compare(obj,values[si],
"=")) {
190 int n=mVector.size();
191 for (
int i=0;i<n/2;i++) {
193 mVector[i]=mVector[k];
201 int oldSize=getSize();
204 int newSize=getSize();
205 for (
int i=oldSize;i<newSize;i++) set(i,array[i]);
210 typename vector<T>::const_iterator p=find(mVector.begin(),mVector.end(),obj);
211 return (p!=mVector.end());
217 int dim=mVector.size()+1;
219 for (
int i=dim-1;i>index+1;i--) {
220 mVector[i]=mVector[i-1];
222 if (((
int)mVector.size())>index+1)
229 if (p_indices.get()==
null)
return;
233 int nIndices=indices.
getSize();
234 int nValues=values.getSize();
236 for (
int i=0;i<nValues;i++)
237 nValuesToAdd+=values[i]->getSize();
240 int dim=mVector.size()+nValuesToAdd;
241 vector<T> newValues(dim);
243 int cur_newValues=dim-1;
244 int cur_indices=nIndices-1;
245 int cur_mVector=mVector.size()-1;
248 while (cur_indices>-1) {
249 insertIndex=indices[cur_indices];
253 for (
int i=cur_mVector;i>insertIndex;i--) {
254 newValues[cur_newValues]=mVector[i];
258 cur_mVector=insertIndex;
264 for (
int i=nVals-1;i>=0;i--) {
265 newValues[cur_newValues]=vals[i];
276 for (
int i=cur_mVector;i>=0;i--) {
277 newValues[cur_newValues]=mVector[i];
284 for (
int i=0;i<dim;i++) mVector[i]=newValues[i];
301 if (compare(items[i],
310 while ((j>=h) && (!compare(items[j-h],
tBoolean remove()
remove the last pointer
Definition: CORE_Vector.h:345
void sort(const tString &order)
sort the vector decreasing order < increasing order
Definition: CORE_Vector.h:323
this class describes an array
Definition: CORE_Vector.h:18
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
int insertInOrder(const T &obj, const tBoolean &evenIfEqual)
insert T
Definition: CORE_Vector.hpp:85
this class describes a list
Definition: CORE_List.h:12
tBoolean exists(const T &obj) const
exists
Definition: CORE_Vector.hpp:209
void reverse()
reverse the vector
Definition: CORE_Vector.hpp:188
#define tBoolean
Definition: types.h:35
tBoolean removeAtIndex(const int &i)
remove the pointer at index i
Definition: CORE_Vector.hpp:56
#define null
Definition: types.h:13
CORE_Vector()
build a vector of T
Definition: CORE_Vector.hpp:11
virtual ~CORE_Vector()
destroy an array of T*
Definition: CORE_Vector.hpp:34
int size() const
return the size of the vector
Definition: CORE_Vector.h:384
static int search(const vector< T > &values, const T &value, const tString &order)
search the value in values vector ordered in order
Definition: CORE_Vector.hpp:129
tBoolean insert(int i, const T &obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_Vector.hpp:73
int getSize() const
return the size of the vector
Definition: CORE_Vector.h:387
tBoolean set(int i, const T &obj)
set the pointer at the index i
Definition: CORE_Vector.hpp:178
#define tString
Definition: types.h:36
void permute(const int &i, const int &j)
permute
Definition: CORE_Vector.hpp:65
const T & get(int i) const
get the pointer at index i ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_Vector.h:367
void addAfterIndex(const int &index, const T &v)
add an element after index
Definition: CORE_Vector.hpp:216
void addAfterIndices(boost::shared_ptr< CORE_Vector< int > > &p_indices, const CORE_SharedPointersList< CORE_Vector< T > > &values)
add alements after indices
Definition: CORE_Vector.hpp:227
void merge(const CORE_Vector< T > &array)
merge the array in this
Definition: CORE_Vector.hpp:200