Documentation
¶
Overview ¶
Package permutation provides algorithms about permutations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NextPermutation ¶
Transform data to its next permutation in lexical order. It returns false if data.Len() == 0 or the permutations are exhausted, and true otherwise. Time complexity: O(n), where n = data.Len().
Types ¶
type ArrayAdapter ¶
An adapter for: Array + LessFunc -> Interface.
func (*ArrayAdapter) Len ¶
func (ad *ArrayAdapter) Len() int
func (*ArrayAdapter) Less ¶
func (ad *ArrayAdapter) Less(i, j int) bool
func (*ArrayAdapter) Swap ¶
func (ad *ArrayAdapter) Swap(i, j int)
type Interface ¶
type Interface interface {
// Return the number of items in the permutation.
// It returns 0 if the permutation is nil.
Len() int
// Test whether the i-th item is less than j-th item of the permutation.
// It panics if i or j is out of range.
Less(i, j int) bool
// Swap the i-th and j-th items.
// It panics if i or j is out of range.
Swap(i, j int)
}
A type standing for an integer-indexed permutation. It is the same as sort.Interface.
Click to show internal directories.
Click to hide internal directories.