All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.metafacture.commons.tries.ACNode Maven / Gradle / Ivy

/*
 * Copyright 2013, 2014 Deutsche Nationalbibliothek
 *
 * Licensed under the Apache License, Version 2.0 the "License";
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.metafacture.commons.tries;

import java.util.Collection;
import java.util.Map.Entry;
import java.util.Set;

/**
 * Node representing a character in a trie.
 *
 * @param 

type of the value associated with this node in the trie. * @author Markus Michael Geipel */ final class ACNode

{ private P value; private final CharMap> links = new CharMap>(); private ACNode

failure; private final int depth; ACNode(final P value, final int depth) { this.value = value; this.depth = depth; } ACNode

addNext(final char key) { return addNext(key, null); } ACNode

addNext(final char key, final P currentValue) { final ACNode

next = new ACNode

(currentValue, depth + 1); links.put(key, next); return next; } void setValue(final P value) { this.value = value; } P getValue() { return value; } ACNode

getNext(final char key) { return links.get(key); } Collection> getNext() { return links.values(); } ACNode

getFailure() { return failure; } void setFailure(final ACNode

failure) { this.failure = failure; } int getDepth() { return depth; } Set>> getLinks() { return links.entrySet(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy