本文整理汇总了C++中BList::IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ BList::IndexOf方法的具体用法?C++ BList::IndexOf怎么用?C++ BList::IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BList
的用法示例。
在下文中一共展示了BList::IndexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: curImage
// Function taken from Haiku ShowImage,
// function originally written by Michael Pfeiffer
bool
SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind)
{
// ASSERT(next || !rewind);
BEntry curImage(in_current);
entry_ref entry, *ref;
BDirectory parent;
BList entries;
bool found = false;
int32 cur;
if (curImage.GetParent(&parent) != B_OK)
return false;
while (parent.GetNextRef(&entry) == B_OK) {
if (entry != *in_current) {
entries.AddItem(new entry_ref(entry));
} else {
// insert current ref, so we can find it easily after sorting
entries.AddItem(in_current);
}
}
entries.SortItems(CompareEntries);
cur = entries.IndexOf(in_current);
// ASSERT(cur >= 0);
// remove it so FreeEntries() does not delete it
entries.RemoveItem(in_current);
if (next) {
// find the next image in the list
if (rewind) cur = 0; // start with first
for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) {
if (IsImage(ref)) {
found = true;
*out_image = (const entry_ref)*ref;
break;
}
}
} else {
// find the previous image in the list
cur --;
for (; cur >= 0; cur --) {
ref = (entry_ref*)entries.ItemAt(cur);
if (IsImage(ref)) {
found = true;
*out_image = (const entry_ref)*ref;
break;
}
}
}
FreeEntries(&entries);
return found;
}
示例2:
static void
_DoSwap(BList& list, int32 firstIndex, int32 secondIndex, BList* firstItems,
BList* secondItems)
{
BListItem* item = (BListItem*)list.ItemAt(firstIndex);
list.SwapItems(firstIndex, secondIndex);
list.RemoveItems(secondIndex + 1, secondItems->CountItems());
list.RemoveItems(firstIndex + 1, firstItems->CountItems());
list.AddList(secondItems, firstIndex + 1);
int32 newIndex = list.IndexOf(item);
if (newIndex + 1 < list.CountItems())
list.AddList(firstItems, newIndex + 1);
else
list.AddList(firstItems);
}