intrange

package
v11.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Max

func Max(a, b int) int

Max returns max value between a and b.

func Min

func Min(a, b int) int

Min returns min value between a and b.

Types

type IntRange

type IntRange struct {
	// contains filtered or unexported fields
}

IntRange stores a max and min amount for range.

func (IntRange) Get

func (r IntRange) Get(n int) bool

Get returns true if the argument n is included in the closed range between min and max.

type IntRanges

type IntRanges []IntRange

IntRanges is a slice of IntRange.

func ParseNumberMenu

func ParseNumberMenu(input string) (include, exclude IntRanges,
	otherInclude, otherExclude stringset.StringSet)

ParseNumberMenu parses input for number menus split by spaces or commas supports individual selection: 1 2 3 4 supports range selections: 1-4 10-20 supports negation: ^1 ^1-4

include and excule holds numbers that should be added and should not be added respectively. other holds anything that can't be parsed as an int. This is intended to allow words inside of number menus. e.g. 'all' 'none' 'abort' of course the implementation is up to the caller, this function mearley parses the input and organizes it.

func (IntRanges) Get

func (rs IntRanges) Get(n int) bool

Get returns true if the argument n is included in the closed range between min and max of any of the provided IntRanges.

Jump to

Keyboard shortcuts

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