Top Description Inners Fields Constructors Methods
org.eclipse.jetty.util

public Class BlockingArrayQueue<E>

extends AbstractList<E>
implements BlockingQueue<E>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.BlockingQueue, java.util.Queue, java.util.Collection, java.lang.Iterable
Type Parameters
<E>
The element type
Imports
java.util.AbstractList, .Collection, .Iterator, .ListIterator, .NoSuchElementException, .Objects, java.util.concurrent.BlockingQueue, .TimeUnit, java.util.concurrent.atomic.AtomicInteger, java.util.concurrent.locks.Condition, .Lock, .ReentrantLock

A BlockingQueue backed by a circular array capable or growing.

This queue is uses a variant of the two lock queue algorithm to provide an efficient queue or list backed by a growable circular array.

Unlike java.util.concurrent.ArrayBlockingQueue, this class is able to grow and provides a blocking put call.

The queue has both a capacity (the size of the array currently allocated) and a max capacity (the maximum size that may be allocated), which defaults to Integer#MAX_VALUE.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private Object[]
private final int
private final Lock
private final int[]
_indexes

Array that holds the head and tail indexes, separated by a cache line to avoid false sharing

private final int
private final Condition
private final AtomicInteger
private final Lock
public static final int
DEFAULT_CAPACITY

Default initial capacity, 128.

public static final int
DEFAULT_GROWTH

Default growth factor, 64.

private static final int
HEAD_OFFSET

The head offset in the _indexes array, displaced by 15 slots to avoid false sharing with the array length (stored before the first element of the array itself).

private static final int
TAIL_OFFSET

The tail offset in the _indexes array, displaced by 16 slots from the head to avoid false sharing with it.

Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
public
BlockingArrayQueue()

Creates an unbounded BlockingArrayQueue with default initial capacity and grow factor.

public
BlockingArrayQueue(int
the maximum capacity
maxCapacity
)

Creates a bounded BlockingArrayQueue that does not grow.

public
BlockingArrayQueue(int
the initial capacity
capacity
,
int
the growth factor
growBy
)

Creates an unbounded BlockingArrayQueue that grows by the given parameter.

public
BlockingArrayQueue(int
the initial capacity
capacity
,
int
the growth factor
growBy
,
int
the maximum capacity
maxCapacity
)

Create a bounded BlockingArrayQueue that grows by the given parameter.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(E
the element to add
e
)

Overrides java.util.AbstractList.add.

Implements java.util.concurrent.BlockingQueue.add, java.util.List.add, java.util.Collection.add.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

public void
add(int
index at which the specified element is to be inserted
index
,
E
element to be inserted
e
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).

public void
clear()

Overrides java.util.AbstractList.clear.

Implements java.util.Collection.clear, java.util.List.clear.

Removes all of the elements from this collection (optional operation).

public int
drainTo(Collection<? super E>
the collection to transfer elements into
c
)

Implements java.util.concurrent.BlockingQueue.drainTo.

Removes all available elements from this queue and adds them to the given collection.

public int
drainTo(Collection<? super E>
the collection to transfer elements into
c
,
int
the maximum number of elements to transfer
maxElements
)

Implements java.util.concurrent.BlockingQueue.drainTo.

Removes at most the given number of available elements from this queue and adds them to the given collection.

public E
element()

Implements java.util.Queue.element.

Retrieves, but does not remove, the head of this queue.

public E
get(int
index of the element to return
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Returns the element at the specified position in this list.

public int

Returns:

the current capacity of this queue
getCapacity
()

Get the current capacity of this queue.

public int

Returns:

the max capacity of this queue, or -1 if this queue is unbounded
getMaxCapacity
()

Get the max capacity of this queue, or -1 if this queue is unbounded.

private boolean
grow()

public Iterator<E>
iterator()

Overrides java.util.AbstractList.iterator.

Implements java.util.Collection.iterator, java.util.List.iterator.

Returns an iterator over the elements in this collection.

public ListIterator<E>
listIterator(int
index of the first element to be returned from the list iterator (by a call to next)
index
)

Overrides java.util.AbstractList.listIterator.

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.

public boolean
offer(E
the element to add
e
)

Implements java.util.concurrent.BlockingQueue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available.

public boolean
offer(E
the element to add
o
,
long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingQueue.offer.

Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to become available.

public E
peek()

Implements java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

public E
poll()

Implements java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

public E
poll(long
how long to wait before giving up, in units of unit
time
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingQueue.poll.

Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.

public void
put(E
the element to add
o
)

Implements java.util.concurrent.BlockingQueue.put.

Inserts the specified element into this queue, waiting if necessary for space to become available.

public int
remainingCapacity()

Implements java.util.concurrent.BlockingQueue.remainingCapacity.

Returns the number of additional elements that this queue can ideally (in the absence of memory or resource constraints) accept without blocking, or Integer.MAX_VALUE if there is no intrinsic limit.

public E
remove()

Implements java.util.Queue.remove.

Retrieves and removes the head of this queue.

public E
remove(int
the index of the element to be removed
index
)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).

public boolean
remove(Object
element to be removed from this queue, if present
o
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.concurrent.BlockingQueue.remove, java.util.List.remove, java.util.Collection.remove.

Removes a single instance of the specified element from this queue, if it is present.

public E
set(int
index of the element to replace
index
,
E
element to be stored at the specified position
e
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size, java.util.List.size.

Returns the number of elements in this collection.

public E
take()

Implements java.util.concurrent.BlockingQueue.take.

Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.

Inherited from java.util.AbstractList:
addAllequalshashCodeindexOflastIndexOflistIteratorremoveRangesubList

Field Detail

_elementsback to summary
private Object[] _elements
_growCapacityback to summary
private final int _growCapacity
_headLockback to summary
private final Lock _headLock
_indexesback to summary
private final int[] _indexes

Array that holds the head and tail indexes, separated by a cache line to avoid false sharing

_maxCapacityback to summary
private final int _maxCapacity
_notEmptyback to summary
private final Condition _notEmpty
_sizeback to summary
private final AtomicInteger _size
_tailLockback to summary
private final Lock _tailLock
DEFAULT_CAPACITYback to summary
public static final int DEFAULT_CAPACITY

Default initial capacity, 128.

DEFAULT_GROWTHback to summary
public static final int DEFAULT_GROWTH

Default growth factor, 64.

HEAD_OFFSETback to summary
private static final int HEAD_OFFSET

The head offset in the _indexes array, displaced by 15 slots to avoid false sharing with the array length (stored before the first element of the array itself).

TAIL_OFFSETback to summary
private static final int TAIL_OFFSET

The tail offset in the _indexes array, displaced by 16 slots from the head to avoid false sharing with it.

Constructor Detail

BlockingArrayQueueback to summary
public BlockingArrayQueue()

Creates an unbounded BlockingArrayQueue with default initial capacity and grow factor.

See Also
DEFAULT_CAPACITY, DEFAULT_GROWTH
BlockingArrayQueueback to summary
public BlockingArrayQueue(int maxCapacity)

Creates a bounded BlockingArrayQueue that does not grow. The capacity of the queue is fixed and equal to the given parameter.

Parameters
maxCapacity:int

the maximum capacity

BlockingArrayQueueback to summary
public BlockingArrayQueue(int capacity, int growBy)

Creates an unbounded BlockingArrayQueue that grows by the given parameter.

Parameters
capacity:int

the initial capacity

growBy:int

the growth factor

BlockingArrayQueueback to summary
public BlockingArrayQueue(int capacity, int growBy, int maxCapacity)

Create a bounded BlockingArrayQueue that grows by the given parameter.

Parameters
capacity:int

the initial capacity

growBy:int

the growth factor

maxCapacity:int

the maximum capacity

Method Detail

addback to summary
public boolean add(E e)

Overrides java.util.AbstractList.add.

Implements java.util.concurrent.BlockingQueue.add, java.util.List.add, java.util.Collection.add.

Doc from java.util.concurrent.BlockingQueue.add.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available. When using a capacity-restricted queue, it is generally preferable to use offer.

Parameters
e:E

the element to add

Returns:boolean

true (as specified by Collection#add)

Annotations
@Override
addback to summary
public void add(int index, E e)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Doc from java.util.AbstractList.add.

Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters
index:int

Doc from java.util.List.add.

index at which the specified element is to be inserted

e:E

Doc from java.util.List.add.

element to be inserted

Annotations
@Override
clearback to summary
public void clear()

Overrides java.util.AbstractList.clear.

Implements java.util.Collection.clear, java.util.List.clear.

Doc from java.util.Collection.clear.

Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.

Annotations
@Override
drainToback to summary
public int drainTo(Collection<? super E> c)

Implements java.util.concurrent.BlockingQueue.drainTo.

Doc from java.util.concurrent.BlockingQueue.drainTo.

Removes all available elements from this queue and adds them to the given collection. This operation may be more efficient than repeatedly polling this queue. A failure encountered while attempting to add elements to collection c may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Parameters
c:Collection<? super E>

the collection to transfer elements into

Returns:int

the number of elements transferred

Annotations
@Override
drainToback to summary
public int drainTo(Collection<? super E> c, int maxElements)

Implements java.util.concurrent.BlockingQueue.drainTo.

Doc from java.util.concurrent.BlockingQueue.drainTo.

Removes at most the given number of available elements from this queue and adds them to the given collection. A failure encountered while attempting to add elements to collection c may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Parameters
c:Collection<? super E>

the collection to transfer elements into

maxElements:int

the maximum number of elements to transfer

Returns:int

the number of elements transferred

Annotations
@Override
elementback to summary
public E element()

Implements java.util.Queue.element.

Doc from java.util.Queue.element.

Retrieves, but does not remove, the head of this queue. This method differs from peek only in that it throws an exception if this queue is empty.

Returns:E

the head of this queue

Annotations
@Override
getback to summary
public E get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Doc from java.util.AbstractList.get.

Returns the element at the specified position in this list.

Parameters
index:int

Doc from java.util.List.get.

index of the element to return

Returns:E

Doc from java.util.List.get.

the element at the specified position in this list

Annotations
@SuppressWarnings:unchecked
@Override
getCapacityback to summary
public int getCapacity()

Get the current capacity of this queue.

Returns:int

the current capacity of this queue

getMaxCapacityback to summary
public int getMaxCapacity()

Get the max capacity of this queue, or -1 if this queue is unbounded.

Returns:int

the max capacity of this queue, or -1 if this queue is unbounded

growback to summary
private boolean grow()
iteratorback to summary
public Iterator<E> iterator()

Overrides java.util.AbstractList.iterator.

Implements java.util.Collection.iterator, java.util.List.iterator.

Doc from java.util.Collection.iterator.

Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).

Returns:Iterator<E>

an Iterator over the elements in this collection

Annotations
@Override
listIteratorback to summary
public ListIterator<E> listIterator(int index)

Overrides java.util.AbstractList.listIterator.

Implements java.util.List.listIterator.

Doc from java.util.AbstractList.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.

Parameters
index:int

Doc from java.util.List.listIterator.

index of the first element to be returned from the list iterator (by a call to next)

Returns:ListIterator<E>

Doc from java.util.List.listIterator.

a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list

Annotations
@Override
offerback to summary
public boolean offer(E e)

Implements java.util.concurrent.BlockingQueue.offer.

Doc from java.util.concurrent.BlockingQueue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available. When using a capacity-restricted queue, this method is generally preferable to add, which can fail to insert an element only by throwing an exception.

Parameters
e:E

the element to add

Returns:boolean

true if the element was added to this queue, else false

Annotations
@Override
offerback to summary
public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.BlockingQueue.offer.

Doc from java.util.concurrent.BlockingQueue.offer.

Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to become available.

Parameters
o:E

the element to add

timeout:long

how long to wait before giving up, in units of unit

unit:TimeUnit

a TimeUnit determining how to interpret the timeout parameter

Returns:boolean

true if successful, or false if the specified waiting time elapses before space is available

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
peekback to summary
public E peek()

Implements java.util.Queue.peek.

Doc from java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

Returns:E

the head of this queue, or null if this queue is empty

Annotations
@SuppressWarnings:unchecked
@Override
pollback to summary
public E poll()

Implements java.util.Queue.poll.

Doc from java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

Returns:E

the head of this queue, or null if this queue is empty

Annotations
@SuppressWarnings:unchecked
@Override
pollback to summary
public E poll(long time, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.BlockingQueue.poll.

Doc from java.util.concurrent.BlockingQueue.poll.

Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.

Parameters
time:long

how long to wait before giving up, in units of unit

unit:TimeUnit

a TimeUnit determining how to interpret the timeout parameter

Returns:E

the head of this queue, or null if the specified waiting time elapses before an element is available

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
InterruptedException:
if interrupted while waiting
putback to summary
public void put(E o) throws InterruptedException

Implements java.util.concurrent.BlockingQueue.put.

Doc from java.util.concurrent.BlockingQueue.put.

Inserts the specified element into this queue, waiting if necessary for space to become available.

Parameters
o:E

the element to add

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
remainingCapacityback to summary
public int remainingCapacity()

Implements java.util.concurrent.BlockingQueue.remainingCapacity.

Doc from java.util.concurrent.BlockingQueue.remainingCapacity.

Returns the number of additional elements that this queue can ideally (in the absence of memory or resource constraints) accept without blocking, or Integer.MAX_VALUE if there is no intrinsic limit.

Note that you cannot always tell if an attempt to insert an element will succeed by inspecting remainingCapacity because it may be the case that another thread is about to insert or remove an element.

Returns:int

the remaining capacity

Annotations
@Override
removeback to summary
public E remove()

Implements java.util.Queue.remove.

Doc from java.util.Queue.remove.

Retrieves and removes the head of this queue. This method differs from poll() only in that it throws an exception if this queue is empty.

Returns:E

the head of this queue

Annotations
@Override
removeback to summary
public E remove(int index)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Doc from java.util.AbstractList.remove.

Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters
index:int

Doc from java.util.List.remove.

the index of the element to be removed

Returns:E

Doc from java.util.List.remove.

the element previously at the specified position

Annotations
@SuppressWarnings:unchecked
@Override
removeback to summary
public boolean remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.concurrent.BlockingQueue.remove, java.util.List.remove, java.util.Collection.remove.

Doc from java.util.concurrent.BlockingQueue.remove.

Removes a single instance of the specified element from this queue, if it is present. More formally, removes an element e such that o.equals(e), if this queue contains one or more such elements. Returns true if this queue contained the specified element (or equivalently, if this queue changed as a result of the call).

Parameters
o:Object

element to be removed from this queue, if present

Returns:boolean

true if this queue changed as a result of the call

Annotations
@Override
setback to summary
public E set(int index, E e)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Doc from java.util.AbstractList.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

Doc from java.util.List.set.

index of the element to replace

e:E

Doc from java.util.List.set.

element to be stored at the specified position

Returns:E

Doc from java.util.List.set.

the element previously at the specified position

Annotations
@SuppressWarnings:unchecked
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size, java.util.List.size.

Doc from java.util.Collection.size.

Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this collection

Annotations
@Override
takeback to summary
public E take() throws InterruptedException

Implements java.util.concurrent.BlockingQueue.take.

Doc from java.util.concurrent.BlockingQueue.take.

Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.

Returns:E

the head of this queue

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
InterruptedException:
if interrupted while waiting
org.eclipse.jetty.util back to summary

private Class BlockingArrayQueue.Itr

extends Object
implements ListIterator<E>
Class Inheritance
All Implemented Interfaces
java.util.ListIterator, java.util.Iterator

Field Summary

Modifier and TypeField and Description
private int
private final Object[]

Constructor Summary

AccessConstructor and Description
public
Itr(Object[] elements, int offset)

Method Summary

Modifier and TypeMethod and Description
public void
add(E
the element to insert
e
)

Implements java.util.ListIterator.add.

Inserts the specified element into the list (optional operation).

public boolean
hasNext()

Implements java.util.ListIterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction.

public boolean
hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.

public E
next()

Implements java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position.

public int
nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.

public E
previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards.

public int
previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.

public void
remove()

Implements java.util.ListIterator.remove.

Removes from the list the last element that was returned by next or previous (optional operation).

public void
set(E
the element with which to replace the last element returned by next or previous
e
)

Implements java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_cursorback to summary
private int _cursor
_elementsback to summary
private final Object[] _elements

Constructor Detail

Itrback to summary
public Itr(Object[] elements, int offset)

Method Detail

addback to summary
public void add(E e)

Implements java.util.ListIterator.add.

Doc from java.util.ListIterator.add.

Inserts the specified element into the list (optional operation). The element is inserted immediately before the element that would be returned by next, if any, and after the element that would be returned by previous, if any. (If the list contains no elements, the new element becomes the sole element on the list.) The new element is inserted before the implicit cursor: a subsequent call to next would be unaffected, and a subsequent call to previous would return the new element. (This call increases by one the value that would be returned by a call to nextIndex or previousIndex.)

Parameters
e:E

the element to insert

Annotations
@Override
hasNextback to summary
public boolean hasNext()

Implements java.util.ListIterator.hasNext.

Doc from java.util.ListIterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the forward direction

Annotations
@Override
hasPreviousback to summary
public boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Doc from java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if previous would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the reverse direction

Annotations
@Override
nextback to summary
public E next()

Implements java.util.ListIterator.next.

Doc from java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position. This method may be called repeatedly to iterate through the list, or intermixed with calls to previous to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:E

the next element in the list

Annotations
@SuppressWarnings:unchecked
@Override
nextIndexback to summary
public int nextIndex()

Implements java.util.ListIterator.nextIndex.

Doc from java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next. (Returns list size if the list iterator is at the end of the list.)

Returns:int

the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list

Annotations
@Override
previousback to summary
public E previous()

Implements java.util.ListIterator.previous.

Doc from java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:E

the previous element in the list

Annotations
@SuppressWarnings:unchecked
@Override
previousIndexback to summary
public int previousIndex()

Implements java.util.ListIterator.previousIndex.

Doc from java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

Returns:int

the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list

Annotations
@Override
removeback to summary
public void remove()

Implements java.util.ListIterator.remove.

Doc from java.util.ListIterator.remove.

Removes from the list the last element that was returned by next or previous (optional operation). This call can only be made once per call to next or previous. It can be made only if add has not been called after the last call to next or previous.

Annotations
@Override
setback to summary
public void set(E e)

Implements java.util.ListIterator.set.

Doc from java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation). This call can be made only if neither remove nor add have been called after the last call to next or previous.

Parameters
e:E

the element with which to replace the last element returned by next or previous

Annotations
@Override