package stringset
import "golang.org/x/text/internal/stringset"
Package stringset provides a way to represent a collection of strings compactly.
Index ¶
- func Search(s *Set, str string) int
- type Builder
- func NewBuilder() *Builder
- func (b *Builder) Add(ss ...string)
- func (b *Builder) Index(s string) int
- func (b *Builder) Set() Set
- type Set
Functions ¶
func Search ¶
Search returns the index of the given string or -1 if it is not in the set. The Set must have been created with strings in sorted order.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
A Builder constructs Sets.
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder returns a new and initialized Builder.
func (*Builder) Add ¶
Add adds a string to the index. Strings that are added by a single Add will be stored together, unless they match an existing string.
func (*Builder) Index ¶
Index returns the index for the given string, which must have been added before.
func (*Builder) Set ¶
Set creates the set created so far.
type Set ¶
A Set holds a collection of strings that can be looked up by an index number.
func (*Set) Elem ¶
Elem returns the string with index i. It panics if i is out of range.
func (*Set) Len ¶
Len returns the number of strings in the set.
Source Files ¶
set.go
- Version
- v0.22.0 (latest)
- Published
- Feb 4, 2025
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 1 day ago –
Tools for package owners.