Packages

c

de.christofreichardt.scala.combinations

LazyBinomialCombinator

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.

Linear Supertypes
Tracing, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. LazyBinomialCombinator
  2. Tracing
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. 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

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. 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

  9. val firstSolution: IndexedSeq[Int]

    The lexicographic smallest solution

  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  11. 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
  12. 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

  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. val k: Int
  16. val n: Int
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  20. def produceAll: LazyList[IndexedSeq[Int]]

    Produces a LazyList of all solutions.

    Produces a LazyList of all solutions. Solutions are computed only when they are needed. This is great if the solution space is very big.

    returns

    a LazyList comprising the solutions

  21. def solutions(solution: IndexedSeq[Int]): LazyList[IndexedSeq[Int]]

    Produces a LazyList of solutions given a particular solution.

    Produces a LazyList of solutions given a particular solution.

    solution

    the starting point

    returns

    a LazyList comprising the solutions

  22. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  23. 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
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  26. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  27. 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

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from Tracing

Inherited from AnyRef

Inherited from Any

Ungrouped