本文整理汇总了C++中boost::unordered_set::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_set::clear方法的具体用法?C++ unordered_set::clear怎么用?C++ unordered_set::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::unordered_set
的用法示例。
在下文中一共展示了unordered_set::clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enableUpdates
inline void ObservableSettings::enableUpdates() {
updatesEnabled_ = true;
updatesDeferred_ = false;
// if there are outstanding deferred updates, do the notification
if (deferredObservers_.size() > 0)
{
bool successful = true;
std::string errMsg;
QL_TRACE("deferred notification of " << deferredObservers_.size() << " observers");
for (iterator i=deferredObservers_.begin(); i!=deferredObservers_.end(); ++i) {
try {
(*i)->update();
} catch (std::exception& e) {
successful = false;
errMsg = e.what();
} catch (...) {
successful = false;
}
}
deferredObservers_.clear();
QL_ENSURE(successful,
"could not notify one or more observers: " << errMsg);
}
}
示例2: load
void load(Archive & ar, boost::unordered_set<T> & t, unsigned int version)
{
// clear the set
t.clear();
// read the size
typedef typename boost::unordered_set<T>::size_type size_type;
size_type size;
ar & BOOST_SERIALIZATION_NVP(size);
for (size_type i = 0; i < size; i++) {
// read a pair
T item;
ar & boost::serialization::make_nvp("item"+i, item);
// insert it into the set
t.insert(item);
}
}
示例3: Load
bool HyperTreeLoader::Load(AllOptions const& opts,
const std::vector<FactorType> &input,
const std::vector<FactorType> &output,
const std::string &inFile,
const RuleTableFF &ff,
HyperTree &trie,
boost::unordered_set<std::size_t> &sourceTermSet)
{
PrintUserTime(std::string("Start loading HyperTree"));
sourceTermSet.clear();
std::size_t count = 0;
std::ostream *progress = NULL;
IFVERBOSE(1) progress = &std::cerr;
util::FilePiece in(inFile.c_str(), progress);
// reused variables
std::vector<float> scoreVector;
StringPiece line;
double_conversion::StringToDoubleConverter converter(double_conversion::StringToDoubleConverter::NO_FLAGS, NAN, NAN, "inf", "nan");
HyperPathLoader hyperPathLoader;
Phrase dummySourcePhrase;
{
Word *lhs = NULL;
dummySourcePhrase.CreateFromString(Input, input, "hello", &lhs);
delete lhs;
}
while(true) {
try {
line = in.ReadLine();
} catch (const util::EndOfFileException &e) {
break;
}
util::TokenIter<util::MultiCharacter> pipes(line, "|||");
StringPiece sourceString(*pipes);
StringPiece targetString(*++pipes);
StringPiece scoreString(*++pipes);
StringPiece alignString;
if (++pipes) {
StringPiece temp(*pipes);
alignString = temp;
}
++pipes; // counts
scoreVector.clear();
for (util::TokenIter<util::AnyCharacter, true> s(scoreString, " \t"); s; ++s) {
int processed;
float score = converter.StringToFloat(s->data(), s->length(), &processed);
UTIL_THROW_IF2(std::isnan(score), "Bad score " << *s << " on line " << count);
scoreVector.push_back(FloorScore(TransformScore(score)));
}
const std::size_t numScoreComponents = ff.GetNumScoreComponents();
if (scoreVector.size() != numScoreComponents) {
UTIL_THROW2("Size of scoreVector != number (" << scoreVector.size() << "!="
<< numScoreComponents << ") of score components on line " << count);
}
// Source-side
HyperPath sourceFragment;
hyperPathLoader.Load(sourceString, sourceFragment);
ExtractSourceTerminalSetFromHyperPath(sourceFragment, sourceTermSet);
// Target-side
TargetPhrase *targetPhrase = new TargetPhrase(&ff);
Word *targetLHS = NULL;
targetPhrase->CreateFromString(Output, output, targetString, &targetLHS);
targetPhrase->SetTargetLHS(targetLHS);
targetPhrase->SetAlignmentInfo(alignString);
if (++pipes) {
StringPiece sparseString(*pipes);
targetPhrase->SetSparseScore(&ff, sparseString);
}
if (++pipes) {
StringPiece propertiesString(*pipes);
targetPhrase->SetProperties(propertiesString);
}
targetPhrase->GetScoreBreakdown().Assign(&ff, scoreVector);
targetPhrase->EvaluateInIsolation(dummySourcePhrase,
ff.GetFeaturesToApply());
// Add rule to trie.
TargetPhraseCollection::shared_ptr phraseColl
= GetOrCreateTargetPhraseCollection(trie, sourceFragment);
phraseColl->Add(targetPhrase);
count++;
}
//.........这里部分代码省略.........
示例4: unregisterWithAll
inline void Observer::unregisterWithAll() {
for (iterator i=observables_.begin(); i!=observables_.end(); ++i)
(*i)->unregisterObserver(this);
observables_.clear();
}
示例5: exec
static void exec(ArcType& a, boost::unordered_set<T>& vec){
vec.clear();
deserialize_iterator<ArcType, T>(a, std::inserter(vec,vec.end()));
}