All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kzc_linked_list.h File Reference

Doubly-linked list. More...

Classes

struct  KzcLinkedListIterator
 Read-only iterator for LinkedList. More...
 
struct  KzcLinkedListMutableIterator
 Mutable iterator for LinkedList. More...
 

Macros

#define kzcLinkedListIterate(iterator_param)
 Finds the next entry in the attached linked list. More...
 
#define kzcLinkedListIteratorGetValue(iterator_param)
 Returns the value of the linked list entry pointed by the iterator. More...
 
#define kzcLinkedListMutableIterate(iterator_param)
 Finds the next entry in the attached linked list. More...
 
#define kzcLinkedListMutableIteratorGetValue(iterator_param)
 Returns the value of the linked list entry pointed by the iterator. More...
 
#define kzcLinkedListMutableIteratorRemove(iterator_param)
 Removes current entry of the linked list pointed by the iterator. More...
 

Functions

kzsError kzcLinkedListCreate (const struct KzcMemoryManager *memoryManager, struct KzcLinkedList **out_linkedList)
 Creates a new initially empty linked list. More...
 
kzsError kzcLinkedListDelete (struct KzcLinkedList *linkedList)
 Frees the memory allocated for the linked list. More...
 
kzsError kzcLinkedListAdd (struct KzcLinkedList *linkedList, void *element)
 Adds the specified element to the linked list. More...
 
kzsError kzcLinkedListAddToBeginning (struct KzcLinkedList *linkedList, void *element)
 Adds the specified element to the beginning of linked list. More...
 
kzsError kzcLinkedListAddAfter (struct KzcLinkedList *linkedList, const void *previousElement, void *element)
 Adds the specified element after specified previousElement to the linked list. More...
 
kzsError kzcLinkedListAddBefore (struct KzcLinkedList *linkedList, const void *nextElement, void *element)
 Adds the specified element before specified nextElement to the linked list. More...
 
kzsError kzcLinkedListRemove (struct KzcLinkedList *linkedList, const void *element)
 Removes the specified element from the linked list. More...
 
kzsError kzcLinkedListRemoveFirst (struct KzcLinkedList *linkedList)
 Removes the first element from the linked list. More...
 
kzsError kzcLinkedListRemoveLast (struct KzcLinkedList *linkedList)
 Removes the last element from the linked list. More...
 
kzUint kzcLinkedListGetSize (const struct KzcLinkedList *linkedList)
 Returns the number of elements in the linked list. More...
 
kzBool kzcLinkedListIsEmpty (const struct KzcLinkedList *linkedList)
 Checks if the linked list is empty or not. More...
 
kzsError kzcLinkedListGetFirst (const struct KzcLinkedList *linkedList, void **out_element)
 Returns the first element in the linked list. More...
 
kzsError kzcLinkedListGetLast (const struct KzcLinkedList *linkedList, void **out_element)
 Returns the last element in the linked list. More...
 
kzsError kzcLinkedListClear (struct KzcLinkedList *linkedList)
 Clears the linked list by removing all items from it. More...
 
struct KzcLinkedListIterator kzcLinkedListGetIterator (const struct KzcLinkedList *linkedList)
 Returns a first-to-last iterator for all elements in the linked list. More...
 
struct KzcLinkedListIterator kzcLinkedListGetReverseIterator (const struct KzcLinkedList *linkedList)
 Returns a last-to-first iterator for all elements in the linked list. More...
 
kzBool kzcLinkedListIterate_private (struct KzcLinkedListIterator *iterator)
 
void * kzcLinkedListIteratorGetValue_private (const struct KzcLinkedListIterator *iterator)
 
struct KzcLinkedListMutableIterator kzcLinkedListGetMutableIterator (struct KzcLinkedList *linkedList)
 Returns a mutable first-to-last iterator for all elements in the linked list. More...
 
struct KzcLinkedListMutableIterator kzcLinkedListGetReverseMutableIterator (struct KzcLinkedList *linkedList)
 Returns a mutable last-to-first iterator for all elements in the linked list. More...
 
kzBool kzcLinkedListMutableIterate_private (struct KzcLinkedListMutableIterator *iterator)
 
void * kzcLinkedListMutableIteratorGetValue_private (const struct KzcLinkedListMutableIterator *iterator)
 
kzsError kzcLinkedListMutableIteratorRemove_private (struct KzcLinkedListMutableIterator *iterator)
 

Detailed Description

Doubly-linked list.

For some operations such as remove and addAfter the target is located based on simple element address comparison.

Copyright 2008-2020 by Rightware. All rights reserved.

Macro Definition Documentation

#define kzcLinkedListIterate (   iterator_param)

Finds the next entry in the attached linked list.

Returns KZ_TRUE if next entry is found, otherwise KZ_FALSE.

#define kzcLinkedListIteratorGetValue (   iterator_param)

Returns the value of the linked list entry pointed by the iterator.

#define kzcLinkedListMutableIterate (   iterator_param)

Finds the next entry in the attached linked list.

Returns KZ_TRUE if next entry is found, otherwise KZ_FALSE.

#define kzcLinkedListMutableIteratorGetValue (   iterator_param)

Returns the value of the linked list entry pointed by the iterator.

#define kzcLinkedListMutableIteratorRemove (   iterator_param)

Removes current entry of the linked list pointed by the iterator.

Function Documentation

kzsError kzcLinkedListCreate ( const struct KzcMemoryManager memoryManager,
struct KzcLinkedList **  out_linkedList 
)

Creates a new initially empty linked list.

kzsError kzcLinkedListDelete ( struct KzcLinkedList linkedList)

Frees the memory allocated for the linked list.

kzsError kzcLinkedListAdd ( struct KzcLinkedList linkedList,
void *  element 
)

Adds the specified element to the linked list.

kzsError kzcLinkedListAddToBeginning ( struct KzcLinkedList linkedList,
void *  element 
)

Adds the specified element to the beginning of linked list.

kzsError kzcLinkedListAddAfter ( struct KzcLinkedList linkedList,
const void *  previousElement,
void *  element 
)

Adds the specified element after specified previousElement to the linked list.

kzsError kzcLinkedListAddBefore ( struct KzcLinkedList linkedList,
const void *  nextElement,
void *  element 
)

Adds the specified element before specified nextElement to the linked list.

kzsError kzcLinkedListRemove ( struct KzcLinkedList linkedList,
const void *  element 
)

Removes the specified element from the linked list.

Returns error if element is not found.

kzsError kzcLinkedListRemoveFirst ( struct KzcLinkedList linkedList)

Removes the first element from the linked list.

Returns error if the linked list is empty.

kzsError kzcLinkedListRemoveLast ( struct KzcLinkedList linkedList)

Removes the last element from the linked list.

Returns error if the linked list is empty.

kzUint kzcLinkedListGetSize ( const struct KzcLinkedList linkedList)

Returns the number of elements in the linked list.

kzBool kzcLinkedListIsEmpty ( const struct KzcLinkedList linkedList)

Checks if the linked list is empty or not.

kzsError kzcLinkedListGetFirst ( const struct KzcLinkedList linkedList,
void **  out_element 
)

Returns the first element in the linked list.

kzsError kzcLinkedListGetLast ( const struct KzcLinkedList linkedList,
void **  out_element 
)

Returns the last element in the linked list.

kzsError kzcLinkedListClear ( struct KzcLinkedList linkedList)

Clears the linked list by removing all items from it.

struct KzcLinkedListIterator kzcLinkedListGetIterator ( const struct KzcLinkedList linkedList)

Returns a first-to-last iterator for all elements in the linked list.

struct KzcLinkedListIterator kzcLinkedListGetReverseIterator ( const struct KzcLinkedList linkedList)

Returns a last-to-first iterator for all elements in the linked list.

kzBool kzcLinkedListIterate_private ( struct KzcLinkedListIterator iterator)
void* kzcLinkedListIteratorGetValue_private ( const struct KzcLinkedListIterator iterator)
struct KzcLinkedListMutableIterator kzcLinkedListGetMutableIterator ( struct KzcLinkedList linkedList)

Returns a mutable first-to-last iterator for all elements in the linked list.

struct KzcLinkedListMutableIterator kzcLinkedListGetReverseMutableIterator ( struct KzcLinkedList linkedList)

Returns a mutable last-to-first iterator for all elements in the linked list.

kzBool kzcLinkedListMutableIterate_private ( struct KzcLinkedListMutableIterator iterator)
void* kzcLinkedListMutableIteratorGetValue_private ( const struct KzcLinkedListMutableIterator iterator)
kzsError kzcLinkedListMutableIteratorRemove_private ( struct KzcLinkedListMutableIterator iterator)