Skip to content
StringSet is a string cache used for storing a key up to once
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
map.go
stringset.go
stringset_test.go

README.md

StringSet

StringSet is a string cache used for storing a key up to once. This utility is useful when managing set-lists for unique keys.

Usage

New

func ExampleNew() {
	// Initialize new stringset
	testKeys = New()
}

StringSet.Set

func ExampleStringSet_Set() {
	// Set foo key
	testKeys.Set("foo")
	// Set bar key
	testKeys.Set("bar")
}

StringSet.Unset

func ExampleStringSet_Unset() {
	// Remove bar key
	testKeys.Unset("bar")
}

StringSet.Has

func ExampleStringSet_Has() {
	if testKeys.Has("foo") {
		fmt.Println("We have foo!")
	}

	if !testKeys.Has("bar") {
		fmt.Println("We do not have bar!")
	}
}

StringSet.Slice

func ExampleStringSet_Slice() {
	keys := testKeys.Slice()
	for _, key := range keys {
		fmt.Printf("Iterating key: %s\n", key)
	}
}
You can’t perform that action at this time.