]>
git.ipfire.org Git - thirdparty/squid.git/blob - lib/libTrie/TrieNode.h
03d0783f0bc056b237be39d35d965ad6070cf1b3
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_TRIENODE_H
10 #define LIBTRIE_TRIENODE_H
12 #include "TrieCharTransform.h"
14 #include <sys/types.h>
17 /* TODO: parameterize this to be more generic -
18 * i.e. M-ary internal node sizes etc
27 TrieNode(TrieNode
const &);
28 TrieNode
&operator= (TrieNode
const &);
31 * If found, return the private data.
32 * If not found, return NULL.
34 inline void *find (char const *, size_t, TrieCharTransform
*, bool const prefix
) const;
37 * returns false if the string is already
38 * present or can't be added.
41 bool add (char const *, size_t, void *, TrieCharTransform
*);
45 /* The char index into internal is an
46 * 8-bit prefix to a string in the trie.
47 * internal[0] is the terminal node for
48 * a string and may not be used
50 TrieNode
* internal
[256];
52 /* If a string ends here, non NULL */
56 /* recursive. TODO? make iterative */
58 TrieNode::find (char const *aString
, size_t theLength
, TrieCharTransform
*transform
, bool const prefix
) const
62 unsigned char pos
= transform
? (*transform
) (*aString
) : *aString
;
69 result
= internal
[index
]->find(aString
+ 1, theLength
- 1, transform
, prefix
);
84 #endif /* LIBTRIE_TRIENODE_H */