class LazyBinomialCombinator extends Tracing
Produces all combinations of k unordered integers which can be chosen from among n integers (k <= n) by applying a lexicographic algorithm. The starting point is given by the lexicographic smallest word comprising k integers, e.g. (0,1,2) for k == 3. First, the algorithm evaluates the rightmost column in order to find new combinations, e.g. (0,1,3), (0,1,4) and (0,1,5) for n == 6. Now the algorithm has run out of options for the rightmost column and switches to (0,2,3) but not (0,2,1) since the latter would be identical to (0,1,2). In due course more to the left columns have to be considered, e.g. at (0,4,5). The algorithm finishes if the options have run out for all columns. For k == 3 and n == 6 that would be (3,4,5). The total number of solutions is given by the binomial coefficient "n choose k". For the given example that would be 20. To compute actual solution sizes , see WolframAlpha.
- Alphabetic
- By Inheritance
- LazyBinomialCombinator
- Tracing
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new LazyBinomialCombinator(n: Int, k: Int)
Creates a problem instance "n choose k".
Creates a problem instance "n choose k".
- n
defines the basic set of integers
- k
the number of integers which are to be chosen from the basic set
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def findNextSolution(solution: IndexedSeq[Int]): Option[IndexedSeq[Int]]
Given a solution the lexicographic next solution will be produced, if any.
Given a solution the lexicographic next solution will be produced, if any.
- solution
the current solution
- returns
some solution or none
- val firstSolution: IndexedSeq[Int]
The lexicographic smallest solution
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def getCurrentTracer(): AbstractTracer
Returns the present tracer for this object.
Returns the present tracer for this object.
- returns
the current tracer, by default the NullTracer
- Definition Classes
- Tracing
- def hasNextSolution(solution: IndexedSeq[Int]): Boolean
Checks if there is a next solution for a given word.
Checks if there is a next solution for a given word.
- solution
the current solution
- returns
true if there is another solution
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val k: Int
- val n: Int
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def produceAll: LazyList[IndexedSeq[Int]]
Produces a
LazyListof all solutions.Produces a
LazyListof all solutions. Solutions are computed only when they are needed. This is great if the solution space is very big.- returns
a
LazyListcomprising the solutions
- def solutions(solution: IndexedSeq[Int]): LazyList[IndexedSeq[Int]]
Produces a
LazyListof solutions given a particular solution.Produces a
LazyListof solutions given a particular solution.- solution
the starting point
- returns
a
LazyListcomprising the solutions
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
Gives a textual representation of the problem instance.
Gives a textual representation of the problem instance.
- returns
the textual presentation
- Definition Classes
- LazyBinomialCombinator → AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withTracer[T](resultType: String, callee: AnyRef, method: String)(block: => T): T
Custom control structure for tracing of embraced code blocks.
Custom control structure for tracing of embraced code blocks.
- T
the actual type of the embraced code block
- resultType
denotes the return type
- callee
the call site
- method
denotes the method signature
- block
the embraced code block
- returns
returns whatever block returns
- Definition Classes
- Tracing
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated