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


C++ StringVector::front方法代码示例

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


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

示例1: combineStringVector

static std::string combineStringVector(const StringVector& v)
{
  if (v.empty())
    return "";
  if (v.size() == 1)
    return v.front();
  std::string s = v.front();
  for(StringVector::size_type i = 1;i < v.size();i++)
    s += " " + v[i];
  return s;
}
开发者ID:luwrain,项目名称:voiceman,代码行数:11,代码来源:LineParser.cpp

示例2: extendLeaves

// Extend each leaf node
void StringThreader::extendLeaves()
{
    STNodePtrList newLeaves;
    for(STNodePtrList::iterator iter = m_leaves.begin(); iter != m_leaves.end(); ++iter)
    {
        StringVector extensions = getDeBruijnExtensions(*iter);

        // Either extend the current node or branch it
        // If no extension, do nothing and this node
        // is no longer considered a leaf
        if(extensions.size() == 1)
        {
            // Single extension, do not branch
            (*iter)->extend(extensions.front());
            newLeaves.push_back(*iter);
        }
        else if(extensions.size() > 1)
        {
            // Branch
            for(size_t i = 0; i < extensions.size(); ++i)
            {
                StringThreaderNode* pAdded = (*iter)->createChild(extensions[i]);
                newLeaves.push_back(pAdded);
            }
        }
    }

    m_leaves.clear();
    m_leaves = newLeaves;
}
开发者ID:Buttonwood,项目名称:sga,代码行数:31,代码来源:StringThreader.cpp

示例3: processKmer

std::string MetAssemble::processKmer(const std::string& str, int count)
{
    MetagenomeBuilder builder;
    builder.setSource(str, count);
    builder.setKmerParameters(m_parameters.kmer, m_parameters.kmerThreshold);
    builder.setIndex(m_parameters.pBWT, m_parameters.pRevBWT, m_parameters.pBWTCache, m_parameters.pRevBWTCache);
    builder.run();

    StringVector contigs;
    builder.getContigs(contigs);
    std::string out = contigs.empty() ? "" : contigs.front();
    //std::cout << "Constructed " << contigs.size() << " contigs from kmer (size: " << out.size() << ")\n";
    return out;
}
开发者ID:Buttonwood,项目名称:sga,代码行数:14,代码来源:MetAssembleProcess.cpp

示例4: AfterReinstall

	virtual void AfterReinstall(const string & id, DistInfo & dist) {
		ServerInstanceInfo inst( Name, id );
		uid_t uid = mgr_user::Uid( inst.UserName );
		string user_home_dir = getpwuid( uid )->pw_dir;
		mgr_file::Attrs attrs(0744, uid, mgr_user::GroupGid(inst.UserName));
		const string link_dir = mgr_file::ConcatPath( user_home_dir, ".steam/sdk32/" );
		mgr_file::MkDir( link_dir, &attrs );
		mgr_file::MkLink( mgr_file::ConcatPath( inst.GetInstancePath(), "bin/steamclient.so" ),
					mgr_file::ConcatPath( link_dir, "steamclient.so" ) );
		Debug( "Link to steamclient.so created" );
		
		StringVector maps;
		GetMaps(inst, maps);
		if( !maps.empty() )
			inst.SetParam( "map", maps.front() );

	}
开发者ID:sabinich,项目名称:gsmanager,代码行数:17,代码来源:teamfortress_mini.cpp

示例5: parseVocationString

std::string parseVocationString(StringVector vocStringVec)
{
	std::string str = "";
	if(!vocStringVec.empty())
	{
		for(StringVector::iterator it = vocStringVec.begin(); it != vocStringVec.end(); ++it)
		{
			if((*it) != vocStringVec.front())
			{
				if((*it) != vocStringVec.back())
					str += ", ";
				else
					str += " and ";
			}

			str += (*it);
			str += "s";
		}
	}

	return str;
}
开发者ID:novasdream,项目名称:tyano-core,代码行数:22,代码来源:tools.cpp

示例6: rangeMatchingPredicate

void
ycom::NullTermArray::eraseAppended (StringVector const &values)
{
    typedef typename StringVector::iterator SVIterator;

    SVIterator storedNewStringsEnd = priv->storedNewStrings.end ();
    /* Start search from at least values.size () from the end */
    auto searchStartPoint = storedNewStringsEnd -
                            (values.size ());
    SVIterator firstStoredNewStringsIterator =
        std::find (searchStartPoint,
                   storedNewStringsEnd,
                   values.front ());

    if (firstStoredNewStringsIterator != storedNewStringsEnd)
    {
        typedef typename StringVector::const_iterator CSVIterator;

        auto stringsEqual =
        [](SVIterator const &lhs, CSVIterator const &rhs) -> bool {
            return *lhs == *rhs;
        };

        auto lastStoredNewStringIterator =
            rangeMatchingPredicate (values,
                                    firstStoredNewStringsIterator,
                                    storedNewStringsEnd,
                                    stringsEqual);

        typedef std::vector <char const *>::iterator CVIterator;

        /* Handle the duplicate-pointers edge case by
         * starting from end - distance (first, last) - 1 */
        CVIterator vectorEnd = priv->vector.end ();
        auto searchStartPoint =
            vectorEnd - std::distance (firstStoredNewStringsIterator,
                                       lastStoredNewStringIterator) - 1;

        auto pointerInVectorMatchingRawStringPointer =
        [&firstStoredNewStringsIterator](char const *str) -> bool {
            /* We want to compare the pointers, as it was pointers
             * that were inserted, not new values */
            return firstStoredNewStringsIterator->c_str () == str;
        };

        CVIterator firstPointerInVector =
            std::find_if (searchStartPoint,
                          vectorEnd,
                          pointerInVectorMatchingRawStringPointer);

        if (firstPointerInVector != vectorEnd)
        {
            auto stringEqualsCharacterArray =
            [](CVIterator const &lhs, CSVIterator const &rhs) -> bool {
                return *lhs == rhs->c_str ();
            };

            auto lastPointerInVector =
                rangeMatchingPredicate (values,
                                        firstPointerInVector,
                                        vectorEnd,
                                        stringEqualsCharacterArray);

            /* Erase this from the vector of pointers */
            priv->vector.erase (firstPointerInVector,
                                lastPointerInVector);
        }

        /* Erase this block from the vector of stored
         * new strings */
        priv->storedNewStrings.erase (firstStoredNewStringsIterator,
                                      lastStoredNewStringIterator);
    }
}
开发者ID:smspillaz,项目名称:yiqi,代码行数:74,代码来源:commandline.cpp

示例7: extractConstantDefs

    //---------------------------------------------------------------------
    void GLSLProgramManagerCommon::extractConstantDefs(const String& src,
        GpuNamedConstants& defs, const String& filename)
    {
        // Parse the output string and collect all uniforms
        // NOTE this relies on the source already having been preprocessed
        // which is done in GLSLProgram::loadFromSource
        String line;
        String::size_type currPos = src.find("uniform");
        while (currPos != String::npos)
        {
            // Now check for using the word 'uniform' in a larger string & ignore
            bool inLargerString = false;
            if (currPos != 0)
            {
                char prev = src.at(currPos - 1);
                if (prev != ' ' && prev != '\t' && prev != '\r' && prev != '\n'
                    && prev != ';')
                    inLargerString = true;
            }
            if (!inLargerString && currPos + 7 < src.size())
            {
                char next = src.at(currPos + 7);
                if (next != ' ' && next != '\t' && next != '\r' && next != '\n')
                    inLargerString = true;
            }

            // skip 'uniform'
            currPos += 7;

            if (!inLargerString)
            {
                String::size_type endPos;
                GpuSharedParametersPtr blockSharedParams;

                // Check for a type. If there is one, then the semicolon is missing
                // otherwise treat as if it is a uniform block
                String::size_type lineEndPos = src.find_first_of("\n\r", currPos);
                line = src.substr(currPos, lineEndPos - currPos);
                StringVector parts = StringUtil::split(line, " \t");
                StringToEnumMap::iterator typei = mTypeEnumMap.find(parts.front());
                if (typei == mTypeEnumMap.end())
                {
                    // Gobble up the external name
                    String externalName = parts.front();

                    // Now there should be an opening brace
                    String::size_type openBracePos = src.find("{", currPos);
                    if (openBracePos != String::npos)
                    {
                        currPos = openBracePos + 1;
                    }
                    else
                    {
                        LogManager::getSingleton().logMessage("Missing opening brace in GLSL Uniform Block in file "
                                                              + filename);
                        break;
                    }

                    // First we need to find the internal name for the uniform block
                    String::size_type endBracePos = src.find("}", currPos);

                    // Find terminating semicolon
                    currPos = endBracePos + 1;
                    endPos = src.find(";", currPos);
                    if (endPos == String::npos)
                    {
                        // problem, missing semicolon, abort
                        break;
                    }

                    // TODO: We don't need the internal name. Just skip over to the end of the block
                    // But we do need to know if this is an array of blocks. Is that legal?

// Find the internal name.
// This can be an array.
//                    line = src.substr(currPos, endPos - currPos);
//                    StringVector internalParts = StringUtil::split(line, ", \t\r\n");
//                    String internalName = "";
//                    uint16 arraySize = 0;
//                    for (StringVector::iterator i = internalParts.begin(); i != internalParts.end(); ++i)
//                    {
//                        StringUtil::trim(*i);
//                        String::size_type arrayStart = i->find("[", 0);
//                        if (arrayStart != String::npos)
//                        {
//                            // potential name (if butted up to array)
//                            String name = i->substr(0, arrayStart);
//                            StringUtil::trim(name);
//                            if (!name.empty())
//                                internalName = name;
//
//                            String::size_type arrayEnd = i->find("]", arrayStart);
//                            String arrayDimTerm = i->substr(arrayStart + 1, arrayEnd - arrayStart - 1);
//                            StringUtil::trim(arrayDimTerm);
//                            arraySize = StringConverter::parseUnsignedInt(arrayDimTerm);
//                        }
//                        else
//                        {
//                            internalName = *i;
//.........这里部分代码省略.........
开发者ID:devxkh,项目名称:FrankE,代码行数:101,代码来源:OgreGLSLProgramManagerCommon.cpp

示例8: extractConstantDefs

	//---------------------------------------------------------------------
	void GLSLESProgramManagerCommon::extractConstantDefs(const String& src,
		GpuNamedConstants& defs, const String& filename)
	{
		// Parse the output string and collect all uniforms
		// NOTE this relies on the source already having been preprocessed
		// which is done in GLSLESProgram::loadFromSource
		String line;
		String::size_type currPos = src.find("uniform");
		while (currPos != String::npos)
		{
			GpuConstantDefinition def;
			String paramName;

			// Now check for using the word 'uniform' in a larger string & ignore
			bool inLargerString = false;
			if (currPos != 0)
			{
				char prev = src.at(currPos - 1);
				if (prev != ' ' && prev != '\t' && prev != '\r' && prev != '\n'
					&& prev != ';')
					inLargerString = true;
			}
			if (!inLargerString && currPos + 7 < src.size())
			{
				char next = src.at(currPos + 7);
				if (next != ' ' && next != '\t' && next != '\r' && next != '\n')
					inLargerString = true;
			}

			// skip 'uniform'
			currPos += 7;

			if (!inLargerString)
			{
                String::size_type endPos;
                String typeString;
                GpuSharedParametersPtr blockSharedParams;

                // Check for a type. If there is one, then the semicolon is missing
                // otherwise treat as if it is a uniform block
				String::size_type lineEndPos = src.find_first_of("\n\r", currPos);
				line = src.substr(currPos, lineEndPos - currPos);
                StringVector parts = StringUtil::split(line, " \t");

                // Skip over precision keywords
                if(StringUtil::match((parts.front()), "lowp") ||
                   StringUtil::match((parts.front()), "mediump") ||
                   StringUtil::match((parts.front()), "highp"))
                    typeString = parts[1];
                else
                    typeString = parts[0];

                StringToEnumMap::iterator typei = mTypeEnumMap.find(typeString);
                if (typei == mTypeEnumMap.end())
                {
                    // Gobble up the external name
                    String externalName = parts.front();

                    // Now there should be an opening brace
                    String::size_type openBracePos = src.find("{", currPos);
                    if (openBracePos != String::npos)
                    {
                        currPos = openBracePos + 1;
                    }
                    else
                    {
                        LogManager::getSingleton().logMessage("Missing opening brace in GLSL Uniform Block in file "
                                                              + filename);
                        break;
                    }

                    // First we need to find the internal name for the uniform block
                    String::size_type endBracePos = src.find("}", currPos);

                    // Find terminating semicolon
                    currPos = endBracePos + 1;
                    endPos = src.find(";", currPos);
                    if (endPos == String::npos)
                    {
                        // problem, missing semicolon, abort
                        break;
                    }
                }
                else
                {
                    // find terminating semicolon
                    endPos = src.find(";", currPos);
                    if (endPos == String::npos)
                    {
                        // problem, missing semicolon, abort
                        break;
                    }
                    
                    parseIndividualConstant(src, defs, currPos, filename, blockSharedParams);
                }
                line = src.substr(currPos, endPos - currPos);
			} // not commented or a larger symbol

			// Find next one
//.........这里部分代码省略.........
开发者ID:albmarvil,项目名称:The-Eternal-Sorrow,代码行数:101,代码来源:OgreGLSLESProgramManagerCommon.cpp

示例9: process

MetAssembleResult MetAssemble::process(const SequenceWorkItem& item)
{
    MetAssembleResult result;
    SeqRecord currRead = item.read;
    std::string w = item.read.seq.toString();
    if(w.size() <= m_parameters.kmer)
    {
        return result;
    }

    // Perform a backwards search using the read sequence
    // Check which k-mers have already been visited using the
    // shared bitvector. If any bit in the range [l,u] is set
    // for a suffix of the read, then we do not visit those kmers
    // later
    int len = w.size();
    int num_kmers = len - m_parameters.kmer + 1;
    std::vector<bool> visitedKmers(false, num_kmers);

    int j = len - 1;
    char curr = w[j];
    BWTInterval interval;
    BWTAlgorithms::initInterval(interval, curr, m_parameters.pBWT);
    --j;

    for(;j >= 0; --j)
    {
        curr = w[j];
        BWTAlgorithms::updateInterval(interval, curr, m_parameters.pBWT);
        assert(interval.isValid());

        // At this point interval represents the suffix [j,len)
        // Check if the starting point of this interval is set
        if(j < num_kmers)
            visitedKmers[j] = m_parameters.pBitVector->test(interval.lower);
    }
    
    // Process the kmers that have not been previously visited
    for(j = 0; j < num_kmers; ++j)
    {
        if(visitedKmers[j])
            continue; // skip

        std::string kmer = w.substr(j, m_parameters.kmer);
        
        // Get the interval for this kmer
        BWTInterval interval = BWTAlgorithms::findIntervalWithCache(m_parameters.pBWT, m_parameters.pBWTCache, kmer);

        // Check if this interval has been marked by a previous iteration of the loop
        assert(interval.isValid());
        if(m_parameters.pBitVector->test(interval.lower))
            continue;

        BWTInterval rc_interval = BWTAlgorithms::findIntervalWithCache(m_parameters.pBWT, m_parameters.pBWTCache, reverseComplement(kmer));

        size_t count = interval.size();
        if(rc_interval.isValid())
            count += rc_interval.size();

        if(count >= m_parameters.kmerThreshold)
        {
            // Process the kmer
            std::string contig = processKmer(kmer, count);

            // We must determine if this contig has been assembled by another thread.
            // Break the contig into lexicographically ordered set of kmers. The lowest kmer is chosen
            // to represent the contig. If this kmer has been marked as visited, we discard the contig
            // otherwise we mark all kmers in the contig and output the contig.
            StringVector kmers = getLexicographicKmers(contig);

            // Get the lowest kmer in the set
            assert(!kmers.empty());
            std::string lowest = kmers.front();
            BWTInterval lowInterval = BWTAlgorithms::findIntervalWithCache(m_parameters.pBWT, m_parameters.pBWTCache, lowest);
            BWTInterval lowRCInterval = BWTAlgorithms::findIntervalWithCache(m_parameters.pBWT, m_parameters.pBWTCache, reverseComplement(lowest));
            bool marked = false;

            // If the kmer exists in the read set (the interval is valid), we attempt to mark it
            // Otherwise, we attempt to mark its reverse complement. If either call succeeds
            // we output the contig. This block of code gives the synchronization between threads.
            // If multiple threads attempt to assemble the same contig, marked will be true for only
            // one of the threads.
            if(lowInterval.isValid())
                marked = m_parameters.pBitVector->updateCAS(lowInterval.lower, false, true);
            else
                marked = m_parameters.pBitVector->updateCAS(lowRCInterval.lower, false, true);

            // Mark all the kmers in the contig so they will not be visited again
            markSequenceKmers(contig);

            // If the collision check passed, output the contig
            if(marked)
            {
                if(contig.size() >= m_parameters.minLength)
                    result.contigs.push_back(contig);
            }
        }

        // Update the bit vector for the source kmer
        for(int64_t i = interval.lower; i <= interval.upper; ++i)
//.........这里部分代码省略.........
开发者ID:Buttonwood,项目名称:sga,代码行数:101,代码来源:MetAssembleProcess.cpp


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