Skip to content

Commit

Permalink
Sort members
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jan 20, 2024
1 parent 708b1e1 commit 01bd494
Show file tree
Hide file tree
Showing 492 changed files with 41,472 additions and 41,472 deletions.
44 changes: 22 additions & 22 deletions src/main/java/org/apache/commons/collections4/ArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
*/
final class ArrayUtils {

/**
* Don't allow instances.
*/
private ArrayUtils() {
}

/**
* <p>
* Checks if the object is in the given array.
Expand All @@ -58,22 +52,6 @@ static boolean contains(final Object[] array, final Object objectToFind) {
return indexOf(array, objectToFind) != CollectionUtils.INDEX_NOT_FOUND;
}

/**
* <p>
* Finds the index of the given object in the array.
* </p>
* <p>
* This method returns {@link CollectionUtils#INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.
* </p>
*
* @param array the array to search through for the object, may be {@code null}
* @param objectToFind the object to find, may be {@code null}
* @return the index of the object within the array, {@link CollectionUtils#INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input
*/
static <T> int indexOf(final T[] array, final Object objectToFind) {
return indexOf(array, objectToFind, 0);
}

/**
* <p>
* Finds the index of the given object in the array starting at the given index.
Expand Down Expand Up @@ -114,4 +92,26 @@ static int indexOf(final Object[] array, final Object objectToFind, int startInd
return CollectionUtils.INDEX_NOT_FOUND;
}

/**
* <p>
* Finds the index of the given object in the array.
* </p>
* <p>
* This method returns {@link CollectionUtils#INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.
* </p>
*
* @param array the array to search through for the object, may be {@code null}
* @param objectToFind the object to find, may be {@code null}
* @return the index of the object within the array, {@link CollectionUtils#INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input
*/
static <T> int indexOf(final T[] array, final Object objectToFind) {
return indexOf(array, objectToFind, 0);
}

/**
* Don't allow instances.
*/
private ArrayUtils() {
}

}
108 changes: 54 additions & 54 deletions src/main/java/org/apache/commons/collections4/Bag.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@
*/
public interface Bag<E> extends Collection<E> {

/**
* Returns the number of occurrences (cardinality) of the given
* object currently in the bag. If the object does not exist in the
* bag, return 0.
*
* @param object the object to search for
* @return the number of occurrences of the object, zero if not found
*/
int getCount(Object object);

/**
* <i>(Violation)</i>
* Adds one copy of the specified object to the Bag.
Expand Down Expand Up @@ -91,6 +81,47 @@ public interface Bag<E> extends Collection<E> {
*/
boolean add(E object, int nCopies);

/**
* <i>(Violation)</i>
* Returns {@code true} if the bag contains all elements in
* the given collection, respecting cardinality. That is, if the
* given collection {@code coll} contains {@code n} copies
* of a given object, calling {@link #getCount(Object)} on that object must
* be {@code &gt;= n} for all {@code n} in {@code coll}.
*
* <p>
* The {@link Collection#containsAll(Collection)} method specifies
* that cardinality should <i>not</i> be respected; this method should
* return true if the bag contains at least one of every object contained
* in the given collection.
* </p>
*
* @param coll the collection to check against
* @return {@code true} if the Bag contains all the collection
*/
@Override
boolean containsAll(Collection<?> coll);

/**
* Returns the number of occurrences (cardinality) of the given
* object currently in the bag. If the object does not exist in the
* bag, return 0.
*
* @param object the object to search for
* @return the number of occurrences of the object, zero if not found
*/
int getCount(Object object);

/**
* Returns an {@link Iterator} over the entire set of members,
* including copies due to cardinality. This iterator is fail-fast
* and will not tolerate concurrent modifications.
*
* @return iterator over all elements in the Bag
*/
@Override
Iterator<E> iterator();

/**
* <i>(Violation)</i>
* Removes all occurrences of the given object from the bag.
Expand Down Expand Up @@ -122,45 +153,6 @@ public interface Bag<E> extends Collection<E> {
*/
boolean remove(Object object, int nCopies);

/**
* Returns a {@link Set} of unique elements in the Bag.
* <p>
* Uniqueness constraints are the same as those in {@link java.util.Set}.
* </p>
*
* @return the Set of unique Bag elements
*/
Set<E> uniqueSet();

/**
* Returns the total number of items in the bag across all types.
*
* @return the total size of the Bag
*/
@Override
int size();

/**
* <i>(Violation)</i>
* Returns {@code true} if the bag contains all elements in
* the given collection, respecting cardinality. That is, if the
* given collection {@code coll} contains {@code n} copies
* of a given object, calling {@link #getCount(Object)} on that object must
* be {@code &gt;= n} for all {@code n} in {@code coll}.
*
* <p>
* The {@link Collection#containsAll(Collection)} method specifies
* that cardinality should <i>not</i> be respected; this method should
* return true if the bag contains at least one of every object contained
* in the given collection.
* </p>
*
* @param coll the collection to check against
* @return {@code true} if the Bag contains all the collection
*/
@Override
boolean containsAll(Collection<?> coll);

/**
* <i>(Violation)</i>
* Remove all elements represented in the given collection,
Expand Down Expand Up @@ -207,14 +199,22 @@ public interface Bag<E> extends Collection<E> {
boolean retainAll(Collection<?> coll);

/**
* Returns an {@link Iterator} over the entire set of members,
* including copies due to cardinality. This iterator is fail-fast
* and will not tolerate concurrent modifications.
* Returns the total number of items in the bag across all types.
*
* @return iterator over all elements in the Bag
* @return the total size of the Bag
*/
@Override
Iterator<E> iterator();
int size();

/**
* Returns a {@link Set} of unique elements in the Bag.
* <p>
* Uniqueness constraints are the same as those in {@link java.util.Set}.
* </p>
*
* @return the Set of unique Bag elements
*/
Set<E> uniqueSet();

// The following is not part of the formal Bag interface, however where possible
// Bag implementations should follow these comments.
Expand Down

0 comments on commit 01bd494

Please sign in to comment.