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; }
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; }
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; }
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; }