Skip to content

Code and style improvements #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions set.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ package mapset
// represents an unordered set of data and a large number of
// operations that can be applied to that set.
type Set[T comparable] interface {
// Adds an element to the set. Returns whether
// Add adds an element to the set. Returns whether
// the item was added.
Add(val T) bool

// Returns the number of elements in the set.
// Cardinality returns the number of elements in the set.
Cardinality() int

// Removes all elements from the set, leaving
// Clear removes all elements from the set, leaving
// the empty set.
Clear()

// Returns a clone of the set using the same
// Clone returns a clone of the set using the same
// implementation, duplicating all keys.
Clone() Set[T]

// Returns whether the given items
// Contains returns whether the given items
// are all in the set.
Contains(val ...T) bool

// Returns the difference between this set
// Difference returns the difference between this set
// and other. The returned set will contain
// all elements of this set that are not also
// elements of other.
Expand All @@ -69,7 +69,7 @@ type Set[T comparable] interface {
// panic.
Difference(other Set[T]) Set[T]

// Determines if two sets are equal to each
// Equal determines if two sets are equal to each
// other. If they have the same cardinality
// and contain the same elements, they are
// considered equal. The order in which
Expand All @@ -80,7 +80,7 @@ type Set[T comparable] interface {
// method. Otherwise, Equal will panic.
Equal(other Set[T]) bool

// Returns a new set containing only the elements
// Intersect returns a new set containing only the elements
// that exist only in both sets.
//
// Note that the argument to Intersect
Expand All @@ -89,7 +89,7 @@ type Set[T comparable] interface {
// panic.
Intersect(other Set[T]) Set[T]

// Determines if every element in this set is in
// IsProperSubset determines if every element in this set is in
// the other set but the two sets are not equal.
//
// Note that the argument to IsProperSubset
Expand All @@ -98,7 +98,7 @@ type Set[T comparable] interface {
// will panic.
IsProperSubset(other Set[T]) bool

// Determines if every element in the other set
// IsProperSuperset determines if every element in the other set
// is in this set but the two sets are not
// equal.
//
Expand All @@ -108,7 +108,7 @@ type Set[T comparable] interface {
// panic.
IsProperSuperset(other Set[T]) bool

// Determines if every element in this set is in
// IsSubset determines if every element in this set is in
// the other set.
//
// Note that the argument to IsSubset
Expand All @@ -117,7 +117,7 @@ type Set[T comparable] interface {
// panic.
IsSubset(other Set[T]) bool

// Determines if every element in the other set
// IsSuperset determines if every element in the other set
// is in this set.
//
// Note that the argument to IsSuperset
Expand All @@ -126,26 +126,26 @@ type Set[T comparable] interface {
// panic.
IsSuperset(other Set[T]) bool

// Iterates over elements and executes the passed func against each element.
// Each iterates over elements and executes the passed func against each element.
// If passed func returns true, stop iteration at the time.
Each(func(T) bool)

// Returns a channel of elements that you can
// Iter returns a channel of elements that you can
// range over.
Iter() <-chan T

// Returns an Iterator object that you can
// Iterator returns an Iterator object that you can
// use to range over the set.
Iterator() *Iterator[T]

// Remove a single element from the set.
// Remove removes a single element from the set.
Remove(i T)

// Provides a convenient string representation
// String provides a convenient string representation
// of the current state of the set.
String() string

// Returns a new set with all elements which are
// SymmetricDifference returns a new set with all elements which are
// in either this set or the other set but not in both.
//
// Note that the argument to SymmetricDifference
Expand All @@ -154,7 +154,7 @@ type Set[T comparable] interface {
// will panic.
SymmetricDifference(other Set[T]) Set[T]

// Returns a new set with all elements in both sets.
// Union returns a new set with all elements in both sets.
//
// Note that the argument to Union must be of the
// same type as the receiver of the method.
Expand All @@ -164,7 +164,7 @@ type Set[T comparable] interface {
// Pop removes and returns an arbitrary item from the set.
Pop() (T, bool)

// Returns the members of the set as a slice.
// ToSlice returns the members of the set as a slice.
ToSlice() []T

// MarshalJSON will marshal the set into a JSON-based representation.
Expand All @@ -182,7 +182,7 @@ func NewSet[T comparable](vals ...T) Set[T] {
for _, item := range vals {
s.Add(item)
}
return &s
return s
}

// NewThreadUnsafeSet creates and returns a new set with the given elements.
Expand All @@ -192,5 +192,5 @@ func NewThreadUnsafeSet[T comparable](vals ...T) Set[T] {
for _, item := range vals {
s.Add(item)
}
return &s
return s
}
Loading