00001
00002
00003
00004
00005
00006 #ifndef CoinIndexedVector_H
00007 #define CoinIndexedVector_H
00008
00009 #if defined(_MSC_VER)
00010
00011 # pragma warning(disable:4786)
00012 #endif
00013
00014 #include <map>
00015 #include "CoinFinite.hpp"
00016 #ifndef CLP_NO_VECTOR
00017 #include "CoinPackedVectorBase.hpp"
00018 #endif
00019 #include "CoinSort.hpp"
00020 #include "CoinHelperFunctions.hpp"
00021 #include <cassert>
00022
00023 #ifndef COIN_FLOAT
00024 #define COIN_INDEXED_TINY_ELEMENT 1.0e-50
00025 #define COIN_INDEXED_REALLY_TINY_ELEMENT 1.0e-100
00026 #else
00027 #define COIN_INDEXED_TINY_ELEMENT 1.0e-35
00028 #define COIN_INDEXED_REALLY_TINY_ELEMENT 1.0e-39
00029 #endif
00030
00104 class CoinIndexedVector {
00105 friend void CoinIndexedVectorUnitTest();
00106
00107 public:
00110
00111 inline int getNumElements() const { return nElements_; }
00113 inline const int * getIndices() const { return indices_; }
00115
00117 inline int * getIndices() { return indices_; }
00121 inline double * denseVector() const { return elements_; }
00123 inline void setDenseVector(double * array)
00124 { elements_ = array;}
00126 inline void setIndexVector(int * array)
00127 { indices_ = array;}
00130 double & operator[](int i) const;
00131
00133
00134
00135
00136
00139
00140 inline void setNumElements(int value) { nElements_ = value;
00141 if (!nElements_) packedMode_=false;}
00143 void clear();
00145 void empty();
00147 CoinIndexedVector & operator=(const CoinIndexedVector &);
00148 #ifndef CLP_NO_VECTOR
00149
00151 CoinIndexedVector & operator=(const CoinPackedVectorBase & rhs);
00152 #endif
00153
00156 void copy(const CoinIndexedVector & rhs, double multiplier=1.0);
00157
00160 void borrowVector(int size, int numberIndices, int* inds, double* elems);
00161
00165 void returnVector();
00166
00171 void setVector(int numberIndices, const int * inds, const double * elems);
00172
00177 void setVector(int size, int numberIndices, const int * inds, const double * elems);
00178
00180 void setConstant(int size, const int * inds, double elems);
00181
00183 void setFull(int size, const double * elems);
00184
00188 void setElement(int index, double element);
00189
00191 void insert(int index, double element);
00193 inline void quickInsert(int index, double element)
00194 {
00195 assert (!elements_[index]);
00196 indices_[nElements_++] = index;
00197 assert (nElements_<=capacity_);
00198 elements_[index] = element;
00199 }
00202 void add(int index, double element);
00206 inline void quickAdd(int index, double element)
00207 {
00208 if (elements_[index]) {
00209 element += elements_[index];
00210 if ((element > 0 ? element : -element) >= COIN_INDEXED_TINY_ELEMENT) {
00211 elements_[index] = element;
00212 } else {
00213 elements_[index] = 1.0e-100;
00214 }
00215 } else if ((element > 0 ? element : -element) >= COIN_INDEXED_TINY_ELEMENT) {
00216 indices_[nElements_++] = index;
00217 assert (nElements_<=capacity_);
00218 elements_[index] = element;
00219 }
00220 }
00225 inline void quickAddNonZero(int index, double element)
00226 {
00227 assert (element);
00228 if (elements_[index]) {
00229 element += elements_[index];
00230 if ((element > 0 ? element : -element) >= COIN_INDEXED_TINY_ELEMENT) {
00231 elements_[index] = element;
00232 } else {
00233 elements_[index] = COIN_DBL_MIN;
00234 }
00235 } else {
00236 indices_[nElements_++] = index;
00237 assert (nElements_<=capacity_);
00238 elements_[index] = element;
00239 }
00240 }
00243 inline void zero(int index)
00244 {
00245 if (elements_[index])
00246 elements_[index] = COIN_DBL_MIN;
00247 }
00250 int clean(double tolerance);
00252 int cleanAndPack(double tolerance);
00254 int cleanAndPackSafe(double tolerance);
00256 inline void setPacked()
00257 { packedMode_ = true;}
00258 #ifndef NDEBUG
00260 void checkClear();
00262 void checkClean();
00263 #else
00264 inline void checkClear() {};
00265 inline void checkClean() {};
00266 #endif
00268 int scan();
00269
00272 int scan(int start, int end);
00275 int scan(double tolerance);
00279 int scan(int start, int end, double tolerance);
00281 int scanAndPack();
00282 int scanAndPack(int start, int end);
00283 int scanAndPack(double tolerance);
00284 int scanAndPack(int start, int end, double tolerance);
00286 void createPacked(int number, const int * indices,
00287 const double * elements);
00289 void createUnpacked(int number, const int * indices,
00290 const double * elements);
00292 void createOneUnpackedElement(int index, double element);
00294 void expand();
00295 #ifndef CLP_NO_VECTOR
00297 void append(const CoinPackedVectorBase & caboose);
00298 #endif
00300 void append(const CoinIndexedVector & caboose);
00302 void append(CoinIndexedVector & other,int adjustIndex,bool zapElements=false);
00303
00305 void swap(int i, int j);
00306
00308 void truncate(int newSize);
00310 void print() const;
00312
00314
00315 void operator+=(double value);
00317 void operator-=(double value);
00319 void operator*=(double value);
00321 void operator/=(double value);
00323
00326 #ifndef CLP_NO_VECTOR
00327
00329 bool operator==(const CoinPackedVectorBase & rhs) const;
00331 bool operator!=(const CoinPackedVectorBase & rhs) const;
00332 #endif
00333
00335 bool operator==(const CoinIndexedVector & rhs) const;
00337 bool operator!=(const CoinIndexedVector & rhs) const;
00339 int isApproximatelyEqual(const CoinIndexedVector & rhs, double tolerance=1.0e-8) const;
00341
00344
00345 int getMaxIndex() const;
00347 int getMinIndex() const;
00349
00350
00354 void sort()
00355 { std::sort(indices_,indices_+nElements_); }
00356
00357 void sortIncrIndex()
00358 { std::sort(indices_,indices_+nElements_); }
00359
00360 void sortDecrIndex();
00361
00362 void sortIncrElement();
00363
00364 void sortDecrElement();
00365 void sortPacked();
00366
00368
00369
00370
00382
00383 CoinIndexedVector operator+(
00384 const CoinIndexedVector& op2);
00385
00387 CoinIndexedVector operator-(
00388 const CoinIndexedVector& op2);
00389
00391 CoinIndexedVector operator*(
00392 const CoinIndexedVector& op2);
00393
00395 CoinIndexedVector operator/(
00396 const CoinIndexedVector& op2);
00398 void operator+=(const CoinIndexedVector& op2);
00399
00401 void operator-=( const CoinIndexedVector& op2);
00402
00404 void operator*=(const CoinIndexedVector& op2);
00405
00407 void operator/=(const CoinIndexedVector& op2);
00409
00416 void reserve(int n);
00420 int capacity() const { return capacity_; }
00422 inline void setPackedMode(bool yesNo)
00423 { packedMode_=yesNo;}
00425 inline bool packedMode() const
00426 { return packedMode_;}
00428
00432 CoinIndexedVector();
00434 CoinIndexedVector(int size, const int * inds, const double * elems);
00436 CoinIndexedVector(int size, const int * inds, double element);
00439 CoinIndexedVector(int size, const double * elements);
00441 CoinIndexedVector(int size);
00443 CoinIndexedVector(const CoinIndexedVector &);
00445 CoinIndexedVector(const CoinIndexedVector *);
00446 #ifndef CLP_NO_VECTOR
00447
00448 CoinIndexedVector(const CoinPackedVectorBase & rhs);
00449 #endif
00450
00451 ~CoinIndexedVector ();
00453
00454 private:
00457
00458 void gutsOfSetVector(int size,
00459 const int * inds, const double * elems);
00460 void gutsOfSetVector(int size, int numberIndices,
00461 const int * inds, const double * elems);
00462 void gutsOfSetPackedVector(int size, int numberIndices,
00463 const int * inds, const double * elems);
00465 void gutsOfSetConstant(int size,
00466 const int * inds, double value);
00468
00469 protected:
00472
00473 int * indices_;
00475 double * elements_;
00477 int nElements_;
00479 int capacity_;
00481 int offset_;
00483 bool packedMode_;
00485 };
00486
00487
00493 void
00494 CoinIndexedVectorUnitTest();
00511 class CoinArrayWithLength {
00512
00513 public:
00516
00517 inline int getSize() const
00518 { return size_; }
00520 inline int rawSize() const
00521 { return size_; }
00523 inline bool switchedOn() const
00524 { return size_!=-1; }
00526 inline int capacity() const
00527 { return (size_>-2) ? size_ : (-size_)-2; }
00529 inline void setCapacity()
00530 { if (size_<=-2) size_ = (-size_)-2; }
00532 inline const char * array() const
00533 { return (size_>-2) ? array_ : NULL; }
00535
00538
00539 inline void setSize(int value)
00540 { size_ = value; }
00542 inline void switchOff()
00543 { size_ = -1; }
00545 inline void switchOn(int alignment=3)
00546 { size_ = -2; alignment_=alignment;}
00548 void setPersistence(int flag,int currentLength);
00550 void clear();
00552 void swap(CoinArrayWithLength & other);
00554 void extend(int newSize);
00556
00559
00560 char * conditionalNew(long sizeWanted);
00562 void conditionalDelete();
00564
00568 inline CoinArrayWithLength()
00569 : array_(NULL),size_(-1),offset_(0),alignment_(0)
00570 { }
00572 inline CoinArrayWithLength(int size)
00573 : size_(-1),offset_(0),alignment_(0)
00574 { array_=new char [size];}
00581 CoinArrayWithLength(int size, int mode);
00583 CoinArrayWithLength(const CoinArrayWithLength & rhs);
00585 CoinArrayWithLength(const CoinArrayWithLength * rhs);
00587 CoinArrayWithLength& operator=(const CoinArrayWithLength & rhs);
00589 void copy(const CoinArrayWithLength & rhs, int numberBytes=-1);
00591 void allocate(const CoinArrayWithLength & rhs, int numberBytes);
00593 ~CoinArrayWithLength ();
00595 void getArray(int size);
00597 void reallyFreeArray();
00599 void getCapacity(int numberBytes,int numberIfNeeded=-1);
00601
00602 protected:
00605
00606 char * array_;
00608 CoinBigIndex size_;
00610 int offset_;
00612 int alignment_;
00614 };
00616
00617 class CoinDoubleArrayWithLength : public CoinArrayWithLength {
00618
00619 public:
00622
00623 inline int getSize() const
00624 { return size_/CoinSizeofAsInt(double); }
00626 inline double * array() const
00627 { return reinterpret_cast<double *> ((size_>-2) ? array_ : NULL); }
00629
00632
00633 inline void setSize(int value)
00634 { size_ = value*CoinSizeofAsInt(double); }
00636
00639
00640 inline double * conditionalNew(int sizeWanted)
00641 { return reinterpret_cast<double *> ( CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> ((sizeWanted)*CoinSizeofAsInt(double)) : -1)); }
00643
00647 inline CoinDoubleArrayWithLength()
00648 { array_=NULL; size_=-1;}
00650 inline CoinDoubleArrayWithLength(int size)
00651 { array_=new char [size*CoinSizeofAsInt(double)]; size_=-1;}
00656 inline CoinDoubleArrayWithLength(int size, int mode)
00657 : CoinArrayWithLength(size*CoinSizeofAsInt(double),mode) {}
00659 inline CoinDoubleArrayWithLength(const CoinDoubleArrayWithLength & rhs)
00660 : CoinArrayWithLength(rhs) {}
00662 inline CoinDoubleArrayWithLength(const CoinDoubleArrayWithLength * rhs)
00663 : CoinArrayWithLength(rhs) {}
00665 inline CoinDoubleArrayWithLength& operator=(const CoinDoubleArrayWithLength & rhs)
00666 { CoinArrayWithLength::operator=(rhs); return *this;}
00668 };
00670
00671 class CoinFactorizationDoubleArrayWithLength : public CoinArrayWithLength {
00672
00673 public:
00676
00677 inline int getSize() const
00678 { return size_/CoinSizeofAsInt(CoinFactorizationDouble); }
00680 inline CoinFactorizationDouble * array() const
00681 { return reinterpret_cast<CoinFactorizationDouble *> ((size_>-2) ? array_ : NULL); }
00683
00686
00687 inline void setSize(int value)
00688 { size_ = value*CoinSizeofAsInt(CoinFactorizationDouble); }
00690
00693
00694 inline CoinFactorizationDouble * conditionalNew(int sizeWanted)
00695 { return reinterpret_cast<CoinFactorizationDouble *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(CoinFactorizationDouble)) : -1)); }
00697
00701 inline CoinFactorizationDoubleArrayWithLength()
00702 { array_=NULL; size_=-1;}
00704 inline CoinFactorizationDoubleArrayWithLength(int size)
00705 { array_=new char [size*CoinSizeofAsInt(CoinFactorizationDouble)]; size_=-1;}
00710 inline CoinFactorizationDoubleArrayWithLength(int size, int mode)
00711 : CoinArrayWithLength(size*CoinSizeofAsInt(CoinFactorizationDouble),mode) {}
00713 inline CoinFactorizationDoubleArrayWithLength(const CoinFactorizationDoubleArrayWithLength & rhs)
00714 : CoinArrayWithLength(rhs) {}
00716 inline CoinFactorizationDoubleArrayWithLength(const CoinFactorizationDoubleArrayWithLength * rhs)
00717 : CoinArrayWithLength(rhs) {}
00719 inline CoinFactorizationDoubleArrayWithLength& operator=(const CoinFactorizationDoubleArrayWithLength & rhs)
00720 { CoinArrayWithLength::operator=(rhs); return *this;}
00722 };
00724
00725 class CoinFactorizationLongDoubleArrayWithLength : public CoinArrayWithLength {
00726
00727 public:
00730
00731 inline int getSize() const
00732 { return size_/CoinSizeofAsInt(long double); }
00734 inline long double * array() const
00735 { return reinterpret_cast<long double *> ((size_>-2) ? array_ : NULL); }
00737
00740
00741 inline void setSize(int value)
00742 { size_ = value*CoinSizeofAsInt(long double); }
00744
00747
00748 inline long double * conditionalNew(int sizeWanted)
00749 { return reinterpret_cast<long double *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(long double)) : -1)); }
00751
00755 inline CoinFactorizationLongDoubleArrayWithLength()
00756 { array_=NULL; size_=-1;}
00758 inline CoinFactorizationLongDoubleArrayWithLength(int size)
00759 { array_=new char [size*CoinSizeofAsInt(long double)]; size_=-1;}
00764 inline CoinFactorizationLongDoubleArrayWithLength(int size, int mode)
00765 : CoinArrayWithLength(size*CoinSizeofAsInt(long double),mode) {}
00767 inline CoinFactorizationLongDoubleArrayWithLength(const CoinFactorizationLongDoubleArrayWithLength & rhs)
00768 : CoinArrayWithLength(rhs) {}
00770 inline CoinFactorizationLongDoubleArrayWithLength(const CoinFactorizationLongDoubleArrayWithLength * rhs)
00771 : CoinArrayWithLength(rhs) {}
00773 inline CoinFactorizationLongDoubleArrayWithLength& operator=(const CoinFactorizationLongDoubleArrayWithLength & rhs)
00774 { CoinArrayWithLength::operator=(rhs); return *this;}
00776 };
00778
00779 class CoinIntArrayWithLength : public CoinArrayWithLength {
00780
00781 public:
00784
00785 inline int getSize() const
00786 { return size_/CoinSizeofAsInt(int); }
00788 inline int * array() const
00789 { return reinterpret_cast<int *> ((size_>-2) ? array_ : NULL); }
00791
00794
00795 inline void setSize(int value)
00796 { size_ = value*CoinSizeofAsInt(int); }
00798
00801
00802 inline int * conditionalNew(int sizeWanted)
00803 { return reinterpret_cast<int *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(int)) : -1)); }
00805
00809 inline CoinIntArrayWithLength()
00810 { array_=NULL; size_=-1;}
00812 inline CoinIntArrayWithLength(int size)
00813 { array_=new char [size*CoinSizeofAsInt(int)]; size_=-1;}
00818 inline CoinIntArrayWithLength(int size, int mode)
00819 : CoinArrayWithLength(size*CoinSizeofAsInt(int),mode) {}
00821 inline CoinIntArrayWithLength(const CoinIntArrayWithLength & rhs)
00822 : CoinArrayWithLength(rhs) {}
00824 inline CoinIntArrayWithLength(const CoinIntArrayWithLength * rhs)
00825 : CoinArrayWithLength(rhs) {}
00827 inline CoinIntArrayWithLength& operator=(const CoinIntArrayWithLength & rhs)
00828 { CoinArrayWithLength::operator=(rhs); return *this;}
00830 };
00832
00833 class CoinBigIndexArrayWithLength : public CoinArrayWithLength {
00834
00835 public:
00838
00839 inline int getSize() const
00840 { return size_/CoinSizeofAsInt(CoinBigIndex); }
00842 inline CoinBigIndex * array() const
00843 { return reinterpret_cast<CoinBigIndex *> ((size_>-2) ? array_ : NULL); }
00845
00848
00849 inline void setSize(int value)
00850 { size_ = value*CoinSizeofAsInt(CoinBigIndex); }
00852
00855
00856 inline CoinBigIndex * conditionalNew(int sizeWanted)
00857 { return reinterpret_cast<CoinBigIndex *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(CoinBigIndex)) : -1)); }
00859
00863 inline CoinBigIndexArrayWithLength()
00864 { array_=NULL; size_=-1;}
00866 inline CoinBigIndexArrayWithLength(int size)
00867 { array_=new char [size*CoinSizeofAsInt(CoinBigIndex)]; size_=-1;}
00872 inline CoinBigIndexArrayWithLength(int size, int mode)
00873 : CoinArrayWithLength(size*CoinSizeofAsInt(CoinBigIndex),mode) {}
00875 inline CoinBigIndexArrayWithLength(const CoinBigIndexArrayWithLength & rhs)
00876 : CoinArrayWithLength(rhs) {}
00878 inline CoinBigIndexArrayWithLength(const CoinBigIndexArrayWithLength * rhs)
00879 : CoinArrayWithLength(rhs) {}
00881 inline CoinBigIndexArrayWithLength& operator=(const CoinBigIndexArrayWithLength & rhs)
00882 { CoinArrayWithLength::operator=(rhs); return *this;}
00884 };
00886
00887 class CoinUnsignedIntArrayWithLength : public CoinArrayWithLength {
00888
00889 public:
00892
00893 inline int getSize() const
00894 { return size_/CoinSizeofAsInt(unsigned int); }
00896 inline unsigned int * array() const
00897 { return reinterpret_cast<unsigned int *> ((size_>-2) ? array_ : NULL); }
00899
00902
00903 inline void setSize(int value)
00904 { size_ = value*CoinSizeofAsInt(unsigned int); }
00906
00909
00910 inline unsigned int * conditionalNew(int sizeWanted)
00911 { return reinterpret_cast<unsigned int *> (CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> (( sizeWanted)*CoinSizeofAsInt(unsigned int)) : -1)); }
00913
00917 inline CoinUnsignedIntArrayWithLength()
00918 { array_=NULL; size_=-1;}
00920 inline CoinUnsignedIntArrayWithLength(int size)
00921 { array_=new char [size*CoinSizeofAsInt(unsigned int)]; size_=-1;}
00926 inline CoinUnsignedIntArrayWithLength(int size, int mode)
00927 : CoinArrayWithLength(size*CoinSizeofAsInt(unsigned int),mode) {}
00929 inline CoinUnsignedIntArrayWithLength(const CoinUnsignedIntArrayWithLength & rhs)
00930 : CoinArrayWithLength(rhs) {}
00932 inline CoinUnsignedIntArrayWithLength(const CoinUnsignedIntArrayWithLength * rhs)
00933 : CoinArrayWithLength(rhs) {}
00935 inline CoinUnsignedIntArrayWithLength& operator=(const CoinUnsignedIntArrayWithLength & rhs)
00936 { CoinArrayWithLength::operator=(rhs); return *this;}
00938 };
00940
00941 class CoinVoidStarArrayWithLength : public CoinArrayWithLength {
00942
00943 public:
00946
00947 inline int getSize() const
00948 { return size_/CoinSizeofAsInt(void *); }
00950 inline void ** array() const
00951 { return reinterpret_cast<void **> ((size_>-2) ? array_ : NULL); }
00953
00956
00957 inline void setSize(int value)
00958 { size_ = value*CoinSizeofAsInt(void *); }
00960
00963
00964 inline void ** conditionalNew(int sizeWanted)
00965 { return reinterpret_cast<void **> ( CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long> ((sizeWanted)*CoinSizeofAsInt(void *)) : -1)); }
00967
00971 inline CoinVoidStarArrayWithLength()
00972 { array_=NULL; size_=-1;}
00974 inline CoinVoidStarArrayWithLength(int size)
00975 { array_=new char [size*CoinSizeofAsInt(void *)]; size_=-1;}
00980 inline CoinVoidStarArrayWithLength(int size, int mode)
00981 : CoinArrayWithLength(size*CoinSizeofAsInt(void *),mode) {}
00983 inline CoinVoidStarArrayWithLength(const CoinVoidStarArrayWithLength & rhs)
00984 : CoinArrayWithLength(rhs) {}
00986 inline CoinVoidStarArrayWithLength(const CoinVoidStarArrayWithLength * rhs)
00987 : CoinArrayWithLength(rhs) {}
00989 inline CoinVoidStarArrayWithLength& operator=(const CoinVoidStarArrayWithLength & rhs)
00990 { CoinArrayWithLength::operator=(rhs); return *this;}
00992 };
00994
00995 class CoinArbitraryArrayWithLength : public CoinArrayWithLength {
00996
00997 public:
01000
01001 inline int getSize() const
01002 { return size_/lengthInBytes_; }
01004 inline void ** array() const
01005 { return reinterpret_cast<void **> ((size_>-2) ? array_ : NULL); }
01007
01010
01011 inline void setSize(int value)
01012 { size_ = value*lengthInBytes_; }
01014
01017
01018 inline char * conditionalNew(int length, int sizeWanted)
01019 { lengthInBytes_=length;return reinterpret_cast<char *> ( CoinArrayWithLength::conditionalNew(sizeWanted>=0 ? static_cast<long>
01020 ((sizeWanted)*lengthInBytes_) : -1)); }
01022
01026 inline CoinArbitraryArrayWithLength(int length=1)
01027 { array_=NULL; size_=-1;lengthInBytes_=length;}
01029 inline CoinArbitraryArrayWithLength(int length, int size)
01030 { array_=new char [size*length]; size_=-1; lengthInBytes_=length;}
01035 inline CoinArbitraryArrayWithLength(int length, int size, int mode)
01036 : CoinArrayWithLength(size*length,mode) {lengthInBytes_=length;}
01038 inline CoinArbitraryArrayWithLength(const CoinArbitraryArrayWithLength & rhs)
01039 : CoinArrayWithLength(rhs) {}
01041 inline CoinArbitraryArrayWithLength(const CoinArbitraryArrayWithLength * rhs)
01042 : CoinArrayWithLength(rhs) {}
01044 inline CoinArbitraryArrayWithLength& operator=(const CoinArbitraryArrayWithLength & rhs)
01045 { CoinArrayWithLength::operator=(rhs); return *this;}
01047
01048 protected:
01051
01052 int lengthInBytes_;
01054 };
01055 class CoinPartitionedVector : public CoinIndexedVector {
01056
01057 public:
01058 #ifndef COIN_PARTITIONS
01059 #define COIN_PARTITIONS 8
01060 #endif
01061
01063
01064 inline int getNumElements(int partition) const { assert (partition<COIN_PARTITIONS);
01065 return numberElementsPartition_[partition]; }
01067 inline int getNumPartitions() const
01068 { return numberPartitions_; }
01070 inline int getNumElements() const { return nElements_; }
01072 inline int startPartition(int partition) const { assert (partition<=COIN_PARTITIONS);
01073 return startPartition_[partition]; }
01075 inline const int * startPartitions() const
01076 { return startPartition_; }
01078
01079
01080
01081
01084
01085 inline void setNumElementsPartition(int partition, int value) { assert (partition<COIN_PARTITIONS);
01086 if (numberPartitions_) numberElementsPartition_[partition]=value; }
01088 inline void setTempNumElementsPartition(int partition, int value) { assert (partition<COIN_PARTITIONS);
01089 numberElementsPartition_[partition]=value; }
01091 void computeNumberElements();
01093 void compact();
01096 void reserve(int n);
01098 void setPartitions(int number,const int * starts);
01100 void clearAndReset();
01102 void clearAndKeep();
01104 void clearPartition(int partition);
01105 #ifndef NDEBUG
01107 void checkClear();
01109 void checkClean();
01110 #else
01111 inline void checkClear() {};
01112 inline void checkClean() {};
01113 #endif
01115 int scan(int partition, double tolerance=0.0);
01116
01119
01120 void print() const;
01122
01126 void sort();
01128
01132 CoinPartitionedVector();
01134 CoinPartitionedVector(int size, const int * inds, const double * elems);
01136 CoinPartitionedVector(int size, const int * inds, double element);
01139 CoinPartitionedVector(int size, const double * elements);
01141 CoinPartitionedVector(int size);
01143 CoinPartitionedVector(const CoinPartitionedVector &);
01145 CoinPartitionedVector(const CoinPartitionedVector *);
01147 CoinPartitionedVector & operator=(const CoinPartitionedVector &);
01149 ~CoinPartitionedVector ();
01151 protected:
01154
01155 int startPartition_[COIN_PARTITIONS+1];
01157 int numberElementsPartition_[COIN_PARTITIONS];
01159 int numberPartitions_;
01161 };
01162 #endif