1818import java .util .ArrayList ;
1919import java .util .Collections ;
2020import java .util .HashSet ;
21+ import java .util .LinkedHashSet ;
22+ import java .util .LinkedList ;
2123import java .util .List ;
2224import java .util .Set ;
2325import java .util .regex .Pattern ;
2628 * A simple Trie, which accepts a trailing wildcard
2729 *
2830 * @author Markus Michael Geipel
31+ * @author Pascal Christoph
2932 *
3033 * @param <P>
3134 * type of value stored
@@ -77,7 +80,6 @@ private void simplyPut(final String key, final P value) {
7780
7881 public List <P > get (final String key ) {
7982
80-
8183 nodes .add (root );
8284 final int length = key .length ();
8385 for (int i = 0 ; i < length ; ++i ) {
@@ -130,7 +132,7 @@ public List<P> get(final String key) {
130132 */
131133 private final class Node <T > {
132134
133- private List <T > values = Collections . emptyList ();
135+ private LinkedHashSet <T > values = new LinkedHashSet < T > ();
134136 private final CharMap <Node <T >> links = new CharMap <Node <T >>();
135137
136138 protected Node () {
@@ -143,19 +145,18 @@ public Node<T> addNext(final char key) {
143145 if (key == STAR_WILDCARD ) {
144146 next .links .put (STAR_WILDCARD , next );
145147 }
146-
147148 return next ;
148149 }
149150
150151 public void addValue (final T value ) {
151152 if (values == Collections .emptyList ()) {
152- values = new ArrayList <T >();
153+ values = new LinkedHashSet <T >();
153154 }
154155 this .values .add (value );
155156 }
156157
157158 public List <T > getValues () {
158- return values ;
159+ return new LinkedList < T >( values ) ;
159160 }
160161
161162 public Node <T > getNext (final char key ) {
0 commit comments