E
- element typepublic class SingleLinkedList<E> extends Object implements Iterable<E>, Serializable
Constructor and Description |
---|
SingleLinkedList()
Creates a new instance without elements.
|
SingleLinkedList(Iterable<? extends E> iterable)
Creates a new instance from
Iterable . |
SingleLinkedList(List<? extends E> list)
Creates a new instance from
List . |
Modifier and Type | Method and Description |
---|---|
SingleLinkedList<E> |
concat(E element)
Creates and returns a new list with the value in head of this list.
|
boolean |
equals(Object obj) |
<C extends Collection<? super E>> |
fill(C target)
Fills elements in this list into the target
Collection . |
E |
first()
Returns the first element in this list.
|
E |
get(int index)
Returns the
index -th element in this list. |
int |
hashCode() |
boolean |
isEmpty()
Returns whether this list has no elements.
|
Iterator<E> |
iterator() |
SingleLinkedList<E> |
rest()
Returns a new list dropping the first element from this list.
|
int |
size()
Returns number of elements in this list.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public SingleLinkedList()
public SingleLinkedList(List<? extends E> list)
List
.list
- target listIllegalArgumentException
- if some parameters were null
public SingleLinkedList(Iterable<? extends E> iterable)
Iterable
.iterable
- target iterableIllegalArgumentException
- if some parameters were null
public boolean isEmpty()
true
if this list is empty, otherwise false
public int size()
public SingleLinkedList<E> concat(E element)
element
- target elementpublic E first()
NoSuchElementException
- if this list is emptypublic SingleLinkedList<E> rest()
NoSuchElementException
- if this list is emptypublic E get(int index)
index
-th element in this list.index
- target element index (0-origin)index
-th elementIndexOutOfBoundsException
- if index is out of boundpublic <C extends Collection<? super E>> C fill(C target)
Collection
.C
- collection typetarget
- the target collectiontarget
IllegalArgumentException
- if some parameters were null
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.