List


Classes

struct  ix_entry_t

Defines

#define ix_stack_new(b, c)   ix_list_new( NULL, (b), (c) )
 new stack
#define ix_stack_free(a)   ix_list_free((a))
 free stack
#define ix_stack_push   ix_list_insert
 put element on stack
#define ix_stack_pop   ix_list_last
 pop element from stack
#define ix_queue_new(b, c)   ix_list_new( NULL, (b), (c) )
 new queue
#define ix_queue_free(a)   ix_list_free((a))
 free queue
#define ix_queue_add   ix_list_add
 feed queue (overwrites oldest element if full)
#define ix_queue_insert   ix_list_insert
 feed queue (returns error if full)
#define ix_queue_eat   ix_list_first
 eat from queue

Typedefs

typedef int(*) IX_LIST_CMP_FCT (const void *, const void *)
 compare function used for list ordering
typedef int(*) IX_LIST_TRAVERSE_FCT (const void *, void *)
 function wich is called during list traversing called with entry and userdata, s. ix_list_traverse(), ix_list_traverse_del()
typedef ix_list_s ix_list_t
 list class
typedef ix_list_s ix_queue_t
 queue class
typedef ix_list_s ix_stack_t
 stack class
typedef ix_hash_s ix_hash_t
 hash pool class
typedef ix_rb_s ix_rb_t
 ring buffer class

Enumerations

enum  ix_rb_e { IX_RB_DEFAULT, IX_RB_KEEP }

Functions

ix_list_tix_list_new (IX_LIST_CMP_FCT cmp, void *mem, size_t size)
int ix_list_lock (ix_list_t *plist)
int ix_list_unlock (ix_list_t *plist)
void * ix_list_search (ix_list_t *plist, void *ptr)
int ix_list_delete (ix_list_t *plist, void *ptr)
int ix_list_delete_ret (ix_list_t *plist, void *ptr, void **ret)
int ix_list_free (ix_list_t *plist)
int ix_list_sort (ix_list_t *plist)
int ix_list_insert (ix_list_t *plist, void *ptr)
int ix_list_add (ix_list_t *plist, void *ptr, void **pret)
void * ix_list_first (ix_list_t *plist)
void * ix_list_head (ix_list_t *plist)
void * ix_list_tail (ix_list_t *plist)
void * ix_list_last (ix_list_t *plist)
int ix_list_count (ix_list_t *plist)
int ix_list_overrun (ix_list_t *plist)
int ix_list_fills (ix_list_t *plist)
int ix_list_traverse (ix_list_t *plist, IX_LIST_TRAVERSE_FCT fct, void *arg)
int ix_list_traverse_del (ix_list_t *plist, IX_LIST_TRAVERSE_FCT fct, void *arg)
ix_hash_tix_hash_new (int nel)
void ix_hash_free (ix_hash_t *ph)
int ix_hash_add (ix_hash_t *ph, char *key, void *data, void **retdata)
void * ix_hash_find (ix_hash_t *ph, char *key)
ix_rb_tix_rb_new (size_t len, int flag)
int ix_rb_read (ix_rb_t *prb, char *buf, int len)
int ix_rb_write (ix_rb_t *prb, char *buf, int len)
void ix_rb_free (ix_rb_t *prb)
int ix_rb_no (ix_rb_t *prb)

Detailed Description

This module describe some threadsafe utilities methods to deal with list, queues, stacks.

Typedef Documentation

typedef struct ix_hash_s ix_hash_t

hash pool class

A hash pool is a set of key - data pairs for fast key search.

typedef struct ix_list_s ix_list_t

list class

A class to store void pointers, not more. But you can specify a compare function to sort this pointers, s. IX_LIST_CMP_FCT and find an entry. The list functions are thread-safe. The following queue and stack classes are realised with ix_list_t.

typedef struct ix_list_s ix_queue_t

queue class

s. ix_list_t

typedef struct ix_rb_s ix_rb_t

ring buffer class

"Ring buffer" is realized as a fixed maximum length byte queue. You can add bytes to the end and read bytes from the head of the queue. By creation you have to give the maximum size and the type ix_rb_e of the queue. The type specifies wether it is a real ring (default), i.e. old data is overwritten when the queue becomes full.

typedef struct ix_list_s ix_stack_t

stack class

s. ix_list_t


Enumeration Type Documentation

enum ix_rb_e

Types of ring buffer

Enumerator:
IX_RB_DEFAULT  overwrite data in head of queue
IX_RB_KEEP  no data overwritten in queue


Function Documentation

int ix_hash_add ( ix_hash_t ph,
char *  key,
void *  data,
void **  retdata 
)

adds new data with key to hash pool ph, if key already exists data is overwritten and pointer returned in retdata

Parameters:
ph handle for hash pool
key key of entry
data pointer to userdata
retdata existing data is retrieved in retdata
Returns:
  • 0: OK
  • !0: error

void* ix_hash_find ( ix_hash_t ph,
char *  key 
)

finds data with key in hash pool ph

Parameters:
ph handle for hash pool
key key to look for
Returns:
  • data
  • NULL: not found or error

void ix_hash_free ( ix_hash_t ph  ) 

destructor, frees hash pool

Parameters:
ph handle for hash pool

ix_hash_t* ix_hash_new ( int  nel  ) 

constructor, creates new hash pool

Parameters:
nel estimated number of entries (increased internally)
Returns:
  • handle of new hash pool
  • NULL: error

int ix_list_add ( ix_list_t plist,
void *  ptr,
void **  pret 
)

Add a new element to end of list; if maximal size is reached, the first element is deleted (queue)

Parameters:
plist List handle
ptr elment to add
ret where overwritten element is saved, NULL if not desired
Returns:
  • 0: OK
  • 1: element overwritten and stored to pret
  • <0: error

int ix_list_count ( ix_list_t plist  ) 

Gets number of elements in list

Parameters:
plist List handle
Returns:
  • number of elements
  • <0: Error

int ix_list_delete ( ix_list_t plist,
void *  ptr 
)

delete an element from list

Parameters:
plist List handle
ptr element to supply compare function
Returns:
  • 0: OK
  • !0: error

int ix_list_delete_ret ( ix_list_t plist,
void *  ptr,
void **  ret 
)

delete and retrieve element from list

Parameters:
plist List handle
ptr element to supply compare function
ret deleted element
Returns:
  • 0: OK
  • !0: error

int ix_list_fills ( ix_list_t plist  ) 

gets number of insertions into list

Parameters:
plist List handle
Returns:
  • number of fills
  • <0: Error

void* ix_list_first ( ix_list_t plist  ) 

gets the first entry and deletes it from list

Parameters:
plist List handle
Returns:
  • first element
  • NULL: error

int ix_list_free ( ix_list_t plist  ) 

free whole list (of course not the entries)

Parameters:
plist List handle
Returns:
  • 0: OK
  • !0: error

void* ix_list_head ( ix_list_t plist  ) 

gets the first entry

Parameters:
plist List handle
Returns:
  • first element
  • NULL: error

int ix_list_insert ( ix_list_t plist,
void *  ptr 
)

Insert a new element at proper place

Parameters:
plist List handle
ptr elment to insert
Returns:
  • 0: OK
  • !0: error

void* ix_list_last ( ix_list_t plist  ) 

gets the last entry and deletes it from list

Parameters:
plist List handle
Returns:
  • first element
  • NULL: error

int ix_list_lock ( ix_list_t plist  ) 

list is blocked for other threads

Parameters:
plist List handle
Returns:
  • 0: OK
  • !0: error

ix_list_t* ix_list_new ( IX_LIST_CMP_FCT  cmp,
void *  mem,
size_t  size 
)

constructor, creates new empty list cmp==NULL: unsorted list or queue or stack insert: pointer to data retrieve: pointer to data

Parameters:
cmp compare function
mem memory pointer taken for list, if mem = NULL the memory for number size element entries is allocated, otherwise mem of size(in bytes) is used
size see paramter mem
Returns:
  • Handle for list
  • NULL: error

int ix_list_overrun ( ix_list_t plist  ) 

gets number of overruns for queue-lists

Parameters:
plist List handle
Returns:
  • number of overruns
  • <0: Error

void* ix_list_search ( ix_list_t plist,
void *  ptr 
)

search for a list element, see compare function supplied with ix_list_new()

Parameters:
plist List handle
ptr element to supply compare function
Returns:
  • found element
  • NULL: error

int ix_list_sort ( ix_list_t plist  ) 

sort list

Parameters:
plist List handle
Returns:
  • 0: OK
  • !0: error

void* ix_list_tail ( ix_list_t plist  ) 

gets the last entry

Parameters:
plist List handle
Returns:
  • first element
  • NULL: error

int ix_list_traverse ( ix_list_t plist,
IX_LIST_TRAVERSE_FCT  fct,
void *  arg 
)

traverses list and calls fct with element and arg

Parameters:
plist List handle
fct user function to call. If fct returns < 0 the scan is interrupted.
arg user argument for fct
Returns:
  • maximal return status of fct
  • <0: Error

int ix_list_traverse_del ( ix_list_t plist,
IX_LIST_TRAVERSE_FCT  fct,
void *  arg 
)

traverses list and calls for each list entry fct with list entry and arg

Parameters:
plist List handle
fct user function to call.
  • if fct returns 2 the entry is deleted from list
  • if fct returns 1 the scan is interrupted
arg user argument for fct
Returns:
  • return status of fct
  • <0: Error

int ix_list_unlock ( ix_list_t plist  ) 

list is unblocked for other threads

Parameters:
plist List handle
Returns:
  • 0: OK
  • !0: error

void ix_rb_free ( ix_rb_t prb  ) 

Destructor, frees memory of ringbuffer

Parameters:
prb handle of ring buffer

ix_rb_t* ix_rb_new ( size_t  len,
int  flag 
)

Constructor, creates a new ring buffer of size len

Parameters:
len maximal size of the queue
flag specify type of ring buffer
Returns:
  • Handle
  • NULL: error

int ix_rb_no ( ix_rb_t prb  ) 

returns number of bytes in ring buffer

Parameters:
prb handle of ring buffer
Returns:
  • 0: number of bytes
  • <0: error

int ix_rb_read ( ix_rb_t prb,
char *  buf,
int  len 
)

reads max len bytes from ringbuffer prb,

Parameters:
prb handle of ring buffer
buf buffer to store data
len max number of bytes to read
Returns:
  • number of read bytes
  • <0: error

int ix_rb_write ( ix_rb_t prb,
char *  buf,
int  len 
)

Writes len bytes of buffer to ringbuffer

Parameters:
prb handle of ring buffer
buf buffer with data to write
len number of bytes to write to ringbuffer
Returns:
  • number of bytes written
  • <0: error


Generated on 4 Mar 2014 for ixtools by  doxygen 1.4.7