gishur.core
Class BinarySearchTree

java.lang.Object
  |
  +--gishur.core.BasicTree
        |
        +--gishur.core.BinarySearchTree
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, ControlledCloneable, Owner, java.io.Serializable
Direct Known Subclasses:
RedBlackTree

public class BinarySearchTree
extends BasicTree
implements ControlledCloneable

A binary search tree based upon BasicTree. To ensure that the tree is ordered, a BinarySearchTree-object needs a Comparitor when being constructed. Only objects comparable with the specified Comparitor should be stored in the tree, otherwise there will somewhen occur a CompareException. If the empty constructor BinarySearchTree() is called, a StdComparitor is created and used.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Fields inherited from class gishur.core.BasicTree
_access, ANY_ACCESS, CHILDS_ROOT_ORDER, KEY, LEFT_RIGHT_ROOT_ORDER, LEFT_ROOT_RIGHT_ORDER, NO_ACCESS, ROOT_CHILDS_ORDER, ROOT_LEFT_RIGHT_ORDER, TREEITEM, VALUE
 
Fields inherited from interface gishur.core.ControlledCloneable
DEEP, FLAT
 
Constructor Summary
BinarySearchTree()
          Empty constructor.
BinarySearchTree(Comparitor comparitor)
          Standard constructor.
BinarySearchTree(Comparitor comparitor, boolean left_is_smaller)
          Constructs a BinarySearchTree using the Comparitor comparitor and the definition whether smaller keys shall be sorted to the left or to the right side of the tree.
 
Method Summary
protected  TreeItem add_item(TreeItem item)
          Inserts a new TreeItem into the tree.
 TreeItem add(boolean n)
          add for boolean.
 TreeItem add(double n)
          add for double.
 TreeItem add(float n)
          add for float.
 TreeItem add(int n)
          add for int.
 TreeItem add(long n)
          add for long.
 TreeItem add(java.lang.Object key)
          Inserts a newly generated TreeItem with key key into the tree at the right place.
 TreeItem add(java.lang.Object key, java.lang.Object value)
          Inserts a newly generated TreeItem with key and valueinto the tree at the right place.
 TreeItem add(TreeItem item)
          Inserts the TreeItem item at the right place into the tree.
 void afterAdd(TreeItem item)
          Is called after a TreeItem has been inserted into the tree.
 void afterRemove(TreeItem item)
          Is called after a TreeItem has been removed from the tree.
 boolean allowDuplicates()
          Returns true, if this tree allows elements with equal keys.
 void beforeAdd(TreeItem item)
          Is called before a TreeItem is inserted into the tree.
 void beforeRemove(TreeItem item)
          Is called before a TreeItem is removed from the tree.
 void clear()
          Erases the whole tree.
 java.lang.Object clone()
          Makes a flat clone of this object.
 java.lang.Object clone(java.util.Hashtable h, int level)
          clones the entire tree according to ControlledCloneable.
 Comparitor comparitor()
          Returs the Comparitor-object that is used to compare the keys in this tree.
 boolean contains(TreeItem node)
          Returns true, if the TreeItem node is part of the tree.
 TreeItem double_rotation(TreeItem u, int pos1, int pos2)
          Overrides BasicTree.double_rotation(gishur.core.TreeItem, int, int) to make tree events usable for a binary search tree.
 boolean empty()
          Returns true, if the tree is empty.
 TreeItem find(java.lang.Object key)
          Searches for a TreeItem for which equals(key) returns true in the whole tree.
 TreeItem find(java.lang.Object key, TreeItem start)
          Searches for a TreeItem whose key equals key in the sense of the equals(Object)-method.
 TreeItem findBigger(java.lang.Object key)
          Searches for that TreeItem in the tree, that is the smallest of those which are bigger than key.
 TreeItem findBigger(java.lang.Object key, TreeItem start)
          Searches for that TreeItem in the tree, that is the smallest of those which are bigger than key.
 TreeItem findPath(java.lang.Object key)
          Returns the TreeItem to which the key key would be to attach if the order in the tree should be kept.
 TreeItem findSmaller(java.lang.Object key)
          Searches for that TreeItem in the tree, that is the biggest of those which are smaller than key.
 TreeItem findSmaller(java.lang.Object key, TreeItem start)
          Searches for that TreeItem in the tree, that is the biggest of those which are smaller than key.
 TreeItem first()
          Returns the first TreeItem in the tree following the order BasicTree.LEFT_ROOT_RIGHT_ORDER (symmetric order).
 TreeItem first(byte order)
          Returns the first TreeItem in the tree following the traversal order defined by order.
 int height()
          Calculates the height of the tree.
 int height(TreeItem root)
          Calculates the heigth of the partial tree with root root.
 java.util.Enumeration keys()
          Creates and returns an java.util.Enumeration-object which enumerates all keys in the tree.
 java.util.Enumeration keys(java.lang.Object key1, java.lang.Object key2)
          Returns an java.util.Enumeration-object which enumerates all keys in this tree which are >= key1 and <= key2.
 TreeItem last()
          Returns the last TreeItem in the tree following the traversal order BasicTree.LEFT_ROOT_RIGHT_ORDER (symmetric order).
 TreeItem last(byte order)
          Returns the last TreeItem in the tree following the traversal-order defined by order.
 boolean leftIsSmaller()
          Returns true, if smaller (or equal) keys are to be stored in the left partial trees, false otherwise.
 int length()
          Returns the number of stored elements in the tree.
 int length(TreeItem item)
          Computes the number of TreeItems stored in the partial tree with root item.
 TreeItem max()
          Searches for the TreeItem with maximal key in the tree.
 TreeItem max(TreeItem start)
          Searches for the biggest TreeItem in the partial tree with root start.
 TreeItem min()
          Searches for the TreeItem with minimal key in the tree.
 TreeItem min(TreeItem start)
          Searches for the smallest TreeItem in the partial tree with root start.
 TreeItem next(TreeItem i)
          Returns the next TreeItem in the tree following BasicTree.LEFT_ROOT_RIGHT_ORDER (symmetric order).
 TreeItem next(TreeItem i, byte order)
          Return the next TreeItem in the tree in traversal order order.
 void onDoubleRotation(TreeItem u, TreeItem v, TreeItem w)
          A double rotation has been performed.
 void onLeftRotate(TreeItem x, TreeItem y)
          A left-hand-rotation has been performed by rotating node y onto node x's position.
 void onRightRotate(TreeItem x, TreeItem y)
          A right-hand-rotation has been performed by rotating node x onto node y's position.
 TreeItem prev(TreeItem i)
          Returns the previous TreeItem in symmetric order (BasicTree.LEFT_ROOT_RIGHT_ORDER).
 TreeItem prev(TreeItem i, byte order)
          Returns the previous TreeItem in the tree following the traversal order defined by order.
 TreeItem remove(java.lang.Object key)
          Removes the TreeItem with key key and returns it (or null, if no such TreeItem was found).
 TreeItem remove(TreeItem item)
          Removes TreeItem item from the tree and returns it (or null, if the operation failed).
 boolean requestAccess(int accesstype, java.lang.Object who, java.lang.Object argument)
          Object who asks his Owner for permission to perform an operation of type accesstype with argument argument.
 TreeItem root()
          Returns the root-node.
protected  TreeItem rotation(TreeItem u, int pos1, int pos2)
          Overrides BasicTree.rotation(gishur.core.TreeItem, int, int) to make tree events usable for a binary search tree.
 void setAllowDuplicates(boolean allow)
          Allows or forbids the insertion of duplicate keys into this tree.
 java.util.Enumeration treeItems(java.lang.Object key1, java.lang.Object key2)
          Returns an java.util.Enumeration-object which enumerates all TreeItems in this tree whose keys are >= key1 and <= key2.
 java.util.Enumeration values()
          Creates and returns an java.util.Enumeration-object which enumerates all values in the tree.
 java.util.Enumeration values(java.lang.Object key1, java.lang.Object key2)
          Returns an java.util.Enumeration-object which enumerates all values in this tree whose keys are >= key1 and <= key2.
 
Methods inherited from class gishur.core.BasicTree
add, add, allowAccess, connect, copy, countItems, cutTree, emptyEnumeration, enumerate, enumerate, find, findLast, first, fitInPlace, getListItemChain, getRemovableTreeItem, getTreeString, last, next, ownTree, ownTree, prev, removeSym, removeTree, storeInArray, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BinarySearchTree

public BinarySearchTree()
Empty constructor. The keys' hash-values are used to compare the nodes.

BinarySearchTree

public BinarySearchTree(Comparitor comparitor)
Standard constructor. The specified Comparitor is used to order the tree's elements. This constructor sorts smaller keys to the left side.
Parameters:
comparitor - Comparitor-object to compare keys

BinarySearchTree

public BinarySearchTree(Comparitor comparitor,
                        boolean left_is_smaller)
Constructs a BinarySearchTree using the Comparitor comparitor and the definition whether smaller keys shall be sorted to the left or to the right side of the tree.
Parameters:
comparitor - Comparitor-objekct to compare keys
left_is_smaller - if true, smaller keys are stored on the left side of the tree, otherwise on the right side
Method Detail

comparitor

public Comparitor comparitor()
Returs the Comparitor-object that is used to compare the keys in this tree.
Returns:
Comparitor to compare keys

allowDuplicates

public boolean allowDuplicates()
Returns true, if this tree allows elements with equal keys.
Returns:
true, if duplicate keys are allowed

setAllowDuplicates

public void setAllowDuplicates(boolean allow)
Allows or forbids the insertion of duplicate keys into this tree. This setting does not influence the existing tree but takes effect, when one tries to insert new elements.
Parameters:
allow - true, if duplicate keys shall be allowed, false otherwise

leftIsSmaller

public boolean leftIsSmaller()
Returns true, if smaller (or equal) keys are to be stored in the left partial trees, false otherwise.
Returns:
true, if smaller keys are stored on the left side

clone

public java.lang.Object clone()
Makes a flat clone of this object.
Specified by:
clone in interface Cloneable
Overrides:
clone in class java.lang.Object
Returns:
flat clone
Throws:
InternalError - - if the Object could not be cloned properly
See Also:
Cloneable

clone

public java.lang.Object clone(java.util.Hashtable h,
                              int level)
clones the entire tree according to ControlledCloneable. That means, all TreeItems are cloned and connected proper.
Specified by:
clone in interface ControlledCloneable
Overrides:
clone in class BasicTree
Parameters:
h - Hashtable to indicate which objects are already cloned
level - indicates how deep the objects should be cloned
Returns:
cloned object
Throws:
InternalError - - if the Object could not be cloned properly
See Also:
ControlledCloneable

length

public int length()
Returns the number of stored elements in the tree.
Overrides:
length in class BasicTree
Returns:
number of stored elements

length

public int length(TreeItem item)
Computes the number of TreeItems stored in the partial tree with root item.
Parameters:
item - the root of the partial tree to examine
Returns:
number of TreeItems in the partial tree

empty

public boolean empty()
Returns true, if the tree is empty.
Overrides:
empty in class BasicTree
Returns:
true, if tree is empty.

root

public TreeItem root()
Returns the root-node.
Overrides:
root in class BasicTree
Returns:
the root

height

public int height()
Calculates the height of the tree.
Returns:
the tree's height

height

public int height(TreeItem root)
Calculates the heigth of the partial tree with root root.
Overrides:
height in class BasicTree
Parameters:
root - the root of the partial tree to examine
Returns:
the height of the specified partial tree

contains

public boolean contains(TreeItem node)
Returns true, if the TreeItem node is part of the tree. The test is performed in constant time.
Overrides:
contains in class BasicTree
Parameters:
node - TreeItem to search for
Returns:
true, if node is part of the tree

findPath

public TreeItem findPath(java.lang.Object key)
Returns the TreeItem to which the key key would be to attach if the order in the tree should be kept.
Parameters:
key - key, whose position in the tree shall be found
Returns:
the TreeItem to which key would be to attach

find

public TreeItem find(java.lang.Object key,
                     TreeItem start)
Searches for a TreeItem whose key equals key in the sense of the equals(Object)-method. The operation takes O(n)-time in the worst case and O(log(n)) for balanced trees. start defines the root of the partial tree to search in. If start==null, the whole tree is searched. As the Comparitor is used for the search, it is important that the Comparitor of this tree is compatible to equals(), that means comparitor.compare(key,i)==EQUALS only if i.equals(key)!
Overrides:
find in class BasicTree
Parameters:
key - the key to search for
start - root-node of the partial tree to search in
Returns:
the found TreeItem or null, if no such key was found

find

public TreeItem find(java.lang.Object key)
Searches for a TreeItem for which equals(key) returns true in the whole tree. The complete operation takes O(n)-time in the worst case and O(log(n))-time for balanced trees. As the Comparitor is used for the search, it is important that the Comparitor of this tree is compatible to equals(), that means comparitor.compare(key,i)==EQUALS only if i.equals(key)!
Parameters:
key - the key to search for in the tree
Returns:
the found TreeItem or null, if no such key was found

findBigger

public TreeItem findBigger(java.lang.Object key,
                           TreeItem start)
Searches for that TreeItem in the tree, that is the smallest of those which are bigger than key. start is the root-node of the partial tree to search in. If start==null, the whole tree is searched.
Parameters:
key - the key, for which the least bigger element shall be searched
start - root of the partial tree to search in
Returns:
the least TreeItem in the tree which is >= key

findBigger

public TreeItem findBigger(java.lang.Object key)
Searches for that TreeItem in the tree, that is the smallest of those which are bigger than key.
Parameters:
key - the key, for which the least bigger element shall be searched
Returns:
the least TreeItem in the tree which is >= key

findSmaller

public TreeItem findSmaller(java.lang.Object key,
                            TreeItem start)
Searches for that TreeItem in the tree, that is the biggest of those which are smaller than key. start is the root-node of the partial tree to search in. If start==null, the whole tree is searched.
Parameters:
key - the key, for which the biggest smaller element shall be searched
start - root of the partial tree to search in
Returns:
biggest TreeItem of those in the tree which are <= key

findSmaller

public TreeItem findSmaller(java.lang.Object key)
Searches for that TreeItem in the tree, that is the biggest of those which are smaller than key.
Parameters:
key - the key, for which the biggest smaller element shall be searched
Returns:
biggest TreeItem of those in the tree which are <= key

min

public TreeItem min(TreeItem start)
Searches for the smallest TreeItem in the partial tree with root start. If start==null, the whole tree is searched.
Parameters:
start - root-node of the partial tree to search in
Returns:
the TreeItem with minimal key in the partial tree

min

public TreeItem min()
Searches for the TreeItem with minimal key in the tree.
Returns:
TreeItem with minimal key in the tree

max

public TreeItem max(TreeItem start)
Searches for the biggest TreeItem in the partial tree with root start. If start==null, the whole tree is searched.
Parameters:
start - root-node of the partial tree to search in
Returns:
the TreeItem with maximal key in the partial tree

max

public TreeItem max()
Searches for the TreeItem with maximal key in the tree.
Returns:
the TreeItem with maximal key in the tree

first

public TreeItem first(byte order)
Returns the first TreeItem in the tree following the traversal order defined by order.
Parameters:
order - a traversal-constant (BasicTree.ROOT_CHILDS_ORDER, BasicTree.CHILDS_ROOT_ORDER, BasicTree.LEFT_ROOT_RIGHT_ORDER, BasicTree.LEFT_RIGHT_ROOT_ORDER or BasicTree.ROOT_LEFT_RIGHT_ORDER)
Returns:
first TreeItem following order

first

public TreeItem first()
Returns the first TreeItem in the tree following the order BasicTree.LEFT_ROOT_RIGHT_ORDER (symmetric order).
Returns:
first TreeItem following symmetric order

last

public TreeItem last(byte order)
Returns the last TreeItem in the tree following the traversal-order defined by order.
Parameters:
order - a traversal constant (BasicTree.ROOT_CHILDS_ORDER, BasicTree.CHILDS_ROOT_ORDER, BasicTree.LEFT_ROOT_RIGHT_ORDER, BasicTree.LEFT_RIGHT_ROOT_ORDER or BasicTree.ROOT_LEFT_RIGHT_ORDER)
Returns:
last TreeItem following order

last

public TreeItem last()
Returns the last TreeItem in the tree following the traversal order BasicTree.LEFT_ROOT_RIGHT_ORDER (symmetric order).
Returns:
last TreeItem in symmetric order

next

public TreeItem next(TreeItem i,
                     byte order)
Return the next TreeItem in the tree in traversal order order.
Parameters:
i - TreeItem whose follower shall be found
order - a traversal constant (BasicTree.ROOT_CHILDS_ORDER, BasicTree.CHILDS_ROOT_ORDER, BasicTree.LEFT_ROOT_RIGHT_ORDER, BasicTree.LEFT_RIGHT_ROOT_ORDER or BasicTree.ROOT_LEFT_RIGHT_ORDER)
Returns:
following TreeItem in order order

next

public TreeItem next(TreeItem i)
Returns the next TreeItem in the tree following BasicTree.LEFT_ROOT_RIGHT_ORDER (symmetric order).
Parameters:
i - TreeItem whose follower shall be found
Returns:
next TreeItem in symmetric order

prev

public TreeItem prev(TreeItem i,
                     byte order)
Returns the previous TreeItem in the tree following the traversal order defined by order.
Parameters:
i - TreeItem for which the previous item shall be found
order - a traversal constant (BasicTree.ROOT_CHILDS_ORDER, BasicTree.CHILDS_ROOT_ORDER, BasicTree.LEFT_ROOT_RIGHT_ORDER, BasicTree.LEFT_RIGHT_ROOT_ORDER or BasicTree.ROOT_LEFT_RIGHT_ORDER)
Returns:
previous TreeItem in order order

prev

public TreeItem prev(TreeItem i)
Returns the previous TreeItem in symmetric order (BasicTree.LEFT_ROOT_RIGHT_ORDER).
Parameters:
i - TreeItem for which the previous item shall be found
Returns:
previous TreeItem in symmtric order

keys

public java.util.Enumeration keys()
Creates and returns an java.util.Enumeration-object which enumerates all keys in the tree.
Returns:
an java.util.Enumeration-object for the keys of this tree
See Also:
values()

values

public java.util.Enumeration values()
Creates and returns an java.util.Enumeration-object which enumerates all values in the tree.
Returns:
an java.util.Enumeration-object for the values of this tree
See Also:
keys()

keys

public java.util.Enumeration keys(java.lang.Object key1,
                                  java.lang.Object key2)
Returns an java.util.Enumeration-object which enumerates all keys in this tree which are >= key1 and <= key2. The enumeration is processed in BasicTree.LEFT_ROOT_RIGHT_ORDER, i.e. in ascending order, if leftIsSmaller()==true and in descending order otherwise.
Parameters:
key1 - the key which defines the lower bound of the interval to enumerate or null, if the enumeration should start with the least key
key2 - the key which defines the upper bound of the interval to enumerate or null, if the enumeration should end with the biggest key
Returns:
an java.util.Enumeration-object enumerating the specified interval

values

public java.util.Enumeration values(java.lang.Object key1,
                                    java.lang.Object key2)
Returns an java.util.Enumeration-object which enumerates all values in this tree whose keys are >= key1 and <= key2. The enumeration is processed in BasicTree.LEFT_ROOT_RIGHT_ORDER, i.e. in ascending order, if leftIsSmaller()==true and in descending order otherwise.
Parameters:
key1 - the key which defines the lower bound of the interval to enumerate or null, if the enumeration should start with the least key
key2 - the key which defines the upper bound of the interval to enumerate or null, if the enumeration should end with the biggest key
Returns:
an java.util.Enumeration-object enumerating the specified interval

treeItems

public java.util.Enumeration treeItems(java.lang.Object key1,
                                       java.lang.Object key2)
Returns an java.util.Enumeration-object which enumerates all TreeItems in this tree whose keys are >= key1 and <= key2. The enumeration is processed in BasicTree.LEFT_ROOT_RIGHT_ORDER, i.e. in ascending order, if leftIsSmaller()==true and in descending order otherwise.
Parameters:
key1 - the key which defines the lower bound of the interval to enumerate or null, if the enumeration should start with the least key
key2 - the key which defines the upper bound of the interval to enumerate or null, if the enumeration should end with the biggest key
Returns:
an java.util.Enumeration-object enumerating the specified interval

beforeAdd

public void beforeAdd(TreeItem item)
Is called before a TreeItem is inserted into the tree.
Parameters:
item - TreeItem to be inserted

afterAdd

public void afterAdd(TreeItem item)
Is called after a TreeItem has been inserted into the tree.
Parameters:
item - inserted TreeItem

beforeRemove

public void beforeRemove(TreeItem item)
Is called before a TreeItem is removed from the tree.
Parameters:
item - TreeItem to be removed

afterRemove

public void afterRemove(TreeItem item)
Is called after a TreeItem has been removed from the tree.
Parameters:
item - removed TreeItem

onLeftRotate

public void onLeftRotate(TreeItem x,
                         TreeItem y)
A left-hand-rotation has been performed by rotating node y onto node x's position.
   x                 y
 T1   y      =>    x   T3
    T2 T3        T1 T2
This event is called after the rotation took place.
Parameters:
x,y - rotated TreeItems
See Also:
rotation(gishur.core.TreeItem, int, int), double_rotation(gishur.core.TreeItem, int, int)

onRightRotate

public void onRightRotate(TreeItem x,
                          TreeItem y)
A right-hand-rotation has been performed by rotating node x onto node y's position.
     y               x
   x   T3    =>    T1   y
 T1 T2                T2 T3
This event is called after the rotation took place.
Parameters:
x,y - rotated nodes
See Also:
rotation(gishur.core.TreeItem, int, int), double_rotation(gishur.core.TreeItem, int, int)

onDoubleRotation

public void onDoubleRotation(TreeItem u,
                             TreeItem v,
                             TreeItem w)
A double rotation has been performed. The TreeItems u,v and w are handled as shown in the following figure:
     u                  w
   v    T3    =>     v     u
 T1   w            T1 T2 T3 T4
    T2 T2
This event is called after the double rotation took place.
Parameters:
u,v,w - rotated nodes
See Also:
rotation(gishur.core.TreeItem, int, int), double_rotation(gishur.core.TreeItem, int, int)

rotation

protected TreeItem rotation(TreeItem u,
                            int pos1,
                            int pos2)
Overrides BasicTree.rotation(gishur.core.TreeItem, int, int) to make tree events usable for a binary search tree.
Overrides:
rotation in class BasicTree
See Also:
BasicTree.rotation(gishur.core.TreeItem, int, int)

double_rotation

public TreeItem double_rotation(TreeItem u,
                                int pos1,
                                int pos2)
Overrides BasicTree.double_rotation(gishur.core.TreeItem, int, int) to make tree events usable for a binary search tree.
Overrides:
double_rotation in class BasicTree
See Also:
BasicTree.double_rotation(gishur.core.TreeItem, int, int)

add_item

protected TreeItem add_item(TreeItem item)
Inserts a new TreeItem into the tree. This method is used by all add-methods and should be overridden in balanced trees.
Parameters:
item - new TreeItem
Returns:
inserted TreeItem

add

public TreeItem add(java.lang.Object key)
Inserts a newly generated TreeItem with key key into the tree at the right place. key should be comparable by the tree's Comparitor to other keys in the tree, otherwise earlier or later a CompareException will occur.
Parameters:
key - key of the new TreeItem
Returns:
TreeItem containig the specified key

add

public TreeItem add(java.lang.Object key,
                    java.lang.Object value)
Inserts a newly generated TreeItem with key and valueinto the tree at the right place. key should be comparable by the tree's Comparitor to other keys in the tree, otherwise earlier or later a CompareException will occur.
Parameters:
key - the new TreeItem's key
value - the value to be stored
Returns:
TreeItem with specified key and value

add

public TreeItem add(TreeItem item)
Inserts the TreeItem item at the right place into the tree. Only one TreeItem will be inserted! If it is connected to further TreeItems, all connections to them will be cleared by item or a flat clone of item will be created.
Parameters:
item - TreeItem to insert
Returns:
inserted TreeItem

remove

public TreeItem remove(TreeItem item)
Removes TreeItem item from the tree and returns it (or null, if the operation failed).
Parameters:
{@link - TreeItem} to be removed
Returns:
removed TreeItem

remove

public TreeItem remove(java.lang.Object key)
Removes the TreeItem with key key and returns it (or null, if no such TreeItem was found).
Parameters:
key - this key's TreeItem shall be removed
Returns:
removed TreeItem

clear

public void clear()
Erases the whole tree.

add

public TreeItem add(int n)
add for int.
Parameters:
n - int to be used as key for the new TreeItem to be inserted
Returns:
a TreeItem containing a java.lang.Integer wrapping n as the key

add

public TreeItem add(long n)
add for long.
Parameters:
n - long to be used as key for the new TreeItem to be inserted
Returns:
a TreeItem containing a java.lang.Long wrapping n as the key

add

public TreeItem add(float n)
add for float.
Parameters:
n - float to be used as key for the new TreeItem to be inserted
Returns:
a TreeItem containing a java.lang.Float wrapping n as the key

add

public TreeItem add(double n)
add for double.
Parameters:
n - double to be used as key for the new TreeItem to be inserted
Returns:
a TreeItem containing a java.lang.Double wrapping n as the key

add

public TreeItem add(boolean n)
add for boolean.
Parameters:
n - boolean to be used as key for the new TreeItem to be inserted
Returns:
a TreeItem containing a java.lang.Boolean wrapping n as the key

requestAccess

public boolean requestAccess(int accesstype,
                             java.lang.Object who,
                             java.lang.Object argument)
Object who asks his Owner for permission to perform an operation of type accesstype with argument argument. This method overrides the BasicTree.requestAccess(int, java.lang.Object, java.lang.Object)-method to make it more restrictive (the key and the maximal rank must not be changed).
Overrides:
requestAccess in class BasicTree
Parameters:
accesstype - type of action (i.e. type of required access)
who - object asking his Owner for permission
argument - argument of the requested operation
Returns:
true, if the Owner allows the operation, false otherwise