permutation

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2021 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package permutation provides algorithms about permutations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextPermutation

func NextPermutation(data Interface) bool

NextPermutation transforms 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

type ArrayAdapter struct {
	Data   sequence.Array
	LessFn function.LessFunc
}

ArrayAdapter is an adapter for: sequence.Array + function.LessFunc -> Interface.

func (*ArrayAdapter) Len

func (ad *ArrayAdapter) Len() int

Len returns the number of items in the array.

func (*ArrayAdapter) Less

func (ad *ArrayAdapter) Less(i, j int) bool

Less reports whether the item with index i must sort before the item with index j.

func (*ArrayAdapter) Swap

func (ad *ArrayAdapter) Swap(i, j int)

Swap swaps the items with indexes i and j.

type Interface

type Interface = sort.Interface

Interface represents an integer-indexed permutation. It is the same as sort.Interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL