From f649df4c12b9baa017be55b17626ea48ebebf9fe Mon Sep 17 00:00:00 2001 From: BinacsLee Date: Fri, 15 Jul 2022 15:28:30 +0800 Subject: [PATCH] Re-Generate k8s.io/apimachinery/pkg/util/sets --- .../k8s.io/apimachinery/pkg/util/sets/byte.go | 16 +++++++++++----- .../src/k8s.io/apimachinery/pkg/util/sets/int.go | 16 +++++++++++----- .../k8s.io/apimachinery/pkg/util/sets/int32.go | 16 +++++++++++----- .../k8s.io/apimachinery/pkg/util/sets/int64.go | 16 +++++++++++----- .../k8s.io/apimachinery/pkg/util/sets/string.go | 16 +++++++++++----- 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/util/sets/byte.go b/staging/src/k8s.io/apimachinery/pkg/util/sets/byte.go index 9bfa85d43d4..5d280dd3734 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/sets/byte.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/sets/byte.go @@ -28,7 +28,7 @@ type Byte map[byte]Empty // NewByte creates a Byte from a list of values. func NewByte(items ...byte) Byte { - ss := Byte{} + ss := make(Byte, len(items)) ss.Insert(items...) return ss } @@ -87,6 +87,15 @@ func (s Byte) HasAny(items ...byte) bool { return false } +// Clone returns a new set which is a copy of the current set. +func (s Byte) Clone() Byte { + result := make(Byte, len(s)) + for key := range s { + result.Insert(key) + } + return result +} + // Difference returns a set of objects that are not in s2 // For example: // s1 = {a1, a2, a3} @@ -110,10 +119,7 @@ func (s Byte) Difference(s2 Byte) Byte { // s1.Union(s2) = {a1, a2, a3, a4} // s2.Union(s1) = {a1, a2, a3, a4} func (s1 Byte) Union(s2 Byte) Byte { - result := NewByte() - for key := range s1 { - result.Insert(key) - } + result := s1.Clone() for key := range s2 { result.Insert(key) } diff --git a/staging/src/k8s.io/apimachinery/pkg/util/sets/int.go b/staging/src/k8s.io/apimachinery/pkg/util/sets/int.go index 88bd7096791..f9a79d98164 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/sets/int.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/sets/int.go @@ -28,7 +28,7 @@ type Int map[int]Empty // NewInt creates a Int from a list of values. func NewInt(items ...int) Int { - ss := Int{} + ss := make(Int, len(items)) ss.Insert(items...) return ss } @@ -87,6 +87,15 @@ func (s Int) HasAny(items ...int) bool { return false } +// Clone returns a new set which is a copy of the current set. +func (s Int) Clone() Int { + result := make(Int, len(s)) + for key := range s { + result.Insert(key) + } + return result +} + // Difference returns a set of objects that are not in s2 // For example: // s1 = {a1, a2, a3} @@ -110,10 +119,7 @@ func (s Int) Difference(s2 Int) Int { // s1.Union(s2) = {a1, a2, a3, a4} // s2.Union(s1) = {a1, a2, a3, a4} func (s1 Int) Union(s2 Int) Int { - result := NewInt() - for key := range s1 { - result.Insert(key) - } + result := s1.Clone() for key := range s2 { result.Insert(key) } diff --git a/staging/src/k8s.io/apimachinery/pkg/util/sets/int32.go b/staging/src/k8s.io/apimachinery/pkg/util/sets/int32.go index 96a48555426..fc416c55a34 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/sets/int32.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/sets/int32.go @@ -28,7 +28,7 @@ type Int32 map[int32]Empty // NewInt32 creates a Int32 from a list of values. func NewInt32(items ...int32) Int32 { - ss := Int32{} + ss := make(Int32, len(items)) ss.Insert(items...) return ss } @@ -87,6 +87,15 @@ func (s Int32) HasAny(items ...int32) bool { return false } +// Clone returns a new set which is a copy of the current set. +func (s Int32) Clone() Int32 { + result := make(Int32, len(s)) + for key := range s { + result.Insert(key) + } + return result +} + // Difference returns a set of objects that are not in s2 // For example: // s1 = {a1, a2, a3} @@ -110,10 +119,7 @@ func (s Int32) Difference(s2 Int32) Int32 { // s1.Union(s2) = {a1, a2, a3, a4} // s2.Union(s1) = {a1, a2, a3, a4} func (s1 Int32) Union(s2 Int32) Int32 { - result := NewInt32() - for key := range s1 { - result.Insert(key) - } + result := s1.Clone() for key := range s2 { result.Insert(key) } diff --git a/staging/src/k8s.io/apimachinery/pkg/util/sets/int64.go b/staging/src/k8s.io/apimachinery/pkg/util/sets/int64.go index b375a1b065c..03ecb5f1faf 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/sets/int64.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/sets/int64.go @@ -28,7 +28,7 @@ type Int64 map[int64]Empty // NewInt64 creates a Int64 from a list of values. func NewInt64(items ...int64) Int64 { - ss := Int64{} + ss := make(Int64, len(items)) ss.Insert(items...) return ss } @@ -87,6 +87,15 @@ func (s Int64) HasAny(items ...int64) bool { return false } +// Clone returns a new set which is a copy of the current set. +func (s Int64) Clone() Int64 { + result := make(Int64, len(s)) + for key := range s { + result.Insert(key) + } + return result +} + // Difference returns a set of objects that are not in s2 // For example: // s1 = {a1, a2, a3} @@ -110,10 +119,7 @@ func (s Int64) Difference(s2 Int64) Int64 { // s1.Union(s2) = {a1, a2, a3, a4} // s2.Union(s1) = {a1, a2, a3, a4} func (s1 Int64) Union(s2 Int64) Int64 { - result := NewInt64() - for key := range s1 { - result.Insert(key) - } + result := s1.Clone() for key := range s2 { result.Insert(key) } diff --git a/staging/src/k8s.io/apimachinery/pkg/util/sets/string.go b/staging/src/k8s.io/apimachinery/pkg/util/sets/string.go index e6f37db8874..99b4cab3257 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/sets/string.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/sets/string.go @@ -28,7 +28,7 @@ type String map[string]Empty // NewString creates a String from a list of values. func NewString(items ...string) String { - ss := String{} + ss := make(String, len(items)) ss.Insert(items...) return ss } @@ -87,6 +87,15 @@ func (s String) HasAny(items ...string) bool { return false } +// Clone returns a new set which is a copy of the current set. +func (s String) Clone() String { + result := make(String, len(s)) + for key := range s { + result.Insert(key) + } + return result +} + // Difference returns a set of objects that are not in s2 // For example: // s1 = {a1, a2, a3} @@ -110,10 +119,7 @@ func (s String) Difference(s2 String) String { // s1.Union(s2) = {a1, a2, a3, a4} // s2.Union(s1) = {a1, a2, a3, a4} func (s1 String) Union(s2 String) String { - result := NewString() - for key := range s1 { - result.Insert(key) - } + result := s1.Clone() for key := range s2 { result.Insert(key) }