本文整理汇总了C++中var::key方法的典型用法代码示例。如果您正苦于以下问题:C++ var::key方法的具体用法?C++ var::key怎么用?C++ var::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类var
的用法示例。
在下文中一共展示了var::key方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
bool var::ahead::operator()(const var& x, const var& y) const {
long r = x.primary() - y.primary();
if (r)
return r < 0;
switch (x.primary()) {
case Primary::Object: {
r = reinterpret_cast<long>(x.object().type) - reinterpret_cast<long>(y.object().type);
if (r)
return r < 0;
return x.object().compare(y.object()) < 0;
}
case Primary::Key: {
r = x.key().kind() - y.key().kind();
if (r)
return r < 0;
return x.key().key < y.key().key;
}
case Primary::Symbol:
return x.ptr < y.ptr;
case Primary::Tuple: {
r = x.tuple().size - y.tuple().size;
if (r)
return r < 0;
for (uint i = 0; i < x.tuple().size; ++i)
if ((*this)(x.tuple()[i], y.tuple()[i]))
return true;
}
return false;
}
return 0;
}
示例2: assert
HTK::HTK(var iAttr)
{
// Ring alarm bells
assert(sizeof(float) == 4);
assert(sizeof(int) == 4);
assert(sizeof(short) == 2);
// Set up the attributes
mAttr["kind"] = HTK_USER;
mAttr["period"] = 0.01f;
for (int i=0; i<iAttr.size(); i++)
mAttr[iAttr.key(i)] = iAttr[i];
};
示例3: equal
bool var::equal(const var& x) const {
if (primary() != x.primary())
return false;
switch (primary()) {
case Primary::Symbol:
return symbol() == x.symbol();
case Primary::Key:
return key().key == x.key().key;
case Primary::Object:
if (object().type != x.object().type)
return false;
return object().equal(x.object());
case Primary::Tuple:
return tuple().equal(x.tuple());
}
// Primary::Null
return true;
}
示例4: to_lua
void to_lua(lua_State* L, const var& x) {
switch (x.primary()) {
case Primary::Null:
lua_pushnil(L);
return;
case Primary::Symbol:
to_lua(L, x.symbol());
return;
case Primary::Key:
to_lua(L, x.key());
return;
case Primary::Object:
to_lua(L, x.object());
return;
case Primary::Tuple:
to_lua(L, x.tuple());
return;
}
}
示例5: compare
long var::compare(const var& x) const {
long r = primary() - x.primary();
if (r)
return r;
switch (primary()) {
case Primary::Symbol:
return symbol()->compare(x.symbol());
case Primary::Key:
return key().compare(x.key());
case Primary::Object: {
long r = object().type->compare(x.object().type);
if (r)
return r;
}
return object().compare(x.object());
case Primary::Tuple:
return tuple().compare(x.tuple());
}
return 0;
}