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 InputFileClassArray []InputFileClass
func (s InputFileClassArray ) Sort (less func (a , b InputFileClass ) bool ) InputFileClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputFileClassArray ) SortStable (less func (a , b InputFileClass ) bool ) InputFileClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputFileClassArray ) Retain (keep func (x InputFileClass ) bool ) InputFileClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputFileClassArray ) First () (v InputFileClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputFileClassArray ) Last () (v InputFileClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputFileClassArray ) PopFirst () (v InputFileClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputFileClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputFileClassArray ) Pop () (v InputFileClass , 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 InputFileClassArray ) SortByID () InputFileClassArray {
return s .Sort (func (a , b InputFileClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputFileClassArray ) SortStableByID () InputFileClassArray {
return s .SortStable (func (a , b InputFileClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputFileClassArray ) FillInputFileMap (to map [int64 ]*InputFile ) {
for _ , elem := range s {
value , ok := elem .(*InputFile )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s InputFileClassArray ) InputFileToMap () map [int64 ]*InputFile {
r := make (map [int64 ]*InputFile , len (s ))
s .FillInputFileMap (r )
return r
}
func (s InputFileClassArray ) AsInputFile () (to InputFileArray ) {
for _ , elem := range s {
value , ok := elem .(*InputFile )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputFileClassArray ) FillInputFileBigMap (to map [int64 ]*InputFileBig ) {
for _ , elem := range s {
value , ok := elem .(*InputFileBig )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s InputFileClassArray ) InputFileBigToMap () map [int64 ]*InputFileBig {
r := make (map [int64 ]*InputFileBig , len (s ))
s .FillInputFileBigMap (r )
return r
}
func (s InputFileClassArray ) AsInputFileBig () (to InputFileBigArray ) {
for _ , elem := range s {
value , ok := elem .(*InputFileBig )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type InputFileArray []InputFile
func (s InputFileArray ) Sort (less func (a , b InputFile ) bool ) InputFileArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputFileArray ) SortStable (less func (a , b InputFile ) bool ) InputFileArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputFileArray ) Retain (keep func (x InputFile ) bool ) InputFileArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputFileArray ) First () (v InputFile , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputFileArray ) Last () (v InputFile , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputFileArray ) PopFirst () (v InputFile , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputFile
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputFileArray ) Pop () (v InputFile , 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 InputFileArray ) SortByID () InputFileArray {
return s .Sort (func (a , b InputFile ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputFileArray ) SortStableByID () InputFileArray {
return s .SortStable (func (a , b InputFile ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputFileArray ) FillMap (to map [int64 ]InputFile ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s InputFileArray ) ToMap () map [int64 ]InputFile {
r := make (map [int64 ]InputFile , len (s ))
s .FillMap (r )
return r
}
type InputFileBigArray []InputFileBig
func (s InputFileBigArray ) Sort (less func (a , b InputFileBig ) bool ) InputFileBigArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputFileBigArray ) SortStable (less func (a , b InputFileBig ) bool ) InputFileBigArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputFileBigArray ) Retain (keep func (x InputFileBig ) bool ) InputFileBigArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputFileBigArray ) First () (v InputFileBig , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputFileBigArray ) Last () (v InputFileBig , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputFileBigArray ) PopFirst () (v InputFileBig , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputFileBig
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputFileBigArray ) Pop () (v InputFileBig , 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 InputFileBigArray ) SortByID () InputFileBigArray {
return s .Sort (func (a , b InputFileBig ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputFileBigArray ) SortStableByID () InputFileBigArray {
return s .SortStable (func (a , b InputFileBig ) bool {
return a .GetID () < b .GetID ()
})
}
func (s InputFileBigArray ) FillMap (to map [int64 ]InputFileBig ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s InputFileBigArray ) ToMap () map [int64 ]InputFileBig {
r := make (map [int64 ]InputFileBig , 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 .