stringset

package
v0.0.0-...-2824937 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MIT, BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package stringset provides a way to represent a collection of strings compactly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search(s *Set, str string) int

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

func (b *Builder) Add(ss ...string)

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

func (b *Builder) Index(s string) int

Index returns the index for the given string, which must have been added before.

func (*Builder) Set

func (b *Builder) Set() Set

Set creates the set created so far.

type Set

type Set struct {
	Data  string
	Index []uint16
}

A Set holds a collection of strings that can be looked up by an index number.

func (*Set) Elem

func (s *Set) Elem(i int) string

Elem returns the string with index i. It panics if i is out of range.

func (*Set) Len

func (s *Set) Len() int

Len returns the number of strings in the set.

Jump to

Keyboard shortcuts

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