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

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

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

This object represents a partition in the list, otherwise denoted as a bucket (as per bucketSize). Only one of these SubList objects lives inside a ListNode object; therefore, there are as many SubList objects as there are ListNodes.

The separation of the elements from the ListNodes is to allow iterations and other read operations while modifications to elements occur. This is particularly important for replacements because parent sizes do not need to change since no elements are being added or removed.


Constructor Summary
ScalableList.SubList(int maxSize)
          Constructor which creates a SubList
ScalableList.SubList(int maxSize, E e)
          Constructor to create a SubList
ScalableList.SubList(int maxSize, List<ManagedReference<ManagedObject>> collection)
          Constructor which creates a SubList.
 
Method Summary
(package private)  boolean append(E e)
          Appends the supplied argument to the list.
(package private)  E get(int index)
          Since the list is a collection of ManagedReferences, we are interested in retrieving the value it points to.
(package private)  List<ManagedReference<ManagedObject>> getElements()
          Returns the elements contained in the SubList as an ArrayList.
(package private)  int getMaxChildren()
          Returns the maximum number of children for this structure.
(package private)  int indexOf(Object o)
          Determines the index of the first occurrence of the supplied argument.
(package private)  void insert(int index, E e)
          Inserts the element into the list at a specified location.
static boolean isLegal(int maxSize)
          Performs a quick check to see if the argument is a legal parameter; that is, larger than 0.
(package private)  int lastIndexOf(Object o)
          Returns the index of the element inside the SubList<E>.
(package private)  E remove(int index)
          Removes the element at the supplied index.
(package private)  boolean remove(Object obj)
          Removes the supplied object from the underlying list, if it exists.
(package private)  E set(int index, Object obj)
          Sets the value at the index provided.
(package private)  int size()
          Returns the size of the collection.
 String toString()
          Returns a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScalableList.SubList

ScalableList.SubList(int maxSize,
                     List<ManagedReference<ManagedObject>> collection)
Constructor which creates a SubList.

Parameters:
maxSize - the maximum number of elements which can be stored
collection - the elements to add to the empty list

ScalableList.SubList

ScalableList.SubList(int maxSize)
Constructor which creates a SubList

Parameters:
maxSize - the maximum number of elements which can be stored

ScalableList.SubList

ScalableList.SubList(int maxSize,
                     E e)
Constructor to create a SubList

Parameters:
maxSize - the maximum number of elements which can be stored
e - an element to add to the empty list, at the first index
Method Detail

isLegal

public static boolean isLegal(int maxSize)
Performs a quick check to see if the argument is a legal parameter; that is, larger than 0.


toString

public String toString()
Returns a String representation of this object.

Overrides:
toString in class Object
Returns:
a String representation of this object

getMaxChildren

int getMaxChildren()
Returns the maximum number of children for this structure.

Returns:
the maximum number of children

size

int size()
Returns the size of the collection.

Returns:
the size

getElements

List<ManagedReference<ManagedObject>> getElements()
Returns the elements contained in the SubList as an ArrayList.

Returns:
the elements contained in the SubList

get

E get(int index)
Since the list is a collection of ManagedReferences, we are interested in retrieving the value it points to.

Parameters:
index - the index to retrieve
Returns:
the element, if it exists, or null otherwise
Throws:
IndexOutOfBoundsException - if the index is out of bounds (less than 0 or larger than the SubList size)

set

E set(int index,
      Object obj)
Sets the value at the index provided. The index is not an absolute index; rather, it is relative to the current list. If the index does not correspond to a valid index in the underlying list, an IndexOutOfBoundsException will be thrown.

Parameters:
index - the index to add the element
obj - the element to be added
Returns:
the old element that was replaced
Throws:
IndexOutOfBoundsException - if the index is outside the range of the underlying list

append

boolean append(E e)
Appends the supplied argument to the list.

Parameters:
e - the element to add to append
Returns:
whether the operation was successful; true if so, false otherwise

lastIndexOf

int lastIndexOf(Object o)
Returns the index of the element inside the SubList<E>. If the element does not exist, then -1 is returned.

Parameters:
o - the element whose last index is to be found
Returns:
the index of the element, or -1 if it does not exist

insert

void insert(int index,
            E e)
Inserts the element into the list at a specified location. If the index is not valid, an IndexOutOfBoundsException is thrown.

Parameters:
index - the index to add the new element.
e - the object which is to be inserted at the specified index
Throws:
IndexOutOfBoundsException - if the supplied index is outside of the range of the underlying list

indexOf

int indexOf(Object o)
Determines the index of the first occurrence of the supplied argument. If the element does not exist, then -1 is returned.

Parameters:
o - the element whose index is to be searched
Returns:
the first index of the supplied element, or -1 if it does not exist in the list

remove

E remove(int index)
Removes the element at the supplied index. This method throws an IndexOutOfBoundsException if the index does not exist in the underlying list.

Parameters:
index - the index to remove
Returns:
the object removed from the index
Throws:
IndexOutOfBoundsException - if the index is outside of the range of the underlying list

remove

boolean remove(Object obj)
Removes the supplied object from the underlying list, if it exists.

Parameters:
obj - the element to remove from the list
Returns:
whether the operation was successful; true if so, false otherwise

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