com.accountingenhancements.treearray
Class LeafNode<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Leaf<E>>
              extended by com.accountingenhancements.treearray.LeafNode<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Leaf<E>>, java.util.Collection<Leaf<E>>, java.util.List<Leaf<E>>, java.util.RandomAccess

public class LeafNode<E>
extends java.util.ArrayList<Leaf<E>>

An ArrayList of Leaf elements. Each BranchNode contains a LeafNode that contains the Leaf entries.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LeafNode()
          Creates a new instance of LeafNode
LeafNode(int initialCapacity)
           
 
Method Summary
 E addAndReturnElement(E o)
          Appends the specified element to the end of this list.
 Leaf<E> addAndReturnLeaf(Leaf<E> o)
          Appends the specified leaf to the end of this list.
 LeafNode addAndReturnLeafNode(E o)
          Appends the specified element to the end of this list.
 LeafNode addAndReturnLeafNode(Leaf<E> o)
          Appends the specified leaf to the end of this list.
 boolean addLeaf(E o)
          Appends the specified element to the end of this list (Creates Leaf for the object).
 void addLeaf(int index, E element)
          Inserts the specified element at the specified position in this list (Creates Leaf for the object).
 void addLeaf(int index, Leaf<E> element)
          Inserts the specified leaf at the specified position in this list (Creates Leaf for the object).
 boolean addLeaf(Leaf<E> leaf)
          Appends the specified leaf to the end of this list (Creates Leaf for the object).
 boolean containsElement(E element)
           
 E getLeafElement(int index)
           
 int indexOfElement(E element)
          Find index of specified element
 int lastIndexOfElement(E element)
          Find the last index of specified element
 E setLeaf(int index, E o)
          Replace the element inside a leaf at the specified position in this list.
 java.lang.Object[] toArrayElements()
          Leaf node elements to an array
 E[] toArrayElements(E[] result)
          Leaf node elements to an array
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

LeafNode

public LeafNode()
Creates a new instance of LeafNode


LeafNode

public LeafNode(int initialCapacity)
Method Detail

addAndReturnLeaf

public Leaf<E> addAndReturnLeaf(Leaf<E> o)
Appends the specified leaf to the end of this list.

Parameters:
o - leaft to be appended to this list.
Returns:
the original object. Useful when you want to add the object but continue to work the obect as well.

addAndReturnLeafNode

public LeafNode addAndReturnLeafNode(Leaf<E> o)
Appends the specified leaf to the end of this list.

Parameters:
o - leaf to be appended to this list.
Returns:
the LeafNode class. Useful when you want to add multiple components in a row. You can just chain the adds together. (leafNodes.addAndReturnLeafNodes(obj_1).addAndReturnLeafNodes(obj_2).addAndReturnLeafNodes(obj_3)

addAndReturnElement

public E addAndReturnElement(E o)
Appends the specified element to the end of this list.

Parameters:
o - element to be appended to this list.
Returns:
the original object. Useful when you want to add the object but continue to work the obect as well.

addAndReturnLeafNode

public LeafNode addAndReturnLeafNode(E o)
Appends the specified element to the end of this list.

Parameters:
o - element to be appended to this list.
Returns:
the LeafNode class. Useful when you want to add multiple components in a row. You can just chain the adds together. (leafNodes.addAndReturnLeafNodes(obj_1).addAndReturnLeafNodes(obj_2).addAndReturnLeafNodes(obj_3)

setLeaf

public E setLeaf(int index,
                 E o)
Replace the element inside a leaf at the specified position in this list.

Parameters:
index - - index of element to replace
o - - element to be stored at the specified position.
Returns:
the element previously at the specified position
Throws:
InedxOutOfBoundsException - - if index out of range (index < 0 || index >= size()).

addLeaf

public boolean addLeaf(E o)
Appends the specified element to the end of this list (Creates Leaf for the object).

Parameters:
o - element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

getLeafElement

public E getLeafElement(int index)
Parameters:
index - the index of the Leaf within the LeafNode
Returns:
E the element stored in the leaf

addLeaf

public void addLeaf(int index,
                    E element)
Inserts the specified element at the specified position in this list (Creates Leaf for the object). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index > size()).

addLeaf

public boolean addLeaf(Leaf<E> leaf)
Appends the specified leaf to the end of this list (Creates Leaf for the object).

Parameters:
leaf - element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

containsElement

public boolean containsElement(E element)
Parameters:
element - for which the ArrayList is being searched.
Returns:
true of leaf node contains specified element

indexOfElement

public int indexOfElement(E element)
Find index of specified element

Parameters:
element - for which to search
Returns:
index of found element or -1 if not found

lastIndexOfElement

public int lastIndexOfElement(E element)
Find the last index of specified element

Parameters:
element - for which to search
Returns:
index of found element or -1 if not found

toArrayElements

public java.lang.Object[] toArrayElements()
Leaf node elements to an array

Returns:
E[] array of leaf elements

toArrayElements

public E[] toArrayElements(E[] result)
Leaf node elements to an array

Returns:
E[] array of leaf elements

addLeaf

public void addLeaf(int index,
                    Leaf<E> element)
Inserts the specified leaf at the specified position in this list (Creates Leaf for the object). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index > size()).