Files
mautrix-telegram/pkg/gotd/tg/tl_story_item_slices_gen.go
T
2025-06-27 20:03:37 -07:00

583 lines
13 KiB
Go

//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{}
)
// StoryItemClassArray is adapter for slice of StoryItemClass.
type StoryItemClassArray []StoryItemClass
// Sort sorts slice of StoryItemClass.
func (s StoryItemClassArray) Sort(less func(a, b StoryItemClass) bool) StoryItemClassArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of StoryItemClass.
func (s StoryItemClassArray) SortStable(less func(a, b StoryItemClass) bool) StoryItemClassArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of StoryItemClass.
func (s StoryItemClassArray) Retain(keep func(x StoryItemClass) bool) StoryItemClassArray {
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 StoryItemClassArray) First() (v StoryItemClass, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s StoryItemClassArray) Last() (v StoryItemClass, 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 *StoryItemClassArray) PopFirst() (v StoryItemClass, 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 StoryItemClass
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 *StoryItemClassArray) Pop() (v StoryItemClass, 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
}
// SortByID sorts slice of StoryItemClass by ID.
func (s StoryItemClassArray) SortByID() StoryItemClassArray {
return s.Sort(func(a, b StoryItemClass) bool {
return a.GetID() < b.GetID()
})
}
// SortStableByID sorts slice of StoryItemClass by ID.
func (s StoryItemClassArray) SortStableByID() StoryItemClassArray {
return s.SortStable(func(a, b StoryItemClass) bool {
return a.GetID() < b.GetID()
})
}
// FillStoryItemDeletedMap fills only StoryItemDeleted constructors to given map.
func (s StoryItemClassArray) FillStoryItemDeletedMap(to map[int]*StoryItemDeleted) {
for _, elem := range s {
value, ok := elem.(*StoryItemDeleted)
if !ok {
continue
}
to[value.GetID()] = value
}
}
// StoryItemDeletedToMap collects only StoryItemDeleted constructors to map.
func (s StoryItemClassArray) StoryItemDeletedToMap() map[int]*StoryItemDeleted {
r := make(map[int]*StoryItemDeleted, len(s))
s.FillStoryItemDeletedMap(r)
return r
}
// AsStoryItemDeleted returns copy with only StoryItemDeleted constructors.
func (s StoryItemClassArray) AsStoryItemDeleted() (to StoryItemDeletedArray) {
for _, elem := range s {
value, ok := elem.(*StoryItemDeleted)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// FillStoryItemSkippedMap fills only StoryItemSkipped constructors to given map.
func (s StoryItemClassArray) FillStoryItemSkippedMap(to map[int]*StoryItemSkipped) {
for _, elem := range s {
value, ok := elem.(*StoryItemSkipped)
if !ok {
continue
}
to[value.GetID()] = value
}
}
// StoryItemSkippedToMap collects only StoryItemSkipped constructors to map.
func (s StoryItemClassArray) StoryItemSkippedToMap() map[int]*StoryItemSkipped {
r := make(map[int]*StoryItemSkipped, len(s))
s.FillStoryItemSkippedMap(r)
return r
}
// AsStoryItemSkipped returns copy with only StoryItemSkipped constructors.
func (s StoryItemClassArray) AsStoryItemSkipped() (to StoryItemSkippedArray) {
for _, elem := range s {
value, ok := elem.(*StoryItemSkipped)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// FillStoryItemMap fills only StoryItem constructors to given map.
func (s StoryItemClassArray) FillStoryItemMap(to map[int]*StoryItem) {
for _, elem := range s {
value, ok := elem.(*StoryItem)
if !ok {
continue
}
to[value.GetID()] = value
}
}
// StoryItemToMap collects only StoryItem constructors to map.
func (s StoryItemClassArray) StoryItemToMap() map[int]*StoryItem {
r := make(map[int]*StoryItem, len(s))
s.FillStoryItemMap(r)
return r
}
// AsStoryItem returns copy with only StoryItem constructors.
func (s StoryItemClassArray) AsStoryItem() (to StoryItemArray) {
for _, elem := range s {
value, ok := elem.(*StoryItem)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// StoryItemDeletedArray is adapter for slice of StoryItemDeleted.
type StoryItemDeletedArray []StoryItemDeleted
// Sort sorts slice of StoryItemDeleted.
func (s StoryItemDeletedArray) Sort(less func(a, b StoryItemDeleted) bool) StoryItemDeletedArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of StoryItemDeleted.
func (s StoryItemDeletedArray) SortStable(less func(a, b StoryItemDeleted) bool) StoryItemDeletedArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of StoryItemDeleted.
func (s StoryItemDeletedArray) Retain(keep func(x StoryItemDeleted) bool) StoryItemDeletedArray {
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 StoryItemDeletedArray) First() (v StoryItemDeleted, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s StoryItemDeletedArray) Last() (v StoryItemDeleted, 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 *StoryItemDeletedArray) PopFirst() (v StoryItemDeleted, 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 StoryItemDeleted
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 *StoryItemDeletedArray) Pop() (v StoryItemDeleted, 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
}
// SortByID sorts slice of StoryItemDeleted by ID.
func (s StoryItemDeletedArray) SortByID() StoryItemDeletedArray {
return s.Sort(func(a, b StoryItemDeleted) bool {
return a.GetID() < b.GetID()
})
}
// SortStableByID sorts slice of StoryItemDeleted by ID.
func (s StoryItemDeletedArray) SortStableByID() StoryItemDeletedArray {
return s.SortStable(func(a, b StoryItemDeleted) bool {
return a.GetID() < b.GetID()
})
}
// FillMap fills constructors to given map.
func (s StoryItemDeletedArray) FillMap(to map[int]StoryItemDeleted) {
for _, value := range s {
to[value.GetID()] = value
}
}
// ToMap collects constructors to map.
func (s StoryItemDeletedArray) ToMap() map[int]StoryItemDeleted {
r := make(map[int]StoryItemDeleted, len(s))
s.FillMap(r)
return r
}
// StoryItemSkippedArray is adapter for slice of StoryItemSkipped.
type StoryItemSkippedArray []StoryItemSkipped
// Sort sorts slice of StoryItemSkipped.
func (s StoryItemSkippedArray) Sort(less func(a, b StoryItemSkipped) bool) StoryItemSkippedArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of StoryItemSkipped.
func (s StoryItemSkippedArray) SortStable(less func(a, b StoryItemSkipped) bool) StoryItemSkippedArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of StoryItemSkipped.
func (s StoryItemSkippedArray) Retain(keep func(x StoryItemSkipped) bool) StoryItemSkippedArray {
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 StoryItemSkippedArray) First() (v StoryItemSkipped, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s StoryItemSkippedArray) Last() (v StoryItemSkipped, 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 *StoryItemSkippedArray) PopFirst() (v StoryItemSkipped, 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 StoryItemSkipped
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 *StoryItemSkippedArray) Pop() (v StoryItemSkipped, 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
}
// SortByID sorts slice of StoryItemSkipped by ID.
func (s StoryItemSkippedArray) SortByID() StoryItemSkippedArray {
return s.Sort(func(a, b StoryItemSkipped) bool {
return a.GetID() < b.GetID()
})
}
// SortStableByID sorts slice of StoryItemSkipped by ID.
func (s StoryItemSkippedArray) SortStableByID() StoryItemSkippedArray {
return s.SortStable(func(a, b StoryItemSkipped) bool {
return a.GetID() < b.GetID()
})
}
// SortByDate sorts slice of StoryItemSkipped by Date.
func (s StoryItemSkippedArray) SortByDate() StoryItemSkippedArray {
return s.Sort(func(a, b StoryItemSkipped) bool {
return a.GetDate() < b.GetDate()
})
}
// SortStableByDate sorts slice of StoryItemSkipped by Date.
func (s StoryItemSkippedArray) SortStableByDate() StoryItemSkippedArray {
return s.SortStable(func(a, b StoryItemSkipped) bool {
return a.GetDate() < b.GetDate()
})
}
// FillMap fills constructors to given map.
func (s StoryItemSkippedArray) FillMap(to map[int]StoryItemSkipped) {
for _, value := range s {
to[value.GetID()] = value
}
}
// ToMap collects constructors to map.
func (s StoryItemSkippedArray) ToMap() map[int]StoryItemSkipped {
r := make(map[int]StoryItemSkipped, len(s))
s.FillMap(r)
return r
}
// StoryItemArray is adapter for slice of StoryItem.
type StoryItemArray []StoryItem
// Sort sorts slice of StoryItem.
func (s StoryItemArray) Sort(less func(a, b StoryItem) bool) StoryItemArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of StoryItem.
func (s StoryItemArray) SortStable(less func(a, b StoryItem) bool) StoryItemArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of StoryItem.
func (s StoryItemArray) Retain(keep func(x StoryItem) bool) StoryItemArray {
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 StoryItemArray) First() (v StoryItem, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s StoryItemArray) Last() (v StoryItem, 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 *StoryItemArray) PopFirst() (v StoryItem, 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 StoryItem
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 *StoryItemArray) Pop() (v StoryItem, 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
}
// SortByID sorts slice of StoryItem by ID.
func (s StoryItemArray) SortByID() StoryItemArray {
return s.Sort(func(a, b StoryItem) bool {
return a.GetID() < b.GetID()
})
}
// SortStableByID sorts slice of StoryItem by ID.
func (s StoryItemArray) SortStableByID() StoryItemArray {
return s.SortStable(func(a, b StoryItem) bool {
return a.GetID() < b.GetID()
})
}
// SortByDate sorts slice of StoryItem by Date.
func (s StoryItemArray) SortByDate() StoryItemArray {
return s.Sort(func(a, b StoryItem) bool {
return a.GetDate() < b.GetDate()
})
}
// SortStableByDate sorts slice of StoryItem by Date.
func (s StoryItemArray) SortStableByDate() StoryItemArray {
return s.SortStable(func(a, b StoryItem) bool {
return a.GetDate() < b.GetDate()
})
}
// FillMap fills constructors to given map.
func (s StoryItemArray) FillMap(to map[int]StoryItem) {
for _, value := range s {
to[value.GetID()] = value
}
}
// ToMap collects constructors to map.
func (s StoryItemArray) ToMap() map[int]StoryItem {
r := make(map[int]StoryItem, len(s))
s.FillMap(r)
return r
}