package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type InputStickerSetClassArray []InputStickerSetClass
func (s InputStickerSetClassArray ) Sort (less func (a , b InputStickerSetClass ) bool ) InputStickerSetClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputStickerSetClassArray ) SortStable (less func (a , b InputStickerSetClass ) bool ) InputStickerSetClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputStickerSetClassArray ) Retain (keep func (x InputStickerSetClass ) bool ) InputStickerSetClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputStickerSetClassArray ) First () (v InputStickerSetClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputStickerSetClassArray ) Last () (v InputStickerSetClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputStickerSetClassArray ) PopFirst () (v InputStickerSetClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputStickerSetClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputStickerSetClassArray ) Pop () (v InputStickerSetClass , 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
}
func (s InputStickerSetClassArray ) AsInputStickerSetID () (to InputStickerSetIDArray ) {
for _ , elem := range s {
value , ok := elem .(*InputStickerSetID )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputStickerSetClassArray ) AsInputStickerSetShortName () (to InputStickerSetShortNameArray ) {
for _ , elem := range s {
value , ok := elem .(*InputStickerSetShortName )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputStickerSetClassArray ) AsInputStickerSetDice () (to InputStickerSetDiceArray ) {
for _ , elem := range s {
value , ok := elem .(*InputStickerSetDice )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type InputStickerSetIDArray []InputStickerSetID
func (s InputStickerSetIDArray ) Sort (less func (a , b InputStickerSetID ) bool ) InputStickerSetIDArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputStickerSetIDArray ) SortStable (less func (a , b InputStickerSetID ) bool ) InputStickerSetIDArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputStickerSetIDArray ) Retain (keep func (x InputStickerSetID ) bool ) InputStickerSetIDArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputStickerSetIDArray ) First () (v InputStickerSetID , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputStickerSetIDArray ) Last () (v InputStickerSetID , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputStickerSetIDArray ) PopFirst () (v InputStickerSetID , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputStickerSetID
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputStickerSetIDArray ) Pop () (v InputStickerSetID , 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
}
func (s InputStickerSetIDArray ) SortByID () InputStickerSetIDArray {
return s .Sort (func (a , b InputStickerSetID ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputStickerSetIDArray ) SortStableByID () InputStickerSetIDArray {
return s .SortStable (func (a , b InputStickerSetID ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputStickerSetIDArray ) FillMap (to map [int64 ]InputStickerSetID ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s InputStickerSetIDArray ) ToMap () map [int64 ]InputStickerSetID {
r := make (map [int64 ]InputStickerSetID , len (s ))
s .FillMap (r )
return r
}
type InputStickerSetShortNameArray []InputStickerSetShortName
func (s InputStickerSetShortNameArray ) Sort (less func (a , b InputStickerSetShortName ) bool ) InputStickerSetShortNameArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputStickerSetShortNameArray ) SortStable (less func (a , b InputStickerSetShortName ) bool ) InputStickerSetShortNameArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputStickerSetShortNameArray ) Retain (keep func (x InputStickerSetShortName ) bool ) InputStickerSetShortNameArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputStickerSetShortNameArray ) First () (v InputStickerSetShortName , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputStickerSetShortNameArray ) Last () (v InputStickerSetShortName , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputStickerSetShortNameArray ) PopFirst () (v InputStickerSetShortName , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputStickerSetShortName
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputStickerSetShortNameArray ) Pop () (v InputStickerSetShortName , 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
}
type InputStickerSetDiceArray []InputStickerSetDice
func (s InputStickerSetDiceArray ) Sort (less func (a , b InputStickerSetDice ) bool ) InputStickerSetDiceArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputStickerSetDiceArray ) SortStable (less func (a , b InputStickerSetDice ) bool ) InputStickerSetDiceArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputStickerSetDiceArray ) Retain (keep func (x InputStickerSetDice ) bool ) InputStickerSetDiceArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputStickerSetDiceArray ) First () (v InputStickerSetDice , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputStickerSetDiceArray ) Last () (v InputStickerSetDice , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputStickerSetDiceArray ) PopFirst () (v InputStickerSetDice , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputStickerSetDice
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputStickerSetDiceArray ) Pop () (v InputStickerSetDice , 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
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .