## CamelKeyTable CamelKeyTable |

## Synopsis

    typedef             camel_hash_t;
                        CamelPartitionKey;
                        CamelPartitionKeyBlock;
                        CamelPartitionMap;
                        CamelPartitionMapBlock;
                        CamelPartitionTable;
    CamelPartitionTable * camel_partition_table_new         (struct _CamelBlockFile *bs,
                                                             camel_block_t root);
    gint                camel_partition_table_sync          (CamelPartitionTable *cpi);
    gint                camel_partition_table_add           (CamelPartitionTable *cpi,
                                                             const gchar *key,
                                                             camel_key_t keyid);
    camel_key_t         camel_partition_table_lookup        (CamelPartitionTable *cpi,
                                                             const gchar *key);
    void                camel_partition_table_remove        (CamelPartitionTable *cpi,
                                                             const gchar *key);
                        CamelKeyBlock;
                        CamelKeyRootBlock;
    struct              CamelKeyKey;
    #define             CAMEL_KEY_TABLE_MAX_KEY
                        CamelKeyTable;
    CamelKeyTable *     camel_key_table_new                 (CamelBlockFile *bs,
                                                             camel_block_t root);
    gint                camel_key_table_sync                (CamelKeyTable *ki);
    camel_key_t         camel_key_table_add                 (CamelKeyTable *ki,
                                                             const gchar *key,
                                                             camel_block_t data,
                                                             guint flags);
    void                camel_key_table_set_data            (CamelKeyTable *ki,
                                                             camel_key_t keyid,
                                                             camel_block_t data);
    void                camel_key_table_set_flags           (CamelKeyTable *ki,
                                                             camel_key_t keyid,
                                                             guint flags,
                                                             guint set);
    camel_block_t       camel_key_table_lookup              (CamelKeyTable *ki,
                                                             camel_key_t keyid,
                                                             gchar **key,
                                                             guint *flags);
    camel_key_t         camel_key_table_next                (CamelKeyTable *ki,
                                                             camel_key_t next,
                                                             gchar **keyp,
                                                             guint *flagsp,
                                                             camel_block_t *datap);

## Description

## Details

### camel_hash_t

    typedef guint32 camel_hash_t; /* a hashed key */

### CamelPartitionKey

    typedef struct {
    	camel_hash_t hashid;
    	camel_key_t keyid;
    } CamelPartitionKey;

### CamelPartitionKeyBlock

    typedef struct {
    	guint32 used;
    	struct _CamelPartitionKey keys[(CAMEL_BLOCK_SIZE-4)/sizeof(struct _CamelPartitionKey)];
    } CamelPartitionKeyBlock;

### CamelPartitionMap

    typedef struct {
    	camel_hash_t hashid;
    	camel_block_t blockid;
    } CamelPartitionMap;

### CamelPartitionMapBlock

    typedef struct {
    	camel_block_t next;
    	guint32 used;
    	struct _CamelPartitionMap partition[(CAMEL_BLOCK_SIZE-8)/sizeof(struct _CamelPartitionMap)];
    } CamelPartitionMapBlock;

### CamelPartitionTable

    typedef struct {
    	CamelObject parent;

    	struct _CamelPartitionTablePrivate *priv;

    	CamelBlockFile *blocks;
    	camel_block_t rootid;

    	gint (*is_key)(CamelPartitionTable *cpi, const gchar *key, camel_key_t keyid, gpointer data);
    	gpointer is_key_data;

    	/* we keep a list of partition blocks active at all times */
    	CamelDList partition;
    } CamelPartitionTable;

### camel_partition_table_new ()

    CamelPartitionTable * camel_partition_table_new         (struct _CamelBlockFile *bs,
                                                             camel_block_t root);

`bs` : |
`root` : |
Returns : |

### camel_partition_table_sync ()

    gint                camel_partition_table_sync          (CamelPartitionTable *cpi);

`cpi` : |
Returns : |

### camel_partition_table_add ()

    gint                camel_partition_table_add           (CamelPartitionTable *cpi,
                                                             const gchar *key,
                                                             camel_key_t keyid);

`cpi` : |
`key` : |
`keyid` : |
Returns : |

### camel_partition_table_lookup ()

    camel_key_t         camel_partition_table_lookup        (CamelPartitionTable *cpi,
                                                             const gchar *key);

`cpi` : |
`key` : |
Returns : |

### camel_partition_table_remove ()

    void                camel_partition_table_remove        (CamelPartitionTable *cpi,
                                                             const gchar *key);

`cpi` : |
`key` : |

### CamelKeyBlock

    typedef struct {
    	camel_block_t next;
    	guint32 used;
    	union {
    		struct _CamelKeyKey keys[(CAMEL_BLOCK_SIZE-8)/sizeof(struct _CamelKeyKey)];
    		gchar keydata[CAMEL_BLOCK_SIZE-8];
    	} u;
    } CamelKeyBlock;

### CamelKeyRootBlock

    typedef struct {
    	camel_block_t first;
    	camel_block_t last;
    	camel_key_t free; /* free list */
    } CamelKeyRootBlock;

### struct CamelKeyKey

    struct CamelKeyKey {
    	camel_block_t data;
    	guint offset:10;
    	guint flags:22;
    };

### CAMEL_KEY_TABLE_MAX_KEY

    #define CAMEL_KEY_TABLE_MAX_KEY (128) /* max size of any key */

### CamelKeyTable

    typedef struct {
    	CamelObject parent;

    	struct _CamelKeyTablePrivate *priv;

    	CamelBlockFile *blocks;

    	camel_block_t rootid;

    	CamelKeyRootBlock *root;
    	CamelBlock *root_block;
    } CamelKeyTable;

### camel_key_table_new ()

    CamelKeyTable *     camel_key_table_new                 (CamelBlockFile *bs,
                                                             camel_block_t root);

`bs` : |
`root` : |
Returns : |

### camel_key_table_sync ()

    gint                camel_key_table_sync                (CamelKeyTable *ki);

`ki` : |
Returns : |

### camel_key_table_add ()

    camel_key_t         camel_key_table_add                 (CamelKeyTable *ki,
                                                             const gchar *key,
                                                             camel_block_t data,
                                                             guint flags);

`ki` : |
`key` : |
`data` : |
`flags` : |
Returns : |

### camel_key_table_set_data ()

    void                camel_key_table_set_data            (CamelKeyTable *ki,
                                                             camel_key_t keyid,
                                                             camel_block_t data);

`ki` : |
`keyid` : |
`data` : |

### camel_key_table_set_flags ()

    void                camel_key_table_set_flags           (CamelKeyTable *ki,
                                                             camel_key_t keyid,
                                                             guint flags,
                                                             guint set);

`ki` : |
`keyid` : |
`flags` : |
`set` : |

### camel_key_table_lookup ()

    camel_block_t       camel_key_table_lookup              (CamelKeyTable *ki,
                                                             camel_key_t keyid,
                                                             gchar **key,
                                                             guint *flags);

`ki` : |
`keyid` : |
`key` : |
`flags` : |
Returns : |

### camel_key_table_next ()

    camel_key_t         camel_key_table_next                (CamelKeyTable *ki,
                                                             camel_key_t next,
                                                             gchar **keyp,
                                                             guint *flagsp,
                                                             camel_block_t *datap);

`ki` : |
`next` : |
`keyp` : |
`flagsp` : |
`datap` : |
Returns : |