1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-10 07:42:27 +08:00

refactor: change variable name to

This commit is contained in:
dudaodong
2022-07-18 15:52:51 +08:00
parent 1782b11ec4
commit 44370aef5e
13 changed files with 191 additions and 194 deletions

View File

@@ -222,24 +222,24 @@ func (l *List[T]) Unique() {
// Union creates a new list contain all element in list l and other, remove duplicate element.
func (l *List[T]) Union(other *List[T]) *List[T] {
res := NewList([]T{})
result := NewList([]T{})
res.data = append(res.data, l.data...)
res.data = append(res.data, other.data...)
res.Unique()
result.data = append(result.data, l.data...)
result.data = append(result.data, other.data...)
result.Unique()
return res
return result
}
// Intersection creates a new list whose element both be contained in list l and other
func (l *List[T]) Intersection(other *List[T]) *List[T] {
res := NewList(make([]T, 0, 0))
result := NewList(make([]T, 0, 0))
for _, v := range l.data {
if other.Contain(v) {
res.data = append(res.data, v)
result.data = append(result.data, v)
}
}
return res
return result
}