|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcommon.SubsetIterator
public class SubsetIterator
Class for iterating over all subsets of an ordered set. The subsets are represented by BitSet objects; in fact, the same BitSet object is used to represent each subset in turn. Of course, using this class is only practical for iterating over the subsets of a small set, since the number of subsets of a set of size n is 2^n.
| Constructor Summary | |
|---|---|
SubsetIterator(int n)
Creates a new SubsetIterator over a set of size n. |
|
| Method Summary | |
|---|---|
boolean |
hasNext()
Returns true if the set of size n has a subset that hasn't been returned yet. |
static void |
main(java.lang.String[] args)
|
java.lang.Object |
next()
Returns a BitSet representing a subset that hasn't been returned yet. |
void |
remove()
Throws an exception -- removal makes no sense for this iterator. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SubsetIterator(int n)
| Method Detail |
|---|
public boolean hasNext()
hasNext in interface java.util.Iteratorpublic java.lang.Object next()
next, so you shouldn't rely on that
object remaining stable.
next in interface java.util.Iteratorpublic void remove()
remove in interface java.util.Iteratorpublic static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||