本文整理汇总了C++中Strings::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Strings::size方法的具体用法?C++ Strings::size怎么用?C++ Strings::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Strings
的用法示例。
在下文中一共展示了Strings::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stringToHypergraph
Position stringToHypergraph(Strings const& inputTokens, IMutableHypergraph<Arc>* pHgResult,
StringToHypergraphOptions const& opts = StringToHypergraphOptions(),
TokenWeights const& inputWeights = TokenWeights()) {
IVocabularyPtr const& pVoc = pHgResult->getVocabulary();
if (!pVoc) SDL_THROW_LOG(Hypergraph, InvalidInputException, "pHgResult hypergraph must contain vocabulary");
for (std::size_t i = 0, numNonlexicalStates = inputTokens.size() + 1; i < numNonlexicalStates; ++i)
pHgResult->addState();
pHgResult->setStart(0);
StateId prevState = 0;
typedef typename Arc::Weight Weight;
typedef FeatureInsertFct<Weight> FI;
Position i = 0, n = inputTokens.size();
for (; i != n; ++i) {
std::string const& token = inputTokens[i];
SDL_TRACE(Hypergraph.StringToHypergraph, i << ": " << token);
const Sym sym = opts.terminalMaybeUnk(pVoc.get(), token);
const StateId nextState = prevState + 1;
Arc* pArc = new Arc(nextState, Tails(prevState, pHgResult->addState(sym)));
Weight& weight = pArc->weight();
assert(opts.inputFeatures != NULL);
for (FeatureId featureId : opts.inputFeatures->getFeaturesForInputPosition(i)) {
FI::insertNew(&weight, featureId, 1);
if (opts.tokens) opts.tokens->insert(sym, featureId);
}
inputWeights.reweight(i, weight);
pHgResult->addArc(pArc);
prevState = nextState;
}
pHgResult->setFinal(prevState);
return n;
}
示例2:
void
ZStream::setZipFileSuffixes(Strings const& suffixes)
{
m_suffixes.clear();
m_suffixes.reserve(suffixes.size());
for (unsigned i = 0; i < suffixes.size(); ++i)
m_suffixes.push_back(suffixes[i].front() == '.' ? suffixes[i] : '.' + suffixes[i]);
}
示例3: setup_from_argv
Strings setup_from_argv(const Strings &iargv, std::string description,
std::string usage, int num_positional) {
char **argv = new char *[iargv.size()];
for (unsigned int i = 0; i < iargv.size(); ++i) {
argv[i] = const_cast<char *>(iargv[i].c_str());
}
return setup_from_argv(iargv.size(), &argv[0], description, usage,
num_positional);
}
示例4: FindAllFilesOfType
///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
bool FindAllFilesOfType( const std::string& directory, const std::string& searchPattern, Strings& out_filesFound )
{
#ifdef WIN32
_finddata_t fd;
std::string searchPath = directory + searchPattern;
intptr_t searchHandle = _findfirst( searchPath.c_str(), &fd );
if (searchHandle != -1)
{
do
{
// ConsolePrintf( "%s %i\n", (directory + std::string(fd.name)).c_str(), fd.attrib );
out_filesFound.push_back( directory + std::string( fd.name ) );
} while (_findnext( searchHandle, &fd ) == 0);
}
else return false;
if (_findclose( searchHandle ) == 0 && out_filesFound.size() != 0)
return true;
return false;
#else
return false;
#endif
}
示例5: buildTree
void NeighbourJoining::buildTree(Matrix& distMatrix, const Strings& labels, Tree* tree)
{
// allocation space for temporary variables
m_separationSums = new double[distMatrix.size()];
m_separations = new double[distMatrix.size()];
m_numActiveClusters = distMatrix.size();
m_activeClusters = new bool[distMatrix.size()];
//calculate initial seperation rows
for(uint i = 0; i < distMatrix.size(); i++)
{
double sum = 0;
for(uint j = 0; j < distMatrix.size(); j++)
sum += distMatrix[i][j];
m_separationSums[i] = sum;
m_separations[i] = sum / (m_numActiveClusters-2);
m_activeClusters[i] = true;
}
// create initial singleton clusters
std::vector< Node* > clusters;
for(uint i = 0; i < labels.size(); ++i)
{
Node* node = new Node(labels.at(i));
clusters.push_back(node);
}
while(m_numActiveClusters > 2)
{
findNearestClusters(distMatrix);
updateClusters(distMatrix, clusters);
updateDistanceMatrix(distMatrix);
}
// finish by joining the two remaining clusters
int index1 = -1;
int index2 = -1;
// find the last nodes
for(uint i = 0; i < distMatrix.size(); i++)
{
if(m_activeClusters[i])
{
if(index1 == -1)
index1 = i;
else
{
index2 = i;
break;
}
}
}
// connect remaining subtrees and define arbitrary root of tree
clusters.at(index1)->addChild(clusters.at(index2));
clusters.at(index2)->distanceToParent(distMatrix[index1][index2]);
tree->root(clusters.at(index1));
}
示例6: get_projections
em2d::Images get_projections(const ParticlesTemp &ps,
const RegistrationResults ®istration_values,
int rows, int cols,
const ProjectingOptions &options, Strings names) {
IMP_LOG_VERBOSE("Generating projections from registration results"
<< std::endl);
if (options.save_images && (names.size() < registration_values.size())) {
IMP_THROW("get_projections: Insufficient number of image names provided",
IOException);
}
unsigned long n_projs = registration_values.size();
em2d::Images projections(n_projs);
// Precomputation of all the possible projection masks for the particles
MasksManagerPtr masks(
new MasksManager(options.resolution, options.pixel_size));
masks->create_masks(ps);
for (unsigned long i = 0; i < n_projs; ++i) {
IMP_NEW(em2d::Image, img, ());
img->set_size(rows, cols);
img->set_was_used(true);
String name = "";
if (options.save_images) name = names[i];
get_projection(img, ps, registration_values[i], options, masks, name);
projections[i] = img;
}
return projections;
}
示例7: assert
// Convert a vector of four strings to a Vec3.
// The zeroth string is ignored. Strings 1, 2 & 3 are
// asssumed to be floats.
Vec3f ToVec3(const Strings& strs)
{
if (strs.size() != 4)
{
assert(0);
}
return Vec3f(ToFloat(strs[1]), ToFloat(strs[2]), ToFloat(strs[3]));
}
示例8: ToFloat
// Convert a vector of three strings to a Vec2.
// The zeroth string is ignored. Strings 1 & 2 are
// asssumed to be floats.
Vec2f ToVec2(const Strings& strs)
{
if (strs.size() != 3)
{
//assert(0);
}
return Vec2f(ToFloat(strs[1]), ToFloat(strs[2]));
}
示例9: Load
bool PlayerInfo::Load()
{
// FileExists doesn't append File::Root
if (FileExists(File::GetRoot() + m_filename))
{
#ifdef PI_DEBUG
std::cout << "Loading player info " << m_filename << "...\n";
#endif
}
else
{
#ifdef PI_DEBUG
std::cout << "Loading player info " << m_filename << " doesn't exist! - - it's a new file\n";
#endif
// We assume the player is new and has not saved any player info yet - this is OK.
return true;
}
#ifdef PI_DEBUG
std::cout << "Loading player info " << m_filename << "...\n";
#endif
File f;
if (!f.OpenRead(m_filename))
{
return false;
}
int num = 0;
if (!f.GetInteger(&num))
{
return false;
}
for (int i = 0; i < num; i++)
{
std::string s;
if (!f.GetDataLine(&s))
{
return false;
}
#ifdef PI_DEBUG
std::cout << " Got line: " << s << "\n";
#endif
Strings strs = Split(s, ',');
if (strs.size() != 2)
{
f.ReportError("Bad line in player info: " + s);
return false;
}
PISetString(strs[0], strs[1]);
}
#ifdef PI_DEBUG
std::cout << "End of player info load.\n";
#endif
return true;
}
示例10: toHypergraph
void toHypergraph(std::string const& line, IMutableHypergraph<A>* phg, std::size_t lineNum = 0) const {
Strings words = parseTokens(line, (ParseTokensOptions const&)*this);
SDL_DEBUG(Hypergraph.HgConvertString, lineNum << ": " << printer(words, Util::RangeSep(" ", "", "")));
SDL_INFO(Hypergraph.HgConvertString, lineNum << ": len=" << words.size());
phg->clear(properties());
assert(phg->storesArcs());
assert(phg->getVocabulary());
stringToHypergraph(words, phg);
}
示例11: UpdateText
void CInPlaceList::UpdateText(const CString& text)
{
Strings strings;
SplitList(text, L"=", strings);
CString val = (strings.size() == 2)
? strings[0] : text;
SetWindowText(val);
}
示例12: keys
const Strings
SqlSource::options() const
{
Strings options;
Strings k = keys();
for (size_t i = 0; i < k.size(); ++i)
if (!starts_with(k[i], _T("&")))
options.push_back(k[i]);
return options;
}
示例13: Parse
int String::Parse (Strings &result, const char *chars)
{
String element;
result.clear ();
while (Split (element, chars)) {
result.push_back (element);
}
return ((int) result.size ());
}
示例14: align_seqs_impl
void ExternalAligner::align_seqs_impl(Strings& seqs) const {
std::string input = tmp_file();
ASSERT_FALSE(input.empty());
std::string output = tmp_file();
ASSERT_FALSE(output.empty());
{
boost::shared_ptr<std::ostream> file = name_to_ostream(input);
std::ostream& out = *file;
for (int i = 0; i < seqs.size(); i++) {
write_fasta(out, TO_S(i), "", seqs[i], 60);
}
}
align_file(input, output);
Strings rows;
read_alignment(rows, output);
ASSERT_EQ(rows.size(), seqs.size());
seqs.swap(rows);
if (!go("NPGE_DEBUG").as<bool>()) {
remove_file(input);
remove_file(output);
}
}
示例15: lock
void
QtSqlConnectionBackend::open(SqlDialect *dialect, const SqlSource &source)
{
close();
ScopedLock lock(drv_->conn_mux_);
own_handle_ = true;
conn_name_ = dialect->get_name() + _T("_") + source.db()
+ _T("_") + to_string(drv_->seq_);
++drv_->seq_;
String driver = source.driver();
bool eat_slash = false;
if (driver == _T("QTSQL"))
{
if (dialect->get_name() == _T("MYSQL"))
driver = _T("QMYSQL");
else if (dialect->get_name() == _T("POSTGRES"))
driver = _T("QPSQL");
else if (dialect->get_name() == _T("ORACLE"))
driver = _T("QOCI");
else if (dialect->get_name() == _T("INTERBASE"))
driver = _T("QIBASE");
else if (dialect->get_name() == _T("SQLITE"))
driver = _T("QSQLITE");
if (dialect->native_driver_eats_slash()
&& !str_empty(source.db())
&& char_code(source.db()[0]) == '/')
eat_slash = true;
}
conn_ = new QSqlDatabase(QSqlDatabase::addDatabase(driver, conn_name_));
if (eat_slash)
conn_->setDatabaseName(str_substr(source.db(), 1));
else
conn_->setDatabaseName(source.db());
conn_->setUserName(source.user());
conn_->setPassword(source.passwd());
if (source.port() > 0)
conn_->setPort(source.port());
if (!str_empty(source.host()))
conn_->setHostName(source.host());
String options;
Strings keys = source.options();
for (size_t i = 0; i < keys.size(); ++i) {
if (!str_empty(options))
options += _T(";");
options += keys[i] + _T("=") + source[keys[i]];
}
if (!str_empty(options))
conn_->setConnectOptions(options);
if (!conn_->open())
throw DBError(conn_->lastError().text());
}