Documentation
¶
Index ¶
- type Set
- func (s *Set) Add(elems ...string)
- func (s Set) All() iter.Seq[string]
- func (s Set) Cardinality() int
- func (s Set) MarshalJSON() ([]byte, error)
- func (s Set) MarshalJSONTo(e *jsontext.Encoder) (err error)
- func (s Set) ToSlice() []string
- func (s *Set) UnmarshalJSON(b []byte) error
- func (s *Set) UnmarshalJSONFrom(d *jsontext.Decoder) error
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 is a set of strings that supports comparison with == and != by foregoing O(1) insertion and membership tests. The zero value is the empty set.
This implementation of Set may handle elements containing the byte values of ASCII control characters less efficiently than elements without such bytes.
func (*Set) Add ¶
Add turns s into the union of s and the provided elements.
In the worst case, the time complexity of Add is O(n log n) in the size of the combined set. Typical implementations of Go can Add a single element in O(n) time.
func (Set) Cardinality ¶
Cardinality returns the number of elements in s in O(n) time. It is more efficient than computing the length of the slice returned by ToSlice.