Skip to content

Commit 824c7be

Browse files
committed
feat: move ForEach method from collection to set.
1 parent 4cb8817 commit 824c7be

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

collection.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ type Collection[T any] interface {
1414
// Contains returns true if this collection contains the specified element.
1515
Contains(e T) bool
1616

17-
// ContainsAll returns true if this collection contains all of the elements in the specified collection.
17+
// ContainsAll returns true if this collection contains all of the elements in the specified
18+
// collection.
1819
ContainsAll(c ...T) bool
1920

2021
// Equals compares this collection with the object pass from parameter.
2122
Equals(o any) bool
2223

23-
// ForEach performs the given handler for each elements in the collection until all elements have been processed or the handler returns an error.
24-
ForEach(func(e T) error) error
25-
2624
// IsEmpty returns true if this collection contains no elements.
2725
IsEmpty() bool
2826

list.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package collection
2+
3+
type List[T any] interface {
4+
Add(T)
5+
6+
AddAll(...T)
7+
8+
Insert(int, T)
9+
}

set.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ type Set[T comparable] interface {
66

77
// Clone returns a copy of this set.
88
Clone() Set[T]
9+
10+
// ForEach performs the given handler for each elements in the collection until all elements
11+
// have been processed or the handler returns an error.
12+
ForEach(func(e T) error) error
913
}

0 commit comments

Comments
 (0)