Table Of Contents

Previous topic

SMapClass Structure

Next topic

SList Details

SList

SList containers are data types that holds an ordered collection of values (SObject) , where the same value may occur more than once. There is currently one implementation of the SList container.

The iterator (SIterator) implementation returns the elements (as SObject) of the list for the SIteratorObject(), and SIteratorUnlink() function calls. The SIteratorKey() method is not implemented and will set an error and return NULL if called for SList type iterators.

Also see SList Iteration Example.

Definitions

speect object SList

Inheritance diagram of SObject.SContainer.SList

A list class.

An abstract data structure that implements an ordered collection of values (of type SObject), where the same value may occur more than once.

SList Details

speect object SListClass

Inheritance diagram of SObjectClass.SContainerClass.SListClass

The list class structure.

It inherits from SContainer so that it supports different list implementations.

SList Details.

Functions

Query

s_bool SListIsEmpty(const SList *self, s_erc *error)

Test to see if the given list is empty.

Parameters:
  • self

    The list container.

  • error

    Error code.

Return:

TRUE if empty else, FALSE.

size_t SListSize(const SList *self, s_erc *error)

Return the number of SObject in the list.

Parameters:
  • self

    The list container.

  • error

    Error code.

Return:

The number of SObject objects in the list.

s_bool SListValPresent(const SList *self, const SObject *object, s_erc *error)

Test if the given SObject in the list.

Parameters:
  • self

    The list container.

  • object

    The SObject to test for.

  • error

    Error code.

Return:

TRUE or FALSE.

Note:

The SObjectClass function pointer compare must be implemented for the given object type.

Insertion

void SListAppend(SList *self, const SObject *object, s_erc *error)

Append an SObject to end of list.

Parameters:
  • self

    The list container.

  • object

    SObject to append to end of list.

  • error

    Error code.

Note:

The list takes hold of the appended object, and therefore the object should not be deleted with a call to S_DELETE.

void SListPrepend(SList *self, const SObject *object, s_erc *error)

Prepend SObject to beginning of list.

Parameters:
  • self

    The list container.

  • object

    SObject to prepend to beginning of list.

  • error

    Error code.

Note:

The list takes hold of the prepended object, and therefore the object should not be deleted with a call to S_DELETE.

void SListInsertBefore(SList *self, SIterator *itr, const SObject *object, s_erc *error)

Insert an SObject before the one currently pointed to by the iterator.

Parameters:
  • self

    The list container.

  • itr

    Iterator to current list object.

  • object

    SObject to insert.

  • error

    Error code.

Note:

The list takes hold of the inserted object, and therefore the object should not be deleted with a call to S_DELETE.

void SListInsertAfter(SList *self, SIterator *itr, const SObject *object, s_erc *error)

Insert SObject after the one currently pointed to by the iterator.

Parameters:
  • self

    The list container.

  • itr

    Iterator to current list object.

  • object

    SObject to insert.

  • error

    Error code.

Note:

The list takes hold of the inserted object, and therefore the object should not be deleted with a call to S_DELETE.

Merge/Copy

void SListMerge(SList *self, const SList *with, s_erc *error)

Merge two lists.

Append all the SObject of one list onto another list. For example:

 self = (12, "a", 0.9644)
 with = (5.31, "a")

 SListMerge(self, with, error);

 self = (12, "a", 0.9644, 5.31, "a")
 with = (5.31, "a")

Parameters:
  • self

    The list container that with is merged with.

  • with

    The list to merge with self.

  • error

    Error code.

SList *SListCopy(SList *dst, const SList *src, s_erc *error)

Copy (shallow) the list objects from src to dst.

If dst does not exist a new one will be created.

Parameters:
  • dst

    Pointer to destination list. If NULL then a new list will be created.

  • src

    Pointer to source list.

  • error

    Error code.

Return:

Pointer to destination list.

Queue

void SListPush(SList *self, const SObject *object, s_erc *error)

Push SObject into end of list.

Parameters:
  • self

    The list container.

  • object

    SObject to push into end of list.

  • error

    Error code.

Note:

The list takes hold of the pushed object, and therefore the object should not be deleted with a call to S_DELETE.

SObject *SListPop(SList *self, s_erc *error)

Pop SObject from end of SList.

Parameters:
  • self

    The list container.

  • error

    Error code.

Return:

SObject popped from end of list.

Note:

The SObject is unlinked from the list and it’s memory is the responsibility of the caller.

void SListReverse(SList *self, s_erc *error)

Reverse the order of the elements in the list in place.

Parameters:
  • self

    The list container to reverse.

  • error

    Error code.

Accessing

const SObject *SListNth(const SList *self, uint32 n, s_erc *error)

Return a pointer to the nth SObject in the list.

Parameters:
  • self

    The list container.

  • n

    Index of the SObject.

Parameters:
  • error

    Error code.

Note:

Indexing starts at 0.

Return:

SObject object at index n.

Implementations

SListList

SListList is an implementation of SList, where the underlying data structure is a doubly-linked list.

speect object SListList

Inheritance diagram of SObject.SContainer.SList.SListList

The SListList structure.

Inherits and implements SList as a doubly linked list.