]>
git.ipfire.org Git - thirdparty/squid.git/blob - lib/libTrie/Trie.h
d0d433f07aeeb8a90b10aeac49193bc182ab6b42
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef LIBTRIE_SQUID_H
10 #define LIBTRIE_SQUID_H
14 #include <sys/types.h>
17 class TrieCharTransform
;
19 /* TODO: parameterize this to be more generic -
20 * i.e. M-ary internal node sizes etc
27 Trie(TrieCharTransform
*aTransform
= 0);
30 Trie
&operator= (Trie
const &);
32 /* Find an exact match in the trie.
33 * If found, return the private data.
34 * If not found, return NULL.
36 inline void *find (char const *, size_t);
37 /* find any element of the trie in the buffer from the
40 inline void *findPrefix (char const *, size_t);
43 * returns false if the string is already
44 * present or cannot be added.
47 bool add(char const *, size_t, void *);
52 /* transfor each 8 bits in the element */
53 TrieCharTransform
*transform
;
57 Trie::find (char const *aString
, size_t theLength
)
60 return head
->find (aString
, theLength
, transform
, false);
66 Trie::findPrefix (char const *aString
, size_t theLength
)
69 return head
->find (aString
, theLength
, transform
, true);
74 #endif /* LIBTRIE_SQUID_H */