E - the type of the elements in the bag.public final class ArrayBag<E> extends AbstractBag<E> implements Serializable
Bag implementation based on ArrayList. This implementation
provides a predictable iteration order which is the order in which elements
were inserted into the bag (insertion-order). Also, this implementation
accepts null elements. Instances of this class are not thread-safe.| Constructor and Description |
|---|
ArrayBag()
Creates a new empty
ArrayBag. |
ArrayBag(Collection<? extends E> c)
Creates a new
ArrayBag using the elements contained in the
given Collection. |
ArrayBag(E... elements)
Creates a new
ArrayBag using the elements contained in the
given array. |
ArrayBag(int initialCapacity)
Creates a new empty
ArrayBag having the given initial capacity. |
ArrayBag(Iterable<? extends E> i)
Creates a new
ArrayBag using the elements contained in the
given Iterable. |
ArrayBag(Iterator<? extends E> i)
Creates a new
ArrayBag using the elements contained in the
given Iterator. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
count, equals, hashCodetoStringpublic ArrayBag()
ArrayBag.public ArrayBag(int initialCapacity)
ArrayBag having the given initial capacity.initialCapacity - the bag's initial capacity.IllegalArgumentException - if initialCapacity < 0.public ArrayBag(Collection<? extends E> c)
ArrayBag using the elements contained in the
given Collection.c - the collection to use to populate the created bag.NullPointerException - if c is null.public ArrayBag(Iterable<? extends E> i)
ArrayBag using the elements contained in the
given Iterable.i - the iterable to use to populate the created bag.NullPointerException - if i is null.public ArrayBag(Iterator<? extends E> i)
ArrayBag using the elements contained in the
given Iterator.i - the iterator to use to populate the created bag.NullPointerException - if i is null.public ArrayBag(E... elements)
ArrayBag using the elements contained in the
given array.elements - the elements to use to populate the created bag.NullPointerException - if elements is null.public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>public int size()
size in interface Collection<E>size in class AbstractCollection<E>public void clear()
clear in interface Collection<E>clear in class AbstractCollection<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in class AbstractCollection<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in class AbstractCollection<E>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in class AbstractCollection<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in class AbstractCollection<E>public boolean add(E e)
add in interface Collection<E>add in class AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in class AbstractCollection<E>Copyright © 2012–2015. All rights reserved.