Documentation
¶
Overview ¶
Package permutation provides algorithms about permutations.
For better performance, all functions in this package are unsafe for concurrency unless otherwise specified.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NextPermutation ¶
NextPermutation transforms itf to its next permutation in lexical order. It returns false if itf.Len() == 0 or the permutations are exhausted, and true otherwise.
Time complexity: O(n), where n = itf.Len().
Types ¶
type Interface ¶
type Interface interface { // Len returns the number of items in the permutation. Len() int // Less reports whether the item with index i // is less than the item with index j. // // Less must describe a strict weak ordering. // See <https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings> // for details. // // Note that floating-point comparison // (the < operator on float32 or float64 values) // is not a strict weak ordering // when not-a-number (NaN) values are involved. // // It panics if i or j is out of range. Less(i, j int) bool // Swap exchanges the items with indexes i and j. // // It panics if i or j is out of range. Swap(i, j int) }
Interface represents an integer-indexed permutation with method Less.
It is consistent with the interface sort.Interface.
Click to show internal directories.
Click to hide internal directories.