Remove trailing spaces.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1477752 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
53cf9ed7f6
commit
7d9196da0e
|
@ -45,7 +45,7 @@ public abstract class AbstractBagDecorator<E>
|
|||
|
||||
/**
|
||||
* Constructor that wraps (not copies).
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @throws IllegalArgumentException if list is null
|
||||
*/
|
||||
|
@ -55,7 +55,7 @@ public abstract class AbstractBagDecorator<E>
|
|||
|
||||
/**
|
||||
* Gets the bag being decorated.
|
||||
*
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
@Override
|
||||
|
@ -64,7 +64,7 @@ public abstract class AbstractBagDecorator<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public int getCount(final Object object) {
|
||||
return decorated().getCount(object);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Constructor that assigns the specified Map as the backing store. The map
|
||||
* must be empty and non-null.
|
||||
*
|
||||
*
|
||||
* @param map the map to assign
|
||||
*/
|
||||
protected AbstractMapBag(final Map<E, MutableInteger> map) {
|
||||
|
@ -73,7 +73,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Utility method for implementations to access the map that backs this bag.
|
||||
* Not intended for interactive use outside of subclasses.
|
||||
*
|
||||
*
|
||||
* @return the map being used by the Bag
|
||||
*/
|
||||
protected Map<E, MutableInteger> getMap() {
|
||||
|
@ -83,7 +83,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the number of elements in this bag.
|
||||
*
|
||||
*
|
||||
* @return current size of the bag
|
||||
*/
|
||||
public int size() {
|
||||
|
@ -92,7 +92,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Returns true if the underlying map is empty.
|
||||
*
|
||||
*
|
||||
* @return true if bag is empty
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
|
@ -102,7 +102,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Returns the number of occurrence of the given element in this bag by
|
||||
* looking up its count in the underlying map.
|
||||
*
|
||||
*
|
||||
* @param object the object to search for
|
||||
* @return the number of occurrences of the object, zero if not found
|
||||
*/
|
||||
|
@ -118,7 +118,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Determines if the bag contains the given element by checking if the
|
||||
* underlying map contains the element as a key.
|
||||
*
|
||||
*
|
||||
* @param object the object to search for
|
||||
* @return true if the bag contains the given element
|
||||
*/
|
||||
|
@ -128,7 +128,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Determines if the bag contains the given elements.
|
||||
*
|
||||
*
|
||||
* @param coll the collection to check against
|
||||
* @return <code>true</code> if the Bag contains all the collection
|
||||
*/
|
||||
|
@ -142,7 +142,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Returns <code>true</code> if the bag contains all elements in the given
|
||||
* collection, respecting cardinality.
|
||||
*
|
||||
*
|
||||
* @param other the bag to check against
|
||||
* @return <code>true</code> if the Bag contains all the collection
|
||||
*/
|
||||
|
@ -161,7 +161,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Gets an iterator over the bag elements. Elements present in the Bag more
|
||||
* than once will be returned repeatedly.
|
||||
*
|
||||
*
|
||||
* @return the iterator
|
||||
*/
|
||||
public Iterator<E> iterator() {
|
||||
|
@ -181,7 +181,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param parent the parent bag
|
||||
*/
|
||||
public BagIterator(final AbstractMapBag<E> parent) {
|
||||
|
@ -232,12 +232,10 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Adds a new element to the bag, incrementing its count in the underlying
|
||||
* map.
|
||||
*
|
||||
* Adds a new element to the bag, incrementing its count in the underlying map.
|
||||
*
|
||||
* @param object the object to add
|
||||
* @return <code>true</code> if the object was not already in the
|
||||
* <code>uniqueSet</code>
|
||||
* @return <code>true</code> if the object was not already in the <code>uniqueSet</code>
|
||||
*/
|
||||
public boolean add(final E object) {
|
||||
return add(object, 1);
|
||||
|
@ -245,11 +243,10 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Adds a new element to the bag, incrementing its count in the map.
|
||||
*
|
||||
*
|
||||
* @param object the object to search for
|
||||
* @param nCopies the number of copies to add
|
||||
* @return <code>true</code> if the object was not already in the
|
||||
* <code>uniqueSet</code>
|
||||
* @return <code>true</code> if the object was not already in the <code>uniqueSet</code>
|
||||
*/
|
||||
public boolean add(final E object, final int nCopies) {
|
||||
modCount++;
|
||||
|
@ -268,7 +265,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Invokes {@link #add(Object)} for each element in the given collection.
|
||||
*
|
||||
*
|
||||
* @param coll the collection to add
|
||||
* @return <code>true</code> if this call changed the bag
|
||||
*/
|
||||
|
@ -294,7 +291,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Removes all copies of the specified object from the bag.
|
||||
*
|
||||
*
|
||||
* @param object the object to remove
|
||||
* @return true if the bag changed
|
||||
*/
|
||||
|
@ -311,7 +308,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Removes a specified number of copies of an object from the bag.
|
||||
*
|
||||
*
|
||||
* @param object the object to remove
|
||||
* @param nCopies the number of copies to remove
|
||||
* @return true if the bag changed
|
||||
|
@ -338,7 +335,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Removes objects from the bag according to their count in the specified
|
||||
* collection.
|
||||
*
|
||||
*
|
||||
* @param coll the collection to use
|
||||
* @return true if the bag changed
|
||||
*/
|
||||
|
@ -357,7 +354,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Remove any members of the bag that are not in the given bag, respecting
|
||||
* cardinality.
|
||||
*
|
||||
*
|
||||
* @param coll the collection to retain
|
||||
* @return true if this call changed the collection
|
||||
*/
|
||||
|
@ -372,7 +369,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
* Remove any members of the bag that are not in the given bag, respecting
|
||||
* cardinality.
|
||||
* @see #retainAll(Collection)
|
||||
*
|
||||
*
|
||||
* @param other the bag to retain
|
||||
* @return <code>true</code> if this call changed the collection
|
||||
*/
|
||||
|
@ -429,7 +426,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Returns an array of all of this bag's elements.
|
||||
*
|
||||
*
|
||||
* @return an array of all of this bag's elements
|
||||
*/
|
||||
public Object[] toArray() {
|
||||
|
@ -449,7 +446,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
* Returns an array of all of this bag's elements.
|
||||
* If the input array has more elements than are in the bag,
|
||||
* trailing elements will be set to null.
|
||||
*
|
||||
*
|
||||
* @param <T> the type of the array elements
|
||||
* @param array the array to populate
|
||||
* @return an array of all of this bag's elements
|
||||
|
@ -471,7 +468,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
final E current = it.next();
|
||||
for (int index = getCount(current); index > 0; index--) {
|
||||
// unsafe, will throw ArrayStoreException if types are not compatible, see javadoc
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
final T unchecked = (T) current;
|
||||
array[i++] = unchecked;
|
||||
}
|
||||
|
@ -484,7 +481,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Returns an unmodifiable view of the underlying map's key set.
|
||||
*
|
||||
*
|
||||
* @return the set of unique elements in this bag
|
||||
*/
|
||||
public Set<E> uniqueSet() {
|
||||
|
@ -533,7 +530,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
/**
|
||||
* Compares this Bag to another. This Bag equals another Bag if it contains
|
||||
* the same number of occurrences of the same elements.
|
||||
*
|
||||
*
|
||||
* @param object the Bag to compare to
|
||||
* @return true if equal
|
||||
*/
|
||||
|
@ -563,7 +560,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
* element. The per element hash code is defined as
|
||||
* <code>(e==null ? 0 : e.hashCode()) ^ noOccurances)</code>. This hash code
|
||||
* is compatible with the Set interface.
|
||||
*
|
||||
*
|
||||
* @return the hash code of the Bag
|
||||
*/
|
||||
@Override
|
||||
|
@ -579,7 +576,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
|
||||
/**
|
||||
* Implement a toString() method suitable for debugging.
|
||||
*
|
||||
*
|
||||
* @return a debugging toString
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class AbstractSortedBagDecorator<E>
|
|||
|
||||
/**
|
||||
* Constructor that wraps (not copies).
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @throws IllegalArgumentException if list is null
|
||||
*/
|
||||
|
@ -54,7 +54,7 @@ public abstract class AbstractSortedBagDecorator<E>
|
|||
|
||||
/**
|
||||
* Gets the bag being decorated.
|
||||
*
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
@Override
|
||||
|
@ -63,7 +63,7 @@ public abstract class AbstractSortedBagDecorator<E>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public E first() {
|
||||
return decorated().first();
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class HashBag<E> extends AbstractMapBag<E> implements Bag<E>, Serializabl
|
|||
|
||||
/** Serial version lock */
|
||||
private static final long serialVersionUID = -6561115435802554013L;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an empty {@link HashBag}.
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ public class HashBag<E> extends AbstractMapBag<E> implements Bag<E>, Serializabl
|
|||
|
||||
/**
|
||||
* Constructs a bag containing all the members of the given collection.
|
||||
*
|
||||
*
|
||||
* @param coll a collection to copy into this bag
|
||||
*/
|
||||
public HashBag(final Collection<? extends E> coll) {
|
||||
|
@ -76,5 +76,5 @@ public class HashBag<E> extends AbstractMapBag<E> implements Bag<E>, Serializabl
|
|||
in.defaultReadObject();
|
||||
super.doReadObject(new HashMap<E, MutableInteger>(), in);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class PredicatedBag<E> extends PredicatedCollection<E> implements Bag<E>
|
|||
* <p>
|
||||
* If there are any elements already in the bag being decorated, they
|
||||
* are validated.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param predicate the predicate to use for validation, must not be null
|
||||
|
@ -66,7 +66,7 @@ public class PredicatedBag<E> extends PredicatedCollection<E> implements Bag<E>
|
|||
* <p>
|
||||
* If there are any elements already in the bag being decorated, they
|
||||
* are validated.
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param predicate the predicate to use for validation, must not be null
|
||||
* @throws IllegalArgumentException if bag or predicate is null
|
||||
|
@ -78,16 +78,16 @@ public class PredicatedBag<E> extends PredicatedCollection<E> implements Bag<E>
|
|||
|
||||
/**
|
||||
* Gets the decorated bag.
|
||||
*
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
@Override
|
||||
protected Bag<E> decorated() {
|
||||
return (Bag<E>) super.decorated();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public boolean add(final E object, final int count) {
|
||||
validate(object);
|
||||
return decorated().add(object, count);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class PredicatedSortedBag<E> extends PredicatedBag<E> implements SortedBa
|
|||
* <p>
|
||||
* If there are any elements already in the bag being decorated, they
|
||||
* are validated.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param predicate the predicate to use for validation, must not be null
|
||||
|
@ -65,7 +65,7 @@ public class PredicatedSortedBag<E> extends PredicatedBag<E> implements SortedBa
|
|||
* Constructor that wraps (not copies).
|
||||
* <p>If there are any elements already in the bag being decorated, they
|
||||
* are validated.
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param predicate the predicate to use for validation, must not be null
|
||||
* @throws IllegalArgumentException if bag or predicate is null
|
||||
|
@ -77,16 +77,16 @@ public class PredicatedSortedBag<E> extends PredicatedBag<E> implements SortedBa
|
|||
|
||||
/**
|
||||
* Gets the decorated sorted bag.
|
||||
*
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
@Override
|
||||
protected SortedBag<E> decorated() {
|
||||
return (SortedBag<E>) super.decorated();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public E first() {
|
||||
return decorated().first();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SynchronizedBag<E> extends SynchronizedCollection<E> implements Bag
|
|||
|
||||
/**
|
||||
* Factory method to create a synchronized bag.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @return a new synchronized Bag
|
||||
|
@ -49,11 +49,11 @@ public class SynchronizedBag<E> extends SynchronizedCollection<E> implements Bag
|
|||
public static <E> SynchronizedBag<E> synchronizedBag(final Bag<E> bag) {
|
||||
return new SynchronizedBag<E>(bag);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructor that wraps (not copies).
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @throws IllegalArgumentException if bag is null
|
||||
*/
|
||||
|
@ -63,7 +63,7 @@ public class SynchronizedBag<E> extends SynchronizedCollection<E> implements Bag
|
|||
|
||||
/**
|
||||
* Constructor that wraps (not copies).
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param lock the lock to use, must not be null
|
||||
* @throws IllegalArgumentException if bag is null
|
||||
|
@ -74,15 +74,15 @@ public class SynchronizedBag<E> extends SynchronizedCollection<E> implements Bag
|
|||
|
||||
/**
|
||||
* Gets the bag being decorated.
|
||||
*
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
protected Bag<E> getBag() {
|
||||
return (Bag<E>) decorated();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public boolean add(final E object, final int count) {
|
||||
synchronized (lock) {
|
||||
return getBag().add(object, count);
|
||||
|
@ -107,7 +107,7 @@ public class SynchronizedBag<E> extends SynchronizedCollection<E> implements Bag
|
|||
return getBag().getCount(object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Synchronized Set for the Bag class.
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SynchronizedSortedBag<E> extends SynchronizedBag<E> implements Sort
|
|||
|
||||
/**
|
||||
* Factory method to create a synchronized sorted bag.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @return a new synchronized SortedBag
|
||||
|
@ -49,11 +49,11 @@ public class SynchronizedSortedBag<E> extends SynchronizedBag<E> implements Sort
|
|||
public static <E> SynchronizedSortedBag<E> synchronizedSortedBag(final SortedBag<E> bag) {
|
||||
return new SynchronizedSortedBag<E>(bag);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructor that wraps (not copies).
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @throws IllegalArgumentException if bag is null
|
||||
*/
|
||||
|
@ -63,7 +63,7 @@ public class SynchronizedSortedBag<E> extends SynchronizedBag<E> implements Sort
|
|||
|
||||
/**
|
||||
* Constructor that wraps (not copies).
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param lock the lock to use, must not be null
|
||||
* @throws IllegalArgumentException if bag is null
|
||||
|
@ -74,15 +74,15 @@ public class SynchronizedSortedBag<E> extends SynchronizedBag<E> implements Sort
|
|||
|
||||
/**
|
||||
* Gets the bag being decorated.
|
||||
*
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
protected SortedBag<E> getSortedBag() {
|
||||
return (SortedBag<E>) decorated();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public synchronized E first() {
|
||||
synchronized (lock) {
|
||||
return getSortedBag().first();
|
||||
|
|
|
@ -46,7 +46,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
* <p>
|
||||
* If there are any elements already in the bag being decorated, they
|
||||
* are NOT transformed. Contrast this with {@link #transformedBag(Bag, Transformer)}.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param transformer the transformer to use for conversion, must not be null
|
||||
|
@ -56,7 +56,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
public static <E> Bag<E> transformingBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
|
||||
return new TransformedBag<E>(bag, transformer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Factory method to create a transforming bag that will transform
|
||||
* existing contents of the specified bag.
|
||||
|
@ -64,7 +64,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
* If there are any elements already in the bag being decorated, they
|
||||
* will be transformed by this method.
|
||||
* Contrast this with {@link #transformingBag(Bag, Transformer)}.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param transformer the transformer to use for conversion, must not be null
|
||||
|
@ -91,7 +91,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
* <p>
|
||||
* If there are any elements already in the bag being decorated, they
|
||||
* are NOT transformed.
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param transformer the transformer to use for conversion, must not be null
|
||||
* @throws IllegalArgumentException if bag or transformer is null
|
||||
|
@ -102,7 +102,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
|
||||
/**
|
||||
* Gets the decorated bag.
|
||||
*
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
protected Bag<E> getBag() {
|
||||
|
@ -110,7 +110,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public int getCount(final Object object) {
|
||||
return getBag().getCount(object);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public boolean add(final E object, final int nCopies) {
|
||||
return getBag().add(transform(object), nCopies);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
|||
* <p>
|
||||
* If there are any elements already in the bag being decorated, they
|
||||
* are NOT transformed. Contrast this with {@link #transformedSortedBag(SortedBag, Transformer)}.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param transformer the transformer to use for conversion, must not be null
|
||||
|
@ -55,7 +55,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
|||
final Transformer<? super E, ? extends E> transformer) {
|
||||
return new TransformedSortedBag<E>(bag, transformer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Factory method to create a transforming sorted bag that will transform
|
||||
* existing contents of the specified sorted bag.
|
||||
|
@ -63,7 +63,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
|||
* If there are any elements already in the bag being decorated, they
|
||||
* will be transformed by this method.
|
||||
* Contrast this with {@link #transformingSortedBag(SortedBag, Transformer)}.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param transformer the transformer to use for conversion, must not be null
|
||||
|
@ -92,7 +92,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
|||
* <p>
|
||||
* If there are any elements already in the bag being decorated, they
|
||||
* are NOT transformed.
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @param transformer the transformer to use for conversion, must not be null
|
||||
* @throws IllegalArgumentException if bag or transformer is null
|
||||
|
@ -103,7 +103,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
|||
|
||||
/**
|
||||
* Gets the decorated bag.
|
||||
*
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
protected SortedBag<E> getSortedBag() {
|
||||
|
@ -111,7 +111,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public E first() {
|
||||
return getSortedBag().first();
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, Seria
|
|||
/**
|
||||
* Constructs an empty bag that maintains order on its unique representative
|
||||
* members according to the given {@link Comparator}.
|
||||
*
|
||||
*
|
||||
* @param comparator the comparator to use
|
||||
*/
|
||||
public TreeBag(final Comparator<? super E> comparator) {
|
||||
|
@ -66,7 +66,7 @@ public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, Seria
|
|||
/**
|
||||
* Constructs a {@link TreeBag} containing all the members of the
|
||||
* specified collection.
|
||||
*
|
||||
*
|
||||
* @param coll the collection to copy into the bag
|
||||
*/
|
||||
public TreeBag(final Collection<? extends E> coll) {
|
||||
|
@ -77,21 +77,21 @@ public class TreeBag<E> extends AbstractMapBag<E> implements SortedBag<E>, Seria
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @throws IllegalArgumentException if the object to be added does not implement
|
||||
* {@link Comparable} and the {@link TreeBag} is using natural ordering
|
||||
*/
|
||||
@Override
|
||||
public boolean add(final E object) {
|
||||
if(comparator() == null && !(object instanceof Comparable)) {
|
||||
throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
|
||||
throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
|
||||
"a naturally ordered TreeBag as it does not implement Comparable");
|
||||
}
|
||||
return super.add(object);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public E first() {
|
||||
return getMap().firstKey();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.commons.collections4.iterators.UnmodifiableIterator;
|
|||
* <p>
|
||||
* This class is Serializable from Commons Collections 3.1.
|
||||
* <p>
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
*
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
|
@ -49,7 +49,7 @@ public final class UnmodifiableBag<E>
|
|||
* Factory method to create an unmodifiable bag.
|
||||
* <p>
|
||||
* If the bag passed in is already unmodifiable, it is returned.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @return an unmodifiable Bag
|
||||
|
@ -65,7 +65,7 @@ public final class UnmodifiableBag<E>
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructor that wraps (not copies).
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @throws IllegalArgumentException if bag is null
|
||||
*/
|
||||
|
@ -76,7 +76,7 @@ public final class UnmodifiableBag<E>
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Write the collection out using a custom routine.
|
||||
*
|
||||
*
|
||||
* @param out the output stream
|
||||
* @throws IOException
|
||||
*/
|
||||
|
@ -87,7 +87,7 @@ public final class UnmodifiableBag<E>
|
|||
|
||||
/**
|
||||
* Read the collection in using a custom routine.
|
||||
*
|
||||
*
|
||||
* @param in the input stream
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.commons.collections4.iterators.UnmodifiableIterator;
|
|||
* <p>
|
||||
* This class is Serializable from Commons Collections 3.1.
|
||||
* <p>
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
*
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
|
@ -49,7 +49,7 @@ public final class UnmodifiableSortedBag<E>
|
|||
* Factory method to create an unmodifiable bag.
|
||||
* <p>
|
||||
* If the bag passed in is already unmodifiable, it is returned.
|
||||
*
|
||||
*
|
||||
* @param <E> the type of the elements in the bag
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @return an unmodifiable SortedBag
|
||||
|
@ -65,7 +65,7 @@ public final class UnmodifiableSortedBag<E>
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructor that wraps (not copies).
|
||||
*
|
||||
*
|
||||
* @param bag the bag to decorate, must not be null
|
||||
* @throws IllegalArgumentException if bag is null
|
||||
*/
|
||||
|
@ -76,7 +76,7 @@ public final class UnmodifiableSortedBag<E>
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Write the collection out using a custom routine.
|
||||
*
|
||||
*
|
||||
* @param out the output stream
|
||||
* @throws IOException
|
||||
*/
|
||||
|
@ -87,7 +87,7 @@ public final class UnmodifiableSortedBag<E>
|
|||
|
||||
/**
|
||||
* Read the collection in using a custom routine.
|
||||
*
|
||||
*
|
||||
* @param in the input stream
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* This package contains implementations of the {@link org.apache.commons.collections4.Bag Bag} and
|
||||
* This package contains implementations of the {@link org.apache.commons.collections4.Bag Bag} and
|
||||
* {@link org.apache.commons.collections4.SortedBag SortedBag} interfaces.
|
||||
* A bag stores an object and a count of the number of occurrences of the object.
|
||||
* <p>
|
||||
|
|
Loading…
Reference in New Issue