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 InputPeerClassArray []InputPeerClass
func (s InputPeerClassArray ) Sort (less func (a , b InputPeerClass ) bool ) InputPeerClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerClassArray ) SortStable (less func (a , b InputPeerClass ) bool ) InputPeerClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerClassArray ) Retain (keep func (x InputPeerClass ) bool ) InputPeerClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputPeerClassArray ) First () (v InputPeerClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputPeerClassArray ) Last () (v InputPeerClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputPeerClassArray ) PopFirst () (v InputPeerClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputPeerClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputPeerClassArray ) Pop () (v InputPeerClass , 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 InputPeerClassArray ) AsInputPeerChat () (to InputPeerChatArray ) {
for _ , elem := range s {
value , ok := elem .(*InputPeerChat )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputPeerClassArray ) AsInputPeerUser () (to InputPeerUserArray ) {
for _ , elem := range s {
value , ok := elem .(*InputPeerUser )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputPeerClassArray ) AsInputPeerChannel () (to InputPeerChannelArray ) {
for _ , elem := range s {
value , ok := elem .(*InputPeerChannel )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputPeerClassArray ) AsInputPeerUserFromMessage () (to InputPeerUserFromMessageArray ) {
for _ , elem := range s {
value , ok := elem .(*InputPeerUserFromMessage )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s InputPeerClassArray ) AsInputPeerChannelFromMessage () (to InputPeerChannelFromMessageArray ) {
for _ , elem := range s {
value , ok := elem .(*InputPeerChannelFromMessage )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type InputPeerChatArray []InputPeerChat
func (s InputPeerChatArray ) Sort (less func (a , b InputPeerChat ) bool ) InputPeerChatArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerChatArray ) SortStable (less func (a , b InputPeerChat ) bool ) InputPeerChatArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerChatArray ) Retain (keep func (x InputPeerChat ) bool ) InputPeerChatArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputPeerChatArray ) First () (v InputPeerChat , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputPeerChatArray ) Last () (v InputPeerChat , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputPeerChatArray ) PopFirst () (v InputPeerChat , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputPeerChat
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputPeerChatArray ) Pop () (v InputPeerChat , 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 InputPeerUserArray []InputPeerUser
func (s InputPeerUserArray ) Sort (less func (a , b InputPeerUser ) bool ) InputPeerUserArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerUserArray ) SortStable (less func (a , b InputPeerUser ) bool ) InputPeerUserArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerUserArray ) Retain (keep func (x InputPeerUser ) bool ) InputPeerUserArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputPeerUserArray ) First () (v InputPeerUser , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputPeerUserArray ) Last () (v InputPeerUser , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputPeerUserArray ) PopFirst () (v InputPeerUser , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputPeerUser
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputPeerUserArray ) Pop () (v InputPeerUser , 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 InputPeerChannelArray []InputPeerChannel
func (s InputPeerChannelArray ) Sort (less func (a , b InputPeerChannel ) bool ) InputPeerChannelArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerChannelArray ) SortStable (less func (a , b InputPeerChannel ) bool ) InputPeerChannelArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerChannelArray ) Retain (keep func (x InputPeerChannel ) bool ) InputPeerChannelArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputPeerChannelArray ) First () (v InputPeerChannel , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputPeerChannelArray ) Last () (v InputPeerChannel , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputPeerChannelArray ) PopFirst () (v InputPeerChannel , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputPeerChannel
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputPeerChannelArray ) Pop () (v InputPeerChannel , 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 InputPeerUserFromMessageArray []InputPeerUserFromMessage
func (s InputPeerUserFromMessageArray ) Sort (less func (a , b InputPeerUserFromMessage ) bool ) InputPeerUserFromMessageArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerUserFromMessageArray ) SortStable (less func (a , b InputPeerUserFromMessage ) bool ) InputPeerUserFromMessageArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerUserFromMessageArray ) Retain (keep func (x InputPeerUserFromMessage ) bool ) InputPeerUserFromMessageArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputPeerUserFromMessageArray ) First () (v InputPeerUserFromMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputPeerUserFromMessageArray ) Last () (v InputPeerUserFromMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputPeerUserFromMessageArray ) PopFirst () (v InputPeerUserFromMessage , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputPeerUserFromMessage
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputPeerUserFromMessageArray ) Pop () (v InputPeerUserFromMessage , 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 InputPeerChannelFromMessageArray []InputPeerChannelFromMessage
func (s InputPeerChannelFromMessageArray ) Sort (less func (a , b InputPeerChannelFromMessage ) bool ) InputPeerChannelFromMessageArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerChannelFromMessageArray ) SortStable (less func (a , b InputPeerChannelFromMessage ) bool ) InputPeerChannelFromMessageArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s InputPeerChannelFromMessageArray ) Retain (keep func (x InputPeerChannelFromMessage ) bool ) InputPeerChannelFromMessageArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s InputPeerChannelFromMessageArray ) First () (v InputPeerChannelFromMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s InputPeerChannelFromMessageArray ) Last () (v InputPeerChannelFromMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *InputPeerChannelFromMessageArray ) PopFirst () (v InputPeerChannelFromMessage , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero InputPeerChannelFromMessage
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *InputPeerChannelFromMessageArray ) Pop () (v InputPeerChannelFromMessage , 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 .