Top Description Fields Constructors Methods
io.undertow.util

public final Class HeaderValues

extends AbstractCollection<String>
implements Deque<String>, List<String>, RandomAccess
Class Inheritance
All Implemented Interfaces
java.util.RandomAccess, java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable, java.util.Deque, java.util.Queue
Static Imports
org.wildfly.common.Assert.checkNotNullParam

An array-backed list/deque for header string values.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
pack-priv final HttpString
private static final String[]
pack-priv byte
pack-priv Object

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
add(final int
index at which the specified element is to be inserted
index
,
final String
element to be inserted
s
)

Implements java.util.List.add.

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

public boolean
add(final String
the element to add
s
)

Overrides java.util.AbstractCollection.add.

Implements java.util.Deque.add, java.util.List.add, java.util.Collection.add.

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) 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 boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
final Collection<? extends String>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).

public boolean
addAll(final Collection<? extends String>
the elements to be inserted into this deque
c
)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.Deque.addAll, java.util.List.addAll, java.util.Collection.addAll.

Adds all of the elements in the specified collection at the end of this deque, as if by calling addLast on each one, in the order that they are returned by the collection's iterator.

public void
addFirst(final String
the element to add
s
)

Overrides default java.util.List.addFirst.

Implements java.util.Deque.addFirst.

Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

public void
addLast(final String
the element to add
s
)

Overrides default java.util.List.addLast.

Implements java.util.Deque.addLast.

Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

public void
clear()

Overrides java.util.AbstractCollection.clear.

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

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

private void
public boolean
contains(final Object
element whose presence in this deque is to be tested
o
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Deque.contains, java.util.List.contains, java.util.Collection.contains.

Returns true if this deque contains the specified element.

public Iterator<String>
descendingIterator()

Implements java.util.Deque.descendingIterator.

Returns an iterator over the elements in this deque in reverse sequential order.

public String
element()

Implements java.util.Deque.element.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).

public String
get(int
index of the element to return
idx
)

Implements java.util.List.get.

Returns the element at the specified position in this list.

public String
getFirst()

Overrides default java.util.List.getFirst.

Implements java.util.Deque.getFirst.

Retrieves, but does not remove, the first element of this deque.

public HttpString
public String
getLast()

Overrides default java.util.List.getLast.

Implements java.util.Deque.getLast.

Retrieves, but does not remove, the last element of this deque.

private int
index(int idx)

public int
indexOf(final Object
element to search for
o
)

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

public boolean
isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty, java.util.List.isEmpty.

Returns true if this list contains no elements.

public Iterator<String>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

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

Returns an iterator over the elements in this deque in proper sequence.

private ListIterator<String>
iterator(final int start, final boolean forwards)

public int
lastIndexOf(final Object
element to search for
o
)

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.

public ListIterator<String>
listIterator()

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

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

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.

private boolean
offer(int idx, final String headerValue)

public boolean
offer(final String
the element to add
s
)

Implements java.util.Deque.offer.

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) 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
offerFirst(final String
the element to add
headerValue
)

Implements java.util.Deque.offerFirst.

Inserts the specified element at the front of this deque unless it would violate capacity restrictions.

public boolean
offerLast(final String
the element to add
headerValue
)

Implements java.util.Deque.offerLast.

Inserts the specified element at the end of this deque unless it would violate capacity restrictions.

private void
offerLastMultiValue(String headerValue, int size, String[] value)

public String
peek()

Implements java.util.Deque.peek.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

public String
peekFirst()

Implements java.util.Deque.peekFirst.

Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.

public String
peekLast()

Implements java.util.Deque.peekLast.

Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.

public String
poll()

Implements java.util.Deque.poll.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

public String
pollFirst()

Implements java.util.Deque.pollFirst.

Retrieves and removes the first element of this deque, or returns null if this deque is empty.

public String
pollLast()

Implements java.util.Deque.pollLast.

Retrieves and removes the last element of this deque, or returns null if this deque is empty.

public String
pop()

Implements java.util.Deque.pop.

Pops an element from the stack represented by this deque.

public void
push(final String
the element to push
s
)

Implements java.util.Deque.push.

Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

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

Implements java.util.List.remove.

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

public String
remove()

Implements java.util.Deque.remove.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque).

public boolean
remove(Object
element to be removed from this deque, if present
obj
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Deque.remove, java.util.List.remove, java.util.Collection.remove.

Removes the first occurrence of the specified element from this deque.

public String
removeFirst()

Overrides default java.util.List.removeFirst.

Implements java.util.Deque.removeFirst.

Retrieves and removes the first element of this deque.

public boolean
removeFirstOccurrence(final Object
element to be removed from this deque, if present
o
)

Implements java.util.Deque.removeFirstOccurrence.

Removes the first occurrence of the specified element from this deque.

public String
removeLast()

Overrides default java.util.List.removeLast.

Implements java.util.Deque.removeLast.

Retrieves and removes the last element of this deque.

public boolean
removeLastOccurrence(final Object
element to be removed from this deque, if present
o
)

Implements java.util.Deque.removeLastOccurrence.

Removes the last occurrence of the specified element from this deque.

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

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.Deque.size, java.util.List.size, java.util.Collection.size.

Returns the number of elements in this deque.

public List<String>
subList(final int
low endpoint (inclusive) of the subList
fromIndex
,
final int
high endpoint (exclusive) of the subList
toIndex
)

Implements java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

public String[]
toArray()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray, java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

public <T> T[]
toArray(final T[]
the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray, java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

Inherited from java.util.AbstractCollection:
containsAllremoveAllretainAlltoString

Field Detail

keyback to summary
pack-priv final HttpString key
NO_STRINGSback to summary
private static final String[] NO_STRINGS
sizeback to summary
pack-priv byte size
valueback to summary
pack-priv Object value

Constructor Detail

HeaderValuesback to summary
pack-priv HeaderValues(final HttpString key)

Method Detail

addback to summary
public void add(final int index, final String s)

Implements java.util.List.add.

Doc from java.util.List.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

index at which the specified element is to be inserted

s:String

element to be inserted

addback to summary
public boolean add(final String s)

Overrides java.util.AbstractCollection.add.

Implements java.util.Deque.add, java.util.List.add, java.util.Collection.add.

Doc from java.util.Deque.add.

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) 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 deque, it is generally preferable to use offer.

This method is equivalent to addLast.

Parameters
s:String

the element to add

Returns:boolean

true (as specified by Collection#add)

addAllback to summary
public boolean addAll(int index, final Collection<? extends String> c)

Implements java.util.List.addAll.

Doc from java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

Parameters
index:int

index at which to insert the first element from the specified collection

c:Collection<? extends String>

collection containing elements to be added to this list

Returns:boolean

true if this list changed as a result of the call

addAllback to summary
public boolean addAll(final Collection<? extends String> c)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.Deque.addAll, java.util.List.addAll, java.util.Collection.addAll.

Doc from java.util.Deque.addAll.

Adds all of the elements in the specified collection at the end of this deque, as if by calling addLast on each one, in the order that they are returned by the collection's iterator.

When using a capacity-restricted deque, it is generally preferable to call offer separately on each element.

An exception encountered while trying to add an element may result in only some of the elements having been successfully added when the associated exception is thrown.

Parameters
c:Collection<? extends String>

the elements to be inserted into this deque

Returns:boolean

true if this deque changed as a result of the call

addFirstback to summary
public void addFirst(final String s)

Overrides default java.util.List.addFirst.

Implements java.util.Deque.addFirst.

Doc from java.util.Deque.addFirst.

Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available. When using a capacity-restricted deque, it is generally preferable to use method offerFirst.

Parameters
s:String

the element to add

addLastback to summary
public void addLast(final String s)

Overrides default java.util.List.addLast.

Implements java.util.Deque.addLast.

Doc from java.util.Deque.addLast.

Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available. When using a capacity-restricted deque, it is generally preferable to use method offerLast.

This method is equivalent to add.

Parameters
s:String

the element to add

clearback to summary
public void clear()

Overrides java.util.AbstractCollection.clear.

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

Doc from java.util.List.clear.

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

clearInternalback to summary
private void clearInternal()
containsback to summary
public boolean contains(final Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Deque.contains, java.util.List.contains, java.util.Collection.contains.

Doc from java.util.Deque.contains.

Returns true if this deque contains the specified element. More formally, returns true if and only if this deque contains at least one element e such that Objects.equals(o, e).

Parameters
o:Object

element whose presence in this deque is to be tested

Returns:boolean

true if this deque contains the specified element

descendingIteratorback to summary
public Iterator<String> descendingIterator()

Implements java.util.Deque.descendingIterator.

Doc from java.util.Deque.descendingIterator.

Returns an iterator over the elements in this deque in reverse sequential order. The elements will be returned in order from last (tail) to first (head).

Returns:Iterator<String>

an iterator over the elements in this deque in reverse sequence

elementback to summary
public String element()

Implements java.util.Deque.element.

Doc from java.util.Deque.element.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque). This method differs from peek only in that it throws an exception if this deque is empty.

This method is equivalent to getFirst().

Returns:String

the head of the queue represented by this deque

getback to summary
public String get(int idx)

Implements java.util.List.get.

Doc from java.util.List.get.

Returns the element at the specified position in this list.

Parameters
idx:int

index of the element to return

Returns:String

the element at the specified position in this list

getFirstback to summary
public String getFirst()

Overrides default java.util.List.getFirst.

Implements java.util.Deque.getFirst.

Doc from java.util.Deque.getFirst.

Retrieves, but does not remove, the first element of this deque. This method differs from peekFirst only in that it throws an exception if this deque is empty.

Returns:String

the head of this deque

getHeaderNameback to summary
public HttpString getHeaderName()
getLastback to summary
public String getLast()

Overrides default java.util.List.getLast.

Implements java.util.Deque.getLast.

Doc from java.util.Deque.getLast.

Retrieves, but does not remove, the last element of this deque. This method differs from peekLast only in that it throws an exception if this deque is empty.

Returns:String

the tail of this deque

indexback to summary
private int index(int idx)
indexOfback to summary
public int indexOf(final Object o)

Implements java.util.List.indexOf.

Doc from java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Parameters
o:Object

element to search for

Returns:int

the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element

isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty, java.util.List.isEmpty.

Doc from java.util.List.isEmpty.

Returns true if this list contains no elements.

Returns:boolean

true if this list contains no elements

iteratorback to summary
public Iterator<String> iterator()

Implements abstract java.util.AbstractCollection.iterator.

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

Doc from java.util.Deque.iterator.

Returns an iterator over the elements in this deque in proper sequence. The elements will be returned in order from first (head) to last (tail).

Returns:Iterator<String>

an iterator over the elements in this deque in proper sequence

iteratorback to summary
private ListIterator<String> iterator(final int start, final boolean forwards)
lastIndexOfback to summary
public int lastIndexOf(final Object o)

Implements java.util.List.lastIndexOf.

Doc from java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Parameters
o:Object

element to search for

Returns:int

the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element

listIteratorback to summary
public ListIterator<String> listIterator()

Implements java.util.List.listIterator.

Doc from java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

Returns:ListIterator<String>

a list iterator over the elements in this list (in proper sequence)

listIteratorback to summary
public ListIterator<String> listIterator(final int index)

Implements java.util.List.listIterator.

Doc from 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. 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

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

Returns:ListIterator<String>

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

offerback to summary
private boolean offer(int idx, final String headerValue)
offerback to summary
public boolean offer(final String s)

Implements java.util.Deque.offer.

Doc from java.util.Deque.offer.

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) 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 deque, this method is generally preferable to the add method, which can fail to insert an element only by throwing an exception.

This method is equivalent to offerLast.

Parameters
s:String

the element to add

Returns:boolean

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

offerFirstback to summary
public boolean offerFirst(final String headerValue)

Implements java.util.Deque.offerFirst.

Doc from java.util.Deque.offerFirst.

Inserts the specified element at the front of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to the addFirst method, which can fail to insert an element only by throwing an exception.

Parameters
headerValue:String

the element to add

Returns:boolean

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

offerLastback to summary
public boolean offerLast(final String headerValue)

Implements java.util.Deque.offerLast.

Doc from java.util.Deque.offerLast.

Inserts the specified element at the end of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to the addLast method, which can fail to insert an element only by throwing an exception.

Parameters
headerValue:String

the element to add

Returns:boolean

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

offerLastMultiValueback to summary
private void offerLastMultiValue(String headerValue, int size, String[] value)
peekback to summary
public String peek()

Implements java.util.Deque.peek.

Doc from java.util.Deque.peek.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

This method is equivalent to peekFirst().

Returns:String

the head of the queue represented by this deque, or null if this deque is empty

peekFirstback to summary
public String peekFirst()

Implements java.util.Deque.peekFirst.

Doc from java.util.Deque.peekFirst.

Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.

Returns:String

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

peekLastback to summary
public String peekLast()

Implements java.util.Deque.peekLast.

Doc from java.util.Deque.peekLast.

Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.

Returns:String

the tail of this deque, or null if this deque is empty

pollback to summary
public String poll()

Implements java.util.Deque.poll.

Doc from java.util.Deque.poll.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

This method is equivalent to pollFirst().

Returns:String

the first element of this deque, or null if this deque is empty

pollFirstback to summary
public String pollFirst()

Implements java.util.Deque.pollFirst.

Doc from java.util.Deque.pollFirst.

Retrieves and removes the first element of this deque, or returns null if this deque is empty.

Returns:String

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

pollLastback to summary
public String pollLast()

Implements java.util.Deque.pollLast.

Doc from java.util.Deque.pollLast.

Retrieves and removes the last element of this deque, or returns null if this deque is empty.

Returns:String

the tail of this deque, or null if this deque is empty

popback to summary
public String pop()

Implements java.util.Deque.pop.

Doc from java.util.Deque.pop.

Pops an element from the stack represented by this deque. In other words, removes and returns the first element of this deque.

This method is equivalent to removeFirst().

Returns:String

the element at the front of this deque (which is the top of the stack represented by this deque)

pushback to summary
public void push(final String s)

Implements java.util.Deque.push.

Doc from java.util.Deque.push.

Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

This method is equivalent to addFirst.

Parameters
s:String

the element to push

removeback to summary
public String remove(int idx)

Implements java.util.List.remove.

Doc from java.util.List.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
idx:int

the index of the element to be removed

Returns:String

the element previously at the specified position

removeback to summary
public String remove()

Implements java.util.Deque.remove.

Doc from java.util.Deque.remove.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque). This method differs from poll() only in that it throws an exception if this deque is empty.

This method is equivalent to removeFirst().

Returns:String

the head of the queue represented by this deque

removeback to summary
public boolean remove(Object obj)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Deque.remove, java.util.List.remove, java.util.Collection.remove.

Doc from java.util.Deque.remove.

Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that Objects.equals(o, e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

This method is equivalent to removeFirstOccurrence(Object).

Parameters
obj:Object

element to be removed from this deque, if present

Returns:boolean

true if an element was removed as a result of this call

removeFirstback to summary
public String removeFirst()

Overrides default java.util.List.removeFirst.

Implements java.util.Deque.removeFirst.

Doc from java.util.Deque.removeFirst.

Retrieves and removes the first element of this deque. This method differs from pollFirst only in that it throws an exception if this deque is empty.

Returns:String

the head of this deque

removeFirstOccurrenceback to summary
public boolean removeFirstOccurrence(final Object o)

Implements java.util.Deque.removeFirstOccurrence.

Doc from java.util.Deque.removeFirstOccurrence.

Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that Objects.equals(o, e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

Parameters
o:Object

element to be removed from this deque, if present

Returns:boolean

true if an element was removed as a result of this call

removeLastback to summary
public String removeLast()

Overrides default java.util.List.removeLast.

Implements java.util.Deque.removeLast.

Doc from java.util.Deque.removeLast.

Retrieves and removes the last element of this deque. This method differs from pollLast only in that it throws an exception if this deque is empty.

Returns:String

the tail of this deque

removeLastOccurrenceback to summary
public boolean removeLastOccurrence(final Object o)

Implements java.util.Deque.removeLastOccurrence.

Doc from java.util.Deque.removeLastOccurrence.

Removes the last occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the last element e such that Objects.equals(o, e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

Parameters
o:Object

element to be removed from this deque, if present

Returns:boolean

true if an element was removed as a result of this call

setback to summary
public String set(final int index, final String element)

Implements java.util.List.set.

Doc from java.util.List.set.

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

Parameters
index:int

index of the element to replace

element:String

element to be stored at the specified position

Returns:String

the element previously at the specified position

sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

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

Doc from java.util.Deque.size.

Returns the number of elements in this deque.

Returns:int

the number of elements in this deque

subListback to summary
public List<String> subList(final int fromIndex, final int toIndex)

Implements java.util.List.subList.

Doc from java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:

list.subList(from, to).clear();
Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList.

The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

Parameters
fromIndex:int

low endpoint (inclusive) of the subList

toIndex:int

high endpoint (exclusive) of the subList

Returns:List<String>

a view of the specified range within this list

toArrayback to summary
public String[] toArray()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray, java.util.List.toArray.

Doc from java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Returns:String[]

an array containing all of the elements in this list in proper sequence

toArrayback to summary
public <T> T[] toArray(final T[] a)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray, java.util.List.toArray.

Doc from java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.

If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the list is set to null. (This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.)

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a list known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:

String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Parameters
<T>

Doc from java.util.Collection.toArray. the component type of the array to contain the collection

a:T[]

the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.

Returns:T[]

an array containing the elements of this list