mirror of
https://github.com/danog/gojekyll.git
synced 2024-11-30 06:59:04 +01:00
26 lines
597 B
Go
26 lines
597 B
Go
package utils
|
|
|
|
// A StringSet is a set of strings, represented as a map.
|
|
type StringSet map[string]bool
|
|
|
|
// MakeStringSet creates a characteristic function map that tests for presence in an array.
|
|
func MakeStringSet(a []string) StringSet {
|
|
set := map[string]bool{}
|
|
for _, s := range a {
|
|
set[s] = true
|
|
}
|
|
return set
|
|
}
|
|
|
|
// AddStrings modifies the set to include the strings in an array.
|
|
func (ss StringSet) AddStrings(a []string) {
|
|
for _, s := range a {
|
|
ss[s] = true
|
|
}
|
|
}
|
|
|
|
// Contains returns true iff the string is in the set.
|
|
func (ss StringSet) Contains(s string) bool {
|
|
return ss[s]
|
|
}
|