本文整理汇总了C++中ValueArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ValueArray::size方法的具体用法?C++ ValueArray::size怎么用?C++ ValueArray::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValueArray
的用法示例。
在下文中一共展示了ValueArray::size方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
inline bool operator==(const ValueArray& x, const ValueArray& y)
{
if (x.size() != y.size())
{
return false;
}
for (uint32 i = 0; i < x.size(); i++)
{
if (x[i].Compare(y[i]) != 0)
{
return false;
}
}
return true;
}
示例2: test_set_inter
void test_set_inter(Ardb& db)
{
DBID dbid = 0;
db.SClear(dbid, "myset1");
db.SClear(dbid, "myset2");
db.SClear(dbid, "myset3");
db.SAdd(dbid, "myset1", "a");
db.SAdd(dbid, "myset1", "b");
db.SAdd(dbid, "myset1", "c");
db.SAdd(dbid, "myset1", "d");
db.SAdd(dbid, "myset2", "c");
db.SAdd(dbid, "myset3", "a");
db.SAdd(dbid, "myset3", "c");
db.SAdd(dbid, "myset3", "e");
SliceArray keys;
keys.push_back("myset1");
keys.push_back("myset2");
keys.push_back("myset3");
ValueArray values;
db.SInter(dbid, keys, values);
std::string str;
CHECK_FATAL( values.size() != 1, "Sinter failed:");
CHECK_FATAL(values.begin()->ToString(str) != "c", "Sinter store failed.");
db.SInterStore(dbid, "myset4", keys);
CHECK_FATAL( db.SCard(dbid, "myset4") != 1, "SInterStore myset4 failed");
}
示例3: test_set_diff
void test_set_diff(Ardb& db)
{
DBID dbid = 0;
db.SClear(dbid, "myset1");
db.SClear(dbid, "myset2");
db.SClear(dbid, "myset3");
db.SAdd(dbid, "myset1", "a");
db.SAdd(dbid, "myset1", "b");
db.SAdd(dbid, "myset1", "c");
db.SAdd(dbid, "myset1", "d");
db.SAdd(dbid, "myset2", "c");
db.SAdd(dbid, "myset3", "a");
db.SAdd(dbid, "myset3", "c");
db.SAdd(dbid, "myset3", "e");
std::string str;
SliceArray keys;
keys.push_back("myset1");
keys.push_back("myset2");
keys.push_back("myset3");
ValueArray values;
db.SDiff(dbid, keys, values);
CHECK_FATAL(values.size() != 2, "Sdiff failed:");
CHECK_FATAL(values.begin()->ToString(str) != "b", "Sdiff store failed:");
//CHECK_FATAL(FATAL, values[1] != "d") << "Sdiff store failed:";
int len = db.SDiffStore(dbid, "myset2", keys);
CHECK_FATAL(len != 2, "SDiffStore myset2 failed:%d", len);
len = db.SCard(dbid, "myset2");
CHECK_FATAL(len != 2, "SDiffStore myset2 failed:%d", len);
}
示例4: test_set_union
void test_set_union(Ardb& db)
{
DBID dbid = 0;
db.SClear(dbid, "myset1");
db.SClear(dbid, "myset2");
db.SClear(dbid, "myset3");
db.SAdd(dbid, "myset1", "a");
db.SAdd(dbid, "myset1", "b");
db.SAdd(dbid, "myset1", "c");
db.SAdd(dbid, "myset1", "d");
db.SAdd(dbid, "myset2", "c");
db.SAdd(dbid, "myset3", "a");
db.SAdd(dbid, "myset3", "c");
db.SAdd(dbid, "myset3", "e");
SliceArray keys;
keys.push_back("myset1");
keys.push_back("myset2");
keys.push_back("myset3");
ValueArray values;
db.SUnion(dbid, keys, values);
CHECK_FATAL(values.size() != 5, "SUnion failed:");
std::string str;
CHECK_FATAL( values.begin()->ToString(str) != "a", "SUnion store failed:");
db.SUnionStore(dbid, "myset2", keys);
CHECK_FATAL(db.SCard(dbid, "myset2") != 5, "SUnionStore myset2 failed:");
}
示例5: subtractValues
/**
* Calculates vector a-b.
* @return A new array holding a-b.
*/
static ValueArray subtractValues(const ValueArray& a, const ValueArray& b)
{
ValueArray result;
for (unsigned int i = 0; i < a.size(); i++) {
result[i] = a[i] - b[i];
}
return result;
}
示例6: selfRefValue
Value Alias::selfRefValue(ValueArray templateArguments) const {
assert(templateArguments.size() == templateVariables().size());
if (type()->isBuiltInTypename()) {
const auto aliasRef = selfRefType(std::move(templateArguments));
return Value::TypeRef(aliasRef, type()->createStaticRefType(aliasRef));
} else {
return Value::Alias(*this, std::move(templateArguments));
}
}
示例7: test_set_member
void test_set_member(Ardb& db)
{
DBID dbid = 0;
std::string str;
db.SClear(dbid, "myset");
db.SAdd(dbid, "myset", "v1");
db.SAdd(dbid, "myset", "v2");
db.SAdd(dbid, "myset", "v3");
CHECK_FATAL(db.SIsMember(dbid, "myset", "v0") != false,
"SIsMember myset failed:");
ValueArray members;
db.SMembers(dbid, "myset", members);
CHECK_FATAL( members.size() != 3, "SMembers myset failed:");
CHECK_FATAL( members[0].ToString(str) != "v1", "SMembers myset failed:");
}
示例8: getLength
virtual Size getLength() const override
{
return values.size();
}
示例9: TestMultiRW
TestMultiRW(const ValueArray &Values,
FnWriter pfnWriter,
FnReader pfnReader)
{
ProcessData(&*Values.begin(), Values.size(), pfnWriter, pfnReader);
}
示例10: Sort
int Ardb::Sort(const DBID& db, const Slice& key, const StringArray& args,
ValueArray& values)
{
SortOptions options;
if (parse_sort_options(options, args) < 0)
{
DEBUG_LOG("Failed to parse sort options.");
return ERR_INVALID_ARGS;
}
int type = Type(db, key);
ValueArray sortvals;
switch (type)
{
case LIST_META:
{
LRange(db, key, 0, -1, sortvals);
break;
}
case SET_ELEMENT:
{
SMembers(db, key, sortvals);
break;
}
case ZSET_ELEMENT_SCORE:
{
QueryOptions tmp;
ZRange(db, key, 0, -1, sortvals, tmp);
if(NULL == options.by)
{
options.nosort = true;
}
break;
}
default:
{
return ERR_INVALID_TYPE;
}
}
if (sortvals.empty())
{
return 0;
}
if (options.with_limit)
{
if (options.limit_offset < 0)
{
options.limit_offset = 0;
}
if ((uint32) options.limit_offset > sortvals.size())
{
values.clear();
return 0;
}
if (options.limit_count < 0)
{
options.limit_count = sortvals.size();
}
}
std::vector<SortValue> sortvec;
if (!options.nosort)
{
if (NULL != options.by)
{
sortvec.reserve(sortvals.size());
}
for (uint32 i = 0; i < sortvals.size(); i++)
{
if (NULL != options.by)
{
sortvec.push_back(SortValue(&sortvals[i]));
if (GetValueByPattern(db, options.by, sortvals[i],
sortvec[i].cmp) < 0)
{
DEBUG_LOG("Failed to get value by pattern:%s", options.by);
sortvec[i].cmp.Clear();
continue;
}
}
if (options.with_alpha)
{
if (NULL != options.by)
{
value_convert_to_raw(sortvec[i].cmp);
}
else
{
value_convert_to_raw(sortvals[i]);
}
}
else
{
if (NULL != options.by)
{
value_convert_to_number(sortvec[i].cmp);
}
else
{
value_convert_to_number(sortvals[i]);
//.........这里部分代码省略.........