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 BotAppClassArray []BotAppClass
func (s BotAppClassArray ) Sort (less func (a , b BotAppClass ) bool ) BotAppClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s BotAppClassArray ) SortStable (less func (a , b BotAppClass ) bool ) BotAppClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s BotAppClassArray ) Retain (keep func (x BotAppClass ) bool ) BotAppClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s BotAppClassArray ) First () (v BotAppClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s BotAppClassArray ) Last () (v BotAppClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *BotAppClassArray ) PopFirst () (v BotAppClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero BotAppClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *BotAppClassArray ) Pop () (v BotAppClass , 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 BotAppClassArray ) AsBotApp () (to BotAppArray ) {
for _ , elem := range s {
value , ok := elem .(*BotApp )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s BotAppClassArray ) FillModifiedMap (to map [int64 ]*BotApp ) {
for _ , elem := range s {
value , ok := elem .AsModified ()
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s BotAppClassArray ) ModifiedToMap () map [int64 ]*BotApp {
r := make (map [int64 ]*BotApp , len (s ))
s .FillModifiedMap (r )
return r
}
func (s BotAppClassArray ) AppendOnlyModified (to []*BotApp ) []*BotApp {
for _ , elem := range s {
value , ok := elem .AsModified ()
if !ok {
continue
}
to = append (to , value )
}
return to
}
func (s BotAppClassArray ) AsModified () (to []*BotApp ) {
return s .AppendOnlyModified (to )
}
func (s BotAppClassArray ) FirstAsModified () (v *BotApp , ok bool ) {
value , ok := s .First ()
if !ok {
return
}
return value .AsModified ()
}
func (s BotAppClassArray ) LastAsModified () (v *BotApp , ok bool ) {
value , ok := s .Last ()
if !ok {
return
}
return value .AsModified ()
}
func (s *BotAppClassArray ) PopFirstAsModified () (v *BotApp , ok bool ) {
value , ok := s .PopFirst ()
if !ok {
return
}
return value .AsModified ()
}
func (s *BotAppClassArray ) PopAsModified () (v *BotApp , ok bool ) {
value , ok := s .Pop ()
if !ok {
return
}
return value .AsModified ()
}
type BotAppArray []BotApp
func (s BotAppArray ) Sort (less func (a , b BotApp ) bool ) BotAppArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s BotAppArray ) SortStable (less func (a , b BotApp ) bool ) BotAppArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s BotAppArray ) Retain (keep func (x BotApp ) bool ) BotAppArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s BotAppArray ) First () (v BotApp , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s BotAppArray ) Last () (v BotApp , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *BotAppArray ) PopFirst () (v BotApp , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero BotApp
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *BotAppArray ) Pop () (v BotApp , 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 BotAppArray ) SortByID () BotAppArray {
return s .Sort (func (a , b BotApp ) bool {
return a .GetID () < b .GetID ()
})
}
func (s BotAppArray ) SortStableByID () BotAppArray {
return s .SortStable (func (a , b BotApp ) bool {
return a .GetID () < b .GetID ()
})
}
func (s BotAppArray ) FillMap (to map [int64 ]BotApp ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s BotAppArray ) ToMap () map [int64 ]BotApp {
r := make (map [int64 ]BotApp , len (s ))
s .FillMap (r )
return r
}
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 .