org.vizzini.util.tree
Class ArrayTreeNodeCollection

java.lang.Object
  extended by org.vizzini.util.tree.ArrayTreeNodeCollection
All Implemented Interfaces:
Cloneable, ITreeNodeCollection

public class ArrayTreeNodeCollection
extends Object
implements ITreeNodeCollection

Provides an implementation of a tree node collection which uses an array.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Constructor Summary
ArrayTreeNodeCollection()
          Construct this object.
ArrayTreeNodeCollection(int capacity)
          Construct this object with the given parameter.
 
Method Summary
 void add(int index, ITreeNode child)
          Add the given child at the given index.
 boolean add(ITreeNode child)
          Add the given child.
 boolean addAll(ITreeNodeCollection collection)
          Add the given collection to this.
 void clear()
          Clear the children.
 Object clone()
          Return a clone of this instance.
 boolean contains(ITreeNode treeNode)
          Return true if this contains the given node.
protected  ITreeNode[] deepClone(ITreeNode[] nodes)
          Create a new List which contains clones of the items in the given list.
 boolean equals(Object object)
          Return true if the given object is equal to this.
 ITreeNode get(int index)
          Return the child at the given index.
 int getCapacity()
           
 int getIndex()
           
 ITreeNode[] getNodes()
           
 int hashCode()
          Returns a hash code value for the object.
 int indexOf(ITreeNode treeNode)
          Return the index of the given node.
 boolean isEmpty()
          Return true if this is empty.
 Iterator iterator()
          Return an iterator over this collection.
 ITreeNode remove(int index)
          Remove the object at the given index.
 boolean remove(ITreeNode child)
          Remove the given child.
 ITreeNode set(int index, ITreeNode child)
          Set the given object at the given index.
 void setCapacity(int capacity)
          Set capacity.
 void setIndex(int index)
           
 void setNodes(ITreeNode[] nodes)
           
 int size()
          Return the size of this collection.
 ITreeNode[] toArray()
          Return an array representation of this collection.
 ITreeNode[] toArray(ITreeNode[] nodes)
          Return an array representation of this collection.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayTreeNodeCollection

public ArrayTreeNodeCollection()
Construct this object.

Since:
v0.3

ArrayTreeNodeCollection

public ArrayTreeNodeCollection(int capacity)
Construct this object with the given parameter.

Parameters:
capacity - Capacity.
Since:
v0.3
Method Detail

add

public boolean add(ITreeNode child)
Add the given child.

Specified by:
add in interface ITreeNodeCollection
Since:
v0.3

add

public void add(int index,
                ITreeNode child)
Add the given child at the given index.

Specified by:
add in interface ITreeNodeCollection
Since:
v0.3

addAll

public boolean addAll(ITreeNodeCollection collection)
Add the given collection to this.

Specified by:
addAll in interface ITreeNodeCollection
Since:
v0.3

clear

public void clear()
Clear the children.

Specified by:
clear in interface ITreeNodeCollection
Since:
v0.3

clone

public Object clone()
Return a clone of this instance.

Specified by:
clone in interface ITreeNodeCollection
Overrides:
clone in class Object
Since:
v0.3

contains

public boolean contains(ITreeNode treeNode)
Return true if this contains the given node.

Specified by:
contains in interface ITreeNodeCollection
Since:
v0.3

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.3

get

public ITreeNode get(int index)
Return the child at the given index.

Specified by:
get in interface ITreeNodeCollection
Since:
v0.3

getCapacity

public int getCapacity()
Returns:
capacity
Since:
v0.3

getIndex

public int getIndex()
Returns:
Return index.
Since:
v0.3

getNodes

public ITreeNode[] getNodes()
Returns:
Return nodes.
Since:
v0.3

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object
Since:
v0.3

indexOf

public int indexOf(ITreeNode treeNode)
Return the index of the given node.

Specified by:
indexOf in interface ITreeNodeCollection
Since:
v0.3

isEmpty

public boolean isEmpty()
Return true if this is empty.

Specified by:
isEmpty in interface ITreeNodeCollection
Since:
v0.3

iterator

public Iterator iterator()
Return an iterator over this collection.

Specified by:
iterator in interface ITreeNodeCollection
Since:
v0.3

remove

public boolean remove(ITreeNode child)
Remove the given child.

Specified by:
remove in interface ITreeNodeCollection
Since:
v0.3

remove

public ITreeNode remove(int index)
Remove the object at the given index.

Specified by:
remove in interface ITreeNodeCollection
Since:
v0.3

set

public ITreeNode set(int index,
                     ITreeNode child)
Set the given object at the given index.

Specified by:
set in interface ITreeNodeCollection
Parameters:
index - Index.
child - Child to set.
Returns:
the element previously at the specified position.
Since:
v0.3

setCapacity

public void setCapacity(int capacity)
Set capacity.

Since:
v0.3

setIndex

public void setIndex(int index)
Parameters:
index - the index to set
Since:
v0.3

setNodes

public void setNodes(ITreeNode[] nodes)
Parameters:
nodes - the nodes to set
Since:
v0.3

size

public int size()
Return the size of this collection.

Specified by:
size in interface ITreeNodeCollection
Since:
v0.3

toArray

public ITreeNode[] toArray()
Return an array representation of this collection.

Specified by:
toArray in interface ITreeNodeCollection
Since:
v0.3

toArray

public ITreeNode[] toArray(ITreeNode[] nodes)
Return an array representation of this collection.

Specified by:
toArray in interface ITreeNodeCollection
Since:
v0.3

deepClone

protected ITreeNode[] deepClone(ITreeNode[] nodes)
Create a new List which contains clones of the items in the given list.

Parameters:
nodes - Array of nodes to clone.
Since:
v0.3


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02