com.scottlogic.util
Class UnsortedList.UnsortedNode

java.lang.Object
  extended by com.scottlogic.util.SortedList.Node
      extended by com.scottlogic.util.UnsortedList.UnsortedNode
All Implemented Interfaces:
java.lang.Comparable<SortedList.Node>
Enclosing class:
UnsortedList<T>

protected class UnsortedList.UnsortedNode
extends SortedList.Node

Class representing the individual nodes of an unsorted list extends the regular SortedList.Node class by storing the position of the node in the tree.


Field Summary
 
Fields inherited from class com.scottlogic.util.SortedList.Node
id
 
Method Summary
 int compareTo(SortedList.Node other)
          Compares this node with the given node - which must be an UnsortedNode instance in the same UnsortedList.
protected  int getIndexInList()
          Gets the index of this node in the list, using the cached value if it is not stale and otherwise calculating it from the ancestor nodes and setting the cached value.
 
Methods inherited from class com.scottlogic.util.SortedList.Node
getGrandParent, getLeftChild, getParent, getRightChild, getValue, hasTwoChildren, isLeaf, isLeftChildOfParent, isRightChildOfParent, largestNodeInSubTree, predecessor, sizeOfSubTree, smallestNodeInSubTree, successor, toString, updateAdditionalCachedValues, updateCachedValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getIndexInList

protected int getIndexInList()
Gets the index of this node in the list, using the cached value if it is not stale and otherwise calculating it from the ancestor nodes and setting the cached value.


compareTo

public int compareTo(SortedList.Node other)
Compares this node with the given node - which must be an UnsortedNode instance in the same UnsortedList. The comparison is based on the current position of the nodes in the list.

Nodes with equal indices are compared on whether they are in the tree yet or not; those in the tree are considered to be larger.

Specified by:
compareTo in interface java.lang.Comparable<SortedList.Node>
Overrides:
compareTo in class SortedList.Node
Returns:
the index of this node in the list minus the index of the given node in the list.