@NotThreadSafe public final class ArrayListSimpleCollection<E> extends Object implements SimpleCollection<E>
SimpleCollection
backed by ArrayList
. Not
thread-safe. Mutable. Does not provide an iteration order or permit nulls.Constructor and Description |
---|
ArrayListSimpleCollection()
Create an empty collection.
|
ArrayListSimpleCollection(Collection<E> initial)
Create a collection from a collection.
|
ArrayListSimpleCollection(int initialCapacity)
Create an empty collection with an initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E element)
Add element to the end of the list.
|
E |
get(int index)
Set an element as a specific position.
|
boolean |
isEmpty() |
Iterator<E> |
iterator()
Returns an iterator over the elements in this collection.
|
boolean |
remove(E element) |
E |
set(int index,
E element)
Set an element as a specific position.
|
int |
size()
Returns an estimate of the number of elements in the collection.
|
Iterator<E> |
structuralIterator()
An iterator over the structure of the collection.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
stream
forEach, spliterator
public ArrayListSimpleCollection()
public ArrayListSimpleCollection(Collection<E> initial)
initial
- The initial collectionpublic ArrayListSimpleCollection(int initialCapacity)
initialCapacity
- The initial capacitypublic void add(E element)
element
- The element to addpublic E get(int index) throws IndexOutOfBoundsException
index
- The positionIndexOutOfBoundsException
- If index is greater than the current sizepublic E set(int index, E element)
index
- The positionelement
- The elementpublic boolean remove(E element)
public int size()
SimpleCollection
size
in interface SimpleCollection<E>
public boolean isEmpty()
isEmpty
in interface SimpleCollection<E>
true
if there are no childrenpublic Iterator<E> structuralIterator()
SimpleCollection
structuralIterator
in interface SimpleCollection<E>
public Iterator<E> iterator()
SimpleCollection
Copyright © 2014–2016. All rights reserved.