-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storing arbitrary byte sequences #1
Comments
Changing The amount of work should be about the same as changing the string representation from 0-terminated to length-counted. So, I think changing the type is not necessary. What really matters is |
I think binary keys should be represented with a separate set of APIs, just like how typedef struct _BinKey BinKey;
struct _BinKey {
AlphaChar *key;
int key_len;
}; with some associated functions, say: void bin_key_set (BinKey *bk, AlphaChar *key, int key_len);
void bin_key_cpy (BinKey *dst, const BinKey *src);
int bin_key_cmp (const BinKey *bk1, const BinKey *bk2);
void bin_key_destruct (BinKey *bk); // freeing the allocated *key Then, it can be used in our APIs: Bool trie_bin_retrieve (const Trie *trie, const BinKey *bin_key, TrieData *o_data);
Bool trie_bin_store (Trie *trie, const BinKey *bin_key, TrieData data);
Bool trie_bin_store_if_absent (Trie *trie, const BinKey *bin_key, TrieData data);
Bool trie_bin_delete (Trie *trie, const BinKey *bin_key);
typedef Bool (*TrieBinEnumFunc) (const BinKey *bin_key, TrieData data, void *user_data);
Bool trie_bin_enumerate (const Trie *trie, TrieBinEnumFunc enum_func, void *user_data); The |
I like the API, look forward to seeing it in the next |
I've just got some free time to work on this. And the length-counted key appears to be a bad idea, as the concept of terminating So, let's consider changing the |
Current API of
libdatrie
requires all strings to be nul-terminated. Because of this, the trie can't store arbitrary byte sequences e.g. integers.I see two ways of addressing this limitation:
unit8
touint16
forTrieChar
.The original request was submitted to the Python wrapper, see pytries/datrie#31.
The text was updated successfully, but these errors were encountered: