Skip to content

Commit

Permalink
Use new compare functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ancientlore committed Aug 17, 2023
1 parent 2139952 commit 3bd4959
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
9 changes: 1 addition & 8 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ func NewMapOrdered[K cmp.Ordered, V any]() *Map[K, V] {
return &Map[K, V]{
t: Tree[Pair[K, V]]{
compare: func(v1, v2 Pair[K, V]) int {
switch {
case v1.Key < v2.Key:
return -1
case v1.Key == v2.Key:
return 0
default:
return 1
}
return cmp.Compare(v1.Key, v2.Key)
},
},
}
Expand Down
11 changes: 1 addition & 10 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,7 @@ func New[T any](c func(T, T) int, flags byte) *Tree[T] {
// NewOrdered returns an initialized tree using ordered types.
func NewOrdered[T cmp.Ordered](flags byte) *Tree[T] {
return &Tree[T]{
compare: func(v1, v2 T) int {
switch {
case v1 < v2:
return -1
case v1 == v2:
return 0
default:
return 1
}
},
compare: cmp.Compare[T],
treeFlags: flags,
}
}
Expand Down

0 comments on commit 3bd4959

Please sign in to comment.