mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update github.com/hashicorp/hcl/v2 to v2.19.1
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
46
vendor/github.com/zclconf/go-cty/cty/set/ops.go
generated
vendored
46
vendor/github.com/zclconf/go-cty/cty/set/ops.go
generated
vendored
@ -7,10 +7,10 @@ import (
|
||||
// Add inserts the given value into the receiving Set.
|
||||
//
|
||||
// This mutates the set in-place. This operation is not thread-safe.
|
||||
func (s Set) Add(val interface{}) {
|
||||
func (s Set[T]) Add(val T) {
|
||||
hv := s.rules.Hash(val)
|
||||
if _, ok := s.vals[hv]; !ok {
|
||||
s.vals[hv] = make([]interface{}, 0, 1)
|
||||
s.vals[hv] = make([]T, 0, 1)
|
||||
}
|
||||
bucket := s.vals[hv]
|
||||
|
||||
@ -26,7 +26,7 @@ func (s Set) Add(val interface{}) {
|
||||
|
||||
// Remove deletes the given value from the receiving set, if indeed it was
|
||||
// there in the first place. If the value is not present, this is a no-op.
|
||||
func (s Set) Remove(val interface{}) {
|
||||
func (s Set[T]) Remove(val T) {
|
||||
hv := s.rules.Hash(val)
|
||||
bucket, ok := s.vals[hv]
|
||||
if !ok {
|
||||
@ -35,7 +35,7 @@ func (s Set) Remove(val interface{}) {
|
||||
|
||||
for i, ev := range bucket {
|
||||
if s.rules.Equivalent(val, ev) {
|
||||
newBucket := make([]interface{}, 0, len(bucket)-1)
|
||||
newBucket := make([]T, 0, len(bucket)-1)
|
||||
newBucket = append(newBucket, bucket[:i]...)
|
||||
newBucket = append(newBucket, bucket[i+1:]...)
|
||||
if len(newBucket) > 0 {
|
||||
@ -50,7 +50,7 @@ func (s Set) Remove(val interface{}) {
|
||||
|
||||
// Has returns true if the given value is in the receiving set, or false if
|
||||
// it is not.
|
||||
func (s Set) Has(val interface{}) bool {
|
||||
func (s Set[T]) Has(val T) bool {
|
||||
hv := s.rules.Hash(val)
|
||||
bucket, ok := s.vals[hv]
|
||||
if !ok {
|
||||
@ -67,7 +67,7 @@ func (s Set) Has(val interface{}) bool {
|
||||
|
||||
// Copy performs a shallow copy of the receiving set, returning a new set
|
||||
// with the same rules and elements.
|
||||
func (s Set) Copy() Set {
|
||||
func (s Set[T]) Copy() Set[T] {
|
||||
ret := NewSet(s.rules)
|
||||
for k, v := range s.vals {
|
||||
ret.vals[k] = v
|
||||
@ -92,10 +92,10 @@ func (s Set) Copy() Set {
|
||||
//
|
||||
// Once an iterator has been created for a set, the set *must not* be mutated
|
||||
// until the iterator is no longer in use.
|
||||
func (s Set) Iterator() *Iterator {
|
||||
func (s Set[T]) Iterator() *Iterator[T] {
|
||||
vals := s.Values()
|
||||
|
||||
return &Iterator{
|
||||
return &Iterator[T]{
|
||||
vals: vals,
|
||||
idx: -1,
|
||||
}
|
||||
@ -103,7 +103,7 @@ func (s Set) Iterator() *Iterator {
|
||||
|
||||
// EachValue calls the given callback once for each value in the set, in an
|
||||
// undefined order that callers should not depend on.
|
||||
func (s Set) EachValue(cb func(interface{})) {
|
||||
func (s Set[T]) EachValue(cb func(T)) {
|
||||
it := s.Iterator()
|
||||
for it.Next() {
|
||||
cb(it.Value())
|
||||
@ -114,8 +114,8 @@ func (s Set) EachValue(cb func(interface{})) {
|
||||
// an order then the result is in that order. If no order is provided or if
|
||||
// it is not a total order then the result order is undefined, but consistent
|
||||
// for a particular set value within a specific release of cty.
|
||||
func (s Set) Values() []interface{} {
|
||||
var ret []interface{}
|
||||
func (s Set[T]) Values() []T {
|
||||
var ret []T
|
||||
// Sort the bucketIds to ensure that we always traverse in a
|
||||
// consistent order.
|
||||
bucketIDs := make([]int, 0, len(s.vals))
|
||||
@ -128,7 +128,7 @@ func (s Set) Values() []interface{} {
|
||||
ret = append(ret, s.vals[bucketID]...)
|
||||
}
|
||||
|
||||
if orderRules, ok := s.rules.(OrderedRules); ok {
|
||||
if orderRules, ok := s.rules.(OrderedRules[T]); ok {
|
||||
sort.SliceStable(ret, func(i, j int) bool {
|
||||
return orderRules.Less(ret[i], ret[j])
|
||||
})
|
||||
@ -138,7 +138,7 @@ func (s Set) Values() []interface{} {
|
||||
}
|
||||
|
||||
// Length returns the number of values in the set.
|
||||
func (s Set) Length() int {
|
||||
func (s Set[T]) Length() int {
|
||||
var count int
|
||||
for _, bucket := range s.vals {
|
||||
count = count + len(bucket)
|
||||
@ -149,13 +149,13 @@ func (s Set) Length() int {
|
||||
// Union returns a new set that contains all of the members of both the
|
||||
// receiving set and the given set. Both sets must have the same rules, or
|
||||
// else this function will panic.
|
||||
func (s1 Set) Union(s2 Set) Set {
|
||||
func (s1 Set[T]) Union(s2 Set[T]) Set[T] {
|
||||
mustHaveSameRules(s1, s2)
|
||||
rs := NewSet(s1.rules)
|
||||
s1.EachValue(func(v interface{}) {
|
||||
s1.EachValue(func(v T) {
|
||||
rs.Add(v)
|
||||
})
|
||||
s2.EachValue(func(v interface{}) {
|
||||
s2.EachValue(func(v T) {
|
||||
rs.Add(v)
|
||||
})
|
||||
return rs
|
||||
@ -164,10 +164,10 @@ func (s1 Set) Union(s2 Set) Set {
|
||||
// Intersection returns a new set that contains the values that both the
|
||||
// receiver and given sets have in common. Both sets must have the same rules,
|
||||
// or else this function will panic.
|
||||
func (s1 Set) Intersection(s2 Set) Set {
|
||||
func (s1 Set[T]) Intersection(s2 Set[T]) Set[T] {
|
||||
mustHaveSameRules(s1, s2)
|
||||
rs := NewSet(s1.rules)
|
||||
s1.EachValue(func(v interface{}) {
|
||||
s1.EachValue(func(v T) {
|
||||
if s2.Has(v) {
|
||||
rs.Add(v)
|
||||
}
|
||||
@ -178,10 +178,10 @@ func (s1 Set) Intersection(s2 Set) Set {
|
||||
// Subtract returns a new set that contains all of the values from the receiver
|
||||
// that are not also in the given set. Both sets must have the same rules,
|
||||
// or else this function will panic.
|
||||
func (s1 Set) Subtract(s2 Set) Set {
|
||||
func (s1 Set[T]) Subtract(s2 Set[T]) Set[T] {
|
||||
mustHaveSameRules(s1, s2)
|
||||
rs := NewSet(s1.rules)
|
||||
s1.EachValue(func(v interface{}) {
|
||||
s1.EachValue(func(v T) {
|
||||
if !s2.Has(v) {
|
||||
rs.Add(v)
|
||||
}
|
||||
@ -193,15 +193,15 @@ func (s1 Set) Subtract(s2 Set) Set {
|
||||
// both the receiver and given sets, except those that both sets have in
|
||||
// common. Both sets must have the same rules, or else this function will
|
||||
// panic.
|
||||
func (s1 Set) SymmetricDifference(s2 Set) Set {
|
||||
func (s1 Set[T]) SymmetricDifference(s2 Set[T]) Set[T] {
|
||||
mustHaveSameRules(s1, s2)
|
||||
rs := NewSet(s1.rules)
|
||||
s1.EachValue(func(v interface{}) {
|
||||
s1.EachValue(func(v T) {
|
||||
if !s2.Has(v) {
|
||||
rs.Add(v)
|
||||
}
|
||||
})
|
||||
s2.EachValue(func(v interface{}) {
|
||||
s2.EachValue(func(v T) {
|
||||
if !s1.Has(v) {
|
||||
rs.Add(v)
|
||||
}
|
||||
|
Reference in New Issue
Block a user