|
13 | 13 | * See the License for the specific language governing permissions and
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 |
| -package org.culturegraph.mf.util.tries; |
17 |
| - |
18 |
| -import java.util.Collection; |
19 |
| -import java.util.Map.Entry; |
20 |
| -import java.util.Set; |
21 |
| - |
22 |
| - |
23 |
| -/** |
24 |
| - * @author Markus Michael Geipel |
25 |
| - * |
26 |
| - * @param <P> |
27 |
| - */ |
28 |
| -final public class ACNode<P> { |
29 |
| - private P value; |
30 |
| - private final CharMap<ACNode<P>> links = new CharMap<ACNode<P>>(); |
31 |
| - private ACNode<P> failure; |
32 |
| - private final int depth; |
33 |
| - |
34 |
| - public ACNode(final P value, final int depth) { |
35 |
| - this.value = value; |
36 |
| - this.depth = depth; |
37 |
| - } |
38 |
| - |
39 |
| - public ACNode<P> addNext(final char key){ |
40 |
| - return addNext(key, null); |
41 |
| - } |
42 |
| - |
43 |
| - public ACNode<P> addNext(final char key, final P value){ |
44 |
| - final ACNode<P> next = new ACNode<P>(value, depth+1); |
45 |
| - links.put(key, next); |
46 |
| - return next; |
47 |
| - } |
48 |
| - |
49 |
| - public void setValue(final P value) { |
50 |
| - this.value = value; |
51 |
| - } |
52 |
| - |
53 |
| - public P getValue(){ |
54 |
| - return value; |
55 |
| - } |
56 |
| - |
57 |
| - public ACNode<P> getNext(final char key){ |
58 |
| - return links.get(key); |
59 |
| - } |
60 |
| - |
61 |
| - public ACNode<P> getFailure() { |
62 |
| - return failure; |
63 |
| - } |
64 |
| - |
65 |
| - public void setFailure(final ACNode<P> failure) { |
66 |
| - this.failure = failure; |
67 |
| - } |
68 |
| - |
69 |
| - public int getDepth() { |
70 |
| - return depth; |
71 |
| - } |
72 |
| - |
73 |
| - public Collection<ACNode<P>> getNext(){ |
74 |
| - return links.values(); |
75 |
| - } |
76 |
| - |
77 |
| - public Set<Entry<Character, ACNode<P>>> getLinks() { |
78 |
| - return links.entrySet(); |
79 |
| - } |
80 |
| - |
81 |
| -} |
| 16 | +package org.culturegraph.mf.util.tries; |
| 17 | + |
| 18 | +import java.util.Collection; |
| 19 | +import java.util.Map.Entry; |
| 20 | +import java.util.Set; |
| 21 | + |
| 22 | + |
| 23 | +/** |
| 24 | + * @author Markus Michael Geipel |
| 25 | + * |
| 26 | + * @param <P> |
| 27 | + */ |
| 28 | +public final class ACNode<P> { |
| 29 | + private P value; |
| 30 | + private final CharMap<ACNode<P>> links = new CharMap<ACNode<P>>(); |
| 31 | + private ACNode<P> failure; |
| 32 | + private final int depth; |
| 33 | + |
| 34 | + public ACNode(final P value, final int depth) { |
| 35 | + this.value = value; |
| 36 | + this.depth = depth; |
| 37 | + } |
| 38 | + |
| 39 | + public ACNode<P> addNext(final char key){ |
| 40 | + return addNext(key, null); |
| 41 | + } |
| 42 | + |
| 43 | + public ACNode<P> addNext(final char key, final P value){ |
| 44 | + final ACNode<P> next = new ACNode<P>(value, depth+1); |
| 45 | + links.put(key, next); |
| 46 | + return next; |
| 47 | + } |
| 48 | + |
| 49 | + public void setValue(final P value) { |
| 50 | + this.value = value; |
| 51 | + } |
| 52 | + |
| 53 | + public P getValue(){ |
| 54 | + return value; |
| 55 | + } |
| 56 | + |
| 57 | + public ACNode<P> getNext(final char key){ |
| 58 | + return links.get(key); |
| 59 | + } |
| 60 | + |
| 61 | + public ACNode<P> getFailure() { |
| 62 | + return failure; |
| 63 | + } |
| 64 | + |
| 65 | + public void setFailure(final ACNode<P> failure) { |
| 66 | + this.failure = failure; |
| 67 | + } |
| 68 | + |
| 69 | + public int getDepth() { |
| 70 | + return depth; |
| 71 | + } |
| 72 | + |
| 73 | + public Collection<ACNode<P>> getNext(){ |
| 74 | + return links.values(); |
| 75 | + } |
| 76 | + |
| 77 | + public Set<Entry<Character, ACNode<P>>> getLinks() { |
| 78 | + return links.entrySet(); |
| 79 | + } |
| 80 | + |
| 81 | +} |
0 commit comments