|
GATE Version 3.1-2270 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractList
gate.util.WeakBumpyStack
public class WeakBumpyStack
Weak stack that allow you to bump an element to the front. Objects that are only referenced by this stack will be candidates for garbage collection and wil be removed from the stack as soon as the garbage collector marks them for collection.
*** WARNING: *** the test for this class, TestBumpyStack.testSelfCleaning is not a proper test; it doesn't fail even when it should, and only prints a warning when DEBUG is true. This is because to test it properly you need to force garbage collection, and that isn't possible. So, if you work on this class you must turn DEBUG on on TestBumpyStack in order to run the tests in a meaningfull way.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
WeakBumpyStack()
Creates a new empty stack. |
Method Summary | |
---|---|
void |
add(int index,
Object element)
Inserts the specified element at the specified position in this list. |
boolean |
bump(Object item)
Bump an item to the front of the stack. |
boolean |
empty()
Tests if this stack is empty. |
Object |
get(int index)
Returns the element at the specified position in this list. |
Object |
peek()
Looks at the object at the top of this stack without removing it from the stack. |
Object |
pop()
Removes the object at the top of this stack and returns that object as the value of this function. |
protected void |
processQueue()
Checks the queue for any new weak references that have been cleared and queued and removes them from the underlying stack. |
Object |
push(Object item)
Pushes an item onto the top of this stack. |
Object |
remove(int index)
Removes the element at the specified position in this list. |
int |
search(Object o)
Returns the 1-based position where an object is on this stack. |
Object |
set(int index,
Object element)
Replaces the element at the specified position in this list with the specified element. |
int |
size()
Returns the number of elements in this list. |
Methods inherited from class java.util.AbstractList |
---|
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public WeakBumpyStack()
Method Detail |
---|
public Object push(Object item)
addElement(item)
item
- the item to be pushed onto this stack.
item
argument.public Object pop()
EmptyStackException
- if this stack is empty.public Object peek()
EmptyStackException
- if this stack is empty.public boolean empty()
true
if and only if this stack contains
no items; false
otherwise.public boolean bump(Object item)
item
- the item to bump
public int search(Object o)
o
- the desired object.
-1
indicates that the object is not on the stack.protected void processQueue()
public Object get(int index)
get
in interface List
get
in class AbstractList
index
- index of element to return.
IndexOutOfBoundsException
- if index is out of range (index
< 0 || index >= size()).public int size()
size
in interface Collection
size
in interface List
size
in class AbstractCollection
public Object set(int index, Object element)
set
in interface List
set
in class AbstractList
index
- index of element to replace.element
- element to be stored at the specified position.
IndexOutOfBoundsException
- if index out of range
(index < 0 || index >= size()).public void add(int index, Object element)
add
in interface List
add
in class AbstractList
index
- index at which the specified element is to be inserted.element
- element to be inserted.
IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > size()).public Object remove(int index)
remove
in interface List
remove
in class AbstractList
index
- the index of the element to removed.
IndexOutOfBoundsException
- if index out of range (index
< 0 || index >= size()).
|
GATE Version 3.1-2270 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |