Documentation
¶
Index ¶
- type HashSet
- func (s HashSet[T]) Add(elt T) bool
- func (s HashSet[T]) Choose() optionals.Optional[T]
- func (s HashSet[T]) Clear()
- func (s HashSet[T]) Contains(elt T) bool
- func (s HashSet[T]) Count(f func(T) (bool, error)) (int, error)
- func (s HashSet[T]) CountNoError(f func(T) bool) int
- func (s HashSet[T]) Elements() iter.Seq[T]
- func (s HashSet[T]) Exists(f func(T) (bool, error)) (bool, error)
- func (s HashSet[T]) ExistsNoError(f func(T) bool) bool
- func (s HashSet[T]) Filter(f func(T) (bool, error)) error
- func (s HashSet[T]) FilterNoError(f func(T) bool)
- func (s HashSet[T]) Find(f func(T) (bool, error)) (optionals.Optional[T], error)
- func (s HashSet[T]) FindNoError(f func(T) bool) optionals.Optional[T]
- func (s HashSet[T]) ForAll(f func(T) (bool, error)) (bool, error)
- func (s HashSet[T]) ForAllNoError(f func(T) bool) bool
- func (s HashSet[T]) IsEmpty() bool
- func (s HashSet[T]) MarshalJSON() ([]byte, error)
- func (s HashSet[T]) Remove(elt T)
- func (s HashSet[T]) Size() int
- func (s HashSet[T]) ToSlice() []T
- func (s *HashSet[T]) UnmarshalJSON(data []byte) error
- type Set
- type UnmodifiableSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashSet ¶
type HashSet[T comparable] struct { // contains filtered or unexported fields }
func NewHashSet ¶
func NewHashSet[T comparable](ts ...T) HashSet[T]
func (HashSet[T]) CountNoError ¶
func (HashSet[T]) ExistsNoError ¶
func (HashSet[T]) FilterNoError ¶
func (HashSet[T]) FindNoError ¶
func (HashSet[T]) ForAllNoError ¶
func (HashSet[T]) MarshalJSON ¶
func (*HashSet[T]) UnmarshalJSON ¶
type Set ¶
type Set[T comparable] interface { UnmodifiableSet[T] // Adds the given element to this set. Returns true if the element was not // already a member; false otherwise. Add(T) bool // Clears all elements from this set. Clear() // Retains in this set all elements that satisfy f. All other elements are // removed. // // If f returns an error, then iteration stops and that error is returned. // Filtering is NOT applied to the element that causes the error. Set elements // are processed in the same order as they appear during iteration via // [UnmodifiableSet.Elements]. // // This is the imperative version of [setfun.Filter]. Filter(f func(T) (bool, error)) error // Like [Filter], but without support for errors. // // This is the imperative version of [setfun.FilterNoError]. FilterNoError(f func(T) bool) // Removes the given element from this set. This is a no-op if the element is // not a member of this set. Remove(T) }
func NewEmpty ¶
func NewEmpty[T1 comparable, T2 comparable](s UnmodifiableSet[T1]) Set[T2]
Returns a new set having the same underlying implementation as the one given.
type UnmodifiableSet ¶
type UnmodifiableSet[T comparable] interface { // Returns an arbitrary element of this set, or None if empty. Choose() optionals.Optional[T] // Determines whether the given element is a member of this set. Contains(T) bool // Determines the number of elements in this set that satisfy f. // // If f returns an error, then iteration stops and that error is returned with // the count obtained thus far. If true is returned alongside the error, then // this is included in the returned count. Set elements are processed in the // same order as they appear during iteration via [Elements]. Count(f func(T) (bool, error)) (int, error) // Like [Count], but without support for errors. CountNoError(func(T) bool) int // Returns an interator over the elements in this set. Elements() iter.Seq[T] // Returns true if any element of this set satisfies f. // // If f returns an error, then iteration stops and that error is returned. Set // elements are processed in the same order as they appear during iteration // via [Elements]. Exists(f func(T) (bool, error)) (bool, error) // Like [Exists], but without support for errors. ExistsNoError(func(T) bool) bool // Returns an element of this set that satisfies f. // // If f returns an error, then iteration stops and that error is returned. Set // elements are processed in the same order as they appear during iteration // via [Elements]. Find(func(T) (bool, error)) (optionals.Optional[T], error) // Like [Find], but without support for errors. FindNoError(func(T) bool) optionals.Optional[T] // Returns true if all elements of this set satisfy f. // // If f returns an error, then iteration stops and that error is returned. Set // elements are processed in the same order as they appear during iteration // via [Elements]. ForAll(f func(T) (bool, error)) (bool, error) // Like [ForAll], but without support for errors. ForAllNoError(func(T) bool) bool // Determines whether this set is empty. IsEmpty() bool // Returns the number of elements in this set. Size() int // Returns a slice containing all of the elements in this set. ToSlice() []T }
Click to show internal directories.
Click to hide internal directories.