|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jutil.java.collections.Collections
A utility class for perform operations on collections similar to java.util.Collections.
Field Summary | |
static java.lang.String |
CVS_REVISION
|
Constructor Summary | |
Collections()
|
Method Summary | |
static boolean |
containsExplicitly(java.util.Collection collection,
java.lang.Object element)
public invariant_redundantly (\forall Collection c; c != null; (\forall Object o1; c.contains(o1); (\exists Object o2; containsEplicitly(c, o2); ((o1 == null) && (o2 == null)) || ((o1 != null) && (o1.equals(o2))))); public invariant_redundantly (\forall Collection c; c!= null; (\forall Object o2; containsEplicitly(collection, o2); c.contains(o2))); public behavior pre collection != null; post \result == (\exists int i; i >= 0 && i < collection.toArray().length; collection.toArray()[i] == element); Check whether or not the given collection contains the given element when using == for comparison instead of equals(). |
static boolean |
identical(java.util.Collection first,
java.util.Collection second)
public behavior // True if both collections are null post ((first == null) && (second == null)) ==> \result == true; // False if only one of both is null. post ((first == null) || (second == null)) && !((first == null) && (second == null)) ==> \result ==false; // If both collections are non-null, true if both collections // have the same size and contains the exact same elements. post ((first != null) && (second != null)) ==> \result == (first.size() == second.size()) && (\forall Object o1; containsExplicitly(first, o1); nbExplicitOccurrences(first,o1) == nbExplicitOccurrences(second, o2)); Check whether the two given collections contain the same elements. |
static boolean |
identical(java.util.Map first,
java.util.Map second)
// True if both maps are null post ((first == null) && (second == null)) ==> \result == true; // False if only one of both is null. post ((first == null) || (second == null)) && !((first == null) && (second == null)) ==> \result ==false; // If both maps are non-null, true if both maps // have the same size and contains the same (key,value) pairs. post ((first != null) && (second != null)) ==> \result == (first.size() == second.size()) && (\forall Object k; first.containsKey(k); second.containsKey(k) && second.get(k) == first.get(k)) && first.size() == second.size(); post (\forall Map.Entry e1; first.entrySet().contains(e1); (\exists Map.Entry e2; second.entrySet().contains(e2); (e1.getKey() == e2.getKey()) && Check whether the two given maps contain the same entries. |
static int |
nbExplicitOccurrences(java.lang.Object element,
java.util.Collection collection)
public behavior pre collection != null; post \result == (\num_of int i; i >= 0 && i < collection.toArray().length; collection.toArray()[i] == element); Return the number of times |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CVS_REVISION
Constructor Detail |
public Collections()
Method Detail |
public static boolean containsExplicitly(java.util.Collection collection, java.lang.Object element)
collection
- The collectionelement
- The elementpublic static int nbExplicitOccurrences(java.lang.Object element, java.util.Collection collection)
element
- The element of which the number of occurrences is requested.collection
- The collection in which the number of occurrences has to be counted.public static boolean identical(java.util.Collection first, java.util.Collection second)
first
- The first collectionsecond
- The second collectionpublic static boolean identical(java.util.Map first, java.util.Map second)
first
- The first mapsecond
- The second map
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |