libcomps: /build/libcomps/src/libcomps-0.1.19/libcomps/src/comps_objlist.h File Reference

libcomps ..

Data Structures | Functions
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_Object * | comps_objlist_get (COMPS_ObjList *objlist, unsigned int atpos)
int | comps_objlist_set (COMPS_ObjList *objlist, unsigned int atpos, COMPS_Object *obj)
COMPS_Object * | comps_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_ObjList * | comps_objlist_sublist_it (COMPS_ObjListIt *startit, COMPS_ObjListIt *end)
COMPS_ObjList * | comps_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

  objlist | COMPS_ObjList instance
  obj | appended 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

  objlist | COMPS_ObjList instance
  obj | appended 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

  objlist | COMPS_ObjList object

## ◆ comps_objlist_filter()

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

Returns new sublist from original list

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

Parameters

  list | COMPS_ObjList instance
  filter_func | filter 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

  objlist | COMPS_ObjList object
  atpos | item'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

  objlist | COMPS_ObjList object
  atpos | item'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

  objlist | COMPS_ObjList object
  pos | item's position
  obj | inserted 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

  objlist | COMPS_ObjList object
  obj | removed 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

  objlist | COMPS_ObjList object
  atpos | item'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

  objlist | COMPS_ObjList object
  atpos | item'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

  startit | start item iterator
  end | end item iterator
  list | COMPS_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

  walker | Iterator position in list
  result | object of actual item
  return | non-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

  walker | Iterator position in list
  result | object of actual item
  return | non-zero if walker hasn't reached end, otherwise zero