Documentation ¶
Overview ¶
Package set implements simple present/not data structure supporting arbitrary types (even a mixture).
Internally it uses a simple map assigning zero-byte struct{}s to keys.
Example (Usage) ¶
Insert some numbers into a set, remove one and sum the remainder.
package main import ( "fmt" "gopkg.in/karalabe/cookiejar.v2/collections/set" ) func main() { // Create a new set and insert some data s := set.New() s.Insert(3.14) s.Insert(1.41) s.Insert(2.71) s.Insert(10) // Isn't this one just ugly? // Remove unneeded data and verify that it's gone s.Remove(10) if !s.Exists(10) { fmt.Println("Yay, ugly 10 is no more!") } else { fmt.Println("Welcome To Facebook") } // Sum the remainder and output sum := 0.0 s.Do(func(val interface{}) { sum += val.(float64) }) fmt.Println("Sum:", sum) }
Output: Yay, ugly 10 is no more! Sum: 7.26
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set data structure.
func (*Set) Do ¶
func (s *Set) Do(f func(interface{}))
Executes a function for every element in the set.
Click to show internal directories.
Click to hide internal directories.