Package org.jacop.jasat.utils.structures
Class IntTrie<N extends IntTrie.Node<N>>
java.lang.Object
org.jacop.jasat.utils.structures.IntTrie<N>
- Type Parameters:
N
- the type of the nodes of the Trie
- Direct Known Subclasses:
IntSet
A class that implements, (hopefully) efficiently, a Trie on integers. It is
parametrized by the type of the nodes to carry useful data.
implementation based on Trie (or Radix Tree, see
http://en.wikipedia.org/wiki/Radix_tree).
It can be used directly as a (simple) set.
- Version:
- 4.8
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
class of nodes of the Trie.static final class
The most simple node possible -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal N
add
(int i) add i to the Triefinal void
clear()
empty the Trie, removing all elements from itfinal boolean
contains
(int i) does the Trie contains i ?final N
getNode
(int i) get the node associated with i, or maybe the node that would be associated with i if i was in the Trie (*optional* feature)final N
getRoot()
final boolean
isEmpty()
final boolean
remove
(int i) remove the int i.final int
size()
values()
-
Field Details
-
root
-
size
private int size
-
-
Constructor Details
-
IntTrie
initializes the Trie with a root node- Parameters:
root
- the root node.
-
-
Method Details
-
add
add i to the Trie- Parameters:
i
- the int to add to the Trie- Returns:
- the node corresponding to i
-
contains
public final boolean contains(int i) does the Trie contains i ?- Parameters:
i
- the int- Returns:
- true if the Trie contains i, false otherwise
-
getNode
get the node associated with i, or maybe the node that would be associated with i if i was in the Trie (*optional* feature)- Parameters:
i
- the int- Returns:
- the node associated with i if it exists, null otherwise
-
getRoot
- Returns:
- the root node
-
remove
public final boolean remove(int i) remove the int i.- Parameters:
i
- the int to remove from the Trie- Returns:
- true if i was in the Trie (and has been removed), false if it was not
-
clear
public final void clear()empty the Trie, removing all elements from it -
isEmpty
public final boolean isEmpty()- Returns:
- true if and only if the trie does not contain anything
-
size
public final int size()- Returns:
- the number of elements in the Trie
-
values
- Returns:
- the set of values that the Trie contains (quite inefficient)
-