Beispiel #1
0
void *ListIteratorData(const ListIterator *iterator)
{
    if (!iterator)
    {
        return NULL;
    }
    if (IsIteratorValid(iterator))
    {
        // The list has moved forward, the iterator is invalid now
        return NULL;
    }
    return iterator->current->payload;
}
Beispiel #2
0
int ListIteratorLast(ListIterator *iterator)
{
    if (!iterator)
    {
        return -1;
    }
    if (IsIteratorValid(iterator))
    {
        // The list has moved forward, the iterator is invalid now
        return -1;
    }
    iterator->current = iterator->origin->last;
    return 0;
}
Beispiel #3
0
bool ListIteratorHasPrevious(const ListIterator *iterator)
{
    if (!iterator)
    {
        return false;
    }
    if (IsIteratorValid(iterator))
    {
        // The list has moved forward, the iterator is invalid now
        return false;
    }
    if (iterator->current->previous)
    {
        return true;
    }
    return false;
}
Beispiel #4
0
int ListIteratorPrevious(ListIterator *iterator)
{
    if (!iterator)
    {
        return -1;
    }
    if (IsIteratorValid(iterator))
    {
        // The list has moved forward, the iterator is invalid now
        return -1;
    }
    // Ok, check if we are at the end
    if (iterator->current && iterator->current->previous)
    {
        iterator->current = iterator->current->previous;
    }
    else
    {
        return -1;
    }
    return 0;
}