E - the type of the Bag's elements.public final class ImmutableBag<E> extends AbstractBag<E> implements Serializable
Bag implementation. Accepts null values.| Modifier and Type | Class and Description |
|---|---|
static class |
ImmutableBag.Builder<E>
ImmutableBag builder. |
| 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) |
static <E> Bag<E> |
copyOf(Collection<? extends E> c)
Creates a new
ImmutableBag from the given Collection. |
static <E> Bag<E> |
copyOf(E[] values)
Creates a new
ImmutableBag containing the given elements. |
static <E> Bag<E> |
copyOf(Iterable<? extends E> i)
Creates a new
ImmutableBag from the given Iterable. |
static <E> Bag<E> |
copyOf(Iterator<? extends E> i)
Creates a new
ImmutableBag from the given Iterator. |
int |
count(E e)
Returns the count of the given element in this bag.
|
boolean |
isEmpty() |
Iterator<E> |
iterator() |
static <E> Bag<E> |
of(E... values)
Creates a new
ImmutableBag containing the given elements. |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
equals, hashCodetoStringpublic static <E> Bag<E> copyOf(Collection<? extends E> c)
ImmutableBag from the given Collection.E - the type of the Bag's elements.c - the source Collection.ImmutableBag.NullPointerException - if c is null.public static <E> Bag<E> copyOf(Iterable<? extends E> i)
ImmutableBag from the given Iterable.E - the type of the Bag's elements.i - the source Iterable.ImmutableBag.NullPointerException - if i is null.public static <E> Bag<E> copyOf(Iterator<? extends E> i)
ImmutableBag from the given Iterator.E - the type of the Bag's elements.i - the source Iterator.ImmutableBag.NullPointerException - if i is null.public static <E> Bag<E> copyOf(E[] values)
ImmutableBag containing the given elements.E - the type of the Bag's elements.values - the Bag's elements.ImmutableBag.NullPointerException - if values is null.public static <E> Bag<E> of(E... values)
ImmutableBag containing the given elements.E - the type of the Bag's elements.values - the Bag's elements.ImmutableBag.NullPointerException - if values is null.public int count(E e)
Bagpublic int size()
size in interface Collection<E>size in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in class AbstractCollection<E>public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in class AbstractCollection<E>public boolean add(E e)
add in interface Collection<E>add in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in class AbstractCollection<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in class AbstractCollection<E>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in class AbstractCollection<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in class AbstractCollection<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in class AbstractCollection<E>public void clear()
clear in interface Collection<E>clear in class AbstractCollection<E>Copyright © 2012–2015. All rights reserved.