@@ -4,22 +4,26 @@ import (
44 "github.com/neutrinocorp/nolan/function"
55)
66
7- // ComparatorFunc A functional interface used to indicate if first argument is greater, less or equals than
8- // the second. If equals this will return 0, if less -1 and if greater, then it returns 1.
9- type ComparatorFunc [T any ] function.BiPredicate [T , T , int ]
7+ // ComparatorFunc a functional interface used to indicate if the first argument is greater, less or equals than
8+ // the second.
9+ // If equals, this will return 0, if less -1 and if greater, then it returns 1.
10+ type ComparatorFunc [T any ] function.DelegateBiFunc [T , T , int ]
1011
12+ // ComparableCollection a kind of Collection for comparable types.
13+ // Note that nolan offers a functional way to operate with Collection and comparable types
14+ // without the need of this interface (e.g., Contains, ContainsAll, ContainsSlice).
1115type ComparableCollection [T comparable ] interface {
1216 Collection [T ]
13- // Contains Returns true if this collection contains the specified element.
17+ // Contains returns true if this collection contains the specified element.
1418 Contains (v T ) bool
15- // ContainsAll Returns true if this collection contains all the elements in the specified collection.
19+ // ContainsAll returns true if this collection contains all the elements in the specified collection.
1620 ContainsAll (src Collection [T ]) bool
17- // ContainsSlice Returns true if this collection contains all the elements in the specified slice.
21+ // ContainsSlice returns true if this collection contains all the elements in the specified slice.
1822 ContainsSlice (src ... T ) bool
1923}
2024
21- // used internally to share iterator instances. This helps to reduce malloc as
22- // we can reuse iterator instances.
25+ // NOTE: This is used internally to share iterator instances.
26+ // This helps to reduce malloc as we can reuse iterator instances.
2327func containsWithIterator [T comparable ](iter Iterator [T ], v T ) bool {
2428 for iter .HasNext () {
2529 if val := iter .Next (); val == v {
@@ -29,13 +33,13 @@ func containsWithIterator[T comparable](iter Iterator[T], v T) bool {
2933 return false
3034}
3135
32- // Contains Returns true if this collection contains the specified element.
36+ // Contains returns true if this collection contains the specified element.
3337func Contains [T comparable ](src Collection [T ], v T ) bool {
3438 iter := src .NewIterator ()
3539 return containsWithIterator [T ](iter , v )
3640}
3741
38- // ContainsAll Returns true if this collection contains all the elements in the specified collection.
42+ // ContainsAll returns true if this collection contains all the elements in the specified collection.
3943func ContainsAll [T comparable ](src Collection [T ], cmpColl Collection [T ]) bool {
4044 // Time complexity of O(mn)
4145 srcIter := src .NewIterator ()
@@ -51,7 +55,7 @@ func ContainsAll[T comparable](src Collection[T], cmpColl Collection[T]) bool {
5155 return true
5256}
5357
54- // ContainsSlice Returns true if this collection contains all the elements in the specified slice.
58+ // ContainsSlice returns true if this collection contains all the elements in the specified slice.
5559func ContainsSlice [T comparable ](src Collection [T ], cmpSlice []T ) bool {
5660 iter := src .NewIterator ()
5761 for _ , item := range cmpSlice {
0 commit comments