"Fossies" - the Fresh Open Source Software Archive

Member "mlr-5.6.2/c/containers/lhmslv.h" (25 Aug 2019, 1483 Bytes) of package /linux/misc/mlr-5.6.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "lhmslv.h" see the Fossies "Dox" file reference documentation.

    1 // ================================================================
    2 // Array-only (open addressing) string-list-to-void-star linked hash map with
    3 // linear probing for collisions.
    4 //
    5 // John Kerl 2014-12-22
    6 //
    7 // Notes:
    8 // * null key is not supported.
    9 // * null value is supported.
   10 //
   11 // See also:
   12 // * http://en.wikipedia.org/wiki/Hash_table
   13 // * http://docs.oracle.com/javase/6/docs/api/java/util/Map.html
   14 // ================================================================
   15 
   16 #ifndef LHMSLV_H
   17 #define LHMSLV_H
   18 
   19 #include "containers/slls.h"
   20 
   21 // ----------------------------------------------------------------
   22 typedef struct _lhmslve_t {
   23     int     ideal_index;
   24     slls_t* key;
   25     void*   pvvalue;
   26     char    free_flags;
   27     struct _lhmslve_t *pprev;
   28     struct _lhmslve_t *pnext;
   29 } lhmslve_t;
   30 
   31 typedef unsigned char lhmslve_state_t;
   32 
   33 // ----------------------------------------------------------------
   34 typedef struct _lhmslv_t {
   35     int              num_occupied;
   36     int              num_freed;
   37     int              array_length;
   38     lhmslve_t*       entries;
   39     lhmslve_state_t* states;
   40     lhmslve_t*       phead;
   41     lhmslve_t*       ptail;
   42 } lhmslv_t;
   43 
   44 lhmslv_t* lhmslv_alloc();
   45 void   lhmslv_free(lhmslv_t* pmap);
   46 void*  lhmslv_put(lhmslv_t* pmap, slls_t* key, void* pvvalue, char free_flags);
   47 void*  lhmslv_get(lhmslv_t* pmap, slls_t* key);
   48 int    lhmslv_has_key(lhmslv_t* pmap, slls_t* key);
   49 int    lhmslv_size(lhmslv_t* pmap);
   50 
   51 // Unit-test hook
   52 int lhmslv_check_counts(lhmslv_t* pmap);
   53 
   54 #endif // LHMSLV_H