本文整理汇总了C++中FixedArray::getValues方法的典型用法代码示例。如果您正苦于以下问题:C++ FixedArray::getValues方法的具体用法?C++ FixedArray::getValues怎么用?C++ FixedArray::getValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FixedArray
的用法示例。
在下文中一共展示了FixedArray::getValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __py_pop
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__py_pop(PyObject* self, PyObject* args, PyObject* kwargs)
{
FixedArray* ary = static_cast<FixedArray*>(self);
std::vector<PyObject*>& values = ary->getValues();
if (values.empty())
{
PyErr_SetString(PyExc_IndexError, "FixedArray.pop: empty array");
return NULL;
}
PyObject* pyItem = PyTuple_GetItem(args, 0);
int index = PyLong_AsLong(pyItem);
if (index < 0) index += values.size();
if (uint32(index) >= values.size())
{
PyErr_SetString(PyExc_IndexError, "FixedArray.pop: index out of range");
return NULL;
}
PyObject* pyValue = values[index];
PyObject* pyTuple = PyTuple_New(0);
if (seq_ass_slice(self, index, index + 1, &*pyTuple) != 0)
return NULL;
Py_INCREF(pyValue);
return pyValue;
}
示例2: __py_reduce_ex__
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__py_reduce_ex__(PyObject* self, PyObject* protocol)
{
FixedArray* arr = static_cast<FixedArray*>(self);
PyObject* args = PyTuple_New(2);
PyObject* unpickleMethod = script::Pickler::getUnpickleFunc("FixedArray");
PyTuple_SET_ITEM(args, 0, unpickleMethod);
int len = arr->length();
PyObject* args1 = PyTuple_New(2);
PyObject* pyList = PyList_New(len);
if(len > 0)
{
std::vector<PyObject*>& values = arr->getValues();
for(int i=0; i<len; ++i)
{
Py_INCREF(values[i]);
PyList_SET_ITEM(pyList, i, values[i]);
}
}
PyTuple_SET_ITEM(args1, 0, PyLong_FromLongLong(arr->getDataType()->id()));
PyTuple_SET_ITEM(args1, 1, pyList);
PyTuple_SET_ITEM(args, 1, args1);
if(unpickleMethod == NULL){
Py_DECREF(args);
return NULL;
}
return args;
}