当前位置: 首页>>代码示例>>C++>>正文


C++ UIntVector类代码示例

本文整理汇总了C++中UIntVector的典型用法代码示例。如果您正苦于以下问题:C++ UIntVector类的具体用法?C++ UIntVector怎么用?C++ UIntVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UIntVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    // Några saker som ska fungera:
    UIntVector a(7);           // initiering med 7 element
    UIntVector b(a);           // kopieringskonstruktor
    UIntVector c = a;          // kopieringskonstruktor
    UIntVector d(6);


    a = b;                 // tilldelning genom kopiering
    a[5] = 7;              // tilldelning till element

    const UIntVector e(10);    // konstant objekt med 10 element
    int i = e[5];          // const int oper[](int) const körs
    i = a[0];              // vektorn är nollindexerad
    i = a[5];              // int oper[](int) körs
    
    a[5]++;                // öka värdet till 8

    try {
        i = e[10];             // försöker hämta element som ligger utanför e
    } catch (std::out_of_range e) {
        std::cout << e.what() << std::endl;
    }
    
    // Diverse saker att testa
    e[5] = 3;              // fel: (kompilerar ej) tilldelning till const
    b = b;                 // hmm: se till att inte minnet som skall behållas frigörs

    return 0;
}
开发者ID:kwabe007,项目名称:spel-spelet,代码行数:31,代码来源:test_vec.cpp

示例2: WriteCharsets

EStatusCode CFFEmbeddedFontWriter::WriteCharsets(const UIntVector& inSubsetGlyphIDs,
													UShortVector* inCIDMapping)
{
	// since this is a subset the chances that i'll get a defult charset are 0.
	// hence i'll always do some charset. and using format 0 !!1
	UIntVector::const_iterator it = inSubsetGlyphIDs.begin();
	++it; // skip the 0

	mCharsetPosition = mFontFileStream.GetCurrentPosition();

	mPrimitivesWriter.WriteCard8(0);
	if(mIsCID && inCIDMapping)
	{
		UShortVector::const_iterator itCIDs = inCIDMapping->begin();
		++itCIDs;
		for(; it != inSubsetGlyphIDs.end(); ++it,++itCIDs)
			mPrimitivesWriter.WriteSID(*itCIDs);

	}
	else
	{
		// note that this also works for CIDs! cause in this case the SIDs are actually
		// CIDs
		for(; it != inSubsetGlyphIDs.end(); ++it)
			mPrimitivesWriter.WriteSID(mOpenTypeInput.mCFF.GetGlyphSID(0,*it));
	}
	return mPrimitivesWriter.GetInternalState();
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:28,代码来源:CFFEmbeddedFontWriter.cpp

示例3: GetOrderedKeys

static UIntVector GetOrderedKeys(const UIntAndGlyphEncodingInfoVector& inMap)
{
	UIntVector result;
	for(UIntAndGlyphEncodingInfoVector::const_iterator it = inMap.begin(); it != inMap.end(); ++it)
		result.push_back(it->first);
	sort(result.begin(),result.end());
	return result;
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:8,代码来源:TrueTypeDescendentFontWriter.cpp

示例4: TRACE_LOG1

EStatusCode CFFDescendentFontWriter::WriteFont(	ObjectIDType inDecendentObjectID, 
														const std::string& inFontName,
														FreeTypeFaceWrapper& inFontInfo,
														const UIntAndGlyphEncodingInfoVector& inEncodedGlyphs,
														ObjectsContext* inObjectsContext,
														bool inEmbedFont)
{
	// reset embedded font object ID (and flag...to whether it was actually embedded or not, which may 
	// happen due to font embedding restrictions)
	mEmbeddedFontFileObjectID = 0;

	// Logically speaking, i shouldn't be getting to CID writing
	// if in type 1. at least, this is the current assumption, since
	// i don't intend to support type 1 CIDs, but just regular type 1s.
	// as such - fail if got here for type 1
	const char* fontType = inFontInfo.GetTypeString();
	if(strcmp(scType1,fontType) == 0)
	{
		TRACE_LOG1("CFFDescendentFontWriter::WriteFont, Exception. identified type1 font when writing CFF CID font, font name - %s. type 1 CIDs are not supported.",inFontName.substr(0, MAX_TRACE_SIZE - 200).c_str());
		return PDFHummus::eFailure;
	}

	if (inEmbedFont)
	{
		CFFEmbeddedFontWriter embeddedFontWriter;
		UIntAndGlyphEncodingInfoVector encodedGlyphs = inEncodedGlyphs;
		UIntVector orderedGlyphs;
		UShortVector cidMapping;

		// Gal: the following sort completely ruins everything.
		// the order of the glyphs should be maintained per the ENCODED characthers
		// which is how the input is recieved. IMPORTANT - the order is critical
		// for the success of the embedding, as the order determines the order of the glyphs
		// in the subset font and so their GID which MUST match the encoded char.
		//sort(encodedGlyphs.begin(), encodedGlyphs.end(), sEncodedGlypsSort);

		for (UIntAndGlyphEncodingInfoVector::const_iterator it = encodedGlyphs.begin();
			it != encodedGlyphs.end();
			++it)
		{
			orderedGlyphs.push_back(it->first);
			cidMapping.push_back(it->second.mEncodedCharacter);
		}
		EStatusCode status = embeddedFontWriter.WriteEmbeddedFont(inFontInfo,
			orderedGlyphs,
			scCIDFontType0C,
			inFontName,
			inObjectsContext,
			&cidMapping,
			mEmbeddedFontFileObjectID);
		if (status != PDFHummus::eSuccess)
			return status;
	}

	DescendentFontWriter descendentFontWriter;

	return descendentFontWriter.WriteFont(inDecendentObjectID,inFontName,inFontInfo,inEncodedGlyphs,inObjectsContext,this);
}
开发者ID:galkahana,项目名称:HummusJS,代码行数:58,代码来源:CFFDescendentFontWriter.cpp

示例5:

void Type1ToCFFEmbeddedFontWriter::TranslateFromFreeTypeToType1(FreeTypeFaceWrapper& inFontInfo,
																const UIntVector& inSubsetGlyphIDs,
																StringVector& outGlyphNames)
{
	UIntVector::const_iterator it = inSubsetGlyphIDs.begin();
	
    for(; it != inSubsetGlyphIDs.end(); ++it)
        outGlyphNames.push_back(inFontInfo.GetGlyphName(*it));
    
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:10,代码来源:Type1ToCFFEmbeddedFontWriter.cpp

示例6: data

EStatusCode CFFEmbeddedFontWriter::WriteCharStrings(const UIntVector& inSubsetGlyphIDs)
{
	/*
		1. build the charstrings data, looping the glyphs charstrings and writing a flattened
		   version of each charstring
		2. write the charstring index based on offsets inside the data (size should be according to the max)
		3. copy the data into the stream
	*/


	unsigned long* offsets = new unsigned long[inSubsetGlyphIDs.size() + 1];
	MyStringBuf charStringsData;
	OutputStringBufferStream charStringsDataWriteStream(&charStringsData);
	CharStringType2Flattener charStringFlattener;
	UIntVector::const_iterator itGlyphs = inSubsetGlyphIDs.begin();
	EStatusCode status = PDFHummus::eSuccess;

	do
	{
		unsigned short i=0;
		for(; itGlyphs != inSubsetGlyphIDs.end() && PDFHummus::eSuccess == status; ++itGlyphs,++i)
		{
			offsets[i] = (unsigned long)charStringsDataWriteStream.GetCurrentPosition();
			status = charStringFlattener.WriteFlattenedGlyphProgram(	0,
																		*itGlyphs,
																		&(mOpenTypeInput.mCFF),
																		&charStringsDataWriteStream);
		}
		if(status != PDFHummus::eSuccess)
			break;

		offsets[i] = (unsigned long)charStringsDataWriteStream.GetCurrentPosition();

		charStringsData.pubseekoff(0,std::ios_base::beg);

		// write index section
		mCharStringPosition = mFontFileStream.GetCurrentPosition();
		Byte sizeOfOffset = GetMostCompressedOffsetSize(offsets[i] + 1);
		mPrimitivesWriter.WriteCard16((unsigned short)inSubsetGlyphIDs.size());
		mPrimitivesWriter.WriteOffSize(sizeOfOffset);
		mPrimitivesWriter.SetOffSize(sizeOfOffset);
		for(i=0;i<=inSubsetGlyphIDs.size();++i)
			mPrimitivesWriter.WriteOffset(offsets[i] + 1);

		// Write data
		InputStringBufferStream charStringsDataReadStream(&charStringsData);
		OutputStreamTraits streamCopier(&mFontFileStream);
		status = streamCopier.CopyToOutputStream(&charStringsDataReadStream);
		if(status != PDFHummus::eSuccess)
			break;
	}while(false);

	delete[] offsets;
	return status;
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:55,代码来源:CFFEmbeddedFontWriter.cpp

示例7: WriteFDSelect

EStatusCode CFFEmbeddedFontWriter::WriteFDSelect(const UIntVector& inSubsetGlyphIDs,const FontDictInfoToByteMap& inNewFontDictsIndexes)
{
	// always write format 3. cause at most cases the FD dicts count will be so low that it'd
	// take a bloody mircale for no repeats to occur.
	UIntVector::const_iterator itGlyphs = inSubsetGlyphIDs.begin();


	mFDSelectPosition = mFontFileStream.GetCurrentPosition();
	mPrimitivesWriter.WriteCard8(3);

	LongFilePositionType rangesCountPosition = mFontFileStream.GetCurrentPosition();
	mPrimitivesWriter.WriteCard16(1); // temporary. will get back to this later

	unsigned short rangesCount = 1;
	Byte currentFD,newFD;
	unsigned short glyphIndex = 1;
	FontDictInfoToByteMap::const_iterator itNewIndex = 
		inNewFontDictsIndexes.find(mOpenTypeInput.mCFF.mTopDictIndex[0].mFDSelect[*itGlyphs]);
	
	// k. seems like i probably just imagine exceptions here. i guess there must
	// be a proper FDSelect with FDs for all...so i'm defaulting to some 0
	currentFD = (itNewIndex == inNewFontDictsIndexes.end() ? 0:itNewIndex->second);
	mPrimitivesWriter.WriteCard16(0);
	mPrimitivesWriter.WriteCard8(currentFD);
	++itGlyphs;

	for(; itGlyphs != inSubsetGlyphIDs.end(); ++itGlyphs,++glyphIndex)
	{
		itNewIndex = 
				inNewFontDictsIndexes.find(mOpenTypeInput.mCFF.mTopDictIndex[0].mFDSelect[*itGlyphs]);
		newFD = (itNewIndex == inNewFontDictsIndexes.end() ? 0:itNewIndex->second);
		if(newFD != currentFD)
		{
			currentFD = newFD;
			mPrimitivesWriter.WriteCard16(glyphIndex);
			mPrimitivesWriter.WriteCard8(currentFD);
			++rangesCount;
		}
	}
	mPrimitivesWriter.WriteCard16((unsigned short)inSubsetGlyphIDs.size());
	// go back to ranges count if not equal to what's already written
	if(rangesCount != 1)
	{
		LongFilePositionType currentPosition = mFontFileStream.GetCurrentPosition();
		mFontFileStream.SetPosition(rangesCountPosition);
		mPrimitivesWriter.WriteCard16(rangesCount);
		mFontFileStream.SetPosition(currentPosition);
	}
	return mPrimitivesWriter.GetInternalState();
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:50,代码来源:CFFEmbeddedFontWriter.cpp

示例8: AddDependentGlyphs

EStatusCode CFFEmbeddedFontWriter::AddDependentGlyphs(UIntVector& ioSubsetGlyphIDs)
{
	EStatusCode status = PDFHummus::eSuccess;
	UIntSet glyphsSet;
	UIntVector::iterator it = ioSubsetGlyphIDs.begin();
	bool hasCompositeGlyphs = false;

	for(;it != ioSubsetGlyphIDs.end() && PDFHummus::eSuccess == status; ++it)
	{
		bool localHasCompositeGlyphs;
		status = AddComponentGlyphs(*it,glyphsSet,localHasCompositeGlyphs);
		hasCompositeGlyphs |= localHasCompositeGlyphs;
	}

	if(hasCompositeGlyphs)
	{
		UIntSet::iterator itNewGlyphs;

		for(it = ioSubsetGlyphIDs.begin();it != ioSubsetGlyphIDs.end(); ++it)
			glyphsSet.insert(*it);

		ioSubsetGlyphIDs.clear();
		for(itNewGlyphs = glyphsSet.begin(); itNewGlyphs != glyphsSet.end(); ++itNewGlyphs)
			ioSubsetGlyphIDs.push_back(*itNewGlyphs);
		
		sort(ioSubsetGlyphIDs.begin(),ioSubsetGlyphIDs.end());
	}	
	return status;
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:29,代码来源:CFFEmbeddedFontWriter.cpp

示例9: WriteGlyf

EStatusCode TrueTypeEmbeddedFontWriter::WriteGlyf(const UIntVector& inSubsetGlyphIDs,unsigned long* inLocaTable)
{
	// k. write the glyphs table. you only need to write the glyphs you are actually using.
	// while at it...update the locaTable

	TableEntry* tableEntry = mTrueTypeInput.GetTableEntry("glyf");
	LongFilePositionType startTableOffset = mFontFileStream.GetCurrentPosition();
	UIntVector::const_iterator it = inSubsetGlyphIDs.begin();
	OutputStreamTraits streamCopier(&mFontFileStream);
	unsigned short glyphIndex,previousGlyphIndexEnd = 0;
	inLocaTable[0] = 0;
	EStatusCode status = eSuccess;

	for(;it != inSubsetGlyphIDs.end() && eSuccess == status; ++it)
	{
		glyphIndex = *it;
		if(glyphIndex >= mTrueTypeInput.mMaxp.NumGlyphs)
		{
			TRACE_LOG2("TrueTypeEmbeddedFontWriter::WriteGlyf, error, requested glyph index %ld is larger than the maximum glyph index for this font which is %ld. ",glyphIndex,mTrueTypeInput.mMaxp.NumGlyphs-1);
			status = eFailure;
			break;
		}

		for(unsigned short i= previousGlyphIndexEnd + 1; i<=glyphIndex;++i)
			inLocaTable[i] = inLocaTable[previousGlyphIndexEnd];
		if(mTrueTypeInput.mGlyf[glyphIndex] != NULL)
		{
			mTrueTypeFile.GetInputStream()->SetPosition(tableEntry->Offset + 
															mTrueTypeInput.mLoca[glyphIndex]);
			streamCopier.CopyToOutputStream(mTrueTypeFile.GetInputStream(),
				mTrueTypeInput.mLoca[(glyphIndex) + 1] - mTrueTypeInput.mLoca[glyphIndex]);
		}
		inLocaTable[glyphIndex + 1] = (unsigned long)(mFontFileStream.GetCurrentPosition() - startTableOffset);
		previousGlyphIndexEnd = glyphIndex + 1;
	}

	LongFilePositionType endOfTable = mFontFileStream.GetCurrentPosition();
	mPrimitivesWriter.PadTo4();
	LongFilePositionType endOfStream = mFontFileStream.GetCurrentPosition();

	// write table entry data, which includes movement
	WriteTableEntryData(mGLYFEntryWritingOffset,
						startTableOffset,
						(unsigned long)(endOfTable - startTableOffset));

	// restore position to end of stream
	mFontFileStream.SetPosition(endOfStream); 

	return mPrimitivesWriter.GetInternalState();	
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:50,代码来源:TrueTypeEmbeddedFontWriter.cpp

示例10: DetermineFDArrayIndexes

void CFFEmbeddedFontWriter::DetermineFDArrayIndexes(const UIntVector& inSubsetGlyphIDs,FontDictInfoToByteMap& outNewFontDictsIndexes)
{
	UIntVector::const_iterator itGlyphs = inSubsetGlyphIDs.begin();
	FontDictInfoSet fontDictInfos;

	for(; itGlyphs != inSubsetGlyphIDs.end(); ++itGlyphs)
		if(mOpenTypeInput.mCFF.mTopDictIndex[0].mFDSelect[*itGlyphs])
			fontDictInfos.insert(mOpenTypeInput.mCFF.mTopDictIndex[0].mFDSelect[*itGlyphs]);

	FontDictInfoSet::iterator itFontInfos;
	Byte i=0;

	for(itFontInfos = fontDictInfos.begin(); itFontInfos != fontDictInfos.end(); ++itFontInfos,++i)
		outNewFontDictsIndexes.insert(FontDictInfoToByteMap::value_type(*itFontInfos,i));
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:15,代码来源:CFFEmbeddedFontWriter.cpp

示例11: getTargetsInRange

void TowerTemporal::update(float t)
{
  static const float sShotFadeOut = 0.5f;
  mTimeSinceLastAction += t;
  float atkDur = 1.0f/mAtkSpeed;
  if (mTimeSinceLastAction >= atkDur)
  {
    // Get all Aliens within the tower's range
    Alien* alien = NULL;
    UIntVector ids = getTargetsInRange();
    for (size_t i = 0; i < ids.size(); ++i)
    {
      unsigned int id = ids[i];
      alien = AlienFactory::getSingleton().getAlien(id);
      if (alien && alien->getState() != Alien::DYING && alien->getState() != Alien::DEAD)
        alien->slow(0.5f, atkDur*0.5f);
    }

    // Reset the scale of the shot graphics
    mpShotGraphics->getParentSceneNode()->setScale(Ogre::Vector3::UNIT_SCALE);
    mpShotGraphics->setVisible(true);

    // Reset the time since last action
    mTimeSinceLastAction = 0;
  }
  
  // Update the shot graphics
  if (mTimeSinceLastAction < sShotFadeOut)
  {
    float shotPerc = mTimeSinceLastAction / sShotFadeOut; 
    Ogre::Vector3 scale = Ogre::Vector3::UNIT_SCALE * Ogre::Math::Sqrt(mRangeSqr) * 0.5;
    scale = scale * Ogre::Math::Sqrt(shotPerc);
    mpShotGraphics->getParentSceneNode()->setScale(scale);
    mpShotGraphics->beginUpdate(0);
    for (size_t i = 0; i < mRingVertices.size(); ++i)
    {
      mpShotGraphics->position(mRingVertices[i]);
      mpShotGraphics->colour(0.33, 0.33, 1, 1-shotPerc);
    }
    mpShotGraphics->end();
  }
  else
  {
    mpShotGraphics->setVisible(false);
  }
}
开发者ID:kinfung0602,项目名称:ogre-tower-defense,代码行数:46,代码来源:TowerTemporal.cpp

示例12: Nearest

UIntVector KNearest::Nearest(const RealCoord &state, 
						     const RealCoordVector &state_set) const {
  UIntVector neighbors;
  std::size_t state_num = state_set.size();
  if (state_num <= k_) {
    for (unsigned i = 0; i < state_num; ++i) {
      neighbors.push_back(i);
    }
  } else {
    double *dist = new double[state_num];
	for (unsigned i = 0; i < state_num; ++i) {
      dist[i] = metric_->Distance(state, state_set[i]);
	}
	for (unsigned i = 0; i <= k_; ++i) {
      neighbors.push_back(i);
	}
	for (unsigned i = 1; i < k_; ++i) {
      double di = dist[i];
      unsigned j = i - 1;
	  while (j != std::numeric_limits<unsigned>::max() && dist[i] < dist[j]) {
        dist[j + 1] = dist[j];
        neighbors[j + 1] = neighbors[j];
        --j;
      }
      dist[j + 1] = di;
      neighbors[j + 1] = i;
    }
    for (unsigned i = k_; i < state_num; ++i) {
      double di = dist[i];
      unsigned j = k_ - 1;
	  while (j != std::numeric_limits<unsigned>::max() && dist[i] < dist[j]) {
        dist[j + 1] = dist[j];
        neighbors[j + 1] = neighbors[j];
        --j;
	  }
      neighbors[j + 1] = i;
	}
    delete[] dist;
  }
  neighbors.pop_back();
  return neighbors;
}
开发者ID:snailcoder,项目名称:PASS,代码行数:42,代码来源:KNearest.cpp

示例13: calc_pivot

char WaveletTree::calc_pivot(const std::string& alph, const CharIntMap& counts) {

    UIntVector scores;
    scores.resize(alph.size(), 0);

    for (std::size_t i = 0; i < alph.size(); i++) {

        // calc the number of 0s and 1s
        UInt sum_before = 0;
        UInt sum_after = 0;
        for (std::size_t j = 0; j < i; j++) {
            // operator[] can't be used in const map, so I had to use
            // find to get iterator
            CharIntMap::const_iterator elem = counts.find(alph[j]);
            if (elem == counts.end())
                throw std::runtime_error("counts has missing key");
            sum_before += elem->second;
        }
        for (std::size_t j = i; j < alph.size(); j++) {
            CharIntMap::const_iterator elem = counts.find(alph[j]);
            if (elem == counts.end())
                throw std::runtime_error("counts has missing key");
            sum_after += elem->second;
        }

        // diff between numbers of 0s and 1s
        scores[i] = abs(sum_before - sum_after);
        
        // if current score is worse than prev, than prev is the best,
        // continuing will only give worse scores
        if (i > 0 && scores[i] > scores[i-1])
            return alph[i-1];
    }

    return alph[alph.size() - 1];
}
开发者ID:iborko,项目名称:fmindex,代码行数:36,代码来源:WaveletTree.cpp

示例14: AddDependentGlyphs

void TrueTypeEmbeddedFontWriter::AddDependentGlyphs(UIntVector& ioSubsetGlyphIDs)
{
	UIntSet glyphsSet;
	UIntVector::iterator it = ioSubsetGlyphIDs.begin();
	bool hasCompositeGlyphs = false;

	for(;it != ioSubsetGlyphIDs.end(); ++it)
		hasCompositeGlyphs |= AddComponentGlyphs(*it,glyphsSet);

	if(hasCompositeGlyphs)
	{
		UIntSet::iterator itNewGlyphs;

		for(it = ioSubsetGlyphIDs.begin();it != ioSubsetGlyphIDs.end(); ++it)
			glyphsSet.insert(*it);

		ioSubsetGlyphIDs.clear();
		for(itNewGlyphs = glyphsSet.begin(); itNewGlyphs != glyphsSet.end(); ++itNewGlyphs)
			ioSubsetGlyphIDs.push_back(*itNewGlyphs);
		
		sort(ioSubsetGlyphIDs.begin(),ioSubsetGlyphIDs.end());
	}
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:23,代码来源:TrueTypeEmbeddedFontWriter.cpp

示例15: main

int main()
{
    // Några saker som ska fungera:
    UIntVector a(10);               // initiering med 7 element
    std::cout << "a(10)"<< a.length << std::endl;
    std::cout << "kopiering" << std::endl;
    UIntVector b(a);           // kopieringskonstruktor 
    std::cout << "kopiering" << std::endl;
    a = a;
    std::cout << "slut" << std::endl;
    UIntVector c = a;          // kopieringskonstruktor 

    //Extra tester för alla Requirments
    a = b;                 // tilldelning genom kopiering
    a[5] = 7;              // tilldelning till element

    const UIntVector e(100000);    // konstant objekt med 10 element
    int i = e[5];          // const int oper[](int) const körs
    i = a[0];              // vektorn är nollindexerad
    i = a[5];              // int oper[](int) körs
    
    a[5]++;                // öka värdet till 8
    
    //Extra tester för alla Requirments
    std::cout << "(1)TEST" << std::endl;
    int aa = e[9];
    int ab = e[0];
    std::cout << "(1)SLUT" << aa << ab << std::endl;


    std::cout << "(2)TEST" << std::endl;
    for(long int i = 0; i < 100000; i++)
    {
        e[i];
    } 
    std::cout << "(2)SLUT" << std::endl;




    std::cout << "(3)TEST" << std::endl;
    UIntVector a3(10); UIntVector b3(0); UIntVector c3(0);
    b3 = a3;
    a3 = c3;
    std::cout << "(3)SLUT" << std::endl;




    std::cout << "(4) START" << std::endl;
    std::initializer_list<unsigned int> list = {1,2,3};
    UIntVector a4(list); UIntVector b4(0);
    a4 = b4;
    std::cout << "length a" << a4.size() << "len b " << b4.size() << std::endl;
    std::cout << "(4) SLUT" << std::endl;



    std::cout << "(5)TEST" << std::endl;
    UIntVector b5(list);
    UIntVector a5(std::move(b5));
    std::cout << "(5)SLUT" << std::endl;





    std::cout << "(6)TEST" << std::endl;
    UIntVector a6(30);
    UIntVector b6(a6);
    std::cout << "(6)SLUT" << std::endl;


    std::cout << "(7)TEST" << std::endl;
    UIntVector a7(1); 
    std::cout << "a) len innan " <<a7.length << std::endl;
    UIntVector b7(std::move(a7));
    std::cout << "b) len " <<b7.length << std::endl;
    std::cout << "a) len " <<a7.length << std::endl;
    std::cout << "(7)SLUT" << std::endl;

    std::cout << "(8)TEST" << std::endl;
    UIntVector a8(10);
    a8.reset();
    UIntVector b8(11);
    std::cout << "a) INNAN len " <<a8.size() << "ptr " << a8.vector_ptr <<std::endl;
    UIntVector c8(std::move(a8));
    std::cout << "c) len " <<c8.size() << "ptr" << c8.vector_ptr <<std::endl;
    std::cout << "a) len " <<a8.size() << "ptr " << a8.vector_ptr <<std::endl;
    std::cout << "(8)SLUT" << std::endl;


    std::cout << "(9)TEST COPY TO SELF" << std::endl;
    b8 = b8;
    std::cout << "(9)SLUT" << std::endl;
    try {
        i = e[10];             // försöker hämta element som ligger utanför e
    } catch (std::out_of_range e) {
        std::cout << e.what() << std::endl;
    }
//.........这里部分代码省略.........
开发者ID:TobiasLundin,项目名称:Cpp,代码行数:101,代码来源:test_vec.cpp


注:本文中的UIntVector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。