choco.kernel.memory.trailing
Class StoredBinaryTree

java.lang.Object
  extended by choco.kernel.memory.trailing.StoredBinaryTree
All Implemented Interfaces:
IStateBinaryTree

public final class StoredBinaryTree
extends Object
implements IStateBinaryTree

Created by IntelliJ IDEA. User: julien Date: Apr 24, 2008 Time: 1:27:38 PM


Nested Class Summary
protected static class StoredBinaryTree.TreeIterator
           
 
Nested classes/interfaces inherited from interface choco.kernel.memory.IStateBinaryTree
IStateBinaryTree.Node
 
Field Summary
protected  StoredBinaryTreeTrail myTrail
           
 
Fields inherited from interface choco.kernel.memory.IStateBinaryTree
ADD, INF, LOGGER, REM, SUP
 
Constructor Summary
StoredBinaryTree(EnvironmentTrailing anEnvironment, int a, int b)
           
 
Method Summary
 void add(int a, int b)
          add a new interval [a,b] in the tree
 void add(IStateBinaryTree.Node n)
          Add a node in the tree
 void add(IStateBinaryTree.Node n, boolean save)
          Add a node in the tree and save the operation if requested
 IStateBinaryTree.Node find(int value)
          finds the node which contains the given value
 EnvironmentTrailing getEnvironment()
          Gets the Environment associated with this tree
 IStateBinaryTree.Node getFirstNode()
          Gets the node containing the lowest value in the tree
 DisposableIntIterator getIterator()
          gets an iterator over the value in the tree
 IStateBinaryTree.Node getLastNode()
          Gets the node containing the greatest value in the tree
 IStateBinaryTree.Node getRoot()
          Gets the root of the tree
 int getSize()
          Computes the size of the tree i.e. the number of value contained in the tree
 IStateBinaryTree.Node nextNode(int value)
          gets the node that contains the next integer in the tree
 IStateBinaryTree.Node nextNode(IStateBinaryTree.Node n)
          gets the next node of the given one
 IStateBinaryTree.Node prevNode(int value)
          gets the node that contains the previous integer in the tree
 IStateBinaryTree.Node prevNode(IStateBinaryTree.Node n)
          gets the previous node of the given one
static void print(IStateBinaryTree b)
           
 boolean remove(int value)
          Remove the given value from the tree i.e. updates the tree so that contains(value) would return false;
 void remove(IStateBinaryTree.Node n)
          Remove a node from the tree
 void remove(IStateBinaryTree.Node n, boolean save)
          Remove a node from the tree, and save the operation if requested
 String toDotty()
          get the tree in dot format
 String toDotty(IStateBinaryTree.Node n)
           
 List<IStateBinaryTree.Node> toList()
           
 String toListString()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myTrail

protected final StoredBinaryTreeTrail myTrail
Constructor Detail

StoredBinaryTree

public StoredBinaryTree(EnvironmentTrailing anEnvironment,
                        int a,
                        int b)
Method Detail

getSize

public int getSize()
Description copied from interface: IStateBinaryTree
Computes the size of the tree i.e. the number of value contained in the tree

Specified by:
getSize in interface IStateBinaryTree
Returns:
integer value of the size

find

public IStateBinaryTree.Node find(int value)
Description copied from interface: IStateBinaryTree
finds the node which contains the given value

Specified by:
find in interface IStateBinaryTree
Parameters:
value - the value to be found
Returns:
the node which contains the value, null otherwise

nextNode

public IStateBinaryTree.Node nextNode(int value)
Description copied from interface: IStateBinaryTree
gets the node that contains the next integer in the tree

Specified by:
nextNode in interface IStateBinaryTree
Parameters:
value - the value whose next is to be searched
Returns:
the node containing the next value

prevNode

public IStateBinaryTree.Node prevNode(int value)
Description copied from interface: IStateBinaryTree
gets the node that contains the previous integer in the tree

Specified by:
prevNode in interface IStateBinaryTree
Parameters:
value - the value whose previous is to be searched
Returns:
the node containing the previous value

add

public void add(IStateBinaryTree.Node n)
Description copied from interface: IStateBinaryTree
Add a node in the tree

Specified by:
add in interface IStateBinaryTree
Parameters:
n - the node to be added

remove

public void remove(IStateBinaryTree.Node n)
Description copied from interface: IStateBinaryTree
Remove a node from the tree

Specified by:
remove in interface IStateBinaryTree
Parameters:
n - the node to be removed;

remove

public void remove(IStateBinaryTree.Node n,
                   boolean save)
Description copied from interface: IStateBinaryTree
Remove a node from the tree, and save the operation if requested

Specified by:
remove in interface IStateBinaryTree
Parameters:
n - the node to be removed
save - true if the removal is to be stacked in the trail

add

public void add(int a,
                int b)
Description copied from interface: IStateBinaryTree
add a new interval [a,b] in the tree

Specified by:
add in interface IStateBinaryTree
Parameters:
a - the lower bound
b - the upper bound

add

public void add(IStateBinaryTree.Node n,
                boolean save)
Description copied from interface: IStateBinaryTree
Add a node in the tree and save the operation if requested

Specified by:
add in interface IStateBinaryTree
Parameters:
n - the node to be added
save - true id the addition is to be stacked in the trail

getRoot

public IStateBinaryTree.Node getRoot()
Description copied from interface: IStateBinaryTree
Gets the root of the tree

Specified by:
getRoot in interface IStateBinaryTree
Returns:
the root node of the tree

prevNode

public IStateBinaryTree.Node prevNode(IStateBinaryTree.Node n)
Description copied from interface: IStateBinaryTree
gets the previous node of the given one

Specified by:
prevNode in interface IStateBinaryTree
Parameters:
n - the reference node
Returns:
the previous node in the lexicographic order

nextNode

public IStateBinaryTree.Node nextNode(IStateBinaryTree.Node n)
Description copied from interface: IStateBinaryTree
gets the next node of the given one

Specified by:
nextNode in interface IStateBinaryTree
Parameters:
n - the reference node
Returns:
the next node in the lexicographic order

remove

public boolean remove(int value)
Description copied from interface: IStateBinaryTree
Remove the given value from the tree i.e. updates the tree so that contains(value) would return false;

Specified by:
remove in interface IStateBinaryTree
Parameters:
value - the value to be removed
Returns:
true if the value was in the domain, false otherwise

getEnvironment

public EnvironmentTrailing getEnvironment()
Description copied from interface: IStateBinaryTree
Gets the Environment associated with this tree

Specified by:
getEnvironment in interface IStateBinaryTree
Returns:
the environment associated with this tree

getFirstNode

public IStateBinaryTree.Node getFirstNode()
Description copied from interface: IStateBinaryTree
Gets the node containing the lowest value in the tree

Specified by:
getFirstNode in interface IStateBinaryTree
Returns:
first node in the tree

getLastNode

public IStateBinaryTree.Node getLastNode()
Description copied from interface: IStateBinaryTree
Gets the node containing the greatest value in the tree

Specified by:
getLastNode in interface IStateBinaryTree
Returns:
last node in the tree

toString

public String toString()
Specified by:
toString in interface IStateBinaryTree
Overrides:
toString in class Object

toList

public List<IStateBinaryTree.Node> toList()

toListString

public String toListString()

getIterator

public final DisposableIntIterator getIterator()
Description copied from interface: IStateBinaryTree
gets an iterator over the value in the tree

Specified by:
getIterator in interface IStateBinaryTree
Returns:
an TreeIterator implementing IntIterator

toDotty

public String toDotty()
Description copied from interface: IStateBinaryTree
get the tree in dot format

Specified by:
toDotty in interface IStateBinaryTree
Returns:
a string

toDotty

public String toDotty(IStateBinaryTree.Node n)

print

public static void print(IStateBinaryTree b)


Copyright © 2012. All Rights Reserved.