diff options
| author | EVE <EVE@EVE-PC> | 2017-03-14 12:06:43 -0400 |
|---|---|---|
| committer | EVE <EVE@EVE-PC> | 2017-03-14 12:06:43 -0400 |
| commit | 5c1163df17c46f7d3e15b6c7949c38843ec56146 (patch) | |
| tree | a2db3f0519181e5b6a1486d3129de8398babcd95 /BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java | |
| parent | 27bf571d6413c3cc6a5d664b5bddd38d21d7b1cd (diff) | |
Directory work
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java new file mode 100644 index 0000000..22a7e56 --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/SimpleDirectory.java @@ -0,0 +1,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); + } +}
\ No newline at end of file |
