本文整理汇总了C++中LocalVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalVector::push_back方法的具体用法?C++ LocalVector::push_back怎么用?C++ LocalVector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalVector
的用法示例。
在下文中一共展示了LocalVector::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trie
TEST(DictTrieTest, Test1) {
string s1, s2;
DictTrie trie(DICT_FILE);
ASSERT_LT(trie.GetMinWeight() + 15.6479, 0.001);
string word("来到");
Unicode uni;
ASSERT_TRUE(TransCode::Decode(word, uni));
DictUnit nodeInfo;
nodeInfo.word = uni;
nodeInfo.tag = "v";
nodeInfo.weight = -8.87033;
s1 << nodeInfo;
s2 << (*trie.Find(uni.begin(), uni.end()));
EXPECT_EQ("[\"26469\", \"21040\"] v -8.870", s2);
word = "清华大学";
LocalVector<pair<size_t, const DictUnit*> > res;
const char * words[] = {"清", "清华", "清华大学"};
for (size_t i = 0; i < sizeof(words)/sizeof(words[0]); i++) {
ASSERT_TRUE(TransCode::Decode(words[i], uni));
res.push_back(make_pair(uni.size() - 1, trie.Find(uni.begin(), uni.end())));
//resMap[uni.size() - 1] = trie.Find(uni.begin(), uni.end());
}
vector<pair<size_t, const DictUnit*> > vec;
vector<struct Dag> dags;
ASSERT_TRUE(TransCode::Decode(word, uni));
trie.Find(uni.begin(), uni.end(), dags);
ASSERT_EQ(dags.size(), uni.size());
ASSERT_NE(dags.size(), 0u);
s1 << res;
s2 << dags[0].nexts;
ASSERT_EQ(s1, s2);
}
示例2:
TEST(LocalVector, test1) {
LocalVector<size_t> vec;
ASSERT_EQ(vec.size(), 0u);
ASSERT_EQ(vec.capacity(), LOCAL_VECTOR_BUFFER_SIZE);
ASSERT_TRUE(vec.empty());
size_t size = 129;
for(size_t i = 0; i < size; i++) {
vec.push_back(i);
}
ASSERT_EQ(vec.size(), size);
ASSERT_EQ(vec.capacity(), 256u);
ASSERT_FALSE(vec.empty());
LocalVector<size_t> vec2(vec);
ASSERT_EQ(vec2.capacity(), vec.capacity());
ASSERT_EQ(vec2.size(), vec.size());
}