Skip to content

Commit 10cedcc

Browse files
author
Han Kang
committed
address tim's comments
1 parent c3703b2 commit 10cedcc

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

set/ordered.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ limitations under the License.
1616

1717
package set
1818

19-
// Ordered is a constraint that permits any ordered type: any type
19+
// ordered is a constraint that permits any ordered type: any type
2020
// that supports the operators < <= >= >.
2121
// If future releases of Go add new ordered types,
2222
// this constraint will be modified to include them.
23-
type Ordered interface {
23+
type ordered interface {
2424
integer | float | ~string
2525
}
2626

set/set.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ import (
2424
// string arrays and internal sets, and conversion logic requires public types today.
2525
type Empty struct{}
2626

27-
// Set is a set of the same type elements, implemented via map[comparable]struct{} for minimal memory consumption.
28-
type Set[E Ordered] map[E]Empty
27+
// Set is a set of the same type elements, implemented via map[ordered]struct{} for minimal memory consumption.
28+
type Set[E ordered] map[E]Empty
2929

3030
// New creates a new set.
31-
func New[E Ordered](items ...E) Set[E] {
31+
func New[E ordered](items ...E) Set[E] {
3232
ss := Set[E]{}
3333
ss.Insert(items...)
3434
return ss
3535
}
3636

3737
// KeySet creates a Set[E] from a keys of a map[E](? extends interface{}).
38-
func KeySet[E Ordered, A any](theMap map[E]A) Set[E] {
38+
func KeySet[E ordered, A any](theMap map[E]A) Set[E] {
3939
ret := Set[E]{}
4040
for key := range theMap {
4141
ret.Insert(key)
@@ -98,7 +98,7 @@ func (s Set[E]) Union(s2 Set[E]) Set[E] {
9898
return result
9999
}
100100

101-
// Len returns the size of the set.
101+
// Len returns the number of elements in the set.
102102
func (s Set[E]) Len() int {
103103
return len(s)
104104
}
@@ -158,7 +158,7 @@ func (s Set[E]) Equal(s2 Set[E]) bool {
158158
return s.Len() == s.Len() && s.IsSuperset(s2)
159159
}
160160

161-
type sortableSlice[E Ordered] []E
161+
type sortableSlice[E ordered] []E
162162

163163
func (s sortableSlice[E]) Len() int {
164164
return len(s)

set/set_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func TestStringIntersection(t *testing.T) {
283283
}
284284
}
285285

286-
func TestNewSetFromMapKeys(t *testing.T) {
286+
func TestKeySet(t *testing.T) {
287287
m := map[string]string{
288288
"hallo": "world",
289289
"goodbye": "and goodnight",
@@ -359,7 +359,7 @@ func TestSetClearInSeparateFunction(t *testing.T) {
359359
}
360360
}
361361

362-
func clearSetAndAdd[T Ordered](s Set[T], a T) {
362+
func clearSetAndAdd[T ordered](s Set[T], a T) {
363363
s.Clear()
364364
s.Insert(a)
365365
}

0 commit comments

Comments
 (0)