roboguice.inject
Class ContextScope.WeakActiveStack<T>

java.lang.Object
  extended by roboguice.inject.ContextScope.WeakActiveStack<T>
Type Parameters:
T -
Enclosing class:
ContextScope

public static class ContextScope.WeakActiveStack<T>
extends Object

A circular stack like structure of weak references. Calls to push while not add any new items to stack if the item already exists, it will simply bring the item to the top of the stack. Likewise, pop will not remove the item from the stack, it will simply make the next item the top, move the current top to the bottom. Thus creating a circular linked list type effect. To remove an item explicitly call the remove method. The stack also holds WeakReferences of T, these references will automatically be removed anytime the stack accessed. For performance they are only removed as they are encountered. So it is possible to get a null value back, even though you thought the stack had items in it.


Constructor Summary
ContextScope.WeakActiveStack()
           
 
Method Summary
protected  roboguice.inject.ContextScope.WeakActiveStack.Node<T> disposeOfNode(roboguice.inject.ContextScope.WeakActiveStack.Node<T> node)
          Removes a node ensuring all links are properly updated.
protected  roboguice.inject.ContextScope.WeakActiveStack.Node<T> findNode(T value)
          Finds a node given a value Will dispose of nodes if needed as it iterates the stack.
 T peek()
          Non destructive read of the item at the top of stack.
 T pop()
          Pops the first item off the stack, then moves it to the bottom.
 void push(T value)
          Pushes the value onto the top of the stack.
 void remove(T value)
          Removes the item from the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextScope.WeakActiveStack

public ContextScope.WeakActiveStack()
Method Detail

push

public void push(T value)
Pushes the value onto the top of the stack. If the value exists in the stack it is simply brought to the top.

Parameters:
value -

pop

public T pop()
Pops the first item off the stack, then moves it to the bottom. Popping is an infinite operation that will never end, it just keeps moving the top item to the bottom. Popping will also dispose of items whose weak references have been collected.

Returns:
The value of the item at the top of the stack.

peek

public T peek()
Non destructive read of the item at the top of stack.

Returns:
the first non collected referent held, or null if nothing is available.

remove

public void remove(T value)
Removes the item from the stack.

Parameters:
value -

disposeOfNode

protected roboguice.inject.ContextScope.WeakActiveStack.Node<T> disposeOfNode(roboguice.inject.ContextScope.WeakActiveStack.Node<T> node)
Removes a node ensuring all links are properly updated.

Parameters:
node -
Returns:
The next node in the stack.

findNode

protected roboguice.inject.ContextScope.WeakActiveStack.Node<T> findNode(T value)
Finds a node given a value Will dispose of nodes if needed as it iterates the stack.

Parameters:
value -
Returns:
The node if found or null


Copyright © 2011. All Rights Reserved.