summaryrefslogtreecommitdiffstats
path: root/index.h
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2018-09-21 22:58:08 +0200
committerpgen <p.gen.progs@gmail.com>2018-10-01 19:36:56 +0200
commitcd5ad5c056b6e8f3121adc886e8e7f5daeca6010 (patch)
tree192ce32038ca0748b7f35470e73cc3281402e332 /index.h
parent1389f08f47ee829b48e7db743da66cc14c96f95f (diff)
Start splitting the code into different files
Diffstat (limited to 'index.h')
-rw-r--r--index.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/index.h b/index.h
new file mode 100644
index 0000000..e1fc7ae
--- /dev/null
+++ b/index.h
@@ -0,0 +1,64 @@
+#ifndef TST_H
+#define TST_H
+
+/* *************************************** */
+/* Ternary Search Tree specific structures */
+/* *************************************** */
+
+typedef struct tst_node_s tst_node_t;
+typedef struct sub_tst_s sub_tst_t;
+
+#if 0 /* here for coherency but not used. */
+void tst_cleanup(tst_node_t * p);
+#endif
+
+tst_node_t *
+tst_insert(tst_node_t * p, wchar_t * w, void * data);
+
+void *
+tst_prefix_search(tst_node_t * root, wchar_t * w, int (*callback)(void *));
+
+void *
+tst_search(tst_node_t * root, wchar_t * w);
+
+int
+tst_traverse(tst_node_t * p, int (*callback)(void *), int first_call);
+
+int
+tst_substring_traverse(tst_node_t * p, int (*callback)(void *), int first_call,
+ wchar_t w);
+int
+tst_fuzzy_traverse(tst_node_t * p, int (*callback)(void *), int first_call,
+ wchar_t w);
+
+sub_tst_t *
+sub_tst_new(void);
+
+void
+insert_sorted_index(long ** array, long * size, long * filled, long value);
+
+void
+insert_sorted_ptr(tst_node_t *** array, unsigned long long * size,
+ unsigned long long * filled, tst_node_t * ptr);
+
+/* Ternary node structure */
+/* """""""""""""""""""""" */
+struct tst_node_s
+{
+ wchar_t splitchar;
+
+ tst_node_t *lokid, *eqkid, *hikid;
+ void * data;
+};
+
+/* Structure to contain data and metadata attached to a fuzzy/substring. */
+/* search step. */
+/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
+struct sub_tst_s
+{
+ tst_node_t ** array;
+ unsigned long long size;
+ unsigned long long count;
+};
+
+#endif