|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractSet
|
+--java.util.HashSet
|
+--edu.iu.iv.modeling.tarl.util.impl.ExtendedHashSet
This class defines an extended form of the HashSet - available via the Java Collections Framework. This class adds a few utility methods in order to make the Set more useful to use. Some of the utility methods are :
HashSet,
Serialized Form| Constructor Summary | |
ExtendedHashSet()
Creates a new instance of ExtendedHashSet such that it is empty |
|
ExtendedHashSet(java.util.Collection collection)
Creates a new instance of ExtendedHashSet such that it contains a specified Collection |
|
ExtendedHashSet(int initialCapacity)
Creates a new instance of an empty ExtendedHashSet with the specified initial capacity |
|
ExtendedHashSet(int initialCapacity,
float loadFactor)
Creates a new instance of an empty ExtendedHashSet with the specified initial capacity and load factor |
|
| Method Summary | |
static boolean |
areSetEqual(java.util.Collection collection1,
java.util.Collection collection2)
Tests whether the two Collections are equal or not in terms of Set Equality. |
void |
difference(java.util.Collection collection)
Modifies the Set to be the difference of the current Set and the specified Collection. |
static ExtendedHashSet |
difference(java.util.Collection collection1,
java.util.Collection collection2)
Returns the difference of the two specified Collections. |
java.lang.Object |
getRandomElement()
Returns a Random element from the Set. |
ExtendedHashSet |
getRandomElements(int numElements)
Returns the specified number of different random elements from the Set as an ExtendedHashSet. |
void |
intersection(java.util.Collection collection)
Modifies the Set to be the intersection of the Set and the specified Collection. |
static ExtendedHashSet |
intersection(java.util.Collection collection1,
java.util.Collection collection2)
Returns the intersection of two specified Collections. |
static boolean |
isSubset(java.util.Collection collection1,
java.util.Collection collection2)
Tests whether the Collection specified by the second argument is a subset of the Collection specified by the first argument |
static ExtendedHashSet |
partitionSet(java.util.Collection collection,
int numElements)
Partitions the specified Collection into a Collection of subsets each of a fixed specified size. |
void |
union(java.util.Collection collection)
Modifies the Set to be the union of itself and the specified Collection. |
static ExtendedHashSet |
union(java.util.Collection collection1,
java.util.Collection collection2)
Returns the union of two specified Collections as an ExtendedHashSet. |
| Methods inherited from class java.util.HashSet |
add, clear, clone, contains, isEmpty, iterator, remove, size |
| Methods inherited from class java.util.AbstractSet |
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
addAll, containsAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Constructor Detail |
public ExtendedHashSet()
ExtendedHashSet such that it is empty
public ExtendedHashSet(java.util.Collection collection)
throws java.lang.NullPointerException
ExtendedHashSet such that it contains a specified Collection
collection - Specifies the collection to initialize the extended hash set with
java.lang.NullPointerException - if the specified collection is nullpublic ExtendedHashSet(int initialCapacity)
ExtendedHashSet with the specified initial capacity
initialCapacity - Specifies the initial capacity for the extended hash set
public ExtendedHashSet(int initialCapacity,
float loadFactor)
ExtendedHashSet with the specified initial capacity and load factor
initialCapacity - Specifies the initial capacity for the extended hash setloadFactor - Specifies the load factor for the extended hash set| Method Detail |
public java.lang.Object getRandomElement()
public ExtendedHashSet getRandomElements(int numElements)
ExtendedHashSet. If the specified number is larger than the size of the Set, the entire Set is returned.
numElements - Specifies the number of elements required
public void union(java.util.Collection collection)
throws java.lang.NullPointerException
Collection. It acts like the operation (a = a union b), where a is the current Set and b is the specified Collection
collection - Specifies the collection to be unioned with
java.lang.NullPointerException - if the specified collection is null
public static ExtendedHashSet union(java.util.Collection collection1,
java.util.Collection collection2)
throws java.lang.NullPointerException
Collections as an ExtendedHashSet. Does not change any of the Collections.
collection1 - Specifies the first collectioncollection2 - Specifies the second collection
java.lang.NullPointerException - if any of the specified collection is null
public void intersection(java.util.Collection collection)
throws java.lang.NullPointerException
Collection. It acts like the operation (a = a intersection b), where a is the current Set and b is the specified Collection
collection - Specifies the collection to be intersected with
java.lang.NullPointerException - if the specified collection is null
public static ExtendedHashSet intersection(java.util.Collection collection1,
java.util.Collection collection2)
throws java.lang.NullPointerException
Collections. Does not change any of the Collections.
collection1 - Specifies the first collectioncollection2 - Specifies the second collection
java.lang.NullPointerException - if any of the specified collection is null
public void difference(java.util.Collection collection)
throws java.lang.NullPointerException
Collection. It acts like the operation (a = a - b), where a is the current Set and b is the specified Collection
collection - Specifies the Collection to be intersected with
java.lang.NullPointerException - if the specified collection is null
public static ExtendedHashSet difference(java.util.Collection collection1,
java.util.Collection collection2)
throws java.lang.NullPointerException
Collections. Does not change any of the Collections. The operation can be expressed as (a - b), where a and b are the collections as defined by the first and second argument respectively.
collection1 - Specifies the first Collectioncollection2 - Specifies the second Collection
java.lang.NullPointerException - if the specified collection is null
public static boolean isSubset(java.util.Collection collection1,
java.util.Collection collection2)
throws java.lang.NullPointerException
Collection specified by the second argument is a subset of the Collection specified by the first argument
collection1 - Specifies the first colletioncollection2 - Specifies the second colletion
java.lang.NullPointerException - if the specified collection is null
public static boolean areSetEqual(java.util.Collection collection1,
java.util.Collection collection2)
throws java.lang.NullPointerException
Collections are equal or not in terms of Set Equality. Two collections are Set Equal if first is the subset of the second and the second is a subset of the first.
collection1 - Specifies the first collectioncollection2 - Specifies the second collection
java.lang.NullPointerException - if any of the specified collections is null
public static ExtendedHashSet partitionSet(java.util.Collection collection,
int numElements)
throws java.lang.NullPointerException,
java.lang.IllegalArgumentException
Collection of subsets each of a fixed specified size. The elements for the subsets are chosen randomly. The subsets are mutually exclusive and exhaustive over the entire Set. Each of the subsets do not contain duplicate elements (as given by the equals method). Just one subset may have less number of elements than the number specified if the total number of elements is not exactly divisible by the specified number.
collection - the collection to be partitionednumElements - the number of elements in each subset
java.lang.NullPointerException - if the collection is null
java.lang.IllegalArgumentException - if the value of numElements is 0 or less
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||