com.sun.sgs.app.util
Class ScalableDeque.Element<E>

java.lang.Object
  extended by com.sun.sgs.app.util.ScalableDeque.Element<E>
Type Parameters:
E - The type of element held by the deque
All Implemented Interfaces:
ManagedObject, Serializable
Enclosing class:
ScalableDeque<E>

static class ScalableDeque.Element<E>
extends Object
implements Serializable, ManagedObject

A deque-internal class for wrapping elements within the deque. This class maintains a doubly-linked list of all the elements in the deque. This class relies on ScalableDeque to maintain correct references to to the head and tail of this list, and also to update it accordingly on additions and removals.

The value of the elements themselves are refered to by ManagedReference instances if they implement ManagedObject or are refered to using a standard Java reference.

Element instances use their value's hash code, but can be distinguished by their id, which corresponds to the id assigned to them at the time of their addition to the deque. This method of hashing has the effect that when an Element is added to the deque, and subsequently added to the backing map, the deque can locate all instances of the element by using the element's hash code. This behavior is required to correctly support the random access behavior of remove, removeFirstOccurrence, removeLastOccurrence, and removeAll.

See Also:
ScalableDeque.ElementMatcher

Constructor Summary
ScalableDeque.Element(E value, Long id)
          Constructs a new Element with the provided id to contain the value.
 
Method Summary
 boolean equals(Object o)
          Returns true if o is an instance of Element, contains the same value as this instance and has the same id.
(package private)  long getId()
          Returns the unique id of this Element.
 E getValue()
          Returns the value contained by this element.
 int hashCode()
          Returns the hash code provided by the value contained by this element.
(package private)  ScalableDeque.Element<E> next()
          Returns the Element after this instance in the deque, or null if this element is the tail of the deque.
(package private)  ScalableDeque.Element<E> prev()
          Returns the Element before this instance in the deque, or null if this element is the head of the deque.
(package private)  void setNext(ScalableDeque.Element<E> next)
          Sets the link from this Element to the next Element in the deque to next.
(package private)  void setPrev(ScalableDeque.Element<E> prev)
          Sets the link from this Element to the previous Element in the deque to prev.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScalableDeque.Element

public ScalableDeque.Element(E value,
                             Long id)
Constructs a new Element with the provided id to contain the value.

Parameters:
value - the value held by this Element
id - the id of this element
Method Detail

equals

public boolean equals(Object o)
Returns true if o is an instance of Element, contains the same value as this instance and has the same id.

Overrides:
equals in class Object
Parameters:
o -
Returns:
true if o is an instance of Element, contains the same value as this instance and has the same id.
See Also:
ScalableDeque.ElementMatcher

hashCode

public int hashCode()
Returns the hash code provided by the value contained by this element.

Overrides:
hashCode in class Object
Returns:
the hash code of the value contained by this element

getId

long getId()
Returns the unique id of this Element.

Returns:
the id of this instance

getValue

public E getValue()
Returns the value contained by this element.

Returns:
the value contained by this element

next

ScalableDeque.Element<E> next()
Returns the Element after this instance in the deque, or null if this element is the tail of the deque.

Returns:
the Element after this instance in the deque, or null if this element is the tail of the deque.

prev

ScalableDeque.Element<E> prev()
Returns the Element before this instance in the deque, or null if this element is the head of the deque.

Returns:
the Element before this instance in the deque, or null if this element is the head of the deque.

setNext

void setNext(ScalableDeque.Element<E> next)
Sets the link from this Element to the next Element in the deque to next.


setPrev

void setPrev(ScalableDeque.Element<E> prev)
Sets the link from this Element to the previous Element in the deque to prev.


toString

public String toString()

Overrides:
toString in class Object

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