util

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package util provides various things used by other packages in this module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteLowercase

func ByteLowercase(str string) string

ByteLowercase returns a byte-lowercase version of ASCII string str.

func ByteUppercase added in v0.5.0

func ByteUppercase(str string) string

ByteUppercase returns a byte-uppercase version of ASCII string str.

Types

type ASCIISet added in v0.3.0

type ASCIISet [8]uint32

An ASCIISet represents a set of ASCII bytes.

func MakeASCIISet added in v0.3.0

func MakeASCIISet(chars string) ASCIISet

MakeASCIISet creates a set of ASCII characters and reports whether all characters in chars are ASCII. All bytes in chars are assumed to be less < utf8.RuneSelf. This implementation is adapted from that of the strings package.

func (*ASCIISet) Contains added in v0.3.0

func (as *ASCIISet) Contains(c byte) bool

Contains reports whether c is inside the set.

type Set

type Set SortedSet

A Set represents a set of strings.

func NewSet

func NewSet(elems ...string) (set Set)

NewSet returns a Set that contains all of elems but no other elements.

func (*Set) Add

func (set *Set) Add(e string)

Add adds e to set.

func (Set) Contains

func (set Set) Contains(e string) bool

Contains reports whether e is an element of set.

func (Set) Size added in v0.5.3

func (set Set) Size() int

Size returns the cardinality of set.

func (Set) ToSlice added in v0.5.6

func (set Set) ToSlice() []string

ToSlice returns a slice of set's elements sorted in lexicographical order.

type SortedSet

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

A SortedSet represents a set of strings sorted in lexicographical order. Each element has a unique position ranging from 0 (inclusive) to the set's cardinality (exclusive). The zero value represents an empty set.

func (*SortedSet) Add added in v0.5.6

func (set *SortedSet) Add(e string)

Add adds e to set.

func (SortedSet) IndexAfter added in v0.5.6

func (set SortedSet) IndexAfter(n int, e string) int

IndexAfter returns the position of e in set if it occurs after the first n+1 elements of set, or -1 otherwise.

Precondition: n < set.Size().

func (SortedSet) MaxLen added in v0.5.6

func (set SortedSet) MaxLen() int

MaxLen returns the length of set's longest element, or 0 if set is empty.

func (SortedSet) Size

func (set SortedSet) Size() int

Size returns the cardinality of set.

func (SortedSet) ToSlice added in v0.5.6

func (set SortedSet) ToSlice() []string

ToSlice returns a slice of set's elements sorted in lexicographical order.

Jump to

Keyboard shortcuts

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