本文整理汇总了C++中FixedArray::findFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ FixedArray::findFrom方法的具体用法?C++ FixedArray::findFrom怎么用?C++ FixedArray::findFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FixedArray
的用法示例。
在下文中一共展示了FixedArray::findFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __py_count
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__py_count(PyObject* self, PyObject* args, PyObject* kwargs)
{
FixedArray* ary = static_cast<FixedArray*>(self);
PyObject* pyItem = PyTuple_GetItem(args, 0);
int count = 0, cur;
for (uint32 i = 0; (cur = ary->findFrom(i, &*pyItem)) >= 0; i = cur + 1)
++count;
return PyLong_FromLong(count);
}
示例2: __py_index
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__py_index(PyObject* self, PyObject* args, PyObject* kwargs)
{
FixedArray* ary = static_cast<FixedArray*>(self);
PyObject* pyItem = PyTuple_GetItem(args, 0);
int index = ary->findFrom(0, &*pyItem);
if (index == -1)
{
PyErr_SetString(PyExc_ValueError, "FixedArray::index: value not found");
return NULL;
}
return PyLong_FromLong(index);
}
示例3: __py_remove
//-------------------------------------------------------------------------------------
PyObject* FixedArray::__py_remove(PyObject* self, PyObject* args, PyObject* kwargs)
{
FixedArray* ary = static_cast<FixedArray*>(self);
PyObject* pyItem = PyTuple_GetItem(args, 0);
int index = ary->findFrom(0, &*pyItem);
if (index == -1)
{
PyErr_SetString(PyExc_ValueError, "FixedArray.remove: value not found");
return PyLong_FromLong(-1);
}
PyObject* pyTuple = PyTuple_New(0);
return PyBool_FromLong(seq_ass_slice(self, index, index + 1, &*pyTuple) == 0);
}