本文整理汇总了C++中ListPtr::getItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ListPtr::getItem方法的具体用法?C++ ListPtr::getItem怎么用?C++ ListPtr::getItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListPtr
的用法示例。
在下文中一共展示了ListPtr::getItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sortList
void MultiList::sortList()
{
if (ITEM_NONE == mSortColumnIndex) return;
ListPtr list = mVectorColumnInfo[mSortColumnIndex].list;
size_t count = list->getItemCount();
if (0 == count) return;
VectorSizeT vec;
size_t size = mToSortIndex.size();
vec.resize(size);
for (size_t pos=0; pos<size; ++pos) vec[mToSortIndex[pos]] = pos;
struct Keeper
{
inline void keep(VectorSizeT & vec, VectorSizeT & vec2, VectorColumnInfo & info, size_t _index)
{
text.resize(info.size());
std::vector<Ogre::UTFString>::iterator itext = text.begin();
for (VectorColumnInfo::iterator iter=info.begin(); iter!=info.end(); ++iter, ++itext) {
(*itext) = (*iter).list->getItem(_index);
}
index1 = _index;
index2 = vec2[_index];
}
inline void restore(VectorSizeT & vec, VectorSizeT & vec2, VectorColumnInfo & info, size_t _index)
{
std::vector<Ogre::UTFString>::iterator itext = text.begin();
for (VectorColumnInfo::iterator iter=info.begin(); iter!=info.end(); ++iter, ++itext) {
(*iter).list->setItem(_index, *itext);
}
vec[vec2[_index]] = index1;
vec2[_index] = index2;
}
inline void swap(VectorSizeT & vec, VectorSizeT & vec2, VectorColumnInfo & info, size_t _index1, size_t _index2)
{
for (VectorColumnInfo::iterator iter=info.begin(); iter!=info.end(); ++iter) {
(*iter).list->setItem(_index1, (*iter).list->getItem(_index2));
}
vec[vec2[_index1]] = _index2;
vec2[_index1] = vec2[_index2];
}
std::vector<Ogre::UTFString> text;
size_t index1, index2;
};
Keeper keeper;
int step = (int)count/2;
if (mSortUp) {
for( ; step>0 ; ) {
for( size_t i=0; i<(count-step); ++i ) {
int j = (int)i;
while ( (j>=0) && (list->getItem(j) > list->getItem(j+step)) ){
keeper.keep(mToSortIndex, vec, mVectorColumnInfo, j);
keeper.swap(mToSortIndex, vec, mVectorColumnInfo, j, j+step);
keeper.restore(mToSortIndex, vec, mVectorColumnInfo, j+step);
--j;
}
}
step >>= 1;
}
}
else {
for( ; step>0 ; ) {