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 InputGameClassArray []InputGameClass
func (s InputGameClassArray ) Sort (less func (a , b InputGameClass ) bool ) InputGameClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputGameClassArray ) SortStable (less func (a , b InputGameClass ) bool ) InputGameClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputGameClassArray ) Retain (keep func (x InputGameClass ) bool ) InputGameClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputGameClassArray ) First () (v InputGameClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputGameClassArray ) Last () (v InputGameClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputGameClassArray ) PopFirst () (v InputGameClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputGameClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputGameClassArray ) Pop () (v InputGameClass , 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 InputGameClassArray ) AsInputGameID () (to InputGameIDArray ) {
for _ , elem := range s {
value , ok := elem .(*InputGameID )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputGameClassArray ) AsInputGameShortName () (to InputGameShortNameArray ) {
for _ , elem := range s {
value , ok := elem .(*InputGameShortName )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type InputGameIDArray []InputGameID
func (s InputGameIDArray ) Sort (less func (a , b InputGameID ) bool ) InputGameIDArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputGameIDArray ) SortStable (less func (a , b InputGameID ) bool ) InputGameIDArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputGameIDArray ) Retain (keep func (x InputGameID ) bool ) InputGameIDArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputGameIDArray ) First () (v InputGameID , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputGameIDArray ) Last () (v InputGameID , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputGameIDArray ) PopFirst () (v InputGameID , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputGameID
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputGameIDArray ) Pop () (v InputGameID , 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 InputGameIDArray ) SortByID () InputGameIDArray {
return s .Sort (func (a , b InputGameID ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputGameIDArray ) SortStableByID () InputGameIDArray {
return s .SortStable (func (a , b InputGameID ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputGameIDArray ) FillMap (to map [int64 ]InputGameID ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s InputGameIDArray ) ToMap () map [int64 ]InputGameID {
r := make (map [int64 ]InputGameID , len (s ))
s .FillMap (r )
return r
}
type InputGameShortNameArray []InputGameShortName
func (s InputGameShortNameArray ) Sort (less func (a , b InputGameShortName ) bool ) InputGameShortNameArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputGameShortNameArray ) SortStable (less func (a , b InputGameShortName ) bool ) InputGameShortNameArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputGameShortNameArray ) Retain (keep func (x InputGameShortName ) bool ) InputGameShortNameArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputGameShortNameArray ) First () (v InputGameShortName , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputGameShortNameArray ) Last () (v InputGameShortName , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputGameShortNameArray ) PopFirst () (v InputGameShortName , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputGameShortName
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputGameShortNameArray ) Pop () (v InputGameShortName , 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 .