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


C++ vector::back方法代码示例

本文整理汇总了C++中std::vector::back方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::back方法的具体用法?C++ vector::back怎么用?C++ vector::back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::vector的用法示例。


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

示例1: main

int main(int argc, char **argv) {
    Var x;

    {
        Func f;

        f(x) = print(x * x, "the answer is", 42.0f, "unsigned", cast<uint32_t>(145));
        f.set_custom_print(halide_print);
        Image<int32_t> result = f.realize(10);

        for (int32_t i = 0; i < 10; i++) {
            if (result(i) != i * i) {
                return -1;
            }
        }

        assert(messages.size() == 10);
        for (size_t i = 0; i < messages.size(); i++) {
            long long square;
            float forty_two;
            unsigned long long one_forty_five;

            int scan_count = sscanf(messages[i].c_str(), "%lld the answer is %f unsigned %llu",
                                    &square, &forty_two, &one_forty_five);
            assert(scan_count == 3);
            assert(square == i * i);
            assert(forty_two == 42.0f);
            assert(one_forty_five == 145);
        }
    }

    messages.clear();

    {
        Func f;
        Param<int> param;
        param.set(127);

        // Test a string containing a printf format specifier (It should print it as-is).
        f(x) = print_when(x == 3, x * x, "g", 42.0f, "%s", param);
        f.set_custom_print(halide_print);
        Image<int32_t> result = f.realize(10);

        for (int32_t i = 0; i < 10; i++) {
            if (result(i) != i * i) {
                return -1;
            }
        }

        assert(messages.size() == 1);
        long long nine;
        float forty_two;
        long long p;

        int scan_count = sscanf(messages[0].c_str(), "%lld g %f %%s %lld",
                                &nine, &forty_two, &p);
        assert(scan_count == 3);
        assert(nine == 9);
        assert(forty_two == 42.0f);
        assert(p == 127);

    }

    messages.clear();

    {
        Func f;

        // Test a single message longer than 8K.
        std::vector<Expr> args;
        for (int i = 0; i < 500; i++) {
            uint64_t n = i;
            n *= n;
            n *= n;
            n *= n;
            n *= n;
            n += 100;
            int32_t hi = n >> 32;
            int32_t lo = n & 0xffffffff;
            args.push_back((cast<uint64_t>(hi) << 32) | lo);
            Expr dn = cast<double>((float)(n));
            args.push_back(dn);
        }
        f(x) = print(args);
        f.set_custom_print(halide_print);
        Image<uint64_t> result = f.realize(1);

        if (result(0) != 100) {
            return -1;
        }

        assert(messages.back().size() == 8191);
    }

    messages.clear();

    // Check that Halide's stringification of floats and doubles
    // matches %f and %e respectively.

    #ifndef _MSC_VER
//.........这里部分代码省略.........
开发者ID:AheadIO,项目名称:Halide,代码行数:101,代码来源:print.cpp

示例2: DlgProc

BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
    switch(msg){
		case WM_CLOSE:{
			DestroyWindow(hwnd);
			break;
		}
		case WM_DESTROY:{
			PostQuitMessage(0);
			break;
		}
		case WM_COMMAND:{
			if(HIWORD(wParam) == EN_CHANGE){
				const int ID = LOWORD(wParam);
				switch(ID){
					case IDC_CDLEFT:{
						Globals::PreviewCD.Left = GetDlgItemFloat(hwnd, ID);
						break;
					}
					case IDC_CDRIGHT:{
						Globals::PreviewCD.Right = GetDlgItemFloat(hwnd, ID);
						break;
					}
					case IDC_CDTOP:{
						Globals::PreviewCD.Top = GetDlgItemFloat(hwnd, ID);
						break;
					}
					case IDC_CDBOTTOM:{
						Globals::PreviewCD.Bottom = GetDlgItemFloat(hwnd, ID);
						break;
					}
					default:
						break;
				}
			}
			switch(LOWORD(wParam)){
				case IDM_EXIT1:{
					DestroyWindow(hwnd);
				}
				case IDM_OPEN1:{
					OPENFILENAME sfn;
					char sfPath[MAX_PATH];
					ZeroMemory( &sfn , sizeof( sfn));
					sfn.lStructSize = sizeof (OPENFILENAME);
					sfn.lpstrFile = sfPath;
					sfn.lpstrFile[0] = '\0';
					sfn.nMaxFile = MAX_PATH;
					sfn.lpstrFilter = "Foof Level Tile Set\0*.fts\0\0";
					sfn.nFilterIndex = 1;
					sfn.hwndOwner = hwnd;
					if(GetOpenFileName(&sfn) != 0){
						LevelTileSet.clear();
						AnimationSet.clear();
						DynamicSet.clear();
						DecoSet.clear();
						HazardousSet.clear();
						ifstream FileIn(sfPath);
						if(FileIn.is_open()){
							string Reader;
							FileIn >> Reader;
							if(Reader == "Foof72"){
								int Size = 0;
								FileIn >> Size;
								HWND hListBox = GetDlgItem(hwnd, IDC_COLLIST);
								SendMessage(hListBox, LB_RESETCONTENT, 0,0);
								for(int i = 0; i < Size; i++){
									LevelTile * pLevelTile = new LevelTile;
									FileIn >> pLevelTile->SpriteID;
									FileIn >> pLevelTile->IsCeiling;
									FileIn >> pLevelTile->IsNotWall;
									for(int i = 0; i < 64; i++){
										FileIn >> pLevelTile->HeightMask[i];
									}
									FileIn >> pLevelTile->Name;

									LevelTileSet.push_back(*pLevelTile);


									SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)pLevelTile->Name.c_str());
								}
								FileIn >> Size;
								hListBox = GetDlgItem(hwnd, IDC_ANIMLIST);
								SendMessage(hListBox, LB_RESETCONTENT, 0,0);
								for(int i = 0; i < Size; i++){
									AnimationTrack * pAnim = new AnimationTrack;
									FileIn >> pAnim->Name;
									FileIn >> pAnim->iStartingFrame;
									FileIn >> pAnim->nFrames;
									FileIn >> pAnim->fDefaultSpeed;
									char TruncName[7];
									size_t TruncNameLength = pAnim->Name.copy(TruncName, 6,0);
									TruncName[TruncNameLength] = '\0';
									string Name = TruncName;
									char strFrames[50];
									sprintf(strFrames, "%i", pAnim->nFrames);
									char strFPS[50];
									sprintf(strFPS, "%f", pAnim->fDefaultSpeed);
									string ListEntry = Name + "..." + " - " + strFrames + " Frames" + ", " + strFPS + " FPS";
									SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)ListEntry.c_str());
									AnimationSet.push_back(*pAnim);
								}
//.........这里部分代码省略.........
开发者ID:JIoffe,项目名称:Flame-Broiled-Fury-BETA,代码行数:101,代码来源:main.cpp

示例3: createMdfi

 /**
  * Creates an instruction of the graph starting from an
  * instruction of another graph.
  * \param g The other graph.
  * \param id The id of the mdfi to be copied.
  * \return The id of the created instruction.
  */
 inline uint createMdfi(Mdfg* g, uint id){
     _instructions.emplace_back(g->_instructions.at(id));
     _instructions.back().setId(_nextId);
     ++_nextId;
     return _instructions.size() - 1;
 }
开发者ID:DanieleDeSensi,项目名称:nornir,代码行数:13,代码来源:mdfg.hpp

示例4: if

bool  SteerLib::GJK_EPA::doContainsOrigin(std::vector<Util::Vector>& simplex, Util::Vector& direction)
{
	Util::Vector a = simplex.back();
	Util::Vector ao = a;
	ao.x = -ao.x;
	ao.y = -ao.y;
	ao.z = -ao.z;

	if (simplex.size() == 3)
	{
		Util::Vector c = simplex.at(1);
		Util::Vector b = simplex.at(0);
		Util::Vector ac = c - a;
		Util::Vector ab = b - a;
		Util::Vector abPerp = ab;
		abPerp.x = -ab.z;
		abPerp.y = 0;
		abPerp.z = ab.x;
		
		if (Util::dot(abPerp, c) >= 0.0f)
		{
			abPerp.x = -abPerp.x;
			abPerp.y = -abPerp.y;
			abPerp.z = -abPerp.z;
		}

		if (Util::dot(abPerp, ao) > 0.0f)
		{
			simplex.erase(std::find(simplex.begin(), simplex.end(), c)); 
			direction = abPerp; 
		}
		else
		{			
			Util::Vector acPerp = ac;
			acPerp.x = -ac.z;
			acPerp.y = 0;
			acPerp.z = ac.x;
			
			if (Util::dot(acPerp, b) >= 0.0f)
			{
				acPerp.x = -acPerp.x;
				acPerp.y = -acPerp.y;
				acPerp.z = -acPerp.z;
			}

			if (Util::dot(acPerp, ao) <= 0.0f) 
			{
				return true;
			}

			simplex.erase(std::find(simplex.begin(), simplex.end(), b));
			direction = acPerp;
		}
	}
	else if (simplex.size() == 2)
	{
	
		Util::Vector b = simplex.at(0);
		
		Util::Vector ab = b - a;
		
		Util::Vector abPerp = ab;
		abPerp.x = -ab.z;
		abPerp.y = 0.0f;
		abPerp.z = ab.x;

		if (Util::dot(abPerp, ao) < 0.0f) {
			abPerp.x = -abPerp.x;
			abPerp.y = -abPerp.y;
			abPerp.z = -abPerp.z;
		}
		direction = abPerp;
	}
	return false;
}
开发者ID:purvilpatel,项目名称:SteerLite,代码行数:75,代码来源:GJK_EPA.cpp

示例5: last

	const T& last () const { return vector.back (); }
开发者ID:eyelash,项目名称:wing,代码行数:1,代码来源:basic_types.hpp

示例6: add_file

 node add_file(std::string name) {
     if (!exists(name)) return {};
     files.emplace_back(new file(name));
     return *files.back();
 }
开发者ID:bumblabumbadit,项目名称:NoLifeStory,代码行数:5,代码来源:nx.cpp

示例7: threefoldRepetition

	//Check threefold repetition (= current (!) position has occurred 3 or more times)
	//Return true if draw can be claimed
	bool threefoldRepetition(const std::vector<std::vector<int>>& boardHistory, const std::vector<std::pair<int,int>>& moveHistory, const std::vector<unsigned char>& stateHistory){

		//Return immediately if not enough moves
		if (boardHistory.size() < 3)
			return false;

		//Get current board status
		std::vector<int> currentBoard = boardHistory.back();
		std::pair<int,int> lastMove = moveHistory.back();
		unsigned char currentState = stateHistory.back();

		//Get pawn moves, they're needed for en passant check
		std::vector<int> pawnMoves;
		for (int a=0; a<64; a++){
			if (currentBoard[a] == W_PAWN){
				pawnMoves = join(pawnMoves, whitePawnMoveForwardLeft(currentBoard, a, lastMove));
				pawnMoves = join(pawnMoves, whitePawnMoveForwardRight(currentBoard, a, lastMove));
			}
			else if (currentBoard[a] == B_PAWN){
				pawnMoves = join(pawnMoves, blackPawnMoveForwardLeft(currentBoard, a, lastMove));
				pawnMoves = join(pawnMoves, blackPawnMoveForwardRight(currentBoard, a, lastMove));
			}
		}

		std::vector<int> pawnMovesTemp;

		size_t posCount = 1;
		size_t posNum = boardHistory.size()-1;
		bool ret = false;

		//Find equal positions
		for (size_t i=0; i<boardHistory.size(); i++){

			//Same turn (fast check, skip every 2nd position)
			if (posNum%2 == i%2) {

				//Same piece positions (slow check?)
				if (boardHistory[i] == currentBoard) {

					//Same rights to castle, check flags
					if ( (currentState & 60) && (stateHistory[i] & 60) ) {

						//Same rights to capture en passant
						//Collect all pawn moves
						pawnMovesTemp = std::vector<int>();
						for (int a=0; a<64; a++){
							if (boardHistory[i][a] == W_PAWN){
								pawnMovesTemp = join(pawnMovesTemp, whitePawnMoveForwardLeft(boardHistory[i], a, moveHistory[i]));
								pawnMovesTemp = join(pawnMovesTemp, whitePawnMoveForwardRight(boardHistory[i], a, moveHistory[i]));
							}
							else if (boardHistory[i][a] == B_PAWN){
								pawnMovesTemp = join(pawnMovesTemp, blackPawnMoveForwardLeft(boardHistory[i], a, moveHistory[i]));
								pawnMovesTemp = join(pawnMovesTemp, blackPawnMoveForwardRight(boardHistory[i], a, moveHistory[i]));
							}
						}
						//If the pawns have the same possible moves, then en passant rights are equal
						//Now also the positions are equal
						if (pawnMovesTemp == pawnMoves){
							posCount++;
							if (posCount >= 3){
								ret = true;
								break;
							}
						}
					}
				}
			}
		}

		return ret;
	}
开发者ID:AarneL,项目名称:Chessgame,代码行数:73,代码来源:rules.cpp

示例8: vector_param_access

int vector_param_access(std::vector<int>& v) {
  return v.back(); // shouldn't report anything here
}
开发者ID:hujian004ban,项目名称:infer,代码行数:3,代码来源:empty_access.cpp

示例9: if

  void Preprocess::Callback::ProcessWay(const OSMId& id,
                                        std::vector<OSMId>& nodes,
                                        const TagMap& tagMap)
  {
    TypeInfoRef areaType;
    TypeInfoRef wayType;
    int         isArea=0; // 0==unknown, 1==true, -1==false
    bool        isCoastlineArea=false;
    RawWay      way;
    bool        isCoastline=false;

    if (nodes.size()<2) {
      progress.Warning("Way "+
                       NumberToString(id)+
                       " has less than two nodes!");
      return;
    }

    if (id<lastWayId) {
      waySortingError=true;
    }

    way.SetId(id);

    auto areaTag=tagMap.find(typeConfig->tagArea);

    if (areaTag==tagMap.end()) {
      isArea=0;
    }
    else if (areaTag->second=="no" ||
             areaTag->second=="false" ||
             areaTag->second=="0") {
      isArea=-1;
    }
    else {
      isArea=1;
    }

    auto naturalTag=tagMap.find(typeConfig->tagNatural);

    if (naturalTag!=tagMap.end() &&
        naturalTag->second=="coastline") {
      isCoastline=true;
    }

    if (isCoastline) {
      isCoastlineArea=nodes.size()>3 &&
                      (nodes.front()==nodes.back() ||
                       isArea==1);
    }

    typeConfig->GetWayAreaType(tagMap,
                               wayType,
                               areaType);

    if (isArea==1 &&
        areaType==typeConfig->typeInfoIgnore) {
      isArea=0;
    }
    else if (isArea==-1 &&
             wayType==typeConfig->typeInfoIgnore) {
      isArea=0;
    }

    if (isArea==0) {
      if (wayType!=typeConfig->typeInfoIgnore &&
          areaType==typeConfig->typeInfoIgnore) {
        isArea=-1;
      }
      else if (wayType==typeConfig->typeInfoIgnore &&
               areaType!=typeConfig->typeInfoIgnore) {
        isArea=1;
      }
      else if (wayType!=typeConfig->typeInfoIgnore &&
               areaType!=typeConfig->typeInfoIgnore) {
        if (nodes.size()>3 &&
            nodes.front()==nodes.back()) {
          if (wayType->GetPinWay()) {
            isArea=-1;
          }
          else {
            isArea=1;
          }
        }
        else {
          isArea=-1;
        }
      }
    }

    switch (isArea) {
    case 1:
      areaStat[areaType->GetIndex()]++;

      if (areaType->GetIgnore()) {
        way.SetType(typeConfig->typeInfoIgnore,
                    true);
      }
      else {
        way.SetType(areaType,true);
//.........这里部分代码省略.........
开发者ID:kolosov,项目名称:libosmscout,代码行数:101,代码来源:Preprocess.cpp

示例10: ProcessWay

  void Preprocess::ProcessWay(const TypeConfig& typeConfig,
                              const OSMId& id,
                              std::vector<OSMId>& nodes,
                              const std::map<TagId,std::string>& tagMap)
  {
    TypeId                                      areaType=typeIgnore;
    TypeId                                      wayType=typeIgnore;
    int                                         isArea=0; // 0==unknown, 1==true, -1==false
    std::map<TagId,std::string>::const_iterator areaTag;
    std::map<TagId,std::string>::const_iterator naturalTag;
    RawWay                                      way;
    bool                                        isCoastline=false;

    if (id<lastWayId) {
      waySortingError=true;
    }

    way.SetId(id);

    areaTag=tagMap.find(typeConfig.tagArea);

    if (areaTag==tagMap.end()) {
      isArea=0;
    }
    else if (areaTag->second=="no" ||
             areaTag->second=="false" ||
             areaTag->second=="0") {
      isArea=-1;
    }
    else {
      isArea=1;
    }

    naturalTag=tagMap.find(typeConfig.tagNatural);

    if (naturalTag!=tagMap.end() &&
        naturalTag->second=="coastline") {
      isCoastline=true;
    }

    typeConfig.GetWayAreaTypeId(tagMap,wayType,areaType);
    typeConfig.ResolveTags(tagMap,tags);

    if (isArea==1 &&
        areaType==typeIgnore) {
      isArea=0;
    }
    else if (isArea==-1 &&
             wayType==typeIgnore) {
      isArea=0;
    }

    if (isArea==0) {
      if (wayType!=typeIgnore &&
          areaType==typeIgnore) {
        isArea=-1;
      }
      else if (wayType==typeIgnore &&
               areaType!=typeIgnore) {
        isArea=1;
      }
      else if (wayType!=typeIgnore &&
               areaType!=typeIgnore) {
        if (nodes.size()>3 &&
            nodes.front()==nodes.back()) {
          if (typeConfig.GetTypeInfo(wayType).GetPinWay()) {
            isArea=-1;
          }
          else {
            isArea=1;
          }
        }
        else {
          isArea=-1;
        }
      }
    }

    switch (isArea) {
    case 1:
      way.SetType(areaType,true);

      if (nodes.size()>3 &&
          nodes.front()==nodes.back()) {
        nodes.pop_back();
      }

      areaCount++;
      break;
    case -1:
      way.SetType(wayType,false);
      wayCount++;
      break;
    default:
      if (nodes.size()>3 &&
          nodes.front()==nodes.back()) {
        way.SetType(typeIgnore,
                    true);

        nodes.pop_back();
//.........这里部分代码省略.........
开发者ID:bolidehi,项目名称:libosmscout,代码行数:101,代码来源:Preprocess.cpp

示例11: readTheXmlFile

bool readTheXmlFile(std::string fileName, std::string headNode, std::string secondNode, std::vector<std::string> theNodes, std::vector<std::string> theAttributes, std::vector<ListaDeCaractere*> &theNodeValues, std::vector<std::string> &headAttributesValues)
{
    std::string moFoLongString;
    getTheFileAsString(fileName, moFoLongString);

    bool encoding = false;
    std::string sEncoding = "";
    int lastPosition = 0;

    for(int i = 0; i < moFoLongString.size(); i++)
    {
        lastPosition = i + 1;
        sEncoding += moFoLongString[i];
        if(moFoLongString[i] == '>')
        {
            encoding  = true;
            break;
        }
    }
    if(sEncoding != "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
    {
        std::cout<<"The encoding is not good buddy!!"<<'\n'<<"It should be: "<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<'\n';
        return false;
    }
//    std::cout<<sEncoding<<'\n';

    std::vector<BSNodeXml> listOfActualNodes;

    std::string elementName1 =  "", elementName2 =  "", elementValue =  "", attributeName =  "", attributeValue =  "";
    bool readsAnElementName1 = false, readsAnElementName2 = false, readsAnElementValue = false, readsAnAttributeName = false, readsAnAttributeValue = false;

    for(int i = lastPosition; i < moFoLongString.size(); i++)
    {
        if(moFoLongString[i] == '<')
        {
            readsAnElementName1 = true; readsAnElementValue = false; readsAnAttributeName = false; readsAnAttributeValue = false;
            if(moFoLongString[i + 1] == '/')
            {
                readsAnElementName1 = false; readsAnElementName2 = true;
                i++;
            }
            else
            {
                BSNodeXml newNode;
                listOfActualNodes.push_back(newNode);
            }
            continue;
        }
        else
            if(moFoLongString[i] == ' ' && !readsAnAttributeValue)
            {
                if(attributeValue != "" && attributeName != "")
                {
                    BSAttribute atribut;
                    atribut.name = attributeName;
                    atribut.value = attributeValue;


                    headAttributesValues.push_back(attributeValue);
                    ///theNodeValues.back()->theCharArray2DAttributes.push_back(attributeValue);
                    ///listOfActualNodes.back().attributes.push_back(atribut);
                }
                attributeName = ""; attributeValue = "";

                readsAnElementName1 = false; readsAnElementName2 = false; readsAnElementValue = false; readsAnAttributeName = true; readsAnAttributeValue = false;
                continue;
            }
            else
                if(moFoLongString[i] == '=' && moFoLongString[i + 1] == '"' && !readsAnElementValue)
                {
                    readsAnElementName1 = false; readsAnElementName2 = false; readsAnElementValue = false; readsAnAttributeName = false; readsAnAttributeValue = true;
                    i++;
                    continue;
                }
                else
                    if(moFoLongString[i] == '"' && !readsAnElementValue)
                    {
                        if(attributeValue != "" && attributeName != "")
                        {
                            BSAttribute atribut;
                            atribut.name = attributeName;
                            atribut.value = attributeValue;

                            headAttributesValues.push_back(attributeValue);
                            ///theNodeValues.back()->theCharArray2DAttributes.push_back(attributeValue);
                            ///listOfActualNodes.back().attributes.push_back(atribut);
                        }
                        attributeName = ""; attributeValue = "";

                        readsAnElementName1 = false; readsAnElementName2 = false; readsAnElementValue = false; readsAnAttributeName = false; readsAnAttributeValue = false;
                        continue;
                    }
                    else
                        if(moFoLongString[i] == '>')
                        {
                            readsAnElementValue = true;
                            if(readsAnElementName2)
                            {
                                int index = 0;
                                for(int j = listOfActualNodes.size() - 1; j >= 0; j--)
//.........这里部分代码省略.........
开发者ID:alexbuicescu,项目名称:BrainStorm-Studios-Game-Engine,代码行数:101,代码来源:main.cpp

示例12: getInstance

 static SequencerBase& getInstance ()
 {
     return *_instances.back();
 }
开发者ID:lainegates,项目名称:FreeCAD,代码行数:4,代码来源:Sequencer.cpp

示例13: count_table_columns

 /** Count the total number of columns for the data table
  *
  * @param columns vector of table column descriptions
  * @return total number of columns including sub columns
  */
 size_t count_table_columns(const std::vector<model::table::imaging_column>& columns)
 {
     if(columns.empty()) return 0;
     return columns.back().column_count();
 }
开发者ID:Illumina,项目名称:interop,代码行数:10,代码来源:create_imaging_table.cpp

示例14: main

int main( int argc, char *argv[] )
{
    Alignments alignments ;
    Genome genome ;
    std::vector<int> rascafFileId ;

    char line[2048] ;
    char prefix[512] = "rascaf_scaffold" ;
    int rawAssemblyInd = 1 ;
    FILE *rascafFile ;
    bool contigLevel = false ;
    int i ;
    FILE *outputFile ;
    FILE *infoFile ;

    breakN = 1 ;

    if ( argc < 2 )
    {
        fprintf( stderr, "%s", usage ) ;
        exit( 1 ) ;
    }
    for ( i = 1 ; i < argc ; ++i )
    {
        if ( !strcmp( "-o", argv[i] ) )
        {
            strcpy( prefix, argv[i + 1 ] ) ;
            ++i ;
        }
        else if ( !strcmp( "-ms", argv[i] ) )
        {
            minSupport = atoi( argv[i + 1] ) ;
            ++i ;
        }
        else if ( !strcmp( "-ignoreGap", argv[i] ) )
        {
            ignoreGap = true ;
        }
        else if ( !strcmp( "-r", argv[i] ) )
        {
            rascafFileId.push_back( i + 1 ) ;
            ++i ;
        }
        else
        {
            fprintf( stderr, "Unknown option: %s\n", argv[i] ) ;
            exit( EXIT_FAILURE ) ;
        }

    }

    if ( rascafFileId.size() == 0 )
    {
        fprintf( stderr, "Must use -r to specify rascaf output file.\n" ) ;
        exit( EXIT_FAILURE ) ;
    }

    MAX_NEIGHBOR = 1 + rascafFileId.size() ;

    // Get the bam file.
    rascafFile = fopen( argv[ rascafFileId[0] ], "r" ) ;
    while ( fgets( line, sizeof( line ), rascafFile ) != NULL )
    {
        if ( strstr( line, "command line:" ) )
        {
            char *p ;
            char buffer[512] ;

            p = strstr( line, "-breakN" ) ;
            if ( p != NULL )
            {
                p += 7 ;
                while ( *p == ' ' )
                    ++p ;
                for ( i = 0 ; *p && *p != ' ' ; ++p, ++i )
                    buffer[i] = *p ;
                buffer[i] = '\0' ;
                breakN = atoi( buffer ) ;
            }

            p = strstr( line, "-b" ) ;
            if ( p == NULL )
            {
                fprintf( stderr, "Could not find the bam file specified by -b in Rascaf.\n" ) ;
                exit( 1 ) ;
            }
            p += 2 ;
            while ( *p == ' ' )
                ++p ;
            for ( i = 0 ; *p && *p != ' ' ; ++p, ++i )
                buffer[i] = *p ;
            buffer[i] = '\0' ;
            alignments.Open( buffer ) ;

            p = strstr( line, "-f") ;
            if ( p == NULL )
            {
                fprintf( stderr, "Could not find the raw assembly file specified by -f in Rascaf.\n" ) ;
                exit( 1 ) ;
            }
//.........这里部分代码省略.........
开发者ID:mourisl,项目名称:Rascaf,代码行数:101,代码来源:join.cpp

示例15: fillIndexFromStrip

int TriangleAdjacencyGraph::fillIndexFromStrip ( std::vector<Index> &indexVec,
    TriangleList &strip, bool rev )
{
  Triangle *triangle = rev ? strip.last : strip.first, *nextTriangle;
  HalfEdge *firstEdge, *halfEdge, *gate;
  WalkCase walkCase;
  Index vertex;
  int cost = 0;

  if (triangle) {
    cost = 3;
    indexVec.reserve(32); // find better value

    indexVec.resize(3);
    if ((nextTriangle = (rev ? triangle->prev : triangle->next))) {
      cost++;
      gate = findGateEdge(triangle,nextTriangle);
      firstEdge = gate->next->next;
      indexVec.push_back(vertex = gate->twin->next->vertexEnd());

      walkCase = LEFT;
      for ( triangle = nextTriangle; 
	  (nextTriangle = (rev ? triangle->prev : triangle->next));
	  triangle = nextTriangle ) {
	halfEdge = gate->twin;
	gate = findGateEdge(triangle,nextTriangle); 
	if (walkCase == RIGHT)
	  // RIGHT

	  if (halfEdge->next == gate) {
	    indexVec.push_back(vertex = gate->twin->next->vertexEnd());
	    walkCase = LEFT;
	    cost++;
	  }
	  else {
	    // swap; walkCase stays RIGHT;

	    indexVec.back() = gate->vertexEnd();
	    indexVec.push_back(gate->vertexStart());              
	    indexVec.push_back(vertex = gate->twin->next->vertexEnd());
	    cost += 2;
	  }
	else
	  // LEFT

	  if (halfEdge->next->next == gate) {
	    indexVec.push_back(vertex = gate->twin->next->vertexEnd());
	    walkCase = RIGHT;
	    cost++;
	  }
	  else {
	    // swap; walkCase stays LEFT;

	    indexVec.back() = gate->vertexStart();
	    indexVec.push_back(gate->vertexEnd());
	    indexVec.push_back(vertex = gate->twin->next->vertexEnd());
	    cost += 2;
	  }
      }
    }
    else 
      firstEdge = &triangle->halfEdgeVec[0];      
    indexVec[0] = vertex = firstEdge->vertexStart();
    indexVec[1] = vertex = firstEdge->next->vertexStart();      
    indexVec[2] = vertex = firstEdge->next->next->vertexStart();
  }

  return cost;
}
开发者ID:Sophiealex,项目名称:jgt-code,代码行数:69,代码来源:TriangleAdjacencyGraph.cpp


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