//go:build !no_gotd_slices // +build !no_gotd_slices // Code generated by gotdgen, DO NOT EDIT. package tg import ( "context" "errors" "fmt" "sort" "strings" "go.uber.org/multierr" "go.mau.fi/mautrix-telegram/pkg/gotd/bin" "go.mau.fi/mautrix-telegram/pkg/gotd/tdjson" "go.mau.fi/mautrix-telegram/pkg/gotd/tdp" "go.mau.fi/mautrix-telegram/pkg/gotd/tgerr" ) // No-op definition for keeping imports. var ( _ = bin.Buffer{} _ = context.Background() _ = fmt.Stringer(nil) _ = strings.Builder{} _ = errors.Is _ = multierr.AppendInto _ = sort.Ints _ = tdp.Format _ = tgerr.Error{} _ = tdjson.Encoder{} ) // ChatReactionsClassArray is adapter for slice of ChatReactionsClass. type ChatReactionsClassArray []ChatReactionsClass // Sort sorts slice of ChatReactionsClass. func (s ChatReactionsClassArray) Sort(less func(a, b ChatReactionsClass) bool) ChatReactionsClassArray { sort.Slice(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } // SortStable sorts slice of ChatReactionsClass. func (s ChatReactionsClassArray) SortStable(less func(a, b ChatReactionsClass) bool) ChatReactionsClassArray { sort.SliceStable(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } // Retain filters in-place slice of ChatReactionsClass. func (s ChatReactionsClassArray) Retain(keep func(x ChatReactionsClass) bool) ChatReactionsClassArray { n := 0 for _, x := range s { if keep(x) { s[n] = x n++ } } s = s[:n] return s } // First returns first element of slice (if exists). func (s ChatReactionsClassArray) First() (v ChatReactionsClass, ok bool) { if len(s) < 1 { return } return s[0], true } // Last returns last element of slice (if exists). func (s ChatReactionsClassArray) Last() (v ChatReactionsClass, ok bool) { if len(s) < 1 { return } return s[len(s)-1], true } // PopFirst returns first element of slice (if exists) and deletes it. func (s *ChatReactionsClassArray) PopFirst() (v ChatReactionsClass, ok bool) { if s == nil || len(*s) < 1 { return } a := *s v = a[0] // Delete by index from SliceTricks. copy(a[0:], a[1:]) var zero ChatReactionsClass a[len(a)-1] = zero a = a[:len(a)-1] *s = a return v, true } // Pop returns last element of slice (if exists) and deletes it. func (s *ChatReactionsClassArray) Pop() (v ChatReactionsClass, ok bool) { if s == nil || len(*s) < 1 { return } a := *s v = a[len(a)-1] a = a[:len(a)-1] *s = a return v, true } // AsChatReactionsAll returns copy with only ChatReactionsAll constructors. func (s ChatReactionsClassArray) AsChatReactionsAll() (to ChatReactionsAllArray) { for _, elem := range s { value, ok := elem.(*ChatReactionsAll) if !ok { continue } to = append(to, *value) } return to } // AsChatReactionsSome returns copy with only ChatReactionsSome constructors. func (s ChatReactionsClassArray) AsChatReactionsSome() (to ChatReactionsSomeArray) { for _, elem := range s { value, ok := elem.(*ChatReactionsSome) if !ok { continue } to = append(to, *value) } return to } // ChatReactionsAllArray is adapter for slice of ChatReactionsAll. type ChatReactionsAllArray []ChatReactionsAll // Sort sorts slice of ChatReactionsAll. func (s ChatReactionsAllArray) Sort(less func(a, b ChatReactionsAll) bool) ChatReactionsAllArray { sort.Slice(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } // SortStable sorts slice of ChatReactionsAll. func (s ChatReactionsAllArray) SortStable(less func(a, b ChatReactionsAll) bool) ChatReactionsAllArray { sort.SliceStable(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } // Retain filters in-place slice of ChatReactionsAll. func (s ChatReactionsAllArray) Retain(keep func(x ChatReactionsAll) bool) ChatReactionsAllArray { n := 0 for _, x := range s { if keep(x) { s[n] = x n++ } } s = s[:n] return s } // First returns first element of slice (if exists). func (s ChatReactionsAllArray) First() (v ChatReactionsAll, ok bool) { if len(s) < 1 { return } return s[0], true } // Last returns last element of slice (if exists). func (s ChatReactionsAllArray) Last() (v ChatReactionsAll, ok bool) { if len(s) < 1 { return } return s[len(s)-1], true } // PopFirst returns first element of slice (if exists) and deletes it. func (s *ChatReactionsAllArray) PopFirst() (v ChatReactionsAll, ok bool) { if s == nil || len(*s) < 1 { return } a := *s v = a[0] // Delete by index from SliceTricks. copy(a[0:], a[1:]) var zero ChatReactionsAll a[len(a)-1] = zero a = a[:len(a)-1] *s = a return v, true } // Pop returns last element of slice (if exists) and deletes it. func (s *ChatReactionsAllArray) Pop() (v ChatReactionsAll, ok bool) { if s == nil || len(*s) < 1 { return } a := *s v = a[len(a)-1] a = a[:len(a)-1] *s = a return v, true } // ChatReactionsSomeArray is adapter for slice of ChatReactionsSome. type ChatReactionsSomeArray []ChatReactionsSome // Sort sorts slice of ChatReactionsSome. func (s ChatReactionsSomeArray) Sort(less func(a, b ChatReactionsSome) bool) ChatReactionsSomeArray { sort.Slice(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } // SortStable sorts slice of ChatReactionsSome. func (s ChatReactionsSomeArray) SortStable(less func(a, b ChatReactionsSome) bool) ChatReactionsSomeArray { sort.SliceStable(s, func(i, j int) bool { return less(s[i], s[j]) }) return s } // Retain filters in-place slice of ChatReactionsSome. func (s ChatReactionsSomeArray) Retain(keep func(x ChatReactionsSome) bool) ChatReactionsSomeArray { n := 0 for _, x := range s { if keep(x) { s[n] = x n++ } } s = s[:n] return s } // First returns first element of slice (if exists). func (s ChatReactionsSomeArray) First() (v ChatReactionsSome, ok bool) { if len(s) < 1 { return } return s[0], true } // Last returns last element of slice (if exists). func (s ChatReactionsSomeArray) Last() (v ChatReactionsSome, ok bool) { if len(s) < 1 { return } return s[len(s)-1], true } // PopFirst returns first element of slice (if exists) and deletes it. func (s *ChatReactionsSomeArray) PopFirst() (v ChatReactionsSome, ok bool) { if s == nil || len(*s) < 1 { return } a := *s v = a[0] // Delete by index from SliceTricks. copy(a[0:], a[1:]) var zero ChatReactionsSome a[len(a)-1] = zero a = a[:len(a)-1] *s = a return v, true } // Pop returns last element of slice (if exists) and deletes it. func (s *ChatReactionsSomeArray) Pop() (v ChatReactionsSome, ok bool) { if s == nil || len(*s) < 1 { return } a := *s v = a[len(a)-1] a = a[:len(a)-1] *s = a return v, true }