Documentation ¶
Index ¶
- type Set
- func (s *Set) Add(value ...interface{})
- func (s *Set) AddFront(value ...interface{})
- func (s *Set) CartesianProduct(sets ...*Set) [][]interface{}
- func (s *Set) Clear() *Set
- func (s *Set) Clone() *Set
- func (s *Set) CloneAndClear() *Set
- func (s *Set) Contains(value interface{}) (exists bool)
- func (s *Set) Delete(value ...interface{})
- func (s *Set) IndexOf(k interface{}) int
- func (s *Set) Len() int
- func (s *Set) Merge(set *Set)
- func (s *Set) MergeSlice(data []interface{})
- func (s *Set) MergeStringSlice(data []string)
- func (s *Set) Pop() (value interface{})
- func (s *Set) Range(f func(value interface{}) bool)
- func (s *Set) RangeFast(f func(value interface{}) bool)
- func (s *Set) Shift() (value interface{})
- func (s *Set) String() string
- func (s *Set) ToSlice() []interface{}
- func (s *Set) ToStringSlice() []string
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 each value in set is unique, and keep the sequence of Add() or Merge()
func (*Set) Add ¶
func (s *Set) Add(value ...interface{})
Add adds a value to set, if value not exists in set s.
func (*Set) AddFront ¶
func (s *Set) AddFront(value ...interface{})
AddFront adds a value to set, if value not exists in set s. The value will be stored the first in set s if value not exists.
func (*Set) CartesianProduct ¶
CartesianProduct → {(x, y) | ∀ x ∈ s1, ∀ y ∈ s2} For example:
CartesianProduct(A, B), where A = {1, 2} and B = {7, 8} => {(1, 7), (1, 8), (2, 7), (2, 8)}
func (*Set) IndexOf ¶
IndexOf indicates the index of value in Map s, if not found returns -1.
idx start with 0.
func (*Set) MergeSlice ¶
func (s *Set) MergeSlice(data []interface{})
MergeSlice merges slice values to set s.
Kept the Add() sequence.
func (*Set) MergeStringSlice ¶
MergeStringSlice merges slice values to set s.
Kept the Add() sequence.
func (*Set) Pop ¶
func (s *Set) Pop() (value interface{})
Pop returns last value of set s, and remove it.
func (*Set) Range ¶
Range ranges the value in set s, if function f return false, the range loop will break.
Range keeps the Add() sequence.
func (*Set) RangeFast ¶
RangeFast ranges the value in set s, if function f return false, the range loop will break.
RangeFast do not create a snapshot for range, so you can not modify list s in range loop, indicate do not call Remove(), Add(), Merge() etc.
func (*Set) Shift ¶
func (s *Set) Shift() (value interface{})
Shift returns first value of set s, and remove it.
func (*Set) ToSlice ¶
func (s *Set) ToSlice() []interface{}
ToSlice convert set s to slice []interface{}.
Kept the Add() sequence.
func (*Set) ToStringSlice ¶
ToStringSlice convert set s to slice []interface{}.
Kept the Add() sequence.