org.eclipse.jetty.util
Class ArrayQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.eclipse.jetty.util.ArrayQueue<E>
- Type Parameters:
E -
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, List<E>, Queue<E>
public class ArrayQueue<E>
- extends AbstractList<E>
- implements Queue<E>
Queue backed by circular array.
This partial Queue implementation (also with remove() for stack operation)
is backed by a growable circular array.
| Methods inherited from interface java.util.Collection |
addAll, contains, containsAll, equals, hashCode, iterator, remove, removeAll, retainAll, toArray, toArray |
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
- See Also:
- Constant Field Values
DEFAULT_GROWTH
public static final int DEFAULT_GROWTH
- See Also:
- Constant Field Values
_lock
protected final Object _lock
_growCapacity
protected final int _growCapacity
_elements
protected Object[] _elements
_nextE
protected int _nextE
_nextSlot
protected int _nextSlot
_size
protected int _size
ArrayQueue
public ArrayQueue()
ArrayQueue
public ArrayQueue(int capacity)
ArrayQueue
public ArrayQueue(int initCapacity,
int growBy)
ArrayQueue
public ArrayQueue(int initCapacity,
int growBy,
Object lock)
getCapacity
public int getCapacity()
add
public boolean add(E e)
- Specified by:
add in interface Collection<E>- Specified by:
add in interface List<E>- Specified by:
add in interface Queue<E>- Overrides:
add in class AbstractList<E>
offer
public boolean offer(E e)
- Specified by:
offer in interface Queue<E>
addUnsafe
public void addUnsafe(E e)
- Add without synchronization or bounds checking
- Parameters:
e - the element to add- See Also:
add(Object)
element
public E element()
- Specified by:
element in interface Queue<E>
peek
public E peek()
- Specified by:
peek in interface Queue<E>
poll
public E poll()
- Specified by:
poll in interface Queue<E>
remove
public E remove()
- Specified by:
remove in interface Queue<E>
clear
public void clear()
- Specified by:
clear in interface Collection<E>- Specified by:
clear in interface List<E>- Overrides:
clear in class AbstractList<E>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Collection<E>- Specified by:
isEmpty in interface List<E>- Overrides:
isEmpty in class AbstractCollection<E>
size
public int size()
- Specified by:
size in interface Collection<E>- Specified by:
size in interface List<E>- Specified by:
size in class AbstractCollection<E>
get
public E get(int index)
- Specified by:
get in interface List<E>- Specified by:
get in class AbstractList<E>
getUnsafe
public E getUnsafe(int index)
- Get without synchronization or bounds checking.
- Parameters:
index - index of the element to return
- Returns:
- the element at the specified index
- See Also:
get(int)
remove
public E remove(int index)
- Specified by:
remove in interface List<E>- Overrides:
remove in class AbstractList<E>
set
public E set(int index,
E element)
- Specified by:
set in interface List<E>- Overrides:
set in class AbstractList<E>
add
public void add(int index,
E element)
- Specified by:
add in interface List<E>- Overrides:
add in class AbstractList<E>
grow
protected boolean grow()
Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.