00001
00002
00003 #if defined(_MSC_VER)
00004
00005 # pragma warning(disable:4786)
00006 #endif
00007
00008 #include "CoinHelperFunctions.hpp"
00009 #include "CoinShallowPackedVector.hpp"
00010
00011
00012
00013 void
00014 CoinShallowPackedVector::clear()
00015 {
00016 clearBase();
00017 indices_ = NULL;
00018 elements_ = NULL;
00019 nElements_ = 0;
00020 }
00021
00022
00023
00024 CoinShallowPackedVector&
00025 CoinShallowPackedVector::operator=(const CoinPackedVectorBase & x)
00026 {
00027 if (&x != this) {
00028 indices_ = x.getIndices();
00029 elements_ = x.getElements();
00030 nElements_ = x.getNumElements();
00031 CoinPackedVectorBase::clearBase();
00032 CoinPackedVectorBase::copyMaxMinIndex(x);
00033 try {
00034 CoinPackedVectorBase::duplicateIndex();
00035 }
00036 catch (CoinError e) {
00037 throw CoinError("duplicate index", "operator= from base",
00038 "CoinShallowPackedVector");
00039 }
00040 }
00041 return *this;
00042 }
00043
00044
00045
00046 CoinShallowPackedVector&
00047 CoinShallowPackedVector::operator=(const CoinShallowPackedVector & x)
00048 {
00049 if (&x != this) {
00050 indices_ = x.indices_;
00051 elements_ = x.elements_;
00052 nElements_ = x.nElements_;
00053 CoinPackedVectorBase::clearBase();
00054 CoinPackedVectorBase::copyMaxMinIndex(x);
00055 try {
00056 CoinPackedVectorBase::duplicateIndex();
00057 }
00058 catch (CoinError e) {
00059 throw CoinError("duplicate index", "operator=",
00060 "CoinShallowPackedVector");
00061 }
00062 }
00063 return *this;
00064 }
00065
00066
00067
00068 void
00069 CoinShallowPackedVector::setVector(int size,
00070 const int * inds, const double * elems,
00071 bool testForDuplicateIndex)
00072 throw(CoinError)
00073 {
00074 indices_ = inds;
00075 elements_ = elems;
00076 nElements_ = size;
00077 CoinPackedVectorBase::clearBase();
00078 try {
00079 CoinPackedVectorBase::setTestForDuplicateIndex(testForDuplicateIndex);
00080 }
00081 catch (CoinError e) {
00082 throw CoinError("duplicate index", "setVector",
00083 "CoinShallowPackedVector");
00084 }
00085 }
00086
00087
00088
00089
00090
00091
00092 CoinShallowPackedVector::CoinShallowPackedVector(bool testForDuplicateIndex) :
00093 CoinPackedVectorBase(),
00094 indices_(NULL),
00095 elements_(NULL),
00096 nElements_(0)
00097 {
00098 try {
00099 CoinPackedVectorBase::setTestForDuplicateIndex(testForDuplicateIndex);
00100 }
00101 catch (CoinError e) {
00102 throw CoinError("duplicate index", "default constructor",
00103 "CoinShallowPackedVector");
00104 }
00105 }
00106
00107
00108
00109
00110 CoinShallowPackedVector::CoinShallowPackedVector(int size,
00111 const int * inds,
00112 const double * elems,
00113 bool testForDuplicateIndex) :
00114 CoinPackedVectorBase(),
00115 indices_(inds),
00116 elements_(elems),
00117 nElements_(size)
00118 {
00119 try {
00120 CoinPackedVectorBase::setTestForDuplicateIndex(testForDuplicateIndex);
00121 }
00122 catch (CoinError e) {
00123 throw CoinError("duplicate index", "explicit constructor",
00124 "CoinShallowPackedVector");
00125 }
00126 }
00127
00128
00129
00130
00131 CoinShallowPackedVector::CoinShallowPackedVector(const CoinPackedVectorBase& x) :
00132 CoinPackedVectorBase(),
00133 indices_(x.getIndices()),
00134 elements_(x.getElements()),
00135 nElements_(x.getNumElements())
00136 {
00137 CoinPackedVectorBase::copyMaxMinIndex(x);
00138 try {
00139 CoinPackedVectorBase::setTestForDuplicateIndex(x.testForDuplicateIndex());
00140 }
00141 catch (CoinError e) {
00142 throw CoinError("duplicate index", "copy constructor from base",
00143 "CoinShallowPackedVector");
00144 }
00145 }
00146
00147
00148
00149
00150 CoinShallowPackedVector::CoinShallowPackedVector(const
00151 CoinShallowPackedVector& x) :
00152 CoinPackedVectorBase(),
00153 indices_(x.getIndices()),
00154 elements_(x.getElements()),
00155 nElements_(x.getNumElements())
00156 {
00157 CoinPackedVectorBase::copyMaxMinIndex(x);
00158 try {
00159 CoinPackedVectorBase::setTestForDuplicateIndex(x.testForDuplicateIndex());
00160 }
00161 catch (CoinError e) {
00162 throw CoinError("duplicate index", "copy constructor",
00163 "CoinShallowPackedVector");
00164 }
00165 }