ListEntry

01
typedef	struct tagListEntry
{
  struct tagListEntry *mpPrev;
  struct tagListEntry *mpNext;
} ListEntry;
02 Members:
  • mpPrev: Pointing to the previous ListEntry.
  • mpNext: Pointing to the next ListEntry.
03 The constant C_SEMYS_LIST_NULL initializes this structure to zero values.
04 ListEntry acts as the link for an item within the list, as entry point for the list itself and as an iterator.
05 There is no type safety. The user has to take care about what is inserted into and retrieved from the list.

List entry point

06 The entry point of a list itself is the start and the end of the list. mpNext refers to the first item of the list, mpPrev to the last item. If the list is empty, both member point to the entry point itself.
07 A new list has to be initialized by the function ListInit().

List item

08 A structure that is to be inserted into a list needs ListEntry as its first member. Such a structure can be in one (main) list at a time. For further list membership, SemysAnyReference is needed.

Example

09
struct tagTest
{
  ListEntry mListEntry;

  uint32 mMember1;
} Test;

ListEntry list = C_SEMYS_LIST_NULL, *le = 0;
Test test1, test2;

/* List initialization */
ListInit(&list);

/* Insert items */
ListPushBack(&list, &test1.mListEntry);
ListPushBack(&list, &test2.mListEntry);

/* Iterate (forward) through list */
le = list.mpNext;
while (le != &list)
{
  Test *pTest = (Test *)ListGetNext(&le);

  /* Remove entry */
  ListRemoveEntry(&pTest->mListEntry);
}
10 Reference: SemysList.h
Implementation: Semys Library
See Also: List Sub-System, SemysAnyReference, ListInit()

Goto: Main Page; This page is part of the Semys software documentation. See About: Documentation for details.