Documentation
¶
Overview ¶
Package set is a set container package.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[E comparable] interface { // Add adds an element. Add(elem E) // AddAll adds all elememts. AddAll(elems ...E) // Remove removes the specific element. Remove(elem E) // RemoveAll removes all the specific elements. RemoveAll(elems ...E) // Size returns the size of the set. Size() int // Contains checks whether the element is in the set. Contains(elem E) bool // Empty checks whether the set is empty. Empty() bool // Values returns all elements list of the set. Values() []E // Clear clears the set. Clear() }
Set is interface for set container.
Example ¶
s := New(1, 2) s.Add(3) s.Remove(2) fmt.Println("Contains 1:", s.Contains(1)) fmt.Println("Contains 2:", s.Contains(2)) fmt.Println("Empty:", s.Empty())
Output: Contains 1: true Contains 2: false Empty: false
Click to show internal directories.
Click to hide internal directories.