Electroneum
ID List Management
Collaboration diagram for ID List Management:

Classes

struct  MDB_ID2
 

Macros

#define MDB_IDL_LOGN   16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */
 
#define MDB_IDL_DB_SIZE   (1<<MDB_IDL_LOGN)
 
#define MDB_IDL_UM_SIZE   (1<<(MDB_IDL_LOGN+1))
 
#define MDB_IDL_DB_MAX   (MDB_IDL_DB_SIZE-1)
 
#define MDB_IDL_UM_MAX   (MDB_IDL_UM_SIZE-1)
 
#define MDB_IDL_SIZEOF(ids)   (((ids)[0]+1) * sizeof(MDB_ID))
 
#define MDB_IDL_IS_ZERO(ids)   ( (ids)[0] == 0 )
 
#define MDB_IDL_CPY(dst, src)   (memcpy( dst, src, MDB_IDL_SIZEOF( src ) ))
 
#define MDB_IDL_FIRST(ids)   ( (ids)[1] )
 
#define MDB_IDL_LAST(ids)   ( (ids)[(ids)[0]] )
 
#define MDB_IDL_ALLOCLEN(ids)   ( (ids)[-1] )
 
#define mdb_midl_xappend(idl, id)
 

Typedefs

typedef mdb_size_t MDB_ID
 
typedef MDB_IDMDB_IDL
 
typedef struct MDB_ID2 MDB_ID2
 
typedef MDB_ID2MDB_ID2L
 

Functions

unsigned mdb_midl_search (MDB_IDL ids, MDB_ID id)
 
MDB_IDL mdb_midl_alloc (int num)
 
void mdb_midl_free (MDB_IDL ids)
 
void mdb_midl_shrink (MDB_IDL *idp)
 
int mdb_midl_need (MDB_IDL *idp, unsigned num)
 
int mdb_midl_append (MDB_IDL *idp, MDB_ID id)
 
int mdb_midl_append_list (MDB_IDL *idp, MDB_IDL app)
 
int mdb_midl_append_range (MDB_IDL *idp, MDB_ID id, unsigned n)
 
void mdb_midl_xmerge (MDB_IDL idl, MDB_IDL merge)
 
void mdb_midl_sort (MDB_IDL ids)
 
unsigned mdb_mid2l_search (MDB_ID2L ids, MDB_ID id)
 
int mdb_mid2l_insert (MDB_ID2L ids, MDB_ID2 *id)
 
int mdb_mid2l_append (MDB_ID2L ids, MDB_ID2 *id)
 

Detailed Description

Macro Definition Documentation

◆ MDB_IDL_ALLOCLEN

#define MDB_IDL_ALLOCLEN (   ids)    ( (ids)[-1] )

Current max length of an mdb_midl_alloc()ed IDL

Definition at line 73 of file midl.h.

◆ MDB_IDL_CPY

#define MDB_IDL_CPY (   dst,
  src 
)    (memcpy( dst, src, MDB_IDL_SIZEOF( src ) ))

Definition at line 68 of file midl.h.

◆ MDB_IDL_DB_MAX

#define MDB_IDL_DB_MAX   (MDB_IDL_DB_SIZE-1)

Definition at line 63 of file midl.h.

◆ MDB_IDL_DB_SIZE

#define MDB_IDL_DB_SIZE   (1<<MDB_IDL_LOGN)

Definition at line 60 of file midl.h.

◆ MDB_IDL_FIRST

#define MDB_IDL_FIRST (   ids)    ( (ids)[1] )

Definition at line 69 of file midl.h.

◆ MDB_IDL_IS_ZERO

#define MDB_IDL_IS_ZERO (   ids)    ( (ids)[0] == 0 )

Definition at line 67 of file midl.h.

◆ MDB_IDL_LAST

#define MDB_IDL_LAST (   ids)    ( (ids)[(ids)[0]] )

Definition at line 70 of file midl.h.

◆ MDB_IDL_LOGN

#define MDB_IDL_LOGN   16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */

Definition at line 59 of file midl.h.

◆ MDB_IDL_SIZEOF

#define MDB_IDL_SIZEOF (   ids)    (((ids)[0]+1) * sizeof(MDB_ID))

Definition at line 66 of file midl.h.

◆ MDB_IDL_UM_MAX

#define MDB_IDL_UM_MAX   (MDB_IDL_UM_SIZE-1)

Definition at line 64 of file midl.h.

◆ MDB_IDL_UM_SIZE

#define MDB_IDL_UM_SIZE   (1<<(MDB_IDL_LOGN+1))

Definition at line 61 of file midl.h.

◆ mdb_midl_xappend

#define mdb_midl_xappend (   idl,
  id 
)
Value:
do { \
MDB_ID *xidl = (idl), xlen = ++(xidl[0]); \
xidl[xlen] = (id); \
} while (0)

Append ID to IDL. The IDL must be big enough.

Definition at line 76 of file midl.h.

Typedef Documentation

◆ MDB_ID

typedef mdb_size_t MDB_ID

A generic unsigned ID number. These were entryIDs in back-bdb. Preferably it should have the same size as a pointer.

Definition at line 46 of file midl.h.

◆ MDB_ID2

typedef struct MDB_ID2 MDB_ID2

An ID2 is an ID/pointer pair.

◆ MDB_ID2L

typedef MDB_ID2* MDB_ID2L

An ID2L is an ID2 List, a sorted array of ID2s. The first element's mid member is a count of how many actual elements are in the array. The mptr member of the first element is unused. The array is sorted in ascending order by mid.

Definition at line 157 of file midl.h.

◆ MDB_IDL

typedef MDB_ID* MDB_IDL

An IDL is an ID List, a sorted array of IDs. The first element of the array is a counter for how many actual IDs are in the list. In the original back-bdb code, IDLs are sorted in ascending order. For libmdb IDLs are sorted in descending order.

Definition at line 54 of file midl.h.

Function Documentation

◆ mdb_mid2l_append()

int mdb_mid2l_append ( MDB_ID2L  ids,
MDB_ID2 id 
)

Append an ID2 into a ID2L.

Parameters
[in,out]idsThe ID2L to append into.
[in]idThe ID2 to append.
Returns
0 on success, -2 if the ID2L is too big.

◆ mdb_mid2l_insert()

int mdb_mid2l_insert ( MDB_ID2L  ids,
MDB_ID2 id 
)

Insert an ID2 into a ID2L.

Parameters
[in,out]idsThe ID2L to insert into.
[in]idThe ID2 to insert.
Returns
0 on success, -1 if the ID was already present in the ID2L.

◆ mdb_mid2l_search()

unsigned mdb_mid2l_search ( MDB_ID2L  ids,
MDB_ID  id 
)

Search for an ID in an ID2L.

Parameters
[in]idsThe ID2L to search.
[in]idThe ID to search for.
Returns
The index of the first ID2 whose mid member is greater than or equal to id.

◆ mdb_midl_alloc()

MDB_IDL mdb_midl_alloc ( int  num)

Allocate an IDL. Allocates memory for an IDL of the given size.

Returns
IDL on success, NULL on failure.

◆ mdb_midl_append()

int mdb_midl_append ( MDB_IDL idp,
MDB_ID  id 
)

Append an ID onto an IDL.

Parameters
[in,out]idpAddress of the IDL to append to.
[in]idThe ID to append.
Returns
0 on success, ENOMEM if the IDL is too large.

◆ mdb_midl_append_list()

int mdb_midl_append_list ( MDB_IDL idp,
MDB_IDL  app 
)

Append an IDL onto an IDL.

Parameters
[in,out]idpAddress of the IDL to append to.
[in]appThe IDL to append.
Returns
0 on success, ENOMEM if the IDL is too large.

◆ mdb_midl_append_range()

int mdb_midl_append_range ( MDB_IDL idp,
MDB_ID  id,
unsigned  n 
)

Append an ID range onto an IDL.

Parameters
[in,out]idpAddress of the IDL to append to.
[in]idThe lowest ID to append.
[in]nNumber of IDs to append.
Returns
0 on success, ENOMEM if the IDL is too large.

◆ mdb_midl_free()

void mdb_midl_free ( MDB_IDL  ids)

Free an IDL.

Parameters
[in]idsThe IDL to free.

◆ mdb_midl_need()

int mdb_midl_need ( MDB_IDL idp,
unsigned  num 
)

Make room for num additional elements in an IDL.

Parameters
[in,out]idpAddress of the IDL.
[in]numNumber of elements to make room for.
Returns
0 on success, ENOMEM on failure.

◆ mdb_midl_search()

unsigned mdb_midl_search ( MDB_IDL  ids,
MDB_ID  id 
)

Search for an ID in an IDL.

Parameters
[in]idsThe IDL to search.
[in]idThe ID to search for.
Returns
The index of the first ID greater than or equal to id.

◆ mdb_midl_shrink()

void mdb_midl_shrink ( MDB_IDL idp)

Shrink an IDL. Return the IDL to the default size if it has grown larger.

Parameters
[in,out]idpAddress of the IDL to shrink.

◆ mdb_midl_sort()

void mdb_midl_sort ( MDB_IDL  ids)

Sort an IDL.

Parameters
[in,out]idsThe IDL to sort.

◆ mdb_midl_xmerge()

void mdb_midl_xmerge ( MDB_IDL  idl,
MDB_IDL  merge 
)

Merge an IDL onto an IDL. The destination IDL must be big enough.

Parameters
[in]idlThe IDL to merge into.
[in]mergeThe IDL to merge.