本文整理汇总了C++中CArrRef::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ CArrRef::empty方法的具体用法?C++ CArrRef::empty怎么用?C++ CArrRef::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArrRef
的用法示例。
在下文中一共展示了CArrRef::empty方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f_max
Variant f_max(int _argc, CVarRef value, CArrRef _argv /* = null_array */) {
Variant ret;
if (_argv.empty() && value.is(KindOfArray)) {
Array v = value.toArray();
if (!v.empty()) {
ssize_t pos = v->iter_begin();
if (pos != ArrayData::invalid_index) {
ret = v->getValue(pos);
while (true) {
pos = v->iter_advance(pos);
if (pos == ArrayData::invalid_index) break;
Variant tmp = v->getValue(pos);
if (more(tmp, ret)) {
ret = tmp;
}
}
}
}
} else {
ret = value;
if (!_argv.empty()) {
for (ssize_t pos = _argv->iter_begin(); pos != ArrayData::invalid_index;
pos = _argv->iter_advance(pos)) {
Variant tmp = _argv->getValue(pos);
if (more(tmp, ret)) {
ret = tmp;
}
}
}
}
return ret;
}
示例2: f_spl_autoload_functions
Variant f_spl_autoload_functions() {
CArrRef handlers = AutoloadHandler::s_instance->getHandlers();
if (handlers.empty())
return false;
else
return handlers.values();
}
示例3: MultiSort
bool Array::MultiSort(std::vector<SortData> &data, bool renumber) {
ASSERT(!data.empty());
int count = -1;
for (unsigned int k = 0; k < data.size(); k++) {
SortData &opaque = data[k];
ASSERT(opaque.array);
ASSERT(opaque.cmp_func);
int size = opaque.array->size();
if (count == -1) {
count = size;
} else if (count != size) {
throw_invalid_argument("arrays: (inconsistent sizes)");
return false;
}
opaque.positions.reserve(size);
CArrRef arr = *opaque.array;
if (!arr.empty()) {
for (ssize_t pos = arr->iter_begin(); pos != ArrayData::invalid_index;
pos = arr->iter_advance(pos)) {
opaque.positions.push_back(pos);
}
}
}
if (count == 0) {
return true;
}
int *indices = (int *)malloc(sizeof(int) * count);
for (int i = 0; i < count; i++) {
indices[i] = i;
}
zend_qsort(indices, count, sizeof(int), multi_compare_func, (void *)&data);
for (unsigned int k = 0; k < data.size(); k++) {
SortData &opaque = data[k];
CArrRef arr = *opaque.array;
Array sorted;
for (int i = 0; i < count; i++) {
ssize_t pos = opaque.positions[indices[i]];
Variant k(arr->getKey(pos));
if (renumber && k.isInteger()) {
sorted.append(arr->getValueRef(pos));
} else {
sorted.set(k, arr->getValueRef(pos));
}
}
*opaque.original = sorted;
}
free(indices);
return true;
}
示例4: func_get_args
Array func_get_args(int num_args, CArrRef params, CArrRef args) {
if (params.empty() && args.empty()) return Array::Create();
if (args.empty()) {
if (num_args < params.size()) {
return params.slice(0, num_args, false);
}
return params;
}
Array derefArgs;
for (ArrayIter iter(args); iter; ++iter) {
derefArgs.append(iter.second());
}
if (params.empty()) return derefArgs;
assert(num_args > params.size());
Array ret = Array(params).merge(derefArgs);
return ret;
}
示例5: f_array_unshift
int64_t f_array_unshift(int _argc, VRefParam array, CVarRef var, CArrRef _argv /* = null_array */) {
if (array.toArray()->isVectorData()) {
if (!_argv.empty()) {
for (ssize_t pos = _argv->iter_end(); pos != ArrayData::invalid_index;
pos = _argv->iter_rewind(pos)) {
array.prepend(_argv->getValueRef(pos));
}
}
array.prepend(var);
} else {
{
Array newArray;
newArray.append(var);
if (!_argv.empty()) {
for (ssize_t pos = _argv->iter_begin();
pos != ArrayData::invalid_index;
pos = _argv->iter_advance(pos)) {
newArray.append(_argv->getValueRef(pos));
}
}
for (ArrayIter iter(array); iter; ++iter) {
Variant key(iter.first());
CVarRef value(iter.secondRef());
if (key.isInteger()) {
newArray.appendWithRef(value);
} else {
newArray.lvalAt(key, AccessFlags::Key).setWithRef(value);
}
}
array = newArray;
}
// Reset the array's internal pointer
if (array.is(KindOfArray)) {
array.array_iter_reset();
}
}
return array.toArray().size();
}
示例6: Combine
Array ArrayUtil::Combine(CArrRef keys, CArrRef values) {
if (keys.size() != values.size()) {
throw InvalidArgumentException("keys and values", "(not same count)");
}
if (keys.empty()) {
throw InvalidArgumentException("keys and values", "(empty)");
}
Array ret = Array::Create();
for (ArrayIter iter1(keys), iter2(values); iter1; ++iter1, ++iter2) {
ret.set(iter1.second(), iter2.second());
}
return ret;
}
示例7: Reverse
Variant ArrayUtil::Reverse(CArrRef input, bool preserve_keys /* = false */) {
if (input.empty()) {
return input;
}
Array ret = Array::Create();
for (ssize_t pos = input->iter_end(); pos != ArrayData::invalid_index;
pos = input->iter_rewind(pos)) {
Variant key(input->getKey(pos));
if (preserve_keys || key.isString()) {
ret.setWithRef(key, input->getValueRef(pos), true);
} else {
ret.appendWithRef(input->getValueRef(pos));
}
}
return ret;
}
示例8: f_sscanf
Variant f_sscanf(int _argc, CStrRef str, CStrRef format, CArrRef _argv /* = null_array */) {
Variant ret;
int result;
result = string_sscanf(str, format, _argv.size(), ret);
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) return null;
if (_argv.empty()) return ret;
if (ret.isArray()) {
Array retArray = ret.toArray();
for (int i = 0; i < retArray.size(); i++) {
((Array&)_argv).lvalAt(i) = retArray[i];
}
return retArray.size();
}
if (ret.isNull()) return 0;
return ret;
}
示例9: Combine
Variant ArrayUtil::Combine(CArrRef keys, CArrRef values) {
if (keys.size() != values.size()) {
throw_invalid_argument("keys and values not same count");
return false;
}
if (keys.empty()) {
throw_invalid_argument("keys and values empty");
return false;
}
Array ret = Array::Create();
for (ArrayIter iter1(keys), iter2(values); iter1; ++iter1, ++iter2) {
CVarRef v(iter2.secondRef());
ret.lvalAt(iter1.secondRef()).setWithRef(v);
}
return ret;
}
示例10: Reduce
Variant ArrayUtil::Reduce(CArrRef input, PFUNC_REDUCE reduce_function,
const void *data, CVarRef initial /* = null_variant */) {
if (input.empty()) {
return initial;
}
ArrayIter iter(input);
Variant result;
if (initial.isNull()) {
result = iter.second();
} else {
result = initial;
}
for (++iter; iter; ++iter) {
result = reduce_function(result, iter.second(), data);
}
return result;
}
示例11: f_array_map
Variant f_array_map(int _argc, CVarRef callback, CVarRef arr1, CArrRef _argv /* = null_array */) {
Array inputs;
if (!arr1.isArray()) {
throw_bad_array_exception();
return uninit_null();
}
inputs.append(arr1);
if (!_argv.empty()) {
inputs = inputs.merge(_argv);
}
CallCtx ctx;
ctx.func = NULL;
if (!callback.isNull()) {
EagerCallerFrame cf;
vm_decode_function(callback, cf(), false, ctx);
}
if (ctx.func == NULL) {
return ArrayUtil::Map(inputs, map_func, NULL);
}
return ArrayUtil::Map(inputs, map_func, &ctx);
}