it.unimi.dsi.mg4j.util
Class ImmutableTriePrefixTree

java.lang.Object
  extended by it.unimi.dsi.mg4j.util.ImmutableBinaryTrie
      extended by it.unimi.dsi.mg4j.util.ImmutableTriePrefixTree
All Implemented Interfaces:
PrefixMap, TermMap, ImmutableExternalPrefixDictionary.IntervalApproximator, Serializable

Deprecated. Moved to dsiutils.

@Deprecated
public class ImmutableTriePrefixTree
extends ImmutableBinaryTrie
implements TermMap, PrefixMap, ImmutableExternalPrefixDictionary.IntervalApproximator

A class adapter from immutable binary tries to prefix trees.

Instances of this class map transparently strings into a binary trie. For this to happen, however, the character-to-symbol map provided at construction time must contain all characters with which the trie will be ever queried.

Depending on the default return value of the map, character sequences containing extraneous characters will cause an IndexOutOfBoundsException, or will behave as if the extraneous characters are mapped to the symbol returned as default value.

This class implements both TermMap, and PrefixMap, albeit no optional operation is supported.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class it.unimi.dsi.mg4j.util.ImmutableBinaryTrie
ImmutableBinaryTrie.Node
 
Field Summary
static long serialVersionUID
          Deprecated.  
 
Fields inherited from class it.unimi.dsi.mg4j.util.ImmutableBinaryTrie
root
 
Constructor Summary
ImmutableTriePrefixTree(List<? extends CharSequence> words, PrefixCoder prefixCoder, Char2IntMap char2symbol)
          Deprecated. Creates a new prefix tree.
 
Method Summary
 Interval getApproximatedInterval(CharSequence word)
          Deprecated. Returns an approximated prefix interval around the specified word.
 int getIndex(CharSequence s)
          Deprecated. 
 Interval getInterval(CharSequence prefix)
          Deprecated. Returns the interval of terms starting with the given prefix.
 int getNumber(CharSequence term)
          Deprecated. Returns the ordinal number corresponding to the given term, or possibly (but not necessarily) -1 if the term was not indexed.
 CharSequence getPrefix(Interval interval)
          Deprecated. Returns the maximum prefix common to all terms in the given nonempty interval (optional operation).
 MutableString getPrefix(Interval interval, MutableString prefix)
          Deprecated. Writes in the given mutable string the maximum prefix common to all terms in the given nonempty interval (optional operation).
 CharSequence getTerm(int index)
          Deprecated. Returns the term corresponding to the given ordinal number (optional operation).
 MutableString getTerm(int index, MutableString term)
          Deprecated. Writes in the given mutable string the term corresponding to the given ordinal number (optional operation).
 boolean hasPrefixes()
          Deprecated. Returns true if this prefix map supports prefix retrieval.
 boolean hasTerms()
          Deprecated. Returns true if this prefix map supports term retrieval.
 
Methods inherited from class it.unimi.dsi.mg4j.util.ImmutableBinaryTrie
get, get, getApproximatedInterval, getApproximatedInterval, getInterval, getInterval, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.mg4j.index.TermMap
size
 
Methods inherited from interface it.unimi.dsi.mg4j.index.PrefixMap
size
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Deprecated. 
See Also:
Constant Field Values
Constructor Detail

ImmutableTriePrefixTree

public ImmutableTriePrefixTree(List<? extends CharSequence> words,
                               PrefixCoder prefixCoder,
                               Char2IntMap char2symbol)
Deprecated. 
Creates a new prefix tree.

Parameters:
words - a lexicographically ordered list of words.
prefixCoder - a (lexicographic-order preserving) coder used to encoding words.
char2symbol - the map from characters to symbols in the coder.
Method Detail

getApproximatedInterval

public Interval getApproximatedInterval(CharSequence word)
Deprecated. 
Description copied from interface: ImmutableExternalPrefixDictionary.IntervalApproximator
Returns an approximated prefix interval around the specified word.

Specified by:
getApproximatedInterval in interface ImmutableExternalPrefixDictionary.IntervalApproximator
Parameters:
word - a word.
Returns:
an approximated prefix interval for word

getIndex

@Deprecated
public int getIndex(CharSequence s)
Deprecated. 


getNumber

public int getNumber(CharSequence term)
Deprecated. 
Description copied from interface: TermMap
Returns the ordinal number corresponding to the given term, or possibly (but not necessarily) -1 if the term was not indexed.

We intentionally prefer “ordinal number” to “index” because of the obvious confusion that the latter term can cause.

Specified by:
getNumber in interface TermMap
Parameters:
term - a term.
Returns:
its ordinal number, or possibly (but not necessarily) -1 if the term was not indexed.

getTerm

public CharSequence getTerm(int index)
Deprecated. 
Description copied from interface: TermMap
Returns the term corresponding to the given ordinal number (optional operation).

Specified by:
getTerm in interface TermMap
Parameters:
index - a term ordinal number.
Returns:
the corresponding term, or possibly (but not necessarily) null if the term was not indexed.

getTerm

public MutableString getTerm(int index,
                             MutableString term)
Deprecated. 
Description copied from interface: TermMap
Writes in the given mutable string the term corresponding to the given ordinal number (optional operation).

Specified by:
getTerm in interface TermMap
Parameters:
index - a term ordinal number.
term - a mutable string that will be filled with the corresponding term.
Returns:
term, or possibly (but not necessarily) null if the term was not indexed.

getInterval

public Interval getInterval(CharSequence prefix)
Deprecated. 
Description copied from interface: PrefixMap
Returns the interval of terms starting with the given prefix.

Specified by:
getInterval in interface PrefixMap
Parameters:
prefix - a prefix.
Returns:
the interval of terms starting with prefix (Intervals.EMPTY_INTERVAL in case no term starts with prefix).

getPrefix

public CharSequence getPrefix(Interval interval)
Deprecated. 
Description copied from interface: PrefixMap
Returns the maximum prefix common to all terms in the given nonempty interval (optional operation).

Specified by:
getPrefix in interface PrefixMap
Parameters:
interval - an interval.
Returns:
the maximum prefix common to all terms in the given nonempty interval.

getPrefix

public MutableString getPrefix(Interval interval,
                               MutableString prefix)
Deprecated. 
Description copied from interface: PrefixMap
Writes in the given mutable string the maximum prefix common to all terms in the given nonempty interval (optional operation).

Specified by:
getPrefix in interface PrefixMap
Parameters:
interval - an interval.
prefix - a mutable string that will be filled with the maximum prefix common to all terms in the given nonempty interval.
Returns:
prefix.

hasTerms

public boolean hasTerms()
Deprecated. 
Description copied from interface: TermMap
Returns true if this prefix map supports term retrieval.

Specified by:
hasTerms in interface TermMap
Returns:
true if this prefix map supports term retrieval.

hasPrefixes

public boolean hasPrefixes()
Deprecated. 
Description copied from interface: PrefixMap
Returns true if this prefix map supports prefix retrieval.

Specified by:
hasPrefixes in interface PrefixMap
Returns:
true if this prefix map supports prefix retrieval.