コード例 #1
0
ファイル: CoinPackedVector.cpp プロジェクト: rafapaz/FlopCpp
void
CoinPackedVector::append(const CoinPackedVectorBase & caboose)
{
   const int cs = caboose.getNumElements();
   if (cs == 0) {
       return;
   }
   if (testForDuplicateIndex()) {
       // Just to initialize the index heap
       indexSet("append (1st call)", "CoinPackedVector");
   }
   const int s = nElements_;
   // Make sure there is enough room for the caboose
   if ( capacity_ < s + cs)
      reserve(CoinMax(s + cs, 2 * capacity_));

   const int * cind = caboose.getIndices();
   const double * celem = caboose.getElements();
   CoinDisjointCopyN(cind, cs, indices_ + s);
   CoinDisjointCopyN(celem, cs, elements_ + s);
   CoinIotaN(origIndices_ + s, cs, s);
   nElements_ += cs;
   if (testForDuplicateIndex()) {
      std::set<int>& is = *indexSet("append (2nd call)", "CoinPackedVector");
      for (int i = 0; i < cs; ++i) {
	 if (!is.insert(cind[i]).second)
	    throw CoinError("duplicate index", "append", "CoinPackedVector");
      }
   }
}
コード例 #2
0
void CoinPackedVectorBase::duplicateIndex(const char *methodName,
  const char *className) const
{
  if (testForDuplicateIndex())
    indexSet(methodName, className);
  testedDuplicateIndex_ = true;
}
コード例 #3
0
ファイル: CoinPackedVector.cpp プロジェクト: rafapaz/FlopCpp
void
CoinPackedVector::insert( int index, double element )
{
   const int s = nElements_;
   if (testForDuplicateIndex()) {
      std::set<int>& is = *indexSet("insert", "CoinPackedVector");
      if (! is.insert(index).second)
	 throw CoinError("Index already exists", "insert", "CoinPackedVector");
   }

   if( capacity_ <= s ) {
      reserve( CoinMax(5, 2*capacity_) );
      assert( capacity_ > s );
   }
   indices_[s] = index;
   elements_[s] = element;
   origIndices_[s] = s;
   ++nElements_;
}