Documentation ¶
Index ¶
- type Generic
- func (s *Generic[T]) Add(vals ...T)
- func (s Generic[T]) Contains(vals ...T) bool
- func (s Generic[T]) ContainsAny(vals ...T) bool
- func (s *Generic[T]) Delete(vals ...T)
- func (s Generic[T]) Diff(other Generic[T]) Generic[T]
- func (s Generic[T]) DiffSlice(other []T) Generic[T]
- func (s Generic[T]) FilterContains(slice []T) []T
- func (s Generic[T]) FilterNotContains(slice []T) []T
- func (s Generic[T]) Intersect(other Generic[T]) Generic[T]
- func (s Generic[T]) IntersectSlice(other []T) Generic[T]
- func (s Generic[T]) Iterate(fn func(T))
- func (s Generic[T]) Map() map[T]bool
- func (s Generic[T]) MarshalJSON() ([]byte, error)
- func (s Generic[T]) MarshalYAML() (interface{}, error)
- func (s Generic[T]) Size() int
- func (s Generic[T]) Slice() []T
- func (s Generic[T]) Union(other Generic[T]) Generic[T]
- func (s Generic[T]) UnionSlice(other []T) Generic[T]
- func (s *Generic[T]) UnmarshalJSON(b []byte) error
- func (s *Generic[T]) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Intdeprecated
- func NewInt(vals ...int) Intdeprecated
- func NewIntWithSize(size int) Intdeprecated
- func (s Int) Del(vals ...int)
- func (s Int) Diff(other Int) Int
- func (s Int) DiffSlice(other []int) Int
- func (s Int) FilterExclude(slice []int) []int
- func (s Int) FilterInclude(slice []int) []int
- func (s Int) Intersect(other Int) Int
- func (s Int) IntersectSlice(other []int) Int
- func (s Int) Union(other Int) Int
- func (s Int) UnionSlice(other []int) Int
- type Int32deprecated
- func NewInt32(vals ...int32) Int32deprecated
- func NewInt32WithSize(size int) Int32deprecated
- func (s Int32) Del(vals ...int32)
- func (s Int32) Diff(other Int32) Int32
- func (s Int32) DiffSlice(other []int32) Int32
- func (s Int32) FilterExclude(slice []int32) []int32
- func (s Int32) FilterInclude(slice []int32) []int32
- func (s Int32) Intersect(other Int32) Int32
- func (s Int32) IntersectSlice(other []int32) Int32
- func (s Int32) Union(other Int32) Int32
- func (s Int32) UnionSlice(other []int32) Int32
- type Int64deprecated
- func NewInt64(vals ...int64) Int64deprecated
- func NewInt64WithSize(size int) Int64deprecated
- func (s Int64) Del(vals ...int64)
- func (s Int64) Diff(other Int64) Int64
- func (s Int64) DiffSlice(other []int64) Int64
- func (s Int64) FilterExclude(slice []int64) []int64
- func (s Int64) FilterInclude(slice []int64) []int64
- func (s Int64) Intersect(other Int64) Int64
- func (s Int64) IntersectSlice(other []int64) Int64
- func (s Int64) Union(other Int64) Int64
- func (s Int64) UnionSlice(other []int64) Int64
- type Set
- func (s *Set) Add(vals ...interface{})
- func (s Set) Contains(vals ...interface{}) bool
- func (s Set) ContainsAny(vals ...interface{}) bool
- func (s *Set) Del(vals ...interface{})deprecated
- func (s *Set) Delete(vals ...interface{})
- func (s Set) Diff(other Set) Set
- func (s Set) DiffSlice(other interface{}) Set
- func (s Set) FilterContains(slice interface{}) interface{}
- func (s Set) FilterExclude(slice interface{}) interface{}deprecated
- func (s Set) FilterInclude(slice interface{}) interface{}deprecated
- func (s Set) FilterNotContains(slice interface{}) interface{}
- func (s Set) Intersect(other Set) Set
- func (s Set) IntersectSlice(other interface{}) Set
- func (s Set) Iterate(fn func(interface{}))
- func (s Set) Map() map[interface{}]bool
- func (s Set) MarshalJSON() ([]byte, error)
- func (s Set) MarshalYAML() (interface{}, error)
- func (s Set) Size() int
- func (s Set) Slice() []interface{}
- func (s Set) Union(other Set) Set
- func (s Set) UnionSlice(other interface{}) Set
- func (s *Set) UnmarshalJSON(b []byte) error
- func (s *Set) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Stringdeprecated
- func NewString(vals ...string) Stringdeprecated
- func NewStringWithSize(size int) Stringdeprecated
- func (s String) Del(vals ...string)
- func (s String) Diff(other String) String
- func (s String) DiffSlice(other []string) String
- func (s String) FilterExclude(slice []string) []string
- func (s String) FilterInclude(slice []string) []string
- func (s String) Intersect(other String) String
- func (s String) IntersectSlice(other []string) String
- func (s String) Union(other String) String
- func (s String) UnionSlice(other []string) String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generic ¶
type Generic[T comparable] struct { // contains filtered or unexported fields }
Generic is a generic set collection. The zero value of Generic is an empty instance ready to use. A zero Generic set value shall not be copied, or it may result incorrect behavior.
func New ¶
func New[T comparable](vals ...T) Generic[T]
New creates a set instance and add the given values into the set.
func NewWithSize ¶
func NewWithSize[T comparable](size int) Generic[T]
NewWithSize creates a set instance with given initial size.
func (*Generic[T]) Add ¶
func (s *Generic[T]) Add(vals ...T)
Add adds the given values into the set.
func (Generic[T]) ContainsAny ¶
ContainsAny returns true if the set contains any of the values.
func (*Generic[T]) Delete ¶
func (s *Generic[T]) Delete(vals ...T)
Delete deletes values from the set.
func (Generic[T]) FilterContains ¶
func (s Generic[T]) FilterContains(slice []T) []T
FilterContains returns a new slice which contains values that present in the provided slice and also present in the set.
func (Generic[T]) FilterNotContains ¶
func (s Generic[T]) FilterNotContains(slice []T) []T
FilterNotContains returns a new slice which contains values that present in the provided slice but don't present in the set.
func (Generic[T]) Intersect ¶
Intersect returns a new set about values which other set also contains.
func (Generic[T]) IntersectSlice ¶
IntersectSlice is similar to Intersect, but takes a slice as parameter.
func (Generic[T]) Iterate ¶
func (s Generic[T]) Iterate(fn func(T))
Iterate iterates the set in no particular order and calls the given function for each set element.
func (Generic[T]) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface, the set will be marshaled as a slice []T.
func (Generic[T]) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler interface of the yaml package, the set will be marshaled as a slice []T.
func (Generic[T]) Slice ¶
func (s Generic[T]) Slice() []T
Slice converts the set into a slice of type []T.
func (Generic[T]) UnionSlice ¶
UnionSlice is similar to Union, but takes a slice as parameter.
func (*Generic[T]) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface, it will unmarshal a slice []T to the set.
func (*Generic[T]) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler interface of the yaml package, it will unmarshal a slice []T to the set.
type Int
deprecated
Int is an int set collection. The zero value of Int is an empty instance ready to use. A zero Int value shall not be copied, or it may result incorrect behavior.
Deprecated: Int wraps Generic[int] to be compatible with old code, please use Generic directly in new code.
func NewIntWithSize
deprecated
func (Int) FilterExclude ¶
func (Int) FilterInclude ¶
func (Int) IntersectSlice ¶
func (Int) UnionSlice ¶
type Int32
deprecated
Int32 is an int32 set collection. The zero value of Int32 is an empty instance ready to use. A zero Int32 value shall not be copied, or it may result incorrect behavior.
Deprecated: Int32 wraps Generic[int32] to be compatible with old code, please use Generic directly in new code.
func NewInt32WithSize
deprecated
func (Int32) FilterExclude ¶
func (Int32) FilterInclude ¶
func (Int32) IntersectSlice ¶
func (Int32) UnionSlice ¶
type Int64
deprecated
Int64 is an int64 set collection. The zero value of Int64 is an empty instance ready to use. A zero Int64 value shall not be copied, or it may result incorrect behavior.
Deprecated: Int64 wraps Generic[int64] to be compatible with old code, please use Generic directly in new code.
func NewInt64WithSize
deprecated
func (Int64) FilterExclude ¶
func (Int64) FilterInclude ¶
func (Int64) IntersectSlice ¶
func (Int64) UnionSlice ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a set collection of interface{} type. The zero value of Set is an empty instance ready to use. A zero Set value shall not be copied, or it may result incorrect behavior.
func NewSet ¶
func NewSet(vals ...interface{}) Set
NewSet creates a Set instance and add the given values into the set. If given only one param which is a slice, the elements of the slice will be added into the set using reflection.
func NewSetWithSize ¶
NewSetWithSize creates a Set instance with given initial size.
func (*Set) Add ¶
func (s *Set) Add(vals ...interface{})
Add adds the given values into the set. If given only one param which is a slice, the elements of the slice will be added into the set using reflection.
func (Set) ContainsAny ¶
ContainsAny returns true if the set contains any of the values.
func (Set) DiffSlice ¶
DiffSlice is similar to Diff, but takes a slice as parameter. Param other must be a slice of []interface{} or slice of the concrete element type, else it panics.
func (Set) FilterContains ¶
func (s Set) FilterContains(slice interface{}) interface{}
FilterContains returns a new slice which contains values that present in the provided slice and also present in the Set. Param slice must be a slice of []interface{} or slice of the concrete element type, else it panics.
func (Set) FilterExclude
deprecated
func (s Set) FilterExclude(slice interface{}) interface{}
FilterExclude returns a new slice which contains values that present in the provided slice but don't present in the Set. Param slice must be a slice of []interface{} or slice of the concrete element type, else it panics.
Deprecated: FilterExclude has been renamed to FilterNotContains.
func (Set) FilterInclude
deprecated
func (s Set) FilterInclude(slice interface{}) interface{}
FilterInclude returns a new slice which contains values that present in the provided slice and also present in the Set. Param slice must be a slice of []interface{} or slice of the concrete element type, else it panics.
Deprecated: FilterInclude has been renamed to FilterContains.
func (Set) FilterNotContains ¶
func (s Set) FilterNotContains(slice interface{}) interface{}
FilterNotContains returns a new slice which contains values that present in the provided slice but don't present in the Set. Param slice must be a slice of []interface{} or slice of the concrete element type, else it panics.
func (Set) IntersectSlice ¶
IntersectSlice is similar to Intersect, but takes a slice as parameter. Param other must be a slice of []interface{} or slice of the concrete element type, else it panics.
func (Set) Iterate ¶
func (s Set) Iterate(fn func(interface{}))
Iterate iterates the set in no particular order and calls the given function for each set element.
func (Set) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface, the set will be marshaled as a slice []interface{}.
func (Set) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler interface of the yaml package, the set will be marshaled as a slice []interface{}.
func (Set) Slice ¶
func (s Set) Slice() []interface{}
Slice converts set into a slice of type []interface{}.
func (Set) UnionSlice ¶
UnionSlice is similar to Union, but takes a slice as parameter. Param other must be a slice of []interface{} or slice of the concrete element type, else it panics.
func (*Set) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface, it will unmarshal a slice []interface{} to the set.
func (*Set) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler interface of the yaml package, it will unmarshal a slice []interface{} to the set.
type String
deprecated
String is a string set collection. The zero value of String is an empty instance ready to use. A zero String value shall not be copied, or it may result incorrect behavior.
Deprecated: String wraps Generic[string] to be compatible with old code, please use Generic directly in new code.