本文整理汇总了C++中StringHash::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ StringHash::getValue方法的具体用法?C++ StringHash::getValue怎么用?C++ StringHash::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHash
的用法示例。
在下文中一共展示了StringHash::getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addComponent
void SceneNode::addComponent(Component* component)
{
StringHash type = component->getType();
if (hasComponent(type))
{
Logger::warn("Scene node " + name_ + " has already component of type " + std::to_string(type.getValue()));
return;
}
components_[type] = component;
component->node_ = this;
component->onNodeSet();
}
示例2: main
int main(int argc, char **argv) {
#ifdef _MEMMGR
HeapManager heap;
#endif
clock_t from, to;
double diff;
LongHash lhash;
LongMap lmap;
StringHash shash;
StringMap smap;
srand(clock());
int nelems = 10;
int naccess = 100;
if (argc >= 2) {
sscanf(argv[1], "%d", &nelems);
}
if (argc >= 3) {
sscanf(argv[2], "%d", &naccess);
}
const char *strpool[] = {
"hello",
"_",
"world",
"012",
"before",
"after",
"if",
"then",
"else",
"for",
"while",
"do",
"@",
"~",
"+",
"-",
"function",
"class"
};
size_t nstrings = sizeof(strpool) / sizeof(const char*);
// fill elements
std::vector<std::string> skeys(nelems);
std::vector<long> lkeys(nelems);
std::cout << "Buid hash and map with " << nelems << " elements" << std::endl;
for (int i=0; i<nelems; ++i) {
long k = rand();
lkeys[i] = k;
int p = rand() % nstrings;
int s = rand() % nstrings;
skeys[i] = strpool[p];
skeys[i] += strpool[s];
}
from = clock();
for (int i=0; i<nelems; ++i) {
lhash.insert(lkeys[i], rand());
}
to = clock();
diff = double(to - from) / CLOCKS_PER_SEC;
std::cout << "LongHash fill " << nelems << " values: " << diff << " (s)" << std::endl;
from = clock();
for (int i=0; i<nelems; ++i) {
lmap[lkeys[i]] = rand();
}
to = clock();
diff = double(to - from) / CLOCKS_PER_SEC;
std::cout << "LongMap fill " << nelems << " values: " << diff << " (s)" << std::endl;
from = clock();
for (int i=0; i<nelems; ++i) {
shash.insert(skeys[i], rand());
}
to = clock();
diff = double(to - from) / CLOCKS_PER_SEC;
std::cout << "StringHash fill " << nelems << " values: " << diff << " (s)" << std::endl;
from = clock();
for (int i=0; i<nelems; ++i) {
smap[skeys[i]] = rand();
}
to = clock();
diff = double(to - from) / CLOCKS_PER_SEC;
std::cout << "StringMap fill " << nelems << " values: " << diff << " (s)" << std::endl;
// check datas
/*
std::cout << "Check data" << std::endl;
for (int k=0; k<nelems; ++k) {
long v0 = lhash.getValue(lkeys[k]);
long v1 = lmap[lkeys[k]];
if (v0 != v1) {
std::cout << "Data mismatch at long key \"" << lkeys[k] << "\"" << std::endl;
}
//.........这里部分代码省略.........