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


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

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


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

示例1: pairwiseEqual

//' Calculate pairwise equivalence between sequences
//' 
//' \code{pairwiseEqual} determined pairwise equivalence between a pairs in a 
//' set of sequences, excluding ambiguous positions (Ns and gaps).
//'
//' @param    seq  character vector containing a DNA sequences.
//'
//' @return   A logical matrix of equivalence between each entry in \code{seq}. 
//'           Values are \code{TRUE} when sequences are equivalent and \code{FALSE}
//'           when they are not.
//' 
//' @seealso  Uses \link{seqEqual} for testing equivalence between pairs.
//'           See \link{pairwiseDist} for generating a sequence distance matrix.
//'           
//' @examples
//' # Gaps and Ns will match any character
//' seq <- c(A="ATGGC", B="ATGGG", C="ATGGG", D="AT--C", E="NTGGG")
//' d <- pairwiseEqual(seq)
//' rownames(d) <- colnames(d) <- seq
//' d
//' 
//' @export
// [[Rcpp::export]]
LogicalMatrix pairwiseEqual (StringVector seq) {
    
    // allocate the matrix we will return
    LogicalMatrix rmat(seq.length(), seq.length());
    
    for (int i = 0; i < rmat.nrow(); i++) {
        for (int j = 0; j <= i; j++) {
            
            // check seq equal
            std::string row_seq = as<std::string>(seq[i]);
            std::string col_seq = as<std::string>(seq[j]);
            
            bool is_equal = seqEqual(row_seq, col_seq);
            
            // write to output matrix
            rmat(i,j) = is_equal;
            rmat(j,i) = is_equal;
        }
    }
    
    // Add row and column names
    Rcpp::List dimnames = Rcpp::List::create(seq.attr("names"), 
                                             seq.attr("names"));
    rmat.attr("dimnames") = dimnames;
    
    return rmat;
}
开发者ID:cran,项目名称:alakazam,代码行数:50,代码来源:RcppDistance.cpp

示例2: findItem

void
ConfigScope::dump(
	StringBuffer &			buf,
	bool					wantExpandedUidNames,
	int						indentLevel) const
{
	int						i;
	int						len;
	StringVector			nameVec;
	ConfigItem *			item;
	
	//--------
	// First pass. Dump the variables
	//--------
	listLocalNames(Configuration::CFG_VARIABLES, nameVec);
	nameVec.sort();
	len = nameVec.length();
	for (i = 0; i < len; i++) {
		item = findItem(nameVec[i]);
		assert(item->type() & Configuration::CFG_VARIABLES);
		item->dump(buf, item->name(), wantExpandedUidNames, indentLevel);
	}

	//--------
	// Second pass. Dump the nested scopes
	//--------
	listLocalNames(Configuration::CFG_SCOPE, nameVec);
	nameVec.sort();
	len = nameVec.length();
	for (i = 0; i < len; i++) {
		item = findItem(nameVec[i]);
		assert(item->type() == Configuration::CFG_SCOPE);
		item->dump(buf, item->name(), wantExpandedUidNames, indentLevel);
	}
}
开发者ID:offa,项目名称:config4cpp,代码行数:35,代码来源:ConfigScope.cpp

示例3: pairwiseDistRcpp

// pairwiseDist
// [[Rcpp::export]]
NumericMatrix pairwiseDistRcpp (StringVector seq, NumericMatrix dist_mat) {
    // allocate the matrix we will return
    NumericMatrix rmat(seq.length(), seq.length());
    
    for (int i = 0; i < rmat.nrow(); i++) {
        for (int j = 0; j < i; j++) {
            
            // check seq equal
            std::string row_seq = as<std::string>(seq[i]);
            std::string col_seq = as<std::string>(seq[j]);
            
            double distance = seqDistRcpp(row_seq, col_seq, dist_mat);
            
            // write to output matrix
            rmat(i,j) = distance;
            rmat(j,i) = distance;
        }
    }
    
    // Add row and column names
    Rcpp::List dimnames = Rcpp::List::create(seq.attr("names"), 
                                             seq.attr("names"));
    rmat.attr("dimnames") = dimnames;
    return rmat;
}
开发者ID:cran,项目名称:alakazam,代码行数:27,代码来源:RcppDistance.cpp

示例4: if

void
calculateRuleForName(
	const Configuration *		cfg,
	const char *				name,
	const char *				uName,
	const StringVector &		wildcardedNamesAndTypes,
	StringBuffer &				rule)
{
	int							i;
	int							len;
	const char *				str;
	const char *				keyword;
	const char *				wildcardedName;
	const char *				type;

	rule.empty();
	len = wildcardedNamesAndTypes.length();
	for (i = 0; i < len; i+=3) {
		keyword        = wildcardedNamesAndTypes[i+0]; // @optional or @required
		wildcardedName = wildcardedNamesAndTypes[i+1];
		type           = wildcardedNamesAndTypes[i+2];
		if (Configuration::patternMatch(uName, wildcardedName)) {
			rule << keyword << " " << uName << " = " << type;
			return;
		}
	}

	//--------
	// We couldn's determine the type from the wildcarded_names_and_types 
	// table. So we fall back to using heuristics to guess a good type.
	//--------
	if (cfg->type("", name) == Configuration::CFG_SCOPE) {
		rule << uName << " = scope";
	} else if (cfg->type("", name) == Configuration::CFG_LIST) {
		rule << uName << " = list[string]";
	} else {
		str = cfg->lookupString("", name);
		if (cfg->isBoolean(str)) {
			rule << uName << " = boolean";
		} else if (cfg->isInt(str)) {
			rule << uName << " = int";
		} else if (cfg->isFloat(str)) {
			rule << uName << " = float";
		} else if (cfg->isDurationSeconds(str)) {
			rule << uName << " = durationSeconds";
		} else if (cfg->isDurationMilliseconds(str)) {
			rule << uName << " = durationMilliseconds";
		} else if (cfg->isDurationMicroseconds(str)) {
			rule << uName << " = durationMicroseconds";
		} else if (cfg->isMemorySizeBytes(str)) {
			rule << uName << " = memorySizeBytes";
		} else if (cfg->isMemorySizeKB(str)) {
			rule << uName << " = memorySizeKB";
		} else if (cfg->isMemorySizeMB(str)) {
			rule << uName << " = memorySizeMB";
		} else {
			rule << uName << " = string";
		}
	}
}
开发者ID:2mia,项目名称:config4cpp,代码行数:60,代码来源:config2cpp-main.cpp

示例5:

bool
ConfigScope::listFilter(
	const char *				name,
	const StringVector &		filterPatterns) const
{
	int							i;
	int							len;
	const char *				unexpandedName;
	const char *				pattern;
	StringBuffer				buf;
	UidIdentifierProcessor		uidProc;

	len = filterPatterns.length();
	if (len == 0) {
		return true;
	}

	unexpandedName = uidProc.unexpand(name, buf);
	for (i = 0; i < len; i++) {
		pattern = filterPatterns[i];
		if (Configuration::patternMatch(unexpandedName, pattern)) {
			return true;
		}
	}
	return false;
}
开发者ID:offa,项目名称:config4cpp,代码行数:26,代码来源:ConfigScope.cpp

示例6: throw

void
checkForUnmatchedPatterns(
	const Configuration *		cfg,
	const StringVector &		namesList,
	const StringVector &		wildcardedNamesAndTypes,
	StringVector &				unmatchedPatterns) throw(ConfigurationException)
{
	int							i;
	int							len;
	const char *				wildcardedName;

	unmatchedPatterns.empty();
	//--------
	// Check if there is a wildcarded name that does not match anything
	//--------
	len = wildcardedNamesAndTypes.length();
	for (i = 0; i < len; i += 3) {
		wildcardedName = wildcardedNamesAndTypes[i+1];
		if (!doesPatternMatchAnyUnexpandedNameInList(cfg, wildcardedName,
		                                             namesList))
		{
			unmatchedPatterns.add(wildcardedName);
		}
	}
}
开发者ID:2mia,项目名称:config4cpp,代码行数:25,代码来源:config2cpp-main.cpp

示例7: catch

bool
SchemaTypeInt::isA(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				value,
	const char *				typeName,
	const StringVector &		typeArgs,
	int							indentLevel,
	StringBuffer &				errSuffix) const
{
	int							val;
	int							min;
	int							max;

	try {
		val = cfg->stringToInt("", "", value);
	} catch (const ConfigurationException & ex) {
		return false;
	}
	if (typeArgs.length() == 0) {
		return true;
	}
	min = cfg->stringToInt("", "", typeArgs[0]);
	max = cfg->stringToInt("", "", typeArgs[1]);
	if (val < min || val > max) {
		errSuffix << "the value is outside the permitted range ["
				  << typeArgs[0] << ", " << typeArgs[1] << "]";
		return false;
	}
	return true;
}
开发者ID:2mia,项目名称:config4cpp,代码行数:31,代码来源:SchemaTypeInt.cpp

示例8: catch

bool
SchemaTypeDurationSeconds::isA(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				value,
	const char *				typeName,
	const StringVector &		typeArgs,
	int							indentLevel,
	StringBuffer &				errSuffix) const
{
	bool						ok;
	int							min;
	int							max;
	int							val;

	try {
		val = cfg->stringToDurationSeconds("", "", value);
	} catch (const ConfigurationException & ex) {
		errSuffix << "the value should be in the format '<units> <float>' "
				  << "where <units> is one of: "
				  << "second, seconds, "
				  << "minute, minutes, "
				  << "hour, hours, "
				  << "day, days, "
				  << "week, weeks; "
				  << "alternatively, you can use 'infinite'";
		return false;
	}
	if (typeArgs.length() == 0) {
		return true;
	}
	min = cfg->stringToDurationSeconds("", "", typeArgs[0]);
	max = cfg->stringToDurationSeconds("", "", typeArgs[1]);

	//--------
	// We want to test for "min <= val && val <= max", but this is
	// is complicated by using "-1" for the numerical value of "infinite".
	//--------
	if (min == -1) {
		assert(max == -1);
		ok = (val == -1);
	} else if (val == -1 && max == -1) {
		ok = true;
	} else if (val >= min && (val <= max || max == -1)) {
		ok = true;
	} else {
		ok = false;
	}
	if (!ok) {
		errSuffix << "the value is outside the permitted range ["
				  << typeArgs[0] << ", " << typeArgs[1] << "]";
		return false;
	}
	return true;
}
开发者ID:2mia,项目名称:config4cpp,代码行数:55,代码来源:SchemaTypeDurationSeconds.cpp

示例9: ConfigurationException

void
SchemaTypeTuple::checkRule(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				typeName,
	const StringVector &		typeArgs,
	const char *				rule) const throw(ConfigurationException)
{
    (void) cfg;
    
	StringBuffer				msg;
	int							i;
	int							len;
	const char *				elemType;
	SchemaType *				typeDef;

	//--------
	// Check there is at least one pair of type and name arguments.
	//--------
	len = typeArgs.length();
	if ((len == 0) || (len % 2 != 0)) {
		msg << "the '" << typeName << "' type requires pairs of type and "
			<< "name arguments in rule '" << rule << "'";
		throw ConfigurationException(msg.c_str());
	}

	//--------
	// Check that all the type arguments are valid types.
	//--------
	for (i = 0; i < len; i+=2) {
		elemType = typeArgs[i+0];
		typeDef = findType(sv, elemType);
		if (typeDef == 0) {
			msg << "unknown type '" << elemType << "' in rule '" << rule << "'";
			throw ConfigurationException(msg.c_str());
		}
		switch (typeDef->cfgType()) {
		case Configuration::CFG_STRING:
			break;
		case Configuration::CFG_LIST:
			msg << "you cannot embed a list type ('" << elemType
				<< "') inside a " << "tuple in rule '" << rule << "'";
			throw ConfigurationException(msg.c_str());
		case Configuration::CFG_SCOPE:
			msg << "you cannot embed a scope type ('" << elemType
				<< "') inside a " << "tuple in rule '" << rule << "'";
			throw ConfigurationException(msg.c_str());
		default:
			assert(0); // Bug!
		}
	}
}
开发者ID:offa,项目名称:config4cpp,代码行数:52,代码来源:SchemaTypeTuple.cpp

示例10:

bool
doesVectorcontainString(const StringVector & vec, const char * str)
{
	int				i;
	int				len;

	len = vec.length();
	for (i = 0; i < len; i++) {
		if (strcmp(vec[i], str) == 0) {
			return true;
		}
	}
	return false;
}
开发者ID:2mia,项目名称:config4cpp,代码行数:14,代码来源:config2cpp-main.cpp

示例11:

void
StringVector::add(const StringVector & other)
{
	int				i;
	int				otherLen;

	otherLen = other.length();
	if (m_currSize + otherLen >= m_maxSize) {
		ensureCapacity( (m_currSize + otherLen) * 2 );
	}

	for (i = 0; i < otherLen; i++) {
		add(other[i]);
	}
}
开发者ID:2mia,项目名称:config4cpp,代码行数:15,代码来源:StringVector.cpp

示例12: ConfigurationException

void
SchemaTypeTypedef::checkRule(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				typeName,
	const StringVector &		typeArgs,
	const char *				rule) const throw(ConfigurationException)
{
	StringBuffer				msg;

	if (typeArgs.length() != 0) {
		msg << "you cannot specify arguments when using user-defined type '"
			<< typeName << "' in '" << rule << "'";
		throw ConfigurationException(msg.c_str());
	}
}
开发者ID:2mia,项目名称:config4cpp,代码行数:16,代码来源:SchemaTypeTypedef.cpp

示例13: ConfigurationException

void
SchemaTypeScope::checkRule(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				typeName,
	const StringVector &		typeArgs,
	const char *				rule) const throw(ConfigurationException)
{
	StringBuffer				msg;

	if (typeArgs.length() != 0) {
		msg << "the '" << typeName << "' type should not take arguments "
			<< "in rule '" << rule << "'";
		throw ConfigurationException(msg.c_str());
	}
}
开发者ID:2mia,项目名称:config4cpp,代码行数:16,代码来源:SchemaTypeScope.cpp

示例14: ConfigurationException

void
SchemaTypeInt::checkRule(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				typeName,
	const StringVector &		typeArgs,
	const char *				rule) const throw(ConfigurationException)
{
	StringBuffer				msg;
	int							len;
	int							min;
	int							max;

	len = typeArgs.length();
	if (len == 0) {
		return;
	}
	if (len != 2) {
		msg << "the '" << typeName << "' type should take either no "
			<< "arguments or 2 arguments (denoting min and max values) "
			<< "in rule '" << rule << "'";
		throw ConfigurationException(msg.c_str());
	}
	try {
		min = cfg->stringToInt("", "", typeArgs[0]);
	} catch (const ConfigurationException & ex) {
		msg << "non-integer value for the first ('min') argument in rule '"
			<< rule << "'";
		throw ConfigurationException(msg.c_str());
	}
	try {
		max = cfg->stringToInt("", "", typeArgs[1]);
	} catch (const ConfigurationException & ex) {
		msg << "non-integer value for the second ('max') argument in rule '"
			<< rule << "'";
		throw ConfigurationException(msg.c_str());
	}
	if (min > max) {
		msg << "the first ('min') value is larger than the second ('max') "
			<< "argument " << "in rule '" << rule << "'";
		throw ConfigurationException(msg.c_str());
	}
}
开发者ID:2mia,项目名称:config4cpp,代码行数:43,代码来源:SchemaTypeInt.cpp

示例15: findType

bool
SchemaTypeTypedef::isA(
	const SchemaValidator *		sv,
	const Configuration *		cfg,
	const char *				value,
	const char *				typeName,
	const StringVector &		typeArgs,
	int							indentLevel,
	StringBuffer &				errSuffix) const
{
    (void) value;
    (void) typeName;
    
	assert(typeArgs.length() == 0);
	const char* baseTypeName = m_baseTypeName.c_str();
	SchemaType* baseTypeDef = findType(sv, baseTypeName);
	assert(baseTypeDef != 0);
	bool result = callIsA(baseTypeDef, sv, cfg, value, baseTypeName, m_baseTypeArgs,
					 indentLevel + 1, errSuffix);
	return result;
}
开发者ID:offa,项目名称:config4cpp,代码行数:21,代码来源:SchemaTypeTypedef.cpp


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