a dictionary of tokens More...
#include <ellipsis-tdict.h>
Public Member Functions | |
void | ellipsis‿token‿dictionary‿destroy (ellipsis‿token‿dictionary *dict) |
destroy the whole dictionary | |
token * | ellipsis‿token‿dictionary‿find (ellipsis‿token‿dictionary *dict, ellipsis‿str32 const *s) |
Find token with contents s , or return null pointer. | |
void | ellipsis‿token‿dictionary‿fputs (ellipsis‿token‿dictionary dict[static 1], FILE *, char const prefix[static 1]) |
print the whole dictionary | |
void | ellipsis‿token‿dictionary‿init (ellipsis‿token‿dictionary *const d, size_t len) |
Initialize dictionary pointed-to by D with S slots. | |
bool | ellipsis‿token‿dictionary‿insert (ellipsis‿token‿dictionary *dict, token *t) |
Insert token into dictionary. | |
void | ellipsis‿token‿dictionary‿remove (ellipsis‿token‿dictionary *dict, ellipsis‿str32 const *s) |
mark token with contents s for removal, if it exists | |
Data Fields | |
size_t | comparisons |
size_t | fibfac |
size_t | keys |
ellipsis‿token‿array * | tab |
size_t | tries |
size_t | xeys |
a dictionary of tokens
This uses the contents
member of each token as key.
Do not use any of the members directly.
This implementation uses lazy deletion to avoid quick insertion and deletion cycles of elements.
The hashing uses a Fibonacci factor that is computed on the fly for the current length of the table.
void ellipsis‿token‿dictionary‿destroy | ( | ellipsis‿token‿dictionary * | dict | ) |
destroy the whole dictionary
References ellipsis‿token‿array::array, ellipsis‿token‿array‿delete(), ellipsis‿token‿array::length, and tab.
token * ellipsis‿token‿dictionary‿find | ( | ellipsis‿token‿dictionary * | dict, |
ellipsis‿str32 const * | s | ||
) |
Find token with contents s
, or return null pointer.
References ellipsis‿token‿array::array, ellipsis‿token::cat, ellipsis‿token‿dictionary‿find_pos(), removed, and tab.
void ellipsis‿token‿dictionary‿fputs | ( | ellipsis‿token‿dictionary | dict[static 1], |
FILE * | , | ||
char const | prefix[static 1] | ||
) |
print the whole dictionary
References ellipsis‿token‿array::array, ellipsis‿token::cat, comparisons, ellipsis‿token::contents, ellipsis‿token::data, ellipsis‿str32‿fputs(), ellipsis‿token‿array‿delete(), ellipsis‿token‿what‿binary, ellipsis‿token‿what‿callback, ellipsis‿token‿what‿else, exp_signed, exp_unsigned, ellipsis‿token‿list::first, ellipsis‿token::is_functional, is_variable(), ellipsis‿token::is_what, keys, ellipsis‿token‿array::length, ellipsis‿token::next, parameter, ellipsis‿token::payload, removed, ellipsis‿token::space, stringifier, tab, tries, and ellipsis‿token::value.
void ellipsis‿token‿dictionary‿init | ( | ellipsis‿token‿dictionary *const | d, |
size_t | len | ||
) |
Initialize dictionary pointed-to by D
with S
slots.
References φ, ellipsis‿token‿dictionary‿inverse_inplace(), and ellipsis_init.
bool ellipsis‿token‿dictionary‿insert | ( | ellipsis‿token‿dictionary * | dict, |
token * | t | ||
) |
Insert token into dictionary.
Return true
if that was successful, false
if any of the arguments is null or if a token with that contents exists already.
References ellipsis‿token‿array::array, ellipsis‿token::cat, ellipsis‿token::contents, ellipsis‿error‿verb, ellipsis‿str32‿fputs(), ellipsis‿token‿dictionary‿find_pos(), ellipsis‿token‿dictionary‿maintain(), ELLIPSIS_DIAGNOSTIC, keys, removed, and tab.
void ellipsis‿token‿dictionary‿remove | ( | ellipsis‿token‿dictionary * | dict, |
ellipsis‿str32 const * | s | ||
) |
mark token with contents s
for removal, if it exists
References ellipsis‿token‿dictionary‿catch(), ELLIPSIS_CONTRACT, ellipsis‿token::is_undefinable, keys, and xeys.
size_t comparisons |
Referenced by ellipsis‿token‿dictionary‿find_pos(), and ellipsis‿token‿dictionary‿fputs().
size_t fibfac |
Referenced by ellipsis‿token‿dictionary‿find_pos(), and ellipsis‿token‿dictionary‿resize().
size_t keys |
ellipsis‿token‿array* tab |
Referenced by ellipsis‿token‿dictionary‿catch(), ellipsis‿token‿dictionary‿destroy(), ellipsis‿token‿dictionary‿find(), ellipsis‿token‿dictionary‿find_pos(), ellipsis‿token‿dictionary‿fputs(), ellipsis‿token‿dictionary‿insert(), ellipsis‿token‿dictionary‿maintain(), and ellipsis‿token‿dictionary‿resize().
size_t tries |
Referenced by ellipsis‿token‿dictionary‿find_pos(), and ellipsis‿token‿dictionary‿fputs().
size_t xeys |
Referenced by ellipsis‿token‿dictionary‿maintain(), and ellipsis‿token‿dictionary‿remove().