示例#1
0
int Inventory::getFreeSlot() const
{
    Item **i = std::find_if(mItems, mItems + mSize,
                            std::not1(SlotUsed()));
    return (i == mItems + static_cast<int>(mSize)) ? -1
           : static_cast<int>(i - mItems);
}
示例#2
0
文件: inventory.cpp 项目: Ablu/mana
int Inventory::getLastUsedSlot() const
{
    for (int i = mSize - 1; i >= 0; i--)
        if (SlotUsed()(mItems[i]))
            return i;

    return -1;
}
示例#3
0
int Inventory::getFreeSlot() const
{
    Item *const *const i = std::find_if(mItems,
        mItems + mSize,
        std::not1(SlotUsed()));
    return (i == mItems + mSize) ? -1
        : CAST_S32(i - mItems);
}
示例#4
0
int Inventory::getNumberOfSlotsUsed() const
{
    return count_if(mItems, mItems + mSize, SlotUsed());
}