list.h File Reference

#include "../shared/ufotypes.h"
Include dependency graph for list.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  linkedList_s

Typedefs

typedef struct linkedList_s linkedList_t

Functions

void LIST_AddString (linkedList_t **list, const char *data)
 Adds an string to a new or to an already existing linked list. The string is copied here.
void LIST_AddPointer (linkedList_t **listDest, void *data)
 Adds just a pointer to a new or to an already existing linked list.
linkedList_tLIST_Add (linkedList_t **list, const byte *data, size_t length)
 Adds an entry to a new or to an already existing linked list.
const linkedList_tLIST_ContainsString (const linkedList_t *list, const char *string)
 Searches for the first occurrence of a given string.
linkedList_tLIST_GetPointer (linkedList_t *list, const void *data)
 Searches for the first occurrence of a given string.
void LIST_Delete (linkedList_t **list)
void LIST_RemoveEntry (linkedList_t **list, linkedList_t *entry)
 Removes one entry from the linked list.
qboolean LIST_IsEmpty (const linkedList_t *list)
 Checks whether the given list is empty.
int LIST_Count (const linkedList_t *list)
void * LIST_GetByIdx (linkedList_t *list, int index)
 Get an entry of a linked list by its index in the list.
void * LIST_GetLast (linkedList_t *list)
 Returns the last entry in the linked list.
qboolean LIST_Remove (linkedList_t **list, const void *data)
void * LIST_GetNext (linkedList_t *list, void *lastData)
 Linked list iterator.

Typedef Documentation

typedef struct linkedList_s linkedList_t

Function Documentation

linkedList_t* LIST_Add ( linkedList_t **  listDest,
const byte data,
size_t  length 
)

Adds an entry to a new or to an already existing linked list.

See also:
LIST_AddString
LIST_RemoveEntry
Returns:
Returns a pointer to the data that has been added, wrapped in a linkedList_t
Todo:
Optimize this to not allocate memory for every entry - but use a hunk

Definition at line 22 of file list.c.

References byte, linkedList_s::data, Mem_PoolAlloc, and linkedList_s::next.

Referenced by AB_BuildBase(), AB_LoadXML(), AIR_Add(), CL_DisplayHomebasePopup(), CL_ParseCities(), Com_ParseItem(), CP_CreateNewMission(), CP_LoadMissionsXML(), CP_ParseCharacterData(), HUD_PopupFiremodeReservation(), testLinkedList(), US_LoadXML(), and US_StoreUFO().

void LIST_AddPointer ( linkedList_t **  listDest,
void *  data 
)

Adds just a pointer to a new or to an already existing linked list.

See also:
LIST_Add
LIST_RemoveEntry
Todo:
Optimize this to not allocate memory for every entry - but use a hunk

Definition at line 128 of file list.c.

References byte, linkedList_s::data, Mem_PoolAlloc, linkedList_s::next, linkedList_s::ptr, and qtrue.

Referenced by AIR_AddToAircraftTeam(), AIR_LoadAircraftXML(), B_BuildingAddToList(), CL_GetEventMail(), Com_ParseItem(), E_EmployeeList_f(), E_GetHiredEmployees(), HUD_PopupFiremodeReservation(), PR_UpdateProductionList(), and RS_ParseTechnologies().

void LIST_AddString ( linkedList_t **  listDest,
const char *  data 
)
const linkedList_t* LIST_ContainsString ( const linkedList_t list,
const char *  string 
)

Searches for the first occurrence of a given string.

Returns:
the linkedList_t pointer if the string is found, otherwise NULL
Note:
if string is NULL, the function returns NULL
See also:
LIST_AddString

Definition at line 58 of file list.c.

References linkedList_s::data, and linkedList_s::next.

Referenced by _AddToListBlock(), CP_MapIsSelectable(), GAME_MP_MapInfo(), MAP_PositionFitsTCPNTypes(), NAT_ScriptSanityCheck(), testLinkedList(), and UI_UpdateInvisOptions().

int LIST_Count ( const linkedList_t list  ) 
void LIST_Delete ( linkedList_t **  list  ) 
void* LIST_GetByIdx ( linkedList_t list,
int  index 
)

Get an entry of a linked list by its index in the list.

Parameters:
[in] list Linked list to get the entry from.
[in] index The index of the entry in the linked list.
Returns:
A void pointer of the content in the list-entry.

Definition at line 298 of file list.c.

References count, linkedList_s::data, i, LIST_Count(), and linkedList_s::next.

Referenced by CP_ChooseCity(), E_GetEmployeeByMenuIndex(), HUD_ShotReserve_f(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionType_f(), and testLinkedList().

void* LIST_GetLast ( linkedList_t list  ) 

Returns the last entry in the linked list.

Parameters:
[in] list Linked list to get the entry from.

Definition at line 280 of file list.c.

References linkedList_s::data, linkedList_s::next, and next.

void* LIST_GetNext ( linkedList_t list,
void *  lastData 
)

Linked list iterator.

Parameters:
list The linked list to iterate over
lastData The last data entry

Definition at line 219 of file list.c.

References linkedList_s::data, LIST_GetPointer(), LIST_IsEmpty(), and linkedList_s::next.

Referenced by AB_GetNext(), AIR_GetNextFromBase(), and US_GetNext().

linkedList_t* LIST_GetPointer ( linkedList_t list,
const void *  data 
)

Searches for the first occurrence of a given string.

Returns:
the linkedList_t pointer if the string is found, otherwise NULL
Note:
if data is NULL, the function returns NULL

Definition at line 77 of file list.c.

References linkedList_s::data, and linkedList_s::next.

Referenced by AIR_IsInAircraftTeam(), LIST_GetNext(), and LIST_Remove().

qboolean LIST_IsEmpty ( const linkedList_t list  ) 

Checks whether the given list is empty.

Parameters:
[in] list The linked list to check
Returns:
true if empty, false otherwise

Definition at line 255 of file list.c.

Referenced by LIST_GetNext().

qboolean LIST_Remove ( linkedList_t **  list,
const void *  data 
)
See also:
LIST_Add
LIST_RemoveEntry

Definition at line 242 of file list.c.

References LIST_GetPointer(), and LIST_RemoveEntry().

Referenced by AB_DestroyBase(), AIR_Delete(), and US_RemoveStoredUFO().

void LIST_RemoveEntry ( linkedList_t **  list,
linkedList_t entry 
)

Removes one entry from the linked list.

See also:
LIST_AddString
LIST_Add
LIST_AddPointer
LIST_Delete

Definition at line 163 of file list.c.

References linkedList_s::data, Mem_Free, linkedList_s::next, and linkedList_s::ptr.

Referenced by AIR_RemoveFromAircraftTeam(), CP_MissionRemove(), LIST_Remove(), and testLinkedList().


Generated by  doxygen 1.6.2