com.sun.sgs.app.util
Class ScalableList.ListNode<E>

java.lang.Object
  extended by com.sun.sgs.app.util.ScalableList.ListNode<E>
Type Parameters:
E - the type of element stored in the ScalableList
All Implemented Interfaces:
ManagedObject, ScalableList.Node<E>, Serializable
Enclosing class:
ScalableList<E>

static class ScalableList.ListNode<E>
extends Object
implements ManagedObject, Serializable, ScalableList.Node<E>

Node which parents a SubList<E>. These nodes can be considered as the leaf nodes of the tree and contain references to a portion of the list. A ListNode's parent is always a TreeNode since they are the deepest organizational element of the ScalableList. ListNodes are arranged in a doubly-linked list, each having a reference to its parent.


Constructor Summary
ScalableList.ListNode(ScalableList.TreeNode<E> parent, int maxSize)
          Constructor which uses knowledge of a parent and maximum list size.
ScalableList.ListNode(ScalableList.TreeNode<E> parent, int maxSize, E e)
          Constructor which uses knowledge of a parent and maximum list size.
ScalableList.ListNode(ScalableList.TreeNode<E> parent, int maxSize, List<ManagedReference<ManagedObject>> list)
          Constructor which uses knowledge of a parent and maximum list size.
 
Method Summary
(package private)  void append(E e)
          Appends the supplied object to the list and performs a split if necessary.
 void clear()
          Walks up the tree and removes the object and any of its parents.
(package private)  int getDataIntegrityValue()
          Returns the data integrity value of the ListNode
 ScalableList.TreeNode<E> getParent()
          Retrieves the parent of the ListNode
(package private)  ScalableList.SubList<E> getSubList()
          Returns the SubList object which contains a subset of the elements in the collection.
(package private)  void insert(int index, E e)
          Inserts the supplied value at the given index.
 ScalableList.ListNode<E> next()
          Returns the next Node in sequence, or null if none exists.
 ScalableList.ListNode<E> prev()
          Returns the previous Node in sequence, or null if none exists.
(package private)  E remove(ScalableList<E> list, int index)
          Removes the object at the specified index of the sublist.
(package private)  boolean remove(ScalableList<E> list, Object obj)
          Removes the Object from the SubList<E>, if it exists.
 com.sun.sgs.app.util.ScalableList.SearchResult<E> search(int currentValue, int destIndex)
          Traverses the tree (recursively) in search of the ListNode which contains the index provided.
(package private)  E set(int index, Object obj)
          Sets the element at the supplied index with the provided value.
 void setNext(ScalableList.Node<E> ref)
          Sets the next element to be the supplied argument.
 void setParent(ScalableList.TreeNode<E> parent)
          Sets the Node's parent to the supplied argument.
 void setPrev(ScalableList.Node<E> ref)
          Sets the previous element to be the supplied argument.
 int size()
          The size of the node; that is, the sum of the sizes of its immediate children.
 String toString()
          A String representation of the ListNode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScalableList.ListNode

ScalableList.ListNode(ScalableList.TreeNode<E> parent,
                      int maxSize)
Constructor which uses knowledge of a parent and maximum list size. A ListNode that exceeds maxSize will be subject to splitting.

Parameters:
parent - the intended parent
maxSize - the maximum number of elements that can be stored

ScalableList.ListNode

ScalableList.ListNode(ScalableList.TreeNode<E> parent,
                      int maxSize,
                      E e)
Constructor which uses knowledge of a parent and maximum list size. A ListNode that exceeds maxSize will be subject to splitting.

Parameters:
parent - the intended parent
maxSize - the maximum number of elements that can be stored
e - an element which is to be stored as the first item in the list

ScalableList.ListNode

ScalableList.ListNode(ScalableList.TreeNode<E> parent,
                      int maxSize,
                      List<ManagedReference<ManagedObject>> list)
Constructor which uses knowledge of a parent and maximum list size. A ListNode that exceeds maxSize will be subject to splitting.

Parameters:
parent - the intended parent
maxSize - the maximum number of elements that can be stored
list - a list of items which are to be added into the empty list
Method Detail

getDataIntegrityValue

int getDataIntegrityValue()
Returns the data integrity value of the ListNode

Returns:
the current data integrity value

setNext

public void setNext(ScalableList.Node<E> ref)
Sets the next element to be the supplied argument. The argument should be the same type as the variable.

Specified by:
setNext in interface ScalableList.Node<E>
Parameters:
ref - the next Node

setParent

public void setParent(ScalableList.TreeNode<E> parent)
Sets the Node's parent to the supplied argument.

Specified by:
setParent in interface ScalableList.Node<E>

next

public ScalableList.ListNode<E> next()
Returns the next Node in sequence, or null if none exists.

Specified by:
next in interface ScalableList.Node<E>
Returns:
the next node

setPrev

public void setPrev(ScalableList.Node<E> ref)
Sets the previous element to be the supplied argument. The argument should be the same type as the variable.

Specified by:
setPrev in interface ScalableList.Node<E>
Parameters:
ref - the previous Node

prev

public ScalableList.ListNode<E> prev()
Returns the previous Node in sequence, or null if none exists.

Specified by:
prev in interface ScalableList.Node<E>
Returns:
the previous node

size

public int size()
The size of the node; that is, the sum of the sizes of its immediate children.

Specified by:
size in interface ScalableList.Node<E>
Returns:
the size of this node.

getSubList

ScalableList.SubList<E> getSubList()
Returns the SubList object which contains a subset of the elements in the collection.

Returns:
the SubList containing list elements, or null if one has not yet been instantiated

append

void append(E e)
Appends the supplied object to the list and performs a split if necessary.

Parameters:
e - the element to append

insert

void insert(int index,
            E e)
Inserts the supplied value at the given index. The index is relative to the current list and not the global collection.

Parameters:
index - the index to insert the value, relative to the current SubList
e - the value to insert

remove

E remove(ScalableList<E> list,
         int index)
Removes the object at the specified index of the sublist. The index argument is not an absolute index; it is a relative index which points to a valid index in the list.

For example, if there are five ListNodes with a cluster size of five, the item with an absolute index of 16 corresponds to an element in the fourth ListNode, with a relative offset of 1.

Parameters:
list - a reference to the ScalableList; this argument should only ever be null during the AsynchronousClearTask operation
index - the index corresponding to an element in the list (not an absolute index with respect to the ScalableList object
Returns:
the element that was removed

clear

public void clear()
Walks up the tree and removes the object and any of its parents. This method is intended to be called during the AsynchronousClearTask operation.

Specified by:
clear in interface ScalableList.Node<E>

toString

public String toString()
A String representation of the ListNode.

Overrides:
toString in class Object
Returns:
a String representing the contents of the ListNode

remove

boolean remove(ScalableList<E> list,
               Object obj)
Removes the Object from the SubList<E>, if it exists.

Parameters:
list - a reference to the ScalableList; since this method is not called by the AsynchronousClearTask, this parameter must not be null.
obj - the Object to remove
Returns:
whether the object was removed or not; true if so, false otherwise

set

E set(int index,
      Object obj)
Sets the element at the supplied index with the provided value.

Parameters:
index - the index to set the value
obj - the value to replace the existing one
Returns:
the old value

getParent

public ScalableList.TreeNode<E> getParent()
Retrieves the parent of the ListNode

Specified by:
getParent in interface ScalableList.Node<E>
Returns:
the parent

search

public com.sun.sgs.app.util.ScalableList.SearchResult<E> search(int currentValue,
                                                                int destIndex)
Traverses the tree (recursively) in search of the ListNode which contains the index provided. If no ListNode can be found, then null is returned.

Specified by:
search in interface ScalableList.Node<E>
Parameters:
currentValue - the current index value at the beginning of this current search
destIndex - the absolute index of the desired element
Returns:
the ListNode containing the absolute destIndex

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved