Package it.unimi.dsi.util
Class TernaryIntervalSearchTree
java.lang.Object
it.unimi.dsi.fastutil.objects.AbstractObject2LongFunction<CharSequence>
it.unimi.dsi.util.AbstractPrefixMap
it.unimi.dsi.util.TernaryIntervalSearchTree
- All Implemented Interfaces:
it.unimi.dsi.fastutil.Function<CharSequence,,Long> it.unimi.dsi.fastutil.objects.Object2LongFunction<CharSequence>,PrefixMap<MutableString>,StringMap<MutableString>,Serializable,Function<CharSequence,,Long> ToLongFunction<CharSequence>
Ternary interval search trees.
Ternary search trees are a data structure used to store words over an alphabet; they are a useful alternatives to tries when the alphabet is large.
Ternary interval search trees have the additional properties of being able to locate quickly intervals of words extending a given prefix (where “quickly” means that no more successful character comparisons than the prefix length are performed). They do so by storing at each node the number of words covered by that node.
This implementation exposes a number of interfaces: in particular, the set of words is
seen as a lexicographically ordered ObjectList.
This class is mutable, but for the time it implements only add(CharSequence). Words cannot
be removed.
- See Also:
-
Field Summary
Fields inherited from class it.unimi.dsi.util.AbstractPrefixMap
list, prefixMap, rangeMapFields inherited from class it.unimi.dsi.fastutil.objects.AbstractObject2LongFunction
defRetValue -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty ternary search tree.TernaryIntervalSearchTree(Collection<? extends CharSequence> c) Creates a new empty ternary search tree and populates it with a given collection of character sequences. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(CharSequence s) booleanprotected longprotected IntervalReturns the range of strings having a given prefix.longprotected MutableStringgetTerm(int index, MutableString s) Writes a string specified by index into aMutableString.static voidintsize()Methods inherited from class it.unimi.dsi.util.AbstractPrefixMap
list, prefixMap, rangeMapMethods inherited from class it.unimi.dsi.fastutil.objects.AbstractObject2LongFunction
defaultReturnValue, defaultReturnValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface it.unimi.dsi.fastutil.Function
apply, clearMethods inherited from interface it.unimi.dsi.fastutil.objects.Object2LongFunction
andThen, andThenByte, andThenChar, andThenDouble, andThenFloat, andThenInt, andThenLong, andThenObject, andThenReference, andThenShort, applyAsLong, composeByte, composeChar, composeDouble, composeFloat, composeInt, composeLong, composeObject, composeReference, composeShort, defaultReturnValue, defaultReturnValue, get, getOrDefault, getOrDefault, put, put, remove, removeLong
-
Constructor Details
-
TernaryIntervalSearchTree
public TernaryIntervalSearchTree()Creates a new empty ternary search tree. -
TernaryIntervalSearchTree
Creates a new empty ternary search tree and populates it with a given collection of character sequences.- Parameters:
c- a collection of character sequences.
-
-
Method Details
-
getInterval
Description copied from class:AbstractPrefixMapReturns the range of strings having a given prefix.- Specified by:
getIntervalin classAbstractPrefixMap- Parameters:
s- a prefix.- Returns:
- the corresponding range of strings as an interval.
-
getApproximatedInterval
-
getTerm
Description copied from class:AbstractPrefixMapWrites a string specified by index into aMutableString.- Specified by:
getTermin classAbstractPrefixMap- Parameters:
index- the index of a string.s- a mutable string.- Returns:
string.
-
getIndex
-
containsKey
- Specified by:
containsKeyin interfaceit.unimi.dsi.fastutil.Function<CharSequence,Long>
-
getLong
- Specified by:
getLongin interfaceit.unimi.dsi.fastutil.objects.Object2LongFunction<CharSequence>
-
add
-
size
public int size()- Specified by:
sizein interfaceit.unimi.dsi.fastutil.Function<CharSequence,Long>
-
main
public static void main(String[] arg) throws IOException, com.martiansoftware.jsap.JSAPException, NoSuchMethodException - Throws:
IOExceptioncom.martiansoftware.jsap.JSAPExceptionNoSuchMethodException
-