Skip to content

Commit 7e32b02

Browse files
committed
wip: some docs
1 parent 24026d0 commit 7e32b02

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

collection.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ type Collection[T any] interface {
5858
// ProperSubset returns whether the given Collection is a proper subset of the set.
5959
ProperSubset(Collection[T]) bool
6060

61-
// TODO Superset(Collection[T])
62-
63-
// TODO ProperSuperset(Collection[T])
64-
6561
// Size returns the number of elements in the set.
6662
Size() int
6763

hashset.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ func (s *HashSet[T, H]) UnmarshalJSON(data []byte) error {
322322
return unmarshalJSON[T](s, data)
323323
}
324324

325-
// ForEach iterates the set calling visit for each element. If visit returns
326-
// false the iteration is halted.
325+
// ForEach iterates every element in s, apply the given visit function.
326+
//
327+
// If the visit returns false at any point, iteration is halted.
327328
func (s *HashSet[T, H]) ForEach(visit func(T) bool) {
328329
for _, item := range s.items {
329330
if !visit(item) {

set.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ func (s *Set[T]) UnmarshalJSON(data []byte) error {
292292
return unmarshalJSON[T](s, data)
293293
}
294294

295+
// ForEach iterates every element in s, applying the given visit function.
296+
//
297+
// If the visit returns false at any point, iteration is halted.
295298
func (s *Set[T]) ForEach(visit func(T) bool) {
296299
for item := range s.items {
297300
if !visit(item) {

treeset.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ func (s *TreeSet[T]) StringFunc(f func(element T) string) string {
520520
return fmt.Sprintf("%s", l)
521521
}
522522

523+
// ForEach iterates every element in s, applying the given visit function.
524+
//
525+
// If the visit function returns false at any point, iteration is halted.
523526
func (s *TreeSet[T]) ForEach(visit func(T) bool) {
524527
s.infix(func(n *node[T]) (next bool) {
525528
return visit(n.element)

0 commit comments

Comments
 (0)