stringset

package
v0.15.0-m1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package stringset provides a type storing sets of strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Add adds the given string to the set, if it’s not already present.
	// Returns true if the string was added, false otherwise (it was already present).
	Add(s string) bool

	// AddAll adds all the given strings to the set.
	AddAll(s ...string)

	// Remove removes the given string from the set.
	// Returns true if the string was present in the set, false otherwise.
	Remove(s string) bool

	// RemoveAll clears the set.
	RemoveAll()

	// Contains determines whether the set contains the given string.
	Contains(s string) bool

	// Size returns the size of the set.
	Size() int

	// Elements returns the contents of the set as a slice
	Elements() []string

	// Difference returns the difference between this set and the given object,
	// i.e. all the strings in this set which aren’t in other.
	Difference(other Interface) []string
}

func New

func New(s ...string) Interface

New creates a new set of strings, initialized with the given strings.

func NewSynchronized

func NewSynchronized(s ...string) Interface

New creates a new synchronized set of strings, initialized with the given strings. Changes to the set of strings will lock the set as appropriate to ensure atomicity.

Jump to

Keyboard shortcuts

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