libgpac
Documentation of the core library of GPAC
Generic List object

List object. More...

+ Collaboration diagram for Generic List object:

Typedefs

typedef struct _tag_array GF_List
 

Functions

GF_Listgf_list_new ()
 list constructor More...
 
void gf_list_del (GF_List *ptr)
 list destructor More...
 
u32 gf_list_count (const GF_List *ptr)
 get count More...
 
GF_Err gf_list_add (GF_List *ptr, void *item)
 add item More...
 
GF_Err gf_list_insert (GF_List *ptr, void *item, u32 position)
 inserts item More...
 
GF_Err gf_list_rem (GF_List *ptr, u32 position)
 removes item More...
 
void * gf_list_get (GF_List *ptr, u32 position)
 gets item More...
 
s32 gf_list_find (GF_List *ptr, void *item)
 finds item More...
 
s32 gf_list_del_item (GF_List *ptr, void *item)
 deletes item More...
 
void gf_list_reset (GF_List *ptr)
 resets list More...
 
void * gf_list_last (GF_List *ptr)
 gets last item More...
 
GF_Err gf_list_rem_last (GF_List *ptr)
 removes last item More...
 
void * gf_list_enum (GF_List *ptr, u32 *pos)
 list enumerator More...
 
GF_Err gf_list_swap (GF_List *l1, GF_List *l2)
 list swap More...
 
GF_Err gf_list_transfer (GF_List *dst, GF_List *src)
 list transfer More...
 
GF_Listgf_list_clone (GF_List *ptr)
 clone list More...
 
void * gf_list_pop_front (GF_List *ptr)
 Pop the first element in the list. More...
 
void * gf_list_pop_back (GF_List *ptr)
 Pop the last element in the list. More...
 

Detailed Description

This section documents the list object of the GPAC framework.

Typedef Documentation

◆ GF_List

typedef struct _tag_array GF_List

list object

Function Documentation

◆ gf_list_new()

GF_List* gf_list_new ( )

Constructs a new list object

Returns
new list object

◆ gf_list_del()

void gf_list_del ( GF_List ptr)

Destructs a list object

Parameters
ptrlist object to destruct
Note
It is the caller responsibility to destroy the content of the list if needed

◆ gf_list_count()

u32 gf_list_count ( const GF_List ptr)

Returns number of items in the list

Parameters
ptrtarget list object
Returns
number of items in the list

◆ gf_list_add()

GF_Err gf_list_add ( GF_List ptr,
void *  item 
)

Adds an item at the end of the list

Parameters
ptrtarget list object
itemitem to add
Returns
error if any

◆ gf_list_insert()

GF_Err gf_list_insert ( GF_List ptr,
void *  item,
u32  position 
)

Insert an item in the list

Parameters
ptrtarget list object
itemitem to add
positioninsertion position. It is expressed between 0 and gf_list_count-1, and any bigger value is equivalent to gf_list_add
Returns
error if any

◆ gf_list_rem()

GF_Err gf_list_rem ( GF_List ptr,
u32  position 
)

Removes an item from the list given its position

Parameters
ptrtarget list object
positionposition of the item to remove. It is expressed between 0 and gf_list_count-1.
Returns
error if any
Note
It is the caller responsibility to destroy the content of the list if needed

◆ gf_list_get()

void* gf_list_get ( GF_List ptr,
u32  position 
)

Gets an item from the list given its position

Parameters
ptrtarget list object
positionposition of the item to get. It is expressed between 0 and gf_list_count-1.
Returns
the item or NULL if not found

◆ gf_list_find()

s32 gf_list_find ( GF_List ptr,
void *  item 
)

Finds an item in the list

Parameters
ptrtarget list object.
itemthe item to find.
Returns
0-based item position in the list, or -1 if the item could not be found.

◆ gf_list_del_item()

s32 gf_list_del_item ( GF_List ptr,
void *  item 
)

Deletes an item from the list

Parameters
ptrtarget list object.
itemthe item to find.
Returns
0-based item position in the list before removal, or -1 if the item could not be found.

◆ gf_list_reset()

void gf_list_reset ( GF_List ptr)

Resets the content of the list

Parameters
ptrtarget list object.
Note
It is the caller responsibility to destroy the content of the list if needed

◆ gf_list_last()

void* gf_list_last ( GF_List ptr)

Gets last item o fthe list

Parameters
ptrtarget list object
Returns
the last item

◆ gf_list_rem_last()

GF_Err gf_list_rem_last ( GF_List ptr)

Removes the last item of the list

Parameters
ptrtarget list object
Returns
error if any
Note
It is the caller responsibility to destroy the content of the list if needed

◆ gf_list_enum()

void* gf_list_enum ( GF_List ptr,
u32 pos 
)

Retrieves given list item and increment current position

Parameters
ptrtarget list object
postarget item position. The position is automatically incremented regardless of the return value
Note
A typical enumeration will start with a value of 0 until NULL is returned.
Returns
the current item for the given index

◆ gf_list_swap()

GF_Err gf_list_swap ( GF_List l1,
GF_List l2 
)

Swaps content of two lists

Parameters
l1first list object
l2second list object
Returns
error if any

◆ gf_list_transfer()

GF_Err gf_list_transfer ( GF_List dst,
GF_List src 
)

Transfer content between lists

Parameters
dstdestination list object
srcsource list object
Returns
error if any

◆ gf_list_clone()

GF_List* gf_list_clone ( GF_List ptr)

Returns a new list as an exact copy of the given list

Parameters
ptrthe list to clone
Returns
the cloned list

◆ gf_list_pop_front()

void* gf_list_pop_front ( GF_List ptr)

Removes the first element in the list container, effectively reducing its size by one and returns the popped element.

Parameters
ptrthe list to pop
Returns
the popped element

◆ gf_list_pop_back()

void* gf_list_pop_back ( GF_List ptr)

Removes the last element in the list container, effectively reducing the container size by one and return the popped element.

Parameters
ptrthe list to pop
Returns
the popped element