-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] Add annotations to SortedList[T]
- Loading branch information
1 parent
b2fce64
commit 73caebe
Showing
4 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
package sortedlist | ||
|
||
// Reduce applies a function against an accumulator and each element in the list (from left to right) to reduce it to a single value. | ||
func (l SortedList[T]) Reduce(handler func(T, T) T, initial ...T) (T, error) { | ||
return l.elements.Reduce(handler, initial...) | ||
} | ||
|
||
// ReduceRight applies a function against an accumulator and each element in the list (from right to left) to reduce it to a single value. | ||
func (l SortedList[T]) ReduceRight(handler func(T, T) T, initial ...T) (T, error) { | ||
return l.elements.ReduceRight(handler, initial...) | ||
} | ||
|
||
// Filter creates a new list with all elements that pass the condition implemented by the provided function. | ||
func (l SortedList[T]) Filter(condition func(T) bool) SortedList[T] { | ||
return SortedList[T]{ | ||
l.elements.Filter(condition), | ||
l.cmp, | ||
} | ||
} | ||
|
||
// Some checks if at least one element in the list passes the condition implemented by the provided function. | ||
func (l SortedList[T]) Some(condition func(T) bool) bool { | ||
return l.elements.Some(condition) | ||
} | ||
|
||
// Every checks if all elements in the list pass the condition implemented by the provided function. | ||
func (l SortedList[T]) Every(condition func(T) bool) bool { | ||
return l.elements.Every(condition) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters