blob: 22a7e56aac7750803ed8a9e492a170bbcb558090 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package bjc.utils.esodata;
import bjc.utils.funcdata.FunctionalMap;
import bjc.utils.funcdata.IMap;
/**
* Simple implementation of {@link Directory}.
*
* Has a split namespace for data and children.
*
* @author EVE
*
* @param <K> The key type of the directory.
* @param <V> The value type of the directory.
*/
public class SimpleDirectory<K, V> implements Directory<K, V> {
private IMap<K, Directory<K, V>> children;
private IMap<K, V> data;
/**
* Create a new directory.
*/
public SimpleDirectory() {
children = new FunctionalMap<>();
data = new FunctionalMap<>();
}
@Override
public Directory<K, V> getSubdirectory(K key) {
return children.get(key);
}
@Override
public boolean hasSubdirectory(K key) {
return children.containsKey(key);
}
@Override
public Directory<K, V> putSubdirectory(K key, Directory<K, V> val) {
return children.put(key, val);
}
@Override
public boolean containsKey(K key) {
return data.containsKey(key);
}
@Override
public V getKey(K key) {
return data.get(key);
}
@Override
public V putKey(K key, V val) {
return data.put(key, val);
}
}
|