#define ADD_TO_HASH( what, next, orderby, hash, hash_size ) \
do \
{ \
int __iHash = (orderby)%(hash_size); \
(what)->next = (hash)[__iHash]; \
(hash)[__iHash] = (what); \
} while(0);
#define GET_FROM_HASH( what, member, what_type, next, hash, hash_size, result ) \
do \
{ \
int __iHash = (what)%(hash_size); \
(result) = NULL; \
for ( what_type *__what = (hash)[__iHash]; __what; __what = __what->next ) \
if ( __what->member == (what) ) \
{ \
(result) = __what; \
break; \
} \
} while(0);
#define IS_IN_HASH( what, what_type, next, orderby, hash, hash_size, result ) \
do \
{ \
int __iHash = (orderby)%(hash_size); \
(result) = false; \
for ( what_type *__what = (hash)[__iHash]; __what; __what = __what->next ) \
if ( __what == (what) ) \
(result) = true; \
} while(0);
#define IS_IN_HASH_MEMBER( what, member, what_type, next, hash, hash_size, result ) \
do \
{ \
int __iHash = (what)%(hash_size); \
(result) = false; \
for ( what_type *__what = (hash)[__iHash]; __what; __what = __what->next ) \
if ( __what->member == (what) ) \
{ \
(result) = true; \
break; \
} \
} while(0);
#define REMOVE_FROM_HASH( what, what_type, next, orderby, hash, hash_size ) \
do \
{ \
int __iHash = (orderby)%(hash_size); \
if ( (what) == (hash)[__iHash] ) \
(hash)[__iHash] = (what)->next; \
else \
{ \
for ( what_type *__what = (hash)[__iHash]; __what; __what = __what->next ) \
if ( __what->next == (what) ) \
__what->next = (what)->next; \
} \
} while(0);
#define REMOVE_FROM_HASH_BY_MEMBER( what, member, what_type, next, hash, hash_size ) \
do \
{ \
int __iHash = (what)%(hash_size); \
if ( (what) == (hash)[__iHash] ) \
(hash)[__iHash] = (what)->next \
else \
{ \
for ( what_type *__what = (hash)[__iHash]; __what; __what = __what->next ) \
if ( __what->next && __what->next->member == (what) ) \
{ \
__what->next = __what->next->next; \
break; \
} \
} \
} while(0);