public class List<A> extends AbstractCollection<A> implements List<A>
Lists are always trailed by a sentinel element, whose head and tail are both null.
This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Modifier and Type | Field and Description |
---|---|
A |
head
The first element of the list, supposed to be immutable.
|
List<A> |
tail
The remainder of the list except for its first element, supposed
to be immutable.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
A element) |
boolean |
addAll(int index,
Collection<? extends A> c) |
List<A> |
append(A x)
Append given element at length, forming and returning
a new list.
|
List<A> |
appendList(List<A> x)
Append given list at length, forming and returning
a new list.
|
List<A> |
appendList(ListBuffer<A> x)
Append given list buffer at length, forming and returning a new
list.
|
boolean |
contains(Object x)
Does the list contain the specified element?
|
static <T> List<T> |
convert(Class<T> klass,
List<?> list) |
List<A> |
diff(List<A> that) |
static boolean |
equals(List<?> xs,
List<?> ys)
Are the two lists the same?
|
boolean |
equals(Object other)
Is this list the same as other list?
|
static <A> List<A> |
fill(int len,
A init)
Deprecated.
|
static <A> List<A> |
filter(List<A> l,
A elem)
Returns the list obtained from 'l' after removing all elements 'elem'
|
static <A> List<A> |
from(A[] array)
Construct a list consisting all elements of given array.
|
static <A> List<A> |
from(Iterable<? extends A> coll) |
A |
get(int index) |
int |
hashCode()
Compute a hash code, overrides Object
|
int |
indexOf(Object o) |
List<A> |
intersect(List<A> that) |
boolean |
isEmpty()
Does list have no elements?
|
Iterator<A> |
iterator() |
A |
last()
The last element in the list, if any, or null.
|
int |
lastIndexOf(Object o) |
int |
length()
Return the number of elements in this list.
|
ListIterator<A> |
listIterator() |
ListIterator<A> |
listIterator(int index) |
static <A> List<A> |
nil()
Construct an empty list.
|
boolean |
nonEmpty()
Does list have elements?
|
static <A> List<A> |
of(A x1)
Construct a list consisting of given element.
|
static <A> List<A> |
of(A x1,
A x2)
Construct a list consisting of given elements.
|
static <A> List<A> |
of(A x1,
A x2,
A x3)
Construct a list consisting of given elements.
|
static <A> List<A> |
of(A x1,
A x2,
A x3,
A... rest)
Construct a list consisting of given elements.
|
List<A> |
prepend(A x)
Prepend given element to front of list, forming and returning
a new list.
|
List<A> |
prependList(List<A> xs)
Prepend given list of elements to front of list, forming and returning
a new list.
|
A |
remove(int index) |
List<A> |
reverse()
Reverse list.
|
A |
set(int index,
A element) |
List<A> |
setTail(List<A> tail) |
int |
size() |
List<A> |
subList(int fromIndex,
int toIndex) |
List<A> |
take(int n)
Create a new list from the first
n elements of this list |
Object[] |
toArray() |
<T> T[] |
toArray(T[] vec)
Copy successive elements of this list into given vector until
list is exhausted or end of vector is reached.
|
String |
toString()
Form a string listing all elements with comma as the separator character.
|
String |
toString(String sep)
Form a string listing all elements with given separator character.
|
add, addAll, clear, containsAll, remove, removeAll, retainAll
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, addAll, clear, containsAll, of, of, of, of, of, of, of, remove, removeAll, replaceAll, retainAll, sort, spliterator
parallelStream, removeIf, stream
public A head
public static <A> List<A> nil()
public static <A> List<A> filter(List<A> l, A elem)
public static <A> List<A> of(A x1)
public static <A> List<A> of(A x1, A x2)
public static <A> List<A> of(A x1, A x2, A x3)
public static <A> List<A> of(A x1, A x2, A x3, A... rest)
public static <A> List<A> from(A[] array)
array
- an array; if null
return an empty list@Deprecated public static <A> List<A> fill(int len, A init)
len
- The number of elements in the list.init
- The value of each element.public boolean isEmpty()
isEmpty
in interface Collection<A>
isEmpty
in interface List<A>
isEmpty
in class AbstractCollection<A>
public boolean nonEmpty()
public int length()
public int size()
size
in interface Collection<A>
size
in interface List<A>
size
in class AbstractCollection<A>
public List<A> prepend(A x)
public List<A> prependList(List<A> xs)
public List<A> reverse()
public List<A> appendList(List<A> x)
public List<A> appendList(ListBuffer<A> x)
public <T> T[] toArray(T[] vec)
toArray
in interface Collection<A>
toArray
in interface List<A>
toArray
in class AbstractCollection<A>
public Object[] toArray()
toArray
in interface Collection<A>
toArray
in interface List<A>
toArray
in class AbstractCollection<A>
public String toString(String sep)
public String toString()
toString
in class AbstractCollection<A>
public int hashCode()
hashCode
in interface Collection<A>
hashCode
in interface List<A>
hashCode
in class Object
List.hashCode()
public boolean equals(Object other)
equals
in interface Collection<A>
equals
in interface List<A>
equals
in class Object
List.equals(java.lang.Object)
public boolean contains(Object x)
contains
in interface Collection<A>
contains
in interface List<A>
contains
in class AbstractCollection<A>
public A last()
public boolean addAll(int index, Collection<? extends A> c)
public int lastIndexOf(Object o)
lastIndexOf
in interface List<A>
public ListIterator<A> listIterator()
listIterator
in interface List<A>
public ListIterator<A> listIterator(int index)
listIterator
in interface List<A>
Copyright © 2017 earcam. All rights reserved.