1 /*
2  * Hunt - A refined core library for D programming language.
3  *
4  * Copyright (C) 2018-2019 HuntLabs
5  *
6  * Website: https://www.huntlabs.net/
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 module hunt.collection.AbstractTrie;
13 
14 import hunt.io.ByteBuffer;
15 import hunt.collection.Set;
16 import hunt.collection.Trie;
17 
18 import hunt.Exceptions;
19 import std.conv;
20 
21 abstract class AbstractTrie(V) : Trie!(V) {
22     private bool _caseInsensitive;
23 
24     protected this(bool insensitive) {
25         _caseInsensitive = insensitive;
26     }
27 
28     bool put(string s, V v) {
29         implementationMissing(false);
30         return false;
31     }
32     
33     bool put(V v) {
34         return put(v.to!string(), v);
35     }
36 
37     
38     V remove(string s) {
39         V o = get(s);
40         put(s, V.init);
41         return o;
42     }
43 
44     
45     V get(string s) {
46         return get(s, 0, cast(int)s.length);
47     }
48 
49     V get(string s, int offset, int len) {
50         implementationMissing(false);
51         return V.init;
52     }
53     
54     V get(ByteBuffer b) {
55         return get(b, 0, b.remaining());
56     }
57 
58     V get(ByteBuffer b, int offset, int len) {
59         implementationMissing(false);
60         return V.init;
61     }
62     
63     V getBest(string s) {
64         return getBest(s, 0, cast(int)s.length);
65     }
66 
67     V getBest(string s, int offset, int len) {
68         implementationMissing(false);
69         return V.init;
70     }
71     
72     V getBest(byte[] b, int offset, int len) {
73         return getBest(cast(string)(b[offset .. offset + len]));
74     }
75 
76     V getBest(ByteBuffer b, int offset, int len) {
77         implementationMissing(false);
78         return V.init;
79     }
80 
81     Set!string keySet() {
82         implementationMissing(false);
83         return null;
84     }
85 
86     bool isFull() {        
87         implementationMissing(false);
88         return false;
89     }
90     
91     bool isCaseInsensitive() {
92         return _caseInsensitive;
93     }
94 
95     void clear() {
96         implementationMissing(false);
97     }
98 }