Liu Song’s Projects


~/Projects/sing

git clone https://code.lsong.org/sing

Commit

Commit
096223b346f3196691ad421fd1a308f606ba524d
Author
世界 <[email protected]>
Date
2022-07-25 11:16:20 +0800 +0800
Diffstat
 common/comparable.go | 40 ----------------------------------------

Remove comparable interface


diff --git a/common/comparable.go b/common/comparable.go
deleted file mode 100644
index 0191b2b4cfb5d153eebb02bf53572a7c5626e860..0000000000000000000000000000000000000000
--- a/common/comparable.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package common
-
-type Comparable[T any] interface {
-	Equals(other T) bool
-}
-
-func Equals[T Comparable[T]](obj T, other T) bool {
-	var anyObj any = obj
-	var anyOther any = other
-	if anyObj == nil && anyOther == nil {
-		return true
-	} else if anyObj == nil || anyOther == nil {
-		return false
-	}
-	return obj.Equals(other)
-}
-
-func IsEmptyByEquals[T Comparable[T]](obj T) bool {
-	return obj.Equals(DefaultValue[T]())
-}
-
-func ComparablePtrEquals[T comparable](obj *T, other *T) bool {
-	return *obj == *other
-}
-
-func PtrEquals[T Comparable[T]](obj *T, other *T) bool {
-	return Equals(*obj, *other)
-}
-
-func ComparableSliceEquals[T comparable](arr []T, otherArr []T) bool {
-	return len(arr) == len(otherArr) && AllIndexed(arr, func(index int, it T) bool {
-		return it == otherArr[index]
-	})
-}
-
-func SliceEquals[T Comparable[T]](arr []T, otherArr []T) bool {
-	return len(arr) == len(otherArr) && AllIndexed(arr, func(index int, it T) bool {
-		return Equals(it, otherArr[index])
-	})
-}