libcomps ..
Loading...
Searching...
No Matches
comps_objlist.h File Reference

A Documented file. Details. More...

#include "comps_obj.h"
#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  COMPS_ObjListIt
 
struct  COMPS_ObjList
 

Functions

void comps_objlist_clear (COMPS_ObjList *objlist)
 
int comps_objlist_walk (COMPS_ObjListIt **walker, COMPS_Object **result)
 
int comps_objlist_walk_r (COMPS_ObjListIt *walker_start, COMPS_ObjListIt *mantinel, COMPS_Object **result)
 
int comps_objlist_append_x (COMPS_ObjList *objlist, COMPS_Object *obj)
 
int comps_objlist_append (COMPS_ObjList *objlist, COMPS_Object *obj)
 
COMPS_Objectcomps_objlist_get (COMPS_ObjList *objlist, unsigned int atpos)
 
int comps_objlist_set (COMPS_ObjList *objlist, unsigned int atpos, COMPS_Object *obj)
 
COMPS_Objectcomps_objlist_get_x (COMPS_ObjList *objlist, unsigned int atpos)
 
int comps_objlist_insert_at (COMPS_ObjList *objlist, unsigned int pos, COMPS_Object *obj)
 
int comps_objlist_remove_at (COMPS_ObjList *objlist, unsigned int atpos)
 
int comps_objlist_remove (COMPS_ObjList *objlist, COMPS_Object *obj)
 
COMPS_ObjListcomps_objlist_sublist_it (COMPS_ObjListIt *startit, COMPS_ObjListIt *end)
 
COMPS_ObjListcomps_objlist_filter (COMPS_ObjList *list, char(*filter_func)(COMPS_Object *))
 

Detailed Description

A Documented file. Details.

Function Documentation

◆ comps_objlist_append()

int comps_objlist_append ( COMPS_ObjList * objlist,
COMPS_Object * obj )

Append new object to list

This function increment object's reference counter

Parameters
objlistCOMPS_ObjList instance
objappended object

◆ comps_objlist_append_x()

int comps_objlist_append_x ( COMPS_ObjList * objlist,
COMPS_Object * obj )

Append new object to list

Does not incremented object's reference counter

Parameters
objlistCOMPS_ObjList instance
objappended object

◆ comps_objlist_clear()

void comps_objlist_clear ( COMPS_ObjList * objlist)

Clear the list Remove all items from list and call destructor on each one

Parameters
objlistCOMPS_ObjList object

◆ comps_objlist_filter()

COMPS_ObjList * comps_objlist_filter ( COMPS_ObjList * list,
char(* filter_func )(COMPS_Object *) )

Returns new sublist from original list

Returns new sublist from original list, with items passed through filter

Parameters
listCOMPS_ObjList instance
filter_funcfilter callback
Returns
new sublist

◆ comps_objlist_get()

COMPS_Object * comps_objlist_get ( COMPS_ObjList * objlist,
unsigned int atpos )

Return item's object at specified position

Returned object has incremented reference counter

Parameters
objlistCOMPS_ObjList object
atpositem's position
Returns
if list has enough items, return item's object, otherwise NULL

◆ comps_objlist_get_x()

COMPS_Object * comps_objlist_get_x ( COMPS_ObjList * objlist,
unsigned int atpos )

Return item's object at specified position

Returned object HASN'T incremented reference count

Parameters
objlistCOMPS_ObjList object
atpositem's position
Returns
if list has enough items, return item's object, otherwise NULL

◆ comps_objlist_insert_at()

int comps_objlist_insert_at ( COMPS_ObjList * objlist,
unsigned int pos,
COMPS_Object * obj )

Insert item at specified position

If list doesn't have enough items (specified position is greater then items count, even if position is greater only by 1) fails and returns 0

Parameters
objlistCOMPS_ObjList object
positem's position
objinserted object
Returns
non-zero if success, zero otherwise

◆ comps_objlist_remove()

int comps_objlist_remove ( COMPS_ObjList * objlist,
COMPS_Object * obj )

Remove item with specified object from list

Remove first matching items with object pointer eqaul specifed object pointer.

Parameters
objlistCOMPS_ObjList object
objremoved object
Returns
non-zero if success, zero otherwise

◆ comps_objlist_remove_at()

int comps_objlist_remove_at ( COMPS_ObjList * objlist,
unsigned int atpos )

Remove item on specified position from list

If list doesn't have enough items fails. On succes decrements item object's reference counter and remove item from list

Parameters
objlistCOMPS_ObjList object
atpositem's position
Returns
non-zero if success, zero otherwise

◆ comps_objlist_set()

int comps_objlist_set ( COMPS_ObjList * objlist,
unsigned int atpos,
COMPS_Object * obj )

Set item's object at specified positoin

set new item to specified position, increment new item's reference counter and destroy old item (decrement reference counter). If list hasn't enough items, returns 0.

Parameters
objlistCOMPS_ObjList object
atpositem's position @parma obj new object
Returns
non-zero on success, otherwise returns zero

◆ comps_objlist_sublist_it()

COMPS_ObjList * comps_objlist_sublist_it ( COMPS_ObjListIt * startit,
COMPS_ObjListIt * end )

Returns new sublist from original list

Returns new sublist from original list, starting item startit and ending item end

Parameters
startitstart item iterator
endend item iterator
listCOMPS_ObjList instance
Returns
new sublist

◆ comps_objlist_walk()

int comps_objlist_walk ( COMPS_ObjListIt ** walker,
COMPS_Object ** result )

Traverse the list

Start traversing list from walker position to end of list. Each call store actual item object to result parameter and move walker iterator forward

Parameters
walkerIterator position in list
resultobject of actual item
returnnon-zero if walker hasn't reached end, otherwise zero

◆ comps_objlist_walk_r()

int comps_objlist_walk_r ( COMPS_ObjListIt * walker_start,
COMPS_ObjListIt * mantinel,
COMPS_Object ** result )

Traverse the list with sentinel iterator

Same as comps_objlist_walk with additional sentinel iterator supplying end of list.

Parameters
walkerIterator position in list
resultobject of actual item
returnnon-zero if walker hasn't reached end, otherwise zero