Previous topic

SIterator Structure

Next topic

SMap

SIteratorClass StructureΒΆ

speect class SIteratorClass

The iterator class structure.

All container iterators classes inherit from this class.

Protected Attributes
SObjectClass _inherit

Inherit from SObjectClass.

SIterator *(*const next)(SIterator *self, s_erc *error)

Next iterator function pointer.

Return an iterator to the next object of the container associated with the given iterator.

Parameters:
  • self

    The given iterator.

  • error

    Error code.

Return:

Iterator to the next object of the container. If there are no more objects in the container, then NULL must be returned so that SIteratorNext can delete the iterator.

Note:

If an error occurs then error must be set so that SIteratorNext can catch the error and delete the iterator.

const char *(*const key)(SIterator *self, s_erc *error)

Key iterator function pointer.

Return the key that is pointed to by the iterator. This is only useful for mapping type containers and does not need to be implemented by other types of containers.

Parameters:
  • self

    The given iterator.

  • error

    Error code.

Return:

The key pointed to by the iterator.

const SObject *(*const object)(SIterator *self, s_erc *error)

Object iterator function pointer.

Return the object that is pointed to by the iterator.

Parameters:
  • self

    The given iterator.

  • error

    Error code.

Return:

The object pointed to by the iterator. This object can be anything and depends on the specific container iterator implementation.

Unlink function pointer.

Unlink the object from the container, and return it.

Parameters:
  • self

    The given iterator.

  • error

    Error code.

Return:

The unlinked object pointed to by the iterator. This object can be anything and depends on the specific container iterator implementation.

Note:

The iterator is still valid, but does not point to any objects in the container.

The caller is responsible for the memory of the returned object.