diff options
Diffstat (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSet.java')
| -rw-r--r-- | projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSet.java | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSet.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSet.java index 38a7ec6..ece9e1b 100644 --- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSet.java +++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSSet.java @@ -33,7 +33,9 @@ import java.util.Vector; * @author $Author: cgruber $ * @version $Revision: 893 $ */ -public class NSSet extends HashSet { +public class NSSet<T> extends HashSet<T> { + private static final long serialVersionUID = 4211571026717957124L; + /** * Default constructor. */ @@ -44,14 +46,14 @@ public class NSSet extends HashSet { /** * Constructs a NSSet containing the objects in the specified collection. */ - public NSSet(Collection aCollection) { + public NSSet(Collection<T> aCollection) { super(aCollection); } /** * Constructs a NSSet containing only the specified object. */ - public NSSet(Object anObject) { + public NSSet(T anObject) { super(); add(anObject); } @@ -59,7 +61,7 @@ public class NSSet extends HashSet { /** * Constructs a NSSet containing the objects in the specified array. */ - public NSSet(Object[] anObjectArray) { + public NSSet(T[] anObjectArray) { super(); for (int i = 0; i < anObjectArray.length; i++) { add(anObjectArray[i]); @@ -69,14 +71,16 @@ public class NSSet extends HashSet { /** * Returns an NSArray containing all objects in the set. */ - public NSArray allObjects() { - return new NSArray(this); + public NSArray<T> allObjects() { + return new NSArray<>(this); } /** + * Retrieve an arbitrary object from the set. * + * @return An arbitrary object from the set */ - public Object anyObject() { + public T anyObject() { throw new RuntimeException("Not implemented yet."); } @@ -98,8 +102,8 @@ public class NSSet extends HashSet { * Returns whether this set has one or more elements in common with the * specified set. */ - public boolean intersectsSet(Set aSet) { - Iterator it = aSet.iterator(); + public boolean intersectsSet(Set<T> aSet) { + Iterator<T> it = aSet.iterator(); while (it.hasNext()) { if (this.containsObject(it.next())) { return true; @@ -112,14 +116,14 @@ public class NSSet extends HashSet { /** * Returns whether this set contains the same object as the specified set. */ - public boolean isEqualToSet(Set aSet) { + public boolean isEqualToSet(Set<T> aSet) { return equals(aSet); } /** * Returns whether this set is a subset of the specified set. */ - public boolean isSubsetOfSet(Set aSet) { + public boolean isSubsetOfSet(Set<T> aSet) { return aSet.containsAll(this); } @@ -133,15 +137,15 @@ public class NSSet extends HashSet { /** * Returns an enumerator over the objects in this set. */ - public Enumeration objectEnumerator() { - return new Vector(this).elements(); + public Enumeration<T> objectEnumerator() { + return new Vector<>(this).elements(); } /** * Returns a set that is the intersection of this set and the specified set. */ - public NSSet setByIntersectingSet(Set aSet) { - NSSet result = new NSSet(this); + public NSSet<T> setByIntersectingSet(Set<T> aSet) { + NSSet<T> result = new NSSet<>(this); result.retainAll(aSet); return result; } @@ -150,8 +154,8 @@ public class NSSet extends HashSet { * Returns a set that contains all elements in this set that are not in the * specified set. */ - public NSSet setBySubtractingSet(Set aSet) { - NSSet result = new NSSet(this); + public NSSet<T> setBySubtractingSet(Set<T> aSet) { + NSSet<T> result = new NSSet<>(this); result.removeAll(aSet); return result; } @@ -159,8 +163,8 @@ public class NSSet extends HashSet { /** * Returns a set that is the union of this set and the specified set. */ - public NSSet setByUnioningSet(Set aSet) { - NSSet result = new NSSet(this); + public NSSet<T> setByUnioningSet(Set<T> aSet) { + NSSet<T> result = new NSSet<>(this); result.addAll(aSet); return result; } |
