Package algs35
Class SET<K extends Comparable<? super K>>
java.lang.Object
algs35.SET<K>
- All Implemented Interfaces:
- Iterable<K>
The 
SET class represents an ordered set. It assumes that
  the elements are Comparable.
  It supports the usual add, contains, and delete
  methods. It also provides ordered methods for finding the minimum,
  maximum, floor, and ceiling.
  This implementation uses a balanced binary search tree. The add, contains, delete, minimum, maximum, ceiling, and floor methods take logarithmic time.
For additional documentation, see Section 4.5 of Algorithms in Java, 4th Edition by Robert Sedgewick and Kevin Wayne.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd the key to this set.Return the smallest key in this set>= k.booleanDoes this set contain the given key?voidDelete the given key from this set.booleanDoes this SET equal that set.Return the largest key in this set<= k.inthashCode()intersects(SET<K> that) Return the intersection of this set with that set.booleanisEmpty()Is this set empty?iterator()Return an Iterator for this set.static voidmax()Return the key in this set with the maximum value.min()Return the key in this set with the minimum value.intsize()Return the number of keys in this set.toString()String represenation of this set.Return the union of this set with that set.Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Field Details- 
set
 
- 
- 
Constructor Details- 
SETpublic SET()Create an empty set.
 
- 
- 
Method Details- 
isEmptyIs this set empty?
- 
addAdd the key to this set.
- 
containsDoes this set contain the given key?
- 
deleteDelete the given key from this set.
- 
sizeReturn the number of keys in this set.
- 
iteratorReturn an Iterator for this set.- Specified by:
- iteratorin interface- Iterable<K extends Comparable<? super K>>
 
- 
maxReturn the key in this set with the maximum value.
- 
minReturn the key in this set with the minimum value.
- 
ceilReturn the smallest key in this set>= k.
- 
floorReturn the largest key in this set<= k.
- 
unionReturn the union of this set with that set.
- 
intersectsReturn the intersection of this set with that set.
- 
equalsDoes this SET equal that set.
- 
hashCode
- 
toStringString represenation of this set.
- 
main
 
-