include/it/hlist.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdint.h>
#include <sys/param.h>

Go to the source code of this file.

Data Structures

struct  cell_t
struct  list_header_t
struct  head_t
struct  hash_header_t
struct  hash_t

Defines

#define __HLIST_MAXLEN   12
#define __HLIST_OUTPUT   stderr
#define __object_set_field(o, field, value)
#define __object_get_field(o, field, value)
#define __get_header(l)   ((head)( (char *)(l)-sizeof( list_header )))
#define __idx_value(target, object, idx)   (&(target)?*((int*)(((char*)(target))+((unsigned int)((char*)&(object).idx-(char*)&(object))))):-1)
#define __new_cell(c)
#define __cell_print(c, out)
#define __list_init_prealloc(l)
#define __list_init(l)   __list_init_prealloc( l )
#define __list_get_count(l, cnt)
#define __list_decr_count(l)
#define __list_set_count(l, n)
#define __list_incr_count(l)
#define __list_set_output(l, file)
#define __list_set_name(l, newname)
#define __list_print_header(l)
#define __list_is_empty(l, empty)
#define __list_add_first(l, object)
#define __list_add_last(l, object)
#define __list_add_by_index(l, object, index)
#define __list_add_by_index_reverse(l, object, index)
#define __list_del_first_by_index(l, object, idx)
#define __list_del_all_by_index(l, object, idx)
#define __list_foreach_forward(l, i)   for( (i)=(l)->next; (i)->content; (i) = (i)->next )
#define __list_foreach_reverse(l, i)   for( (i)=(l)->prev; (i)->content; (i) = (i)->prev )
#define __list_foreach(l, i)   __list_foreach_forward( l, i )
#define _save_list_print(l)
#define __list_print(l)
#define __list_del_first(l, object)
#define __list_del_last(l, object)
#define __list_del_first_object(l, object)
#define __list_del_all_object(l, object)
#define __list_contains(l, object, found)
#define __list_delete(l)
#define __list_apply_function(l, function)
#define __list_compare(l1, l2, comp)
#define __list_append(l1, l2)
#define __list_fusion(l1, l2)
#define __list_copy(l1, l2)
#define __list_insert_once(l, object)
#define __list_only_once(l)
#define __list_minus(l1, l2)
#define list_init(l)   __list_init(l)
#define list_set_name(l, name)   __list_set_name(l,name)
#define list_get_count(l, cnt)   __list_get_count(l, cnt)
#define list_set_count(l, cnt)   __list_set_count(l, cnt)
#define list_set_output(l, file)   __list_set_output(l,file)
#define list_is_empty(l, empty)   __list_is_empty(l,empty)
#define list_add_first(l, object)   __list_add_first(l,object)
#define list_add_last(l, object)   __list_add_last(l,object)
#define list_add_by_index(l, object, index)   __list_add_by_index(l,object,index)
#define list_add_by_index_reverse(l, object, index)   __list_add_by_index_reverse(l,object,index)
#define list_del_first_by_index(l, object, index)   __list_del_first_by_index(l,object,index)
#define list_del_all_by_index(l, object, index)   __list_del_all_by_index(l,object,index)
#define list_foreach(l, i)   __list_foreach(l,i)
#define list_foreach_reverse(l, i)   __list_foreach_reverse(l,i)
#define list_print(l)   __list_print(l)
#define list_del_first(l, object)   __list_del_first(l,object)
#define list_del_last(l, object)   __list_del_last(l,object)
#define list_delete(l)   __list_delete(l)
#define list_apply_function(l, function)   __list_apply_function(l,function)
#define list_compare(l1, l2, comp)   __list_compare(l1,l2,comp)
#define list_del_first_object(l, object)   __list_del_first_object(l,object)
#define list_del_all_object(l, object)   __list_del_all_object(l,object)
#define list_contains(l, object, found)   __list_contains(l,object,found)
#define list_append(l1, l2)   __list_append(l1,l2)
#define list_fusion(l1, l2)   __list_fusion(l1,l2)
#define list_copy(l1, l2)   __list_copy(l1,l2)
#define list_insert_once(l, object)   __list_insert_once(l,object)
#define list_only_once(l)   __list_only_once(l)
#define fifo_init(f)   __list_init(f)
#define fifo_push(f, object)   __list_add_first(f,object)
#define fifo_pop(f, object)   __list_del_last(f,object)
#define fifo_delete(f)   __list_delete(f)
#define lifo_init(l)   __list_init(l)
#define lifo_push(l, object)   __list_add_first(l,object)
#define lifo_pop(l, object)   __list_del_first(l,object)
#define lifo_delete(l)   __list_delete(l)
#define HASH_LITTLE_ENDIAN   0
#define HASH_BIG_ENDIAN   0
#define bj_hashsize(n)   ((uint32_t)1<<(n))
#define bj_hashmask(n)   (bj_hashsize(n)-1)
#define bj_rot(x, k)   (((x)<<(k)) | ((x)>>(32-(k))))
#define bj_mix(a, b, c)
#define bj_final(a, b, c)
#define hashlittle2(key, len, pc, pb)
#define __hash_init(h, log2buckets)
#define __hash_set_output(l, file)
#define __hash_set_name(h, newname)
#define __hash_delete(h)
#define __hash_print(h)
#define __hash_bytes(data, start, len, h)
#define __hash_fit(h, hash)
#define __hash_object(object, hash)   __hash_bytes( &(object), 0, sizeof(object), hash )
#define __hash_from_key(object, key, hash)   __hash_bytes( &((object).key), (((char*)&((object).key))-((char*)&(object))), sizeof((object).key), hash )
#define __hash_insert_object(h, object)
#define __hash_remove_object(h, object)
#define __hash_lookup_object(h, object, found)
#define __hash_insert_from_key(h, object, key)
#define __hash_remove_from_key(h, object, key)
#define __hash_lookup_from_key(h, object, key, found)
#define hash_init(h, l2b)   __hash_init(h, l2b)
#define hash_set_name(h, name)   __hash_set_name(h,name)
#define hash_set_output(h, out)   __hash_set_name(h,out)
#define hash_print(h)   __hash_print(h)
#define hash_insert_object(h, object)   __hash_insert_object(h,object)
#define hash_remove_object(h, object)   __hash_remove_object(h,object)
#define hash_lookup_object(h, object, found)   __hash_lookup_object(h,object,found)
#define hash_insert_from_key(h, object, key)   __hash_insert_from_key(h,object,key)
#define hash_remove_from_key(h, object, key)   __hash_remove_from_key(h,object,key)
#define hash_lookup_from_key(h, object, key, found)   __hash_lookup_from_key(h,object,key,found)
#define hash_delete(h)   __hash_delete(h)

Typedefs

typedef struct cell_tcell
typedef struct cell_tlist
typedef struct list_header_t list_header
typedef struct head_thead
typedef list fifo
typedef list lifo
typedef struct hash_header_t hash_header
typedef struct hash_thash


Define Documentation

#define __cell_print ( c,
out   ) 

Value:

do {            \
    fprintf( (out), "cell @ %p: prev @ %p, next @ %p (content @ %p, %d bytes)\n", (void*)(c), (void*)(c)->prev, (void*)(c)->next, (void*)(c)->content, (c)->csz ); \
  } while ( 0 )

Definition at line 112 of file hlist.h.

#define __get_header (  )     ((head)( (char *)(l)-sizeof( list_header )))

Definition at line 96 of file hlist.h.

#define __hash_bytes ( data,
start,
len,
 ) 

Value:

do {    \
    unsigned int h2;            \
    hashlittle2( (((char*)data)+start), len, h, h2 );         \
  } while ( 0 )

Definition at line 915 of file hlist.h.

#define __hash_delete (  ) 

Value:

do {      \
    unsigned int i;       \
    for ( i= 0; i< (1<<(h)->h.count); i++ ) \
      list_delete( (h)->data[i] );    \
    if ( (h)->h.hname ) free( (h)->h.hname ); \
    free( h );          \
  } while ( 0 )

Definition at line 894 of file hlist.h.

#define __hash_fit ( h,
hash   ) 

Value:

do {      \
    unsigned int hfit = hash & ( (1<<(h)->h.count)-1 ); \
    memcpy( &hash, &hfit, sizeof(hash) );   \
  } while ( 0 )

Definition at line 934 of file hlist.h.

#define __hash_from_key ( object,
key,
hash   )     __hash_bytes( &((object).key), (((char*)&((object).key))-((char*)&(object))), sizeof((object).key), hash )

Definition at line 943 of file hlist.h.

#define __hash_init ( h,
log2buckets   ) 

Value:

do {        \
    unsigned int i;             \
    (h) = malloc( sizeof( *(h) ) );         \
    (h)->h.count = log2buckets>32?32:log2buckets;     \
    (h)->h.out = __HLIST_OUTPUT;          \
    (h)->h.hname = NULL;            \
    (h)->data = malloc( (1<<(h)->h.count)*sizeof(struct cell_t) );  \
    for ( i= 0; i< (1<<(h)->h.count); i++ ) list_init( (h)->data[i] );  \
  } while ( 0 )

Definition at line 863 of file hlist.h.

#define __hash_insert_from_key ( h,
object,
key   ) 

Value:

do {  \
    unsigned int hash=0;        \
    __hash_from_key( object, key, hash );   \
    __hash_fit( h, hash );        \
    list_add_first( (h)->data[hash], object );    \
  } while ( 0 )

Definition at line 972 of file hlist.h.

#define __hash_insert_object ( h,
object   ) 

Value:

do {    \
    unsigned int hash=0;        \
    __hash_object( object, hash );      \
    __hash_fit( h, hash );        \
    list_add_first( (h)->data[hash], object );    \
  } while ( 0 )

Definition at line 946 of file hlist.h.

#define __hash_lookup_from_key ( h,
object,
key,
found   ) 

Value:

do {  \
    unsigned int hash=0;          \
    __hash_from_key( object, key, hash );     \
    __hash_fit( h, hash );          \
    list_contains((h)->data[hash],object,found);    \
  } while ( 0 )

Definition at line 990 of file hlist.h.

#define __hash_lookup_object ( h,
object,
found   ) 

Value:

do {  \
    unsigned int hash=0;        \
    __hash_object( object, hash );      \
    __hash_fit( h, hash );        \
    list_contains((h)->data[hash],object,found);  \
  } while ( 0 )

Definition at line 964 of file hlist.h.

#define __hash_object ( object,
hash   )     __hash_bytes( &(object), 0, sizeof(object), hash )

Definition at line 940 of file hlist.h.

#define __hash_print (  ) 

Value:

do {            \
    unsigned int i;             \
    if ( (h)->h.hname )             \
      fprintf( (h)->h.out, "Hash %s @ %p ", (h)->h.hname, (void*)(h) ); \
    else                \
      fprintf( (h)->h.out, "Hash @ %p ", (void*)(h) );      \
    fprintf( (h)->h.out, "(%d buckets)\n", (1<<(h)->h.count) );   \
    for ( i= 0; i< (1<<(h)->h.count); i++ )       \
      list_print( (h)->data[i] );         \
  } while ( 0 )

Definition at line 903 of file hlist.h.

#define __hash_remove_from_key ( h,
object,
key   ) 

Value:

do {  \
    unsigned int hash=0;        \
    __hash_from_key( object, key, hash );   \
    __hash_fit( h, hash );        \
    list_del_all_object((h)->data[hash],object);  \
  } while ( 0 )

Definition at line 980 of file hlist.h.

#define __hash_remove_object ( h,
object   ) 

Value:

do {    \
    unsigned int hash=0;        \
    __hash_object( object, hash );      \
    __hash_fit( h, hash );        \
    list_del_all_object((h)->data[hash],object);  \
  } while ( 0 )

Definition at line 954 of file hlist.h.

#define __hash_set_name ( h,
newname   ) 

Value:

do {        \
    unsigned int i, len;            \
    len = strlen(newname)+1<__HLIST_MAXLEN?strlen(newname):__HLIST_MAXLEN; \
    if ( (h)->h.hname )             \
      {                 \
  fprintf( stderr, "Warning: Changing name!\n" );     \
  free( (h)->h.hname );           \
      }                 \
    (h)->h.hname = malloc( (1+strlen(newname))*sizeof(char) );    \
    for ( i= 0; i< len; i++ ) (h)->h.hname[i] = newname[i];   \
    (h)->h.hname[i] = '\0';           \
  } while ( 0 )               \

Definition at line 880 of file hlist.h.

#define __hash_set_output ( l,
file   ) 

Value:

do {    \
    fprintf( stderr, "Warning: Changing output!\n" ); \
    (h)->h.out = (file);        \
  } while( 0 )

Definition at line 874 of file hlist.h.

#define __HLIST_MAXLEN   12

Definition at line 55 of file hlist.h.

#define __HLIST_OUTPUT   stderr

Definition at line 56 of file hlist.h.

#define __idx_value ( target,
object,
idx   )     (&(target)?*((int*)(((char*)(target))+((unsigned int)((char*)&(object).idx-(char*)&(object))))):-1)

Definition at line 100 of file hlist.h.

#define __list_add_by_index ( l,
object,
index   ) 

Value:

do {      \
    cell c;               \
    cell i = (l)->next;             \
    while( i->content && (object).index > __idx_value( i->content, object, index ) ) \
      i = i->next;              \
    i = i->prev;              \
    __new_cell( c );              \
    c->next = (i)->next;            \
    c->prev = (i);              \
    (i)->next->prev = c;            \
    (i)->next = c;              \
    c->content = malloc( sizeof( object ) );        \
    c->csz = sizeof(object);          \
    memcpy( c->content, &(object), sizeof( object) );     \
    __list_incr_count( l );           \
  } while ( 0 )

Definition at line 228 of file hlist.h.

#define __list_add_by_index_reverse ( l,
object,
index   ) 

Value:

do {    \
    cell c;               \
    cell i = (l)->next;             \
    while( i->content && (object).index < __idx_value( i->content, object, index ) ) \
      i = i->next;              \
    i = i->prev;              \
    __new_cell( c );              \
    c->next = (i)->next;            \
    c->prev = (i);              \
    (i)->next->prev = c;            \
    (i)->next = c;              \
    c->content = malloc( sizeof( object ) );        \
    c->csz = sizeof(object);          \
    memcpy( c->content, &(object), sizeof( object) );     \
    __list_incr_count( l );           \
  } while ( 0 )

Definition at line 246 of file hlist.h.

#define __list_add_first ( l,
object   ) 

Value:

do {        \
    cell c;               \
    __new_cell( c );              \
    c->next = (l)->next;            \
    c->prev = (l);              \
    (l)->next->prev = c;            \
    (l)->next = c;              \
    c->content = malloc( sizeof( object ) );        \
    c->csz = sizeof(object);            \
    memcpy( (c->content), &(object), sizeof( object) );     \
    __list_incr_count( l );           \
  } while(0)

Definition at line 200 of file hlist.h.

#define __list_add_last ( l,
object   ) 

Value:

do {      \
    cell c;             \
    __new_cell( c );            \
    c->prev = (l)->prev;          \
    c->next = (l);            \
    (l)->prev->next = c;          \
    (l)->prev = c;            \
    c->content = malloc( sizeof( object ) );      \
    c->csz = sizeof(object);          \
    memcpy( c->content, &(object), sizeof( object) );   \
    __list_incr_count( l );         \
} while(0)

Definition at line 214 of file hlist.h.

#define __list_append ( l1,
l2   ) 

Value:

do {    \
    head hl1 = __get_header(l1);    \
    head hl2 = __get_header(l2);    \
    l1->prev->next = l2->next;      \
    l2->next->prev = l1->prev;      \
    l2->prev->next = l1;      \
    hl1->h.count += hl1->h.count;   \
    l2 = &(hl2->data);        \
    if ( hl2->h.lname ) free( hl2->h.lname ); \
    free( hl2 );        \
  } while ( 0 )

Definition at line 485 of file hlist.h.

#define __list_apply_function ( l,
function   ) 

Value:

do {  \
    cell c;           \
    __list_foreach_forward( l, c ) {      \
      function( (c)->content );       \
    }             \
  } while ( 0 )

Definition at line 443 of file hlist.h.

#define __list_compare ( l1,
l2,
comp   ) 

Value:

do {    \
    unsigned int s1, s2;      \
    __list_get_count( l1, s1 );     \
    __list_get_count( l2, s2 );     \
    if ( s1 < s2 ) {        \
      s1 = -1;          \
      memcpy( &(comp), &s1, sizeof(comp) ); \
    }           \
    if ( s1 > s2 ) {        \
      s2 = 1;         \
      memcpy( &(comp), &s2, sizeof(comp) ); \
    }           \
    if ( s1==s2 ) {       \
      unsigned int t = 0;     \
      cell c1 = (l1)->next, c2 = (l2)->next;  \
      while ( (c1)->content ) {           \
  if ( (c1)->csz == (c2)->csz && !memcmp((c1)->content,(c2)->content, (c1)->csz)) { \
    c1 = c1->next;            \
    c2 = c2->next;            \
  }               \
  else {                \
    t = 1;              \
    break;              \
  }               \
      }                 \
      memcpy( &(comp), &t, sizeof(t) );         \
    }                 \
  } while ( 0 )

Definition at line 455 of file hlist.h.

#define __list_contains ( l,
object,
found   ) 

Value:

do {      \
    cell i = (l)->next;             \
    int f = -1;               \
    memcpy( &(found), &f, sizeof(f) );          \
    while ( i->content ) {            \
      f++;                \
      if ( !memcmp( i->content, &(object), sizeof(object) ) ) {   \
  memcpy( &(found), &f, sizeof(f) );        \
  break;                \
      }                 \
      i = i->next;              \
    }                 \
  } while ( 0 )

Definition at line 406 of file hlist.h.

#define __list_copy ( l1,
l2   ) 

Value:

do {          \
      cell i;               \
      head hl2 = __get_header( l2 );          \
      __list_init( l1 );            \
      __list_foreach( l2, i ) {           \
  cell c;               \
  __new_cell( c );            \
  c->prev = (l1)->prev;           \
  c->next = (l1);             \
  (l1)->prev->next = c;           \
  (l1)->prev = c;             \
  c->content = malloc( i->csz );          \
  c->csz = i->csz;            \
  memcpy( c->content, i->content, c->csz );     \
      }                 \
      __list_set_count( l1, hl2->h.count );       \
      if ( hl2->h.lname ) __list_set_name( l1, hl2->h.lname );    \
  } while ( 0 )

Definition at line 524 of file hlist.h.

#define __list_decr_count (  ) 

Value:

do {      \
    head hl = __get_header(l);        \
    hl->h.count--;          \
  } while ( 0 )           \

Definition at line 140 of file hlist.h.

#define __list_del_all_by_index ( l,
object,
idx   ) 

Value:

do {      \
    cell i = (l)->next, c;            \
    while( i->content ) {           \
      if ( (object).idx==__idx_value(i->content,object,idx) ) {   \
  if ( &(object) )            \
    memcpy( &(object), i->content, sizeof( (object) ) );    \
  free( i->content );           \
  c = i;                \
  i->next->prev = i->prev;          \
  i->prev->next = i->next;          \
  free( c );              \
  __list_decr_count( l );           \
      }                 \
      i = i->next;              \
    }                 \
  } while ( 0 )

Definition at line 282 of file hlist.h.

#define __list_del_all_object ( l,
object   ) 

Value:

do {        \
    cell i = (l)->next;             \
    while ( i->content ) {            \
      if ( !memcmp( i->content, &(object), sizeof(object) ) ) {   \
  cell c;               \
  i = i->prev;              \
  free( (i)->next->content );         \
  c = i->next;              \
  (i)->next->next->prev = i;          \
  (i)->next = (i)->next->next;          \
  free( c );              \
  __list_decr_count( l );           \
      }                 \
    i = i->next;              \
    }                 \
  } while ( 0 )

Definition at line 386 of file hlist.h.

#define __list_del_first ( l,
object   ) 

Value:

do {        \
    cell c;               \
    if ( &(object) && (l)->next->content )        \
      memcpy( &(object), (l)->next->content, sizeof( (object) ) );  \
    if ( (l)->next->content ) {           \
      free( (l)->next->content );         \
      c = (l)->next;              \
      (l)->next->next->prev = (l);          \
      (l)->next = (l)->next->next;          \
      free( c );              \
      __list_decr_count( l );           \
    }                 \
  } while ( 0 )

Definition at line 339 of file hlist.h.

#define __list_del_first_by_index ( l,
object,
idx   ) 

Value:

do {    \
    cell c;               \
    cell i = (l)->next;             \
    while( i->content && (object).idx != __idx_value( i->content, object, idx ) ) \
      i = i->next;              \
    if ( &(object) )              \
      memcpy( &(object), (i)->next->content, sizeof( (object) ) );  \
    if ( (i)->next->content ) {           \
      free( (i)->next->content );         \
      c = (i)->next;              \
      (i)->next->next->prev = (i);          \
      (i)->next = (i)->next->next;          \
      free( c );              \
      __list_decr_count( l );           \
    }                 \
  } while ( 0 )

Definition at line 264 of file hlist.h.

#define __list_del_first_object ( l,
object   ) 

Value:

do {      \
    cell i = (l)->next;             \
    while ( i->content && memcmp( i->content, &(object), sizeof(object) ) ) \
      i = i->next;              \
    i = i->prev;              \
    if ( (i)->next->content ) {           \
      cell c;               \
      free( (i)->next->content );         \
      c = (i)->next;              \
      (i)->next->next->prev = (i);          \
      (i)->next = (i)->next->next;          \
      free( c );              \
      __list_decr_count( l );           \
    }                 \
  } while ( 0 )

Definition at line 369 of file hlist.h.

#define __list_del_last ( l,
object   ) 

Value:

do {        \
    cell c;               \
    if ( &(object) )              \
      memcpy( &(object), (l)->prev->content, sizeof( (object) ) );  \
    if ( (l)->prev->content ) {           \
      free( (l)->prev->content );         \
      c = (l)->prev;              \
      (l)->prev->prev->next = (l);          \
      (l)->prev = (l)->prev->prev;          \
      free( c );              \
      __list_decr_count( l );           \
    }                 \
  } while ( 0 )

Definition at line 354 of file hlist.h.

#define __list_delete (  ) 

Value:

do {            \
    unsigned int cnt;             \
    cell c;               \
    head hl = (head)( (char *)l-sizeof( (hl->h)) );     \
    __list_get_count( l, cnt );           \
    while( cnt ) {              \
      free( (l)->next->content );         \
      c = (l)->next;              \
      (l)->next->next->prev = (l);          \
      (l)->next = (l)->next->next;          \
      free( c );              \
      __list_decr_count( l );           \
      __list_get_count( l, cnt );         \
    }                 \
    if ( hl->h.lname ) {            \
      free( hl->h.lname );            \
      hl->h.lname = NULL;           \
    }                 \
    free( hl );               \
  } while( 0 )

Definition at line 421 of file hlist.h.

#define __list_foreach ( l,
 )     __list_foreach_forward( l, i )

Definition at line 308 of file hlist.h.

#define __list_foreach_forward ( l,
 )     for( (i)=(l)->next; (i)->content; (i) = (i)->next )

Definition at line 300 of file hlist.h.

#define __list_foreach_reverse ( l,
 )     for( (i)=(l)->prev; (i)->content; (i) = (i)->prev )

Definition at line 304 of file hlist.h.

#define __list_fusion ( l1,
l2   ) 

Value:

do {          \
    cell cc;                \
    __list_foreach( l2, cc ) {            \
      unsigned int prst = 0;            \
      cell c;               \
      __list_foreach( l1, c ) {           \
  if ( !memcmp( cc->content, c->content, sizeof(c->csz) ) ) \
    prst = 1;             \
      }                 \
      if ( !prst ) {              \
  cell t;               \
  __new_cell( t );            \
  t->content = malloc( cc->csz );         \
  t->csz = cc->csz;           \
  t->prev = (l1)->prev;           \
  t->next = (l1);             \
  (l1)->prev->next = t;           \
  (l1)->prev = t;             \
  memcpy( t->content, cc->content, cc->csz );     \
  __list_incr_count(l1);            \
      }                 \
    }                 \
  } while ( 0 )

Definition at line 499 of file hlist.h.

#define __list_get_count ( l,
cnt   ) 

Value:

do {        \
    head hl = __get_header(l);          \
    assert( sizeof( (cnt) ) == sizeof( hl->h.count ) );   \
    memcpy( &(cnt), &(hl->h.count), sizeof( (cnt) ) );    \
  } while ( 0 )

Definition at line 133 of file hlist.h.

#define __list_incr_count (  ) 

Value:

do {      \
    head hl = __get_header(l);        \
    hl->h.count++;          \
  } while ( 0 )           \

Definition at line 152 of file hlist.h.

#define __list_init (  )     __list_init_prealloc( l )

Definition at line 130 of file hlist.h.

#define __list_init_prealloc (  ) 

Value:

do {          \
    head hl = malloc( sizeof( *hl ) );          \
    hl->h.count = 0;              \
    hl->h.lname = NULL;             \
    hl->h.out = __HLIST_OUTPUT;           \
    (l) = (list)&(hl->data);            \
    (l)->content = NULL;            \
    (l)->prev = l;              \
    (l)->next = l;              \
  } while ( 0 )

Definition at line 118 of file hlist.h.

#define __list_insert_once ( l,
object   ) 

Value:

do {        \
    unsigned int prst = 0;            \
    cell c;               \
    __list_foreach( l, c ) {            \
      if ( !memcmp( &(object), c->content, sizeof(object) ) && sizeof(object)==c->csz ) \
  prst = 1;             \
    }                 \
    if ( !prst ) __list_add_first( l, object );       \
  } while ( 0 )

Definition at line 544 of file hlist.h.

#define __list_is_empty ( l,
empty   ) 

Value:

do {  \
    __list_get_count( l, empty );   \
    empty = !empty;       \
  } while ( 0 )

Definition at line 194 of file hlist.h.

#define __list_minus ( l1,
l2   ) 

Definition at line 596 of file hlist.h.

#define __list_only_once (  ) 

Definition at line 555 of file hlist.h.

#define __list_print (  ) 

Value:

do {          \
    cell c;               \
    head hl = __get_header(l);            \
    unsigned int tsz = sizeof(*hl)+(hl->h.lname)?1+strlen(hl->h.lname):0; \
    unsigned int csz = 0;           \
    __list_print_header( l );           \
    __list_foreach( l, c ) {            \
      __cell_print( c, hl->h.out );         \
      csz+= c->csz;             \
      tsz+= sizeof(*c);             \
      }                 \
    fprintf( hl->h.out, "Content total: %d bytes\n", csz );   \
  } while ( 0 )

Definition at line 324 of file hlist.h.

#define __list_print_header (  ) 

Value:

do {          \
    head hl = __get_header(l);            \
    if ( hl->h.lname )              \
      fprintf( hl->h.out, "List %s @ %p ", hl->h.lname, (void*)(l) ); \
    else                \
      fprintf( hl->h.out, "List @ %p ", (void*)l );     \
    if ( hl->h.count==1 || hl->h.count==0)        \
      fprintf( hl->h.out, "(%d item)\n", hl->h.count );     \
    else                \
      fprintf( hl->h.out, "(%d items)\n", hl->h.count );    \
  } while ( 0 )               \

Definition at line 180 of file hlist.h.

#define __list_set_count ( l,
 ) 

Value:

do {    \
      head hl = __get_header(l);    \
      hl->h.count = n;        \
  } while ( 0 )

Definition at line 146 of file hlist.h.

#define __list_set_name ( l,
newname   ) 

Value:

do {        \
    unsigned int i, len;            \
    head hl = __get_header(l);            \
    len = strlen(newname)+1<__HLIST_MAXLEN?strlen(newname):__HLIST_MAXLEN; \
    if ( hl->h.lname )              \
      {                 \
  fprintf( stderr, "Warning: Changing name!\n" );     \
  free( hl->h.lname );            \
      }                 \
    hl->h.lname = malloc( (1+strlen(newname))*sizeof(char) );   \
    for ( i= 0; i< len; i++ ) hl->h.lname[i] = newname[i];    \
    hl->h.lname[i] = '\0';            \
  } while ( 0 )               \

Definition at line 165 of file hlist.h.

#define __list_set_output ( l,
file   ) 

Value:

do {    \
    head hl = __get_header(l);        \
    fprintf( stderr, "Warning: Changing output!\n" ); \
    hl->h.out = (file);         \
  } while( 0 )

Definition at line 158 of file hlist.h.

#define __new_cell (  ) 

Value:

do {      \
    (c) = malloc( sizeof( *(c) ) );   \
    (c)->content = NULL;      \
    (c)->prev = (c);        \
    (c)->next = (c);        \
  } while ( 0 )

Definition at line 104 of file hlist.h.

#define __object_get_field ( o,
field,
value   ) 

Value:

do {  \
    memcpy( &(value), &((o).field), sizeof(value);  \
  } while ( 0 )

Definition at line 91 of file hlist.h.

#define __object_set_field ( o,
field,
value   ) 

Value:

do {      \
    memcpy( &((o).field), &(value), sizeof(value);      \
  } while ( 0 )

Definition at line 86 of file hlist.h.

#define _save_list_print (  ) 

Value:

do {          \
    cell c;               \
    head hl = __get_header(l);            \
    unsigned int sz = sizeof(*hl)+(hl->h.lname)?1+strlen(hl->h.lname):0; \
    unsigned int csz = 0;           \
    __list_print_header( l );           \
    __list_foreach( l, c ) {            \
      __cell_print( c, hl->h.out );         \
      csz+= c->csz;             \
      sz+= sizeof(*c);              \
      }                 \
  } while ( 0 )

Definition at line 311 of file hlist.h.

#define bj_final ( a,
b,
 ) 

Value:

do {      \
  c ^= b; c -= bj_rot(b,14);      \
  a ^= c; a -= bj_rot(c,11);      \
  b ^= a; b -= bj_rot(a,25);      \
  c ^= b; c -= bj_rot(b,16);      \
  a ^= c; a -= bj_rot(c,4);     \
  b ^= a; b -= bj_rot(a,14);      \
  c ^= b; c -= bj_rot(b,24);      \
} while ( 0 )

Definition at line 722 of file hlist.h.

#define bj_hashmask (  )     (bj_hashsize(n)-1)

Definition at line 710 of file hlist.h.

#define bj_hashsize (  )     ((uint32_t)1<<(n))

Definition at line 709 of file hlist.h.

#define bj_mix ( a,
b,
 ) 

Value:

do {         \
  a -= c;  a ^= bj_rot(c, 4);  c += b; \
  b -= a;  b ^= bj_rot(a, 6);  a += c; \
  c -= b;  c ^= bj_rot(b, 8);  b += a; \
  a -= c;  a ^= bj_rot(c,16);  c += b; \
  b -= a;  b ^= bj_rot(a,19);  a += c; \
  c -= b;  c ^= bj_rot(b, 4);  b += a; \
} while ( 0 )

Definition at line 713 of file hlist.h.

#define bj_rot ( x,
 )     (((x)<<(k)) | ((x)>>(32-(k))))

Definition at line 711 of file hlist.h.

#define fifo_delete (  )     __list_delete(f)

Definition at line 664 of file hlist.h.

#define fifo_init (  )     __list_init(f)

Definition at line 661 of file hlist.h.

#define fifo_pop ( f,
object   )     __list_del_last(f,object)

Definition at line 663 of file hlist.h.

#define fifo_push ( f,
object   )     __list_add_first(f,object)

Definition at line 662 of file hlist.h.

#define HASH_BIG_ENDIAN   0

Definition at line 706 of file hlist.h.

#define hash_delete (  )     __hash_delete(h)

Definition at line 1009 of file hlist.h.

#define hash_init ( h,
l2b   )     __hash_init(h, l2b)

Definition at line 999 of file hlist.h.

#define hash_insert_from_key ( h,
object,
key   )     __hash_insert_from_key(h,object,key)

Definition at line 1006 of file hlist.h.

#define hash_insert_object ( h,
object   )     __hash_insert_object(h,object)

Definition at line 1003 of file hlist.h.

#define HASH_LITTLE_ENDIAN   0

Definition at line 705 of file hlist.h.

#define hash_lookup_from_key ( h,
object,
key,
found   )     __hash_lookup_from_key(h,object,key,found)

Definition at line 1008 of file hlist.h.

#define hash_lookup_object ( h,
object,
found   )     __hash_lookup_object(h,object,found)

Definition at line 1005 of file hlist.h.

#define hash_print (  )     __hash_print(h)

Definition at line 1002 of file hlist.h.

#define hash_remove_from_key ( h,
object,
key   )     __hash_remove_from_key(h,object,key)

Definition at line 1007 of file hlist.h.

#define hash_remove_object ( h,
object   )     __hash_remove_object(h,object)

Definition at line 1004 of file hlist.h.

#define hash_set_name ( h,
name   )     __hash_set_name(h,name)

Definition at line 1000 of file hlist.h.

#define hash_set_output ( h,
out   )     __hash_set_name(h,out)

Definition at line 1001 of file hlist.h.

#define hashlittle2 ( key,
len,
pc,
pb   ) 

Definition at line 732 of file hlist.h.

#define lifo_delete (  )     __list_delete(l)

Definition at line 669 of file hlist.h.

#define lifo_init (  )     __list_init(l)

Definition at line 666 of file hlist.h.

#define lifo_pop ( l,
object   )     __list_del_first(l,object)

Definition at line 668 of file hlist.h.

#define lifo_push ( l,
object   )     __list_add_first(l,object)

Definition at line 667 of file hlist.h.

#define list_add_by_index ( l,
object,
index   )     __list_add_by_index(l,object,index)

Definition at line 640 of file hlist.h.

#define list_add_by_index_reverse ( l,
object,
index   )     __list_add_by_index_reverse(l,object,index)

Definition at line 641 of file hlist.h.

#define list_add_first ( l,
object   )     __list_add_first(l,object)

Definition at line 638 of file hlist.h.

#define list_add_last ( l,
object   )     __list_add_last(l,object)

Definition at line 639 of file hlist.h.

#define list_append ( l1,
l2   )     __list_append(l1,l2)

Definition at line 655 of file hlist.h.

#define list_apply_function ( l,
function   )     __list_apply_function(l,function)

Definition at line 650 of file hlist.h.

#define list_compare ( l1,
l2,
comp   )     __list_compare(l1,l2,comp)

Definition at line 651 of file hlist.h.

#define list_contains ( l,
object,
found   )     __list_contains(l,object,found)

Definition at line 654 of file hlist.h.

#define list_copy ( l1,
l2   )     __list_copy(l1,l2)

Definition at line 657 of file hlist.h.

#define list_del_all_by_index ( l,
object,
index   )     __list_del_all_by_index(l,object,index)

Definition at line 643 of file hlist.h.

#define list_del_all_object ( l,
object   )     __list_del_all_object(l,object)

Definition at line 653 of file hlist.h.

#define list_del_first ( l,
object   )     __list_del_first(l,object)

Definition at line 647 of file hlist.h.

#define list_del_first_by_index ( l,
object,
index   )     __list_del_first_by_index(l,object,index)

Definition at line 642 of file hlist.h.

#define list_del_first_object ( l,
object   )     __list_del_first_object(l,object)

Definition at line 652 of file hlist.h.

#define list_del_last ( l,
object   )     __list_del_last(l,object)

Definition at line 648 of file hlist.h.

#define list_delete (  )     __list_delete(l)

Definition at line 649 of file hlist.h.

#define list_foreach ( l,
 )     __list_foreach(l,i)

Definition at line 644 of file hlist.h.

#define list_foreach_reverse ( l,
 )     __list_foreach_reverse(l,i)

Definition at line 645 of file hlist.h.

#define list_fusion ( l1,
l2   )     __list_fusion(l1,l2)

Definition at line 656 of file hlist.h.

#define list_get_count ( l,
cnt   )     __list_get_count(l, cnt)

Definition at line 634 of file hlist.h.

#define list_init (  )     __list_init(l)

Definition at line 632 of file hlist.h.

#define list_insert_once ( l,
object   )     __list_insert_once(l,object)

Definition at line 658 of file hlist.h.

#define list_is_empty ( l,
empty   )     __list_is_empty(l,empty)

Definition at line 637 of file hlist.h.

#define list_only_once (  )     __list_only_once(l)

Definition at line 659 of file hlist.h.

#define list_print (  )     __list_print(l)

Definition at line 646 of file hlist.h.

#define list_set_count ( l,
cnt   )     __list_set_count(l, cnt)

Definition at line 635 of file hlist.h.

#define list_set_name ( l,
name   )     __list_set_name(l,name)

Definition at line 633 of file hlist.h.

#define list_set_output ( l,
file   )     __list_set_output(l,file)

Definition at line 636 of file hlist.h.


Typedef Documentation

typedef struct cell_t * cell

typedef list fifo

Definition at line 81 of file hlist.h.

typedef struct hash_t * hash

typedef struct hash_header_t hash_header

typedef struct head_t * head

typedef list lifo

Definition at line 82 of file hlist.h.

typedef struct cell_t * list

typedef struct list_header_t list_header


Hosted by
Copyright (C) 2005-2006 Hervé Jégou
Vivien Chappelier
Francois Cayre
libit logo courtesy of Jonathan Delhumeau