libtase2  2.4.0
TASE.2/ICCP Protocol Source Code Library for C/C++
Loading...
Searching...
No Matches
LinkedList data type definition and handling functions

Data Structures

struct  LinkedList
 Reference to a linked list or to a linked list element. More...
 

Typedefs

typedef void(* LinkedListValueDeleteFunction) (void *)
 

Functions

PUBLIC_API LinkedList LinkedList_create (void)
 Create a new LinkedList object.
 
PUBLIC_API void LinkedList_destroy (LinkedList self)
 Delete a LinkedList object.
 
PUBLIC_API void LinkedList_destroyDeep (LinkedList self, LinkedListValueDeleteFunction valueDeleteFunction)
 Delete a LinkedList object.
 
PUBLIC_API void LinkedList_destroyStatic (LinkedList self)
 Delete a LinkedList object without freeing the element data.
 
PUBLIC_API void LinkedList_add (LinkedList self, void *data)
 Add a new element to the list.
 
PUBLIC_API LinkedList LinkedList_append (LinkedList list, void *data)
 Append new element to the list and return new list element.
 
PUBLIC_API bool LinkedList_addEx (LinkedList list, void *data)
 Add a new element to the list and return success status.
 
PUBLIC_API bool LinkedList_contains (LinkedList self, void *data)
 Check if the specified data is contained in the list.
 
PUBLIC_API bool LinkedList_remove (LinkedList self, void *data)
 Removed the specified element from the list.
 
PUBLIC_API LinkedList LinkedList_get (LinkedList self, int index)
 Get the list element specified by index (starting with 0).
 
PUBLIC_API LinkedList LinkedList_getNext (LinkedList self)
 Get the next element in the list (iterator).
 
PUBLIC_API LinkedList LinkedList_getLastElement (LinkedList self)
 Get the last element in the list.
 
PUBLIC_API LinkedList LinkedList_insertAfter (LinkedList listElement, void *data)
 Insert a new element int the list.
 
PUBLIC_API int LinkedList_size (LinkedList self)
 Get the size of the list.
 
PUBLIC_API void * LinkedList_getData (LinkedList self)
 
PUBLIC_API void LinkedList_printStringList (LinkedList self)
 

Detailed Description

Typedef Documentation

◆ LinkedListValueDeleteFunction

typedef void(* LinkedListValueDeleteFunction) (void *)

Function Documentation

◆ LinkedList_add()

PUBLIC_API void LinkedList_add ( LinkedList self,
void * data )

Add a new element to the list.

This function will add a new data element to the list. The new element will the last element in the list.

Parameters
selfthe LinkedList instance
datadata to append to the LinkedList instance

◆ LinkedList_addEx()

PUBLIC_API bool LinkedList_addEx ( LinkedList list,
void * data )

Add a new element to the list and return success status.

This function will add a new data element to the list. The new element will the last element in the list.

Parameters
selfthe LinkedList instance
datadata to append to the LinkedList instance
Returns
true in case of success, false otherwise (out of memory)

◆ LinkedList_append()

PUBLIC_API LinkedList LinkedList_append ( LinkedList list,
void * data )

Append new element to the list and return new list element.

This function can be used to add consecutive elements more efficiently to the list.

◆ LinkedList_contains()

PUBLIC_API bool LinkedList_contains ( LinkedList self,
void * data )

Check if the specified data is contained in the list.

Parameters
selfthe LinkedList instance
datadata to remove from the LinkedList instance
Returns
true if data is part of the list, false otherwise

◆ LinkedList_create()

PUBLIC_API LinkedList LinkedList_create ( void )

Create a new LinkedList object.

Returns
the newly created LinkedList instance

◆ LinkedList_destroy()

PUBLIC_API void LinkedList_destroy ( LinkedList self)

Delete a LinkedList object.

This function destroy the LinkedList object. It will free all data structures used by the LinkedList instance. It will call free for all elements of the linked list. This function should only be used if simple objects (like dynamically allocated strings) are stored in the linked list.

Parameters
selfthe LinkedList instance

◆ LinkedList_destroyDeep()

PUBLIC_API void LinkedList_destroyDeep ( LinkedList self,
LinkedListValueDeleteFunction valueDeleteFunction )

Delete a LinkedList object.

This function destroy the LinkedList object. It will free all data structures used by the LinkedList instance. It will call a user provided function for each data element. This user provided function is responsible to properly free the data element.

Parameters
selfthe LinkedList instance
valueDeleteFunctiona function that is called for each data element of the LinkedList with the pointer to the linked list data element.

◆ LinkedList_destroyStatic()

PUBLIC_API void LinkedList_destroyStatic ( LinkedList self)

Delete a LinkedList object without freeing the element data.

This function should be used statically allocated data objects are stored in the LinkedList instance. Other use cases would be if the data elements in the list should not be deleted.

Parameters
selfthe LinkedList instance

◆ LinkedList_get()

PUBLIC_API LinkedList LinkedList_get ( LinkedList self,
int index )

Get the list element specified by index (starting with 0).

Parameters
selfthe LinkedList instance
indexindex of the requested element.

◆ LinkedList_getData()

PUBLIC_API void * LinkedList_getData ( LinkedList self)

◆ LinkedList_getLastElement()

PUBLIC_API LinkedList LinkedList_getLastElement ( LinkedList self)

Get the last element in the list.

Parameters
listElementthe LinkedList instance

◆ LinkedList_getNext()

PUBLIC_API LinkedList LinkedList_getNext ( LinkedList self)

Get the next element in the list (iterator).

Parameters
selfthe LinkedList instance

◆ LinkedList_insertAfter()

PUBLIC_API LinkedList LinkedList_insertAfter ( LinkedList listElement,
void * data )

Insert a new element int the list.

Parameters
listElementthe LinkedList instance

◆ LinkedList_printStringList()

PUBLIC_API void LinkedList_printStringList ( LinkedList self)

◆ LinkedList_remove()

PUBLIC_API bool LinkedList_remove ( LinkedList self,
void * data )

Removed the specified element from the list.

Parameters
selfthe LinkedList instance
datadata to remove from the LinkedList instance
Returns
true if data has been removed from the list, false otherwise

◆ LinkedList_size()

PUBLIC_API int LinkedList_size ( LinkedList self)

Get the size of the list.

Parameters
selfthe LinkedList instance
Returns
number of data elements stored in the list