this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

set: introduce set union

Signed-off-by: oppiliappan <me@oppi.li>

authored by

oppiliappan and committed by
Tangled
b1b9ce16 71c625e2

+12
+12
set.go
··· 1 1 package hashset 2 2 3 + import ( 4 + "maps" 5 + ) 6 + 3 7 type Set[T comparable] map[T]struct{} 4 8 5 9 // New creates and returns a new empty Set. ··· 21 25 func (s Set[T]) Size() int { 22 26 return len(s) 23 27 } 28 + 29 + // Union returns a new set containing all elements from s and other. 30 + func (s Set[T]) Union(other Set[T]) Set[T] { 31 + result := make(Set[T], len(s)+len(other)) 32 + maps.Copy(result, s) 33 + maps.Copy(result, other) 34 + return result 35 + }