summaryrefslogtreecommitdiff
path: root/vendor/github.com/minio/minio-go/v7/pkg/set
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2025-03-09 17:47:56 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2025-12-01 22:08:04 +0100
commitb1af8fd87760b34e3ff2fd3bda38f211815a0473 (patch)
tree9317fad1a7ec298d7a8d2678e4e422953bbc6f33 /vendor/github.com/minio/minio-go/v7/pkg/set
parent[chore] update URLs to forked source (diff)
downloadgotosocial-b1af8fd87760b34e3ff2fd3bda38f211815a0473.tar.xz
[chore] remove vendor
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/pkg/set')
-rw-r--r--vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go149
-rw-r--r--vendor/github.com/minio/minio-go/v7/pkg/set/stringset.go218
2 files changed, 0 insertions, 367 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go b/vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go
deleted file mode 100644
index 7d3c3620b..000000000
--- a/vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * MinIO Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2025 MinIO, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package set
-
-import "github.com/tinylib/msgp/msgp"
-
-// EncodeMsg encodes the message to the writer.
-// Values are stored as a slice of strings or nil.
-func (s StringSet) EncodeMsg(writer *msgp.Writer) error {
- if s == nil {
- return writer.WriteNil()
- }
- err := writer.WriteArrayHeader(uint32(len(s)))
- if err != nil {
- return err
- }
- sorted := s.ToByteSlices()
- for _, k := range sorted {
- err = writer.WriteStringFromBytes(k)
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-// MarshalMsg encodes the message to the bytes.
-// Values are stored as a slice of strings or nil.
-func (s StringSet) MarshalMsg(bytes []byte) ([]byte, error) {
- if s == nil {
- return msgp.AppendNil(bytes), nil
- }
- if len(s) == 0 {
- return msgp.AppendArrayHeader(bytes, 0), nil
- }
- bytes = msgp.AppendArrayHeader(bytes, uint32(len(s)))
- sorted := s.ToByteSlices()
- for _, k := range sorted {
- bytes = msgp.AppendStringFromBytes(bytes, k)
- }
- return bytes, nil
-}
-
-// DecodeMsg decodes the message from the reader.
-func (s *StringSet) DecodeMsg(reader *msgp.Reader) error {
- if reader.IsNil() {
- *s = nil
- return reader.Skip()
- }
- sz, err := reader.ReadArrayHeader()
- if err != nil {
- return err
- }
- dst := *s
- if dst == nil {
- dst = make(StringSet, sz)
- } else {
- for k := range dst {
- delete(dst, k)
- }
- }
- for i := uint32(0); i < sz; i++ {
- var k string
- k, err = reader.ReadString()
- if err != nil {
- return err
- }
- dst[k] = struct{}{}
- }
- *s = dst
- return nil
-}
-
-// UnmarshalMsg decodes the message from the bytes.
-func (s *StringSet) UnmarshalMsg(bytes []byte) ([]byte, error) {
- if msgp.IsNil(bytes) {
- *s = nil
- return bytes[msgp.NilSize:], nil
- }
- // Read the array header
- sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes)
- if err != nil {
- return nil, err
- }
- dst := *s
- if dst == nil {
- dst = make(StringSet, sz)
- } else {
- for k := range dst {
- delete(dst, k)
- }
- }
- for i := uint32(0); i < sz; i++ {
- var k string
- k, bytes, err = msgp.ReadStringBytes(bytes)
- if err != nil {
- return nil, err
- }
- dst[k] = struct{}{}
- }
- *s = dst
- return bytes, nil
-}
-
-// Msgsize returns the maximum size of the message.
-func (s StringSet) Msgsize() int {
- if s == nil {
- return msgp.NilSize
- }
- if len(s) == 0 {
- return msgp.ArrayHeaderSize
- }
- size := msgp.ArrayHeaderSize
- for key := range s {
- size += msgp.StringPrefixSize + len(key)
- }
- return size
-}
-
-// MarshalBinary encodes the receiver into a binary form and returns the result.
-func (s StringSet) MarshalBinary() ([]byte, error) {
- return s.MarshalMsg(nil)
-}
-
-// AppendBinary appends the binary representation of itself to the end of b
-func (s StringSet) AppendBinary(b []byte) ([]byte, error) {
- return s.MarshalMsg(b)
-}
-
-// UnmarshalBinary decodes the binary representation of itself from b
-func (s *StringSet) UnmarshalBinary(b []byte) error {
- _, err := s.UnmarshalMsg(b)
- return err
-}
diff --git a/vendor/github.com/minio/minio-go/v7/pkg/set/stringset.go b/vendor/github.com/minio/minio-go/v7/pkg/set/stringset.go
deleted file mode 100644
index c12651b54..000000000
--- a/vendor/github.com/minio/minio-go/v7/pkg/set/stringset.go
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * MinIO Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 MinIO, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package set
-
-import (
- "encoding/json"
- "fmt"
- "sort"
-)
-
-// StringSet - uses map as set of strings.
-type StringSet map[string]struct{}
-
-// ToSlice - returns StringSet as string slice.
-func (set StringSet) ToSlice() []string {
- keys := make([]string, 0, len(set))
- for k := range set {
- keys = append(keys, k)
- }
- sort.Strings(keys)
- return keys
-}
-
-// ToByteSlices - returns StringSet as a sorted
-// slice of byte slices, using only one allocation.
-func (set StringSet) ToByteSlices() [][]byte {
- length := 0
- for k := range set {
- length += len(k)
- }
- // Preallocate the slice with the total length of all strings
- // to avoid multiple allocations.
- dst := make([]byte, length)
-
- // Add keys to this...
- keys := make([][]byte, 0, len(set))
- for k := range set {
- n := copy(dst, k)
- keys = append(keys, dst[:n])
- dst = dst[n:]
- }
- sort.Slice(keys, func(i, j int) bool {
- return string(keys[i]) < string(keys[j])
- })
- return keys
-}
-
-// IsEmpty - returns whether the set is empty or not.
-func (set StringSet) IsEmpty() bool {
- return len(set) == 0
-}
-
-// Add - adds string to the set.
-func (set StringSet) Add(s string) {
- set[s] = struct{}{}
-}
-
-// Remove - removes string in the set. It does nothing if string does not exist in the set.
-func (set StringSet) Remove(s string) {
- delete(set, s)
-}
-
-// Contains - checks if string is in the set.
-func (set StringSet) Contains(s string) bool {
- _, ok := set[s]
- return ok
-}
-
-// FuncMatch - returns new set containing each value who passes match function.
-// A 'matchFn' should accept element in a set as first argument and
-// 'matchString' as second argument. The function can do any logic to
-// compare both the arguments and should return true to accept element in
-// a set to include in output set else the element is ignored.
-func (set StringSet) FuncMatch(matchFn func(string, string) bool, matchString string) StringSet {
- nset := NewStringSet()
- for k := range set {
- if matchFn(k, matchString) {
- nset.Add(k)
- }
- }
- return nset
-}
-
-// ApplyFunc - returns new set containing each value processed by 'applyFn'.
-// A 'applyFn' should accept element in a set as a argument and return
-// a processed string. The function can do any logic to return a processed
-// string.
-func (set StringSet) ApplyFunc(applyFn func(string) string) StringSet {
- nset := NewStringSet()
- for k := range set {
- nset.Add(applyFn(k))
- }
- return nset
-}
-
-// Equals - checks whether given set is equal to current set or not.
-func (set StringSet) Equals(sset StringSet) bool {
- // If length of set is not equal to length of given set, the
- // set is not equal to given set.
- if len(set) != len(sset) {
- return false
- }
-
- // As both sets are equal in length, check each elements are equal.
- for k := range set {
- if _, ok := sset[k]; !ok {
- return false
- }
- }
-
- return true
-}
-
-// Intersection - returns the intersection with given set as new set.
-func (set StringSet) Intersection(sset StringSet) StringSet {
- nset := NewStringSet()
- for k := range set {
- if _, ok := sset[k]; ok {
- nset.Add(k)
- }
- }
-
- return nset
-}
-
-// Difference - returns the difference with given set as new set.
-func (set StringSet) Difference(sset StringSet) StringSet {
- nset := NewStringSet()
- for k := range set {
- if _, ok := sset[k]; !ok {
- nset.Add(k)
- }
- }
-
- return nset
-}
-
-// Union - returns the union with given set as new set.
-func (set StringSet) Union(sset StringSet) StringSet {
- nset := NewStringSet()
- for k := range set {
- nset.Add(k)
- }
-
- for k := range sset {
- nset.Add(k)
- }
-
- return nset
-}
-
-// MarshalJSON - converts to JSON data.
-func (set StringSet) MarshalJSON() ([]byte, error) {
- return json.Marshal(set.ToSlice())
-}
-
-// UnmarshalJSON - parses JSON data and creates new set with it.
-func (set *StringSet) UnmarshalJSON(data []byte) error {
- sl := []interface{}{}
- var err error
- if err = json.Unmarshal(data, &sl); err == nil {
- *set = make(StringSet)
- for _, s := range sl {
- set.Add(fmt.Sprintf("%v", s))
- }
- } else {
- var s interface{}
- if err = json.Unmarshal(data, &s); err == nil {
- *set = make(StringSet)
- set.Add(fmt.Sprintf("%v", s))
- }
- }
-
- return err
-}
-
-// String - returns printable string of the set.
-func (set StringSet) String() string {
- return fmt.Sprintf("%s", set.ToSlice())
-}
-
-// NewStringSet - creates new string set.
-func NewStringSet() StringSet {
- return make(StringSet)
-}
-
-// CreateStringSet - creates new string set with given string values.
-func CreateStringSet(sl ...string) StringSet {
- set := make(StringSet, len(sl))
- for _, k := range sl {
- set.Add(k)
- }
- return set
-}
-
-// CopyStringSet - returns copy of given set.
-func CopyStringSet(set StringSet) StringSet {
- nset := make(StringSet, len(set))
- for k, v := range set {
- nset[k] = v
- }
- return nset
-}