package
Version:
v0.0.0-...-4553cd5
Opens a new window with list of versions in this module.
Published: Aug 9, 2016
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package set Set Data Structure based on map and sync.RWMutex
Set safe map
package main
import (
"fmt"
"github.com/upyun/utilgo/set"
)
func main() {
s := set.New()
s.Add(1)
s.Add(2)
s.Add(3)
s.Remove(2)
fmt.Println(s.Len())
fmt.Println(s.Has(1))
fmt.Println(s.Has(2))
fmt.Println(s.Has(3))
}
Output:
2
true
false
true
func (s *Set) Add(item interface{})
Add add
Clear removes all items from the set
func (s *Set) Each(fn func(interface{}))
Each call fn on each element in the Set
func (s *Set) Has(item interface{}) bool
Has looks for the existence of an item
IsEmpty checks for emptiness
Len returns the number of items in a set.
func (s *Set) List() []interface{}
List Set returns a slice of all items
func (s *Set) Remove(item interface{})
Remove deletes the specified item from the map
Source Files
¶
Click to show internal directories.
Click to hide internal directories.