mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-14 10:29:29 +02:00
Merge pull request #9159 from ziggie1984/fn-set-addon
fn: Add Size and IsEmpty methods to Set
This commit is contained in:
10
fn/set.go
10
fn/set.go
@@ -31,6 +31,16 @@ func (s Set[T]) Contains(e T) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsEmpty returns true if the set is empty.
|
||||||
|
func (s Set[T]) IsEmpty() bool {
|
||||||
|
return len(s) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Size returns the number of elements in the set.
|
||||||
|
func (s Set[T]) Size() uint {
|
||||||
|
return uint(len(s))
|
||||||
|
}
|
||||||
|
|
||||||
// Diff returns the difference between two sets.
|
// Diff returns the difference between two sets.
|
||||||
func (s Set[T]) Diff(other Set[T]) Set[T] {
|
func (s Set[T]) Diff(other Set[T]) Set[T] {
|
||||||
diff := make(Set[T])
|
diff := make(Set[T])
|
||||||
|
Reference in New Issue
Block a user