Wondercoll
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Classes | Macros | Typedefs
_cvlist.h File Reference
#include <stdlib.h>
#include <assert.h>

Go to the source code of this file.

Classes

struct  _pos
 
struct  _list
 
struct  __index
 

Macros

#define CV_FORCE_INLINE   CV_INLINE
 
#define _LIST_INLINE   CV_FORCE_INLINE
 
#define DECLARE_LIST(type, prefix)
 
#define INSERT_NEW(element_type, l, element)
 
#define INSERT_FREE(element_type, l, element)
 
#define IMPLEMENT_LIST(type, prefix)
 
#define DECLARE_AND_IMPLEMENT_LIST(type, prefix)
 

Typedefs

typedef struct _pos CVPOS
 
typedef struct _list _CVLIST
 
typedef struct __index _index
 

Macro Definition Documentation

#define _LIST_INLINE   CV_FORCE_INLINE
#define CV_FORCE_INLINE   CV_INLINE
#define DECLARE_AND_IMPLEMENT_LIST (   type,
  prefix 
)
Value:
DECLARE_LIST(type, prefix)\
IMPLEMENT_LIST(type, prefix)
#define DECLARE_LIST (   type,
  prefix 
)
Value:
/* Basic element of a list*/\
struct prefix##element_##type\
{\
struct prefix##element_##type* m_prev;\
struct prefix##element_##type* m_next;\
type m_data;\
};\
typedef struct prefix##element_##type ELEMENT_##type;\
/* Initialization and destruction*/\
_LIST_INLINE _CVLIST* prefix##create_list_##type(long);\
_LIST_INLINE void prefix##destroy_list_##type(_CVLIST*);\
/* Access functions*/\
_LIST_INLINE CVPOS prefix##get_head_pos_##type(_CVLIST*);\
_LIST_INLINE CVPOS prefix##get_tail_pos_##type(_CVLIST*);\
_LIST_INLINE type* prefix##get_next_##type(CVPOS*);\
_LIST_INLINE type* prefix##get_prev_##type(CVPOS*);\
/* Modification functions*/\
_LIST_INLINE void prefix##clear_list_##type(_CVLIST*);\
_LIST_INLINE CVPOS prefix##add_head_##type(_CVLIST*, type*);\
_LIST_INLINE CVPOS prefix##add_tail_##type(_CVLIST*, type*);\
_LIST_INLINE void prefix##remove_head_##type(_CVLIST*);\
_LIST_INLINE void prefix##remove_tail_##type(_CVLIST*);\
_LIST_INLINE CVPOS prefix##insert_before_##type(_CVLIST*, CVPOS, type*);\
_LIST_INLINE CVPOS prefix##insert_after_##type(_CVLIST*, CVPOS, type*);\
_LIST_INLINE void prefix##remove_at_##type(_CVLIST*, CVPOS);\
_LIST_INLINE void prefix##set_##type(CVPOS, type*);\
_LIST_INLINE type* prefix##get_##type(CVPOS);\
/* Statistics functions*/\
_LIST_INLINE int prefix##get_count_##type(_CVLIST*);
#define IMPLEMENT_LIST (   type,
  prefix 
)
#define INSERT_FREE (   element_type,
  l,
  element 
)
Value:
if(l->m_head_free.m_pos != NULL)\
{\
((element_type*)l->m_head_free.m_pos)->m_prev = element;\
}\
element->m_next = ((element_type*)l->m_head_free.m_pos);\
l->m_head_free.m_pos = element;
#define INSERT_NEW (   element_type,
  l,
  element 
)
Value:
l->m_size++;\
if(l->m_head_free.m_pos != NULL)\
{\
element = (element_type*)(l->m_head_free.m_pos);\
if(element->m_next != NULL)\
{\
element->m_next->m_prev = NULL;\
l->m_head_free.m_pos = element->m_next;\
}\
else\
{\
l->m_head_free.m_pos = NULL;\
}\
}\
else\
{\
if(l->m_buf_size < l->m_size && l->m_head_free.m_pos == NULL)\
{\
*(void**)l->m_buffer = cvAlloc(l->m_buf_size*sizeof(element_type) + sizeof(void*));\
l->m_buffer = *(void**)l->m_buffer;\
*(void**)l->m_buffer = NULL;\
element = (element_type*)((char*)l->m_buffer + sizeof(void*));\
}\
else\
{\
element = (element_type*)((char*)l->m_buffer + sizeof(void*)) + l->m_size - 1;\
}\
}

Typedef Documentation

typedef struct _list _CVLIST
typedef struct __index _index
typedef struct _pos CVPOS