Mission Base

Program Base Library

pbliterator Implementation


Documentation

Open source C Iterator implementation equivalent to the Java ListIterator interface.

A pbIterator for pblLists that allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list. A ListIterator has no current element; its cursor position always lies between the element that would be returned by a call to previous() and the element that would be returned by a call to next(). In a list of length n, there are n+1 valid index values, from 0 to n, inclusive.

Note that the remove() and set(Object) methods are not defined in terms of the cursor position; they are defined to operate on the last element returned by a call to next() or previous().

The pblIterators are fail-fast: if the list is structurally modified at any time after the iterator is created, in any way except through the Iterator's own remove or add methods, the iterator will return a PBL_ERROR_CONCURRENT_MODIFICATION error.

Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.


Constructors and Destructors

  • pblIteratorNew Returns an iterator over the elements in this collection in proper sequence.
  • pblIteratorReverseNew Returns a reverse iterator over the elements in this collection in proper sequence.
  • pblIteratorFree Frees the memory used by the iterator.

    Functions

  • pblIteratorAdd Inserts the specified element into the underlying collection.
  • pblIteratorHasNext Returns true if this iterator has more elements.
  • pblIteratorHasPrevious Returns true if this iterator has more elements when traversing the collection in the reverse direction.
  • pblIteratorNext Returns the next element in the iteration.
  • pblIteratorNextIndex Returns the index of the element that would be returned by a subsequent call to next.
  • pblIteratorPrevious Returns the previous element in the iteration.
  • pblIteratorPreviousIndex Returns the index of the element that would be returned by a subsequent call to previous.
  • pblIteratorRemove Removes from the underlying list or tree set the last element returned by the iterator.
  • pblIteratorSet Replaces in the underlying list the last element returned by next or previous with the specified element.
  • pblIteratorSize Returns the number of elements in the underlying collection of the iterator.

    Alphabetic index


    GET PBL:


    Copyright(C) 2003 - 2015 Peter Graf, this software is distributed under the MIT License.
    This page was generated with the help of DOC++.