Skip to content

Commit c371b88

Browse files
move NodeView -> MutableMutliTrie.Node.View
1 parent 8f41e21 commit c371b88

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed

enigma/src/main/java/org/quiltmc/enigma/util/multi_trie/CompositeStringMultiTrie.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private static final class Root<V> extends MutableMapNode<Character, V, Branch<V
5454

5555
private final CompositeStringMultiTrie.Branch.Factory<V> branchFactory;
5656

57-
private final NodeView<Character, V> view = new NodeView<>(this);
57+
private final View<Character, V> view = new View<>(this);
5858

5959
private Root(
6060
Map<Character, CompositeStringMultiTrie.Branch<V>> branches, Collection<V> leaves,
@@ -95,7 +95,7 @@ public static final class Branch<V> extends MutableMapNode.Branch<Character, V,
9595

9696
private final CompositeStringMultiTrie.Branch.Factory<V> branchFactory;
9797

98-
private final MultiTrie.Node<Character, V> view = new NodeView<>(this);
98+
private final MultiTrie.Node<Character, V> view = new View<>(this);
9999

100100
private Branch(
101101
MutableMapNode<Character, V, CompositeStringMultiTrie.Branch<V>> parent, char key,

enigma/src/main/java/org/quiltmc/enigma/util/multi_trie/MutableMultiTrie.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.quiltmc.enigma.util.multi_trie;
22

3+
import javax.annotation.Nonnull;
4+
import java.util.stream.Stream;
5+
36
/**
47
* A multi-trie that allows modification which can also provide unmodifiable views of its contents.
58
*
@@ -48,5 +51,34 @@ interface Node<K, V> extends MultiTrie.Node<K, V> {
4851
* @return a live, unmodifiable view of this node
4952
*/
5053
MultiTrie.Node<K, V> getView();
54+
55+
class View<K, V> implements MultiTrie.Node<K, V> {
56+
protected final Node<K, V> viewed;
57+
58+
protected View(Node<K, V> viewed) {
59+
this.viewed = viewed;
60+
}
61+
62+
@Override
63+
public Stream<V> streamLeaves() {
64+
return this.viewed.streamLeaves();
65+
}
66+
67+
@Override
68+
public Stream<V> streamStems() {
69+
return this.viewed.streamStems();
70+
}
71+
72+
@Override
73+
public Stream<V> streamValues() {
74+
return this.viewed.streamValues();
75+
}
76+
77+
@Nonnull
78+
@Override
79+
public MultiTrie.Node<K, V> next(K key) {
80+
return this.viewed.next(key).getView();
81+
}
82+
}
5183
}
5284
}

enigma/src/main/java/org/quiltmc/enigma/util/multi_trie/NodeView.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)