21#ifndef INCLUDED_SETTRIE
22#define INCLUDED_SETTRIE
31#define IMAGE_BUFF_SIZE 6136
34#define STATE_HAS_SET_ID 1
35#define STATE_IS_GARBAGE 2
50typedef std::map<int, String>
IdMap;
106 if (tree[idx].idx_child == 0) {
109 tree.push_back(node);
111 int idx_c = tree.size() - 1;
113 tree[idx].idx_child = idx_c;
118 idx = tree[idx].idx_child;
121 if (tree[idx].value == value)
124 if (tree[idx].idx_next == 0) {
127 tree.push_back(node);
129 int idx_c = tree.size() - 1;
131 tree[idx].idx_next = idx_c;
136 idx = tree[idx].idx_next;
143 int size = set.size();
151 for (
int i = 0; i < size; i++)
152 idx =
insert(idx, set[i]);
161 if ((idx = tree[idx].idx_child) == 0)
165 if (tree[idx].value == value)
168 if ((idx = tree[idx].idx_next) == 0)
176 int size = set.size();
178 for (
int i = 0; i < size; i++)
179 if ((idx =
find(idx, set[i])) == 0)
185 inline void all_supersets(
int t_idx) {
189 result.push_back(t_idx);
191 if (
int ci = tree[t_idx].idx_child)
194 t_idx = tree[t_idx].idx_next;
198 inline void supersets(
int t_idx,
int s_idx) {
205 if ((t_value = tree[t_idx].value) == (q_value = query[s_idx])) {
206 if (s_idx == last_query_idx) {
209 result.push_back(t_idx);
211 if (
int ci = tree[t_idx].idx_child)
216 q_value = query[s_idx + 1];
221 if (t_value < q_value && (ni = tree[t_idx].idx_child) != 0)
224 t_idx = tree[t_idx].idx_next;
228 inline void subsets(
int t_idx,
int s_idx) {
232 if ((t_value = tree[t_idx].value) >= query[s_idx]) {
235 while (ns_idx < last_query_idx && query[ns_idx] < t_value)
238 if (query[ns_idx] == t_value) {
240 result.push_back(t_idx);
243 if ((ni = tree[t_idx].idx_child) != 0) {
246 if (ns_idx <= last_query_idx)
252 t_idx = tree[t_idx].idx_next;
257 StringName::iterator it = hh_nam.find(hh);
259 if (it == hh_nam.end()) {
260 hh_nam[hh].count = 1;
261 hh_nam[hh].name = name; }
String find(StringSet set)
Definition: settrie.cpp:215
int remove(int idx)
Definition: settrie.cpp:387
StringSet subsets(StringSet set)
Definition: settrie.cpp:314
bool save(pBinaryImage &p_bi)
Definition: settrie.cpp:605
int num_dirty_nodes
Definition: settrie.h:98
void insert(StringSet set, String id)
Definition: settrie.cpp:173
SetTrie()
Definition: settrie.h:77
StringSet elements(int idx)
Definition: settrie.cpp:365
int purge()
Definition: settrie.cpp:451
StringSet supersets(StringSet set)
Definition: settrie.cpp:260
bool load(pBinaryImage &p_bi)
Definition: settrie.cpp:490
#define STATE_IN_USE
Definition: settrie.h:33
uint64_t ElementHash
Definition: settrie.h:37
BinaryImage * pBinaryImage
Definition: settrie.h:70
std::map< int, String > IdMap
Definition: settrie.h:50
std::vector< SetNode > BinaryTree
Definition: settrie.h:60
std::vector< String > StringSet
Definition: settrie.h:41
std::map< ElementHash, Name > StringName
Definition: settrie.h:49
#define IMAGE_BUFF_SIZE
Definition: settrie.h:31
std::vector< ImageBlock > BinaryImage
Definition: settrie.h:69
#define STATE_HAS_SET_ID
Definition: settrie.h:34
std::vector< ElementHash > BinarySet
Definition: settrie.h:40
std::vector< int > IdList
Definition: settrie.h:42
std::string String
Definition: settrie.h:38
int size
Definition: settrie.h:64
uint8_t buffer[IMAGE_BUFF_SIZE]
Definition: settrie.h:66
int block_num
Definition: settrie.h:64
int count
Definition: settrie.h:46
String name
Definition: settrie.h:45
int idx_child
Definition: settrie.h:55
int idx_parent
Definition: settrie.h:55
int idx_next
Definition: settrie.h:55
ElementHash value
Definition: settrie.h:53
uint8_t state
Definition: settrie.h:57