E - The type of element managed by the collection.public class Bag<E> extends OrderedCollection<E>
| Constructor and Description |
|---|
Bag()
This constructor creates a new empty bag with no comparator function.
|
Bag(java.util.Comparator<? super E> comparator)
This constructor creates a new bag with the specified comparator function.
|
Bag(E[] elements)
This constructor creates a new bag with no comparator function and seeds
it with the elements from the specified array.
|
Bag(E[] elements,
java.util.Comparator<? super E> comparator)
This constructor creates a new bag with the specified comparator function and seeds
it with the elements from the specified array.
|
Bag(java.lang.Iterable<? extends E> elements)
This constructor creates a new bag with no comparator function and seeds
it with the elements from the specified collection.
|
Bag(java.lang.Iterable<? extends E> elements,
java.util.Comparator<? super E> comparator)
This constructor creates a new bag with the specified comparator function and seeds
it with the elements from the specified collection.
|
| Modifier and Type | Method and Description |
|---|---|
static <E> Bag<E> |
difference(Bag<E> bag1,
Bag<E> bag2)
This function returns a new bag that contains the elements that are
in the first bag but not contained in the second bag specified.
|
static <E> Bag<E> |
merge(Bag<E> bag1,
Bag<E> bag2)
This function returns a new bag that contains the all the elements from
both the specified bags.
|
addElement, containsElement, createDefaultIterator, getNumberOfElements, removeAllElements, removeElementaddElements, addElements, containsAllElementsIn, containsAnyElementsIn, equals, hashCode, isEmpty, iterator, normalizedIndex, removeElements, removeElements, toArray, toString, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitisEmpty, iterator, toArraypublic Bag()
public Bag(E[] elements)
elements - The elements to be used to seed the new bag.public Bag(java.lang.Iterable<? extends E> elements)
elements - The elements to be used to seed the new bag.public Bag(java.util.Comparator<? super E> comparator)
comparator - The comparator to be used to compare two elements during ordering.public Bag(E[] elements, java.util.Comparator<? super E> comparator)
elements - The elements to be used to seed the new bag.comparator - The comparator to be used to compare two elements during ordering.public Bag(java.lang.Iterable<? extends E> elements, java.util.Comparator<? super E> comparator)
elements - The elements to be used to seed the new bag.comparator - The comparator to be used to compare two elements during ordering.public static <E> Bag<E> merge(Bag<E> bag1, Bag<E> bag2)
E - The type of element contained in the bags.bag1 - The first bag whose elements are to be added.bag2 - The second bag whose elements are to be added.public static <E> Bag<E> difference(Bag<E> bag1, Bag<E> bag2)
E - The type of element contained in the bags.bag1 - The bag whose elements are to be removed.bag2 - The bag whose elements are to be removed.Copyright © 2014 Crater Dog Technologies(TM). All rights reserved.