E- the type of elements in this bag
public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, java.io.Serializable
SortedBag, using a
TreeMapto provide the data storage. This is the standard implementation of a sorted bag.
Order will be maintained among the bag members and can be viewed through the iterator.
Bag stores each object in the collection
together with a count of occurrences. Extra methods on the interface allow multiple
copies of an object to be added or removed at once. It is important to read the interface
javadoc carefully as several methods violate the
Collection interface specification.
|Constructor and Description|
Constructs an empty
Constructs an empty bag that maintains order on its unique representative members according to the given
|Modifier and Type||Method and Description|
Adds a new element to the bag, incrementing its count in the underlying map.
Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
Returns the first (lowest) member.
Returns the last (highest) member.
add, addAll, clear, contains, containsAll, equals, getCount, hashCode, isEmpty, iterator, remove, remove, removeAll, retainAll, size, toArray, toArray, toString, uniqueSet
add, containsAll, getCount, iterator, remove, remove, removeAll, retainAll, size, uniqueSet
addAll, clear, contains, equals, hashCode, isEmpty, parallelStream, removeIf, spliterator, stream, toArray, toArray
public TreeBag(java.util.Comparator<? super E> comparator)
comparator- the comparator to use
public boolean add(E object)
object- the object to add
trueif the object was not already in the
java.lang.IllegalArgumentException- if the object to be added does not implement
TreeBagis using natural ordering
java.lang.NullPointerException- if the specified key is null and this bag uses natural ordering, or its comparator does not permit null keys
public E first()
public E last()
Copyright © 2010 - 2020 Adobe. All Rights Reserved