T
- T must be class which has implemented the Comparable interface
(e.g. String, Integer, Date,...)public class ComparableSet<T extends java.lang.Comparable<? super T>> extends java.util.TreeSet<T> implements java.lang.Comparable<ComparableSet<T>>
Constructor and Description |
---|
ComparableSet()
Standard constructor
|
ComparableSet(java.util.TreeSet<T> set)
Overloaded constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ComparableSet<T> comparableSet) |
ComparableSet<T> |
deepCopy()
Makes a copy of the ComparableSet
|
ComparableSet<T> |
difference(ComparableSet<T> comparableSet)
Returns the mathematical difference of two sets
|
java.util.TreeSet<T> |
getTreeSet()
Return a TreeSet
|
ComparableSet<T> |
intersection(ComparableSet<T> comparableSet)
Returns the mathematical intersection of two sets
|
boolean |
isSubset(ComparableSet<T> set)
Returns true if the overgiven set is a subset the set
|
boolean |
member(T element)
Cheks if a element is in the ComparableSet
|
java.lang.String |
serialize()
Return a String representaion of the set e.g: if the ComparableSet
contains [A,B,C] it returns "ABC"
|
java.lang.String |
serializeWithoutBrackets()
Returns a set representation of the set without the brackets e.g: if the
ComparableSet contains [A,B,C] it returns "A,B,C"
|
ComparableSet<T> |
union(ComparableSet<T> comparableSet)
Returns the mathematical union of two sets
|
ComparableSet<T> |
without(T element)
Removes one element of the set
|
add, addAll, ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, remove, size, spliterator, subSet, subSet, tailSet, tailSet
containsAll, retainAll, toArray, toArray, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
public ComparableSet()
public ComparableSet(java.util.TreeSet<T> set)
set
- - a TreeSet as argumentpublic java.util.TreeSet<T> getTreeSet()
public ComparableSet<T> deepCopy()
public boolean member(T element)
element
- public boolean isSubset(ComparableSet<T> set)
set
- public int compareTo(ComparableSet<T> comparableSet)
compareTo
in interface java.lang.Comparable<ComparableSet<T extends java.lang.Comparable<? super T>>>
public ComparableSet<T> union(ComparableSet<T> comparableSet)
comparableSet
- public ComparableSet<T> intersection(ComparableSet<T> comparableSet)
comparableSet
- public ComparableSet<T> difference(ComparableSet<T> comparableSet)
comparableSet
- public ComparableSet<T> without(T element)
public java.lang.String serialize()
public java.lang.String serializeWithoutBrackets()