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 WallPaperClassArray []WallPaperClass
func (s WallPaperClassArray ) Sort (less func (a , b WallPaperClass ) bool ) WallPaperClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WallPaperClassArray ) SortStable (less func (a , b WallPaperClass ) bool ) WallPaperClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WallPaperClassArray ) Retain (keep func (x WallPaperClass ) bool ) WallPaperClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s WallPaperClassArray ) First () (v WallPaperClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s WallPaperClassArray ) Last () (v WallPaperClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *WallPaperClassArray ) PopFirst () (v WallPaperClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero WallPaperClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *WallPaperClassArray ) Pop () (v WallPaperClass , 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 WallPaperClassArray ) SortByID () WallPaperClassArray {
return s .Sort (func (a , b WallPaperClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WallPaperClassArray ) SortStableByID () WallPaperClassArray {
return s .SortStable (func (a , b WallPaperClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WallPaperClassArray ) FillWallPaperMap (to map [int64 ]*WallPaper ) {
for _ , elem := range s {
value , ok := elem .(*WallPaper )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s WallPaperClassArray ) WallPaperToMap () map [int64 ]*WallPaper {
r := make (map [int64 ]*WallPaper , len (s ))
s .FillWallPaperMap (r )
return r
}
func (s WallPaperClassArray ) AsWallPaper () (to WallPaperArray ) {
for _ , elem := range s {
value , ok := elem .(*WallPaper )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s WallPaperClassArray ) FillWallPaperNoFileMap (to map [int64 ]*WallPaperNoFile ) {
for _ , elem := range s {
value , ok := elem .(*WallPaperNoFile )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s WallPaperClassArray ) WallPaperNoFileToMap () map [int64 ]*WallPaperNoFile {
r := make (map [int64 ]*WallPaperNoFile , len (s ))
s .FillWallPaperNoFileMap (r )
return r
}
func (s WallPaperClassArray ) AsWallPaperNoFile () (to WallPaperNoFileArray ) {
for _ , elem := range s {
value , ok := elem .(*WallPaperNoFile )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type WallPaperArray []WallPaper
func (s WallPaperArray ) Sort (less func (a , b WallPaper ) bool ) WallPaperArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WallPaperArray ) SortStable (less func (a , b WallPaper ) bool ) WallPaperArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WallPaperArray ) Retain (keep func (x WallPaper ) bool ) WallPaperArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s WallPaperArray ) First () (v WallPaper , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s WallPaperArray ) Last () (v WallPaper , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *WallPaperArray ) PopFirst () (v WallPaper , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero WallPaper
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *WallPaperArray ) Pop () (v WallPaper , 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 WallPaperArray ) SortByID () WallPaperArray {
return s .Sort (func (a , b WallPaper ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WallPaperArray ) SortStableByID () WallPaperArray {
return s .SortStable (func (a , b WallPaper ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WallPaperArray ) FillMap (to map [int64 ]WallPaper ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s WallPaperArray ) ToMap () map [int64 ]WallPaper {
r := make (map [int64 ]WallPaper , len (s ))
s .FillMap (r )
return r
}
type WallPaperNoFileArray []WallPaperNoFile
func (s WallPaperNoFileArray ) Sort (less func (a , b WallPaperNoFile ) bool ) WallPaperNoFileArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WallPaperNoFileArray ) SortStable (less func (a , b WallPaperNoFile ) bool ) WallPaperNoFileArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WallPaperNoFileArray ) Retain (keep func (x WallPaperNoFile ) bool ) WallPaperNoFileArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s WallPaperNoFileArray ) First () (v WallPaperNoFile , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s WallPaperNoFileArray ) Last () (v WallPaperNoFile , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *WallPaperNoFileArray ) PopFirst () (v WallPaperNoFile , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero WallPaperNoFile
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *WallPaperNoFileArray ) Pop () (v WallPaperNoFile , 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 WallPaperNoFileArray ) SortByID () WallPaperNoFileArray {
return s .Sort (func (a , b WallPaperNoFile ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WallPaperNoFileArray ) SortStableByID () WallPaperNoFileArray {
return s .SortStable (func (a , b WallPaperNoFile ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WallPaperNoFileArray ) FillMap (to map [int64 ]WallPaperNoFile ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s WallPaperNoFileArray ) ToMap () map [int64 ]WallPaperNoFile {
r := make (map [int64 ]WallPaperNoFile , 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 .