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 PhoneConnectionClassArray []PhoneConnectionClass
func (s PhoneConnectionClassArray ) Sort (less func (a , b PhoneConnectionClass ) bool ) PhoneConnectionClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s PhoneConnectionClassArray ) SortStable (less func (a , b PhoneConnectionClass ) bool ) PhoneConnectionClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s PhoneConnectionClassArray ) Retain (keep func (x PhoneConnectionClass ) bool ) PhoneConnectionClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s PhoneConnectionClassArray ) First () (v PhoneConnectionClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s PhoneConnectionClassArray ) Last () (v PhoneConnectionClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *PhoneConnectionClassArray ) PopFirst () (v PhoneConnectionClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero PhoneConnectionClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *PhoneConnectionClassArray ) Pop () (v PhoneConnectionClass , 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 PhoneConnectionClassArray ) SortByID () PhoneConnectionClassArray {
return s .Sort (func (a , b PhoneConnectionClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s PhoneConnectionClassArray ) SortStableByID () PhoneConnectionClassArray {
return s .SortStable (func (a , b PhoneConnectionClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s PhoneConnectionClassArray ) FillPhoneConnectionMap (to map [int64 ]*PhoneConnection ) {
for _ , elem := range s {
value , ok := elem .(*PhoneConnection )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s PhoneConnectionClassArray ) PhoneConnectionToMap () map [int64 ]*PhoneConnection {
r := make (map [int64 ]*PhoneConnection , len (s ))
s .FillPhoneConnectionMap (r )
return r
}
func (s PhoneConnectionClassArray ) AsPhoneConnection () (to PhoneConnectionArray ) {
for _ , elem := range s {
value , ok := elem .(*PhoneConnection )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s PhoneConnectionClassArray ) FillPhoneConnectionWebrtcMap (to map [int64 ]*PhoneConnectionWebrtc ) {
for _ , elem := range s {
value , ok := elem .(*PhoneConnectionWebrtc )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s PhoneConnectionClassArray ) PhoneConnectionWebrtcToMap () map [int64 ]*PhoneConnectionWebrtc {
r := make (map [int64 ]*PhoneConnectionWebrtc , len (s ))
s .FillPhoneConnectionWebrtcMap (r )
return r
}
func (s PhoneConnectionClassArray ) AsPhoneConnectionWebrtc () (to PhoneConnectionWebrtcArray ) {
for _ , elem := range s {
value , ok := elem .(*PhoneConnectionWebrtc )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type PhoneConnectionArray []PhoneConnection
func (s PhoneConnectionArray ) Sort (less func (a , b PhoneConnection ) bool ) PhoneConnectionArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s PhoneConnectionArray ) SortStable (less func (a , b PhoneConnection ) bool ) PhoneConnectionArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s PhoneConnectionArray ) Retain (keep func (x PhoneConnection ) bool ) PhoneConnectionArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s PhoneConnectionArray ) First () (v PhoneConnection , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s PhoneConnectionArray ) Last () (v PhoneConnection , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *PhoneConnectionArray ) PopFirst () (v PhoneConnection , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero PhoneConnection
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *PhoneConnectionArray ) Pop () (v PhoneConnection , 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 PhoneConnectionArray ) SortByID () PhoneConnectionArray {
return s .Sort (func (a , b PhoneConnection ) bool {
return a .GetID () < b .GetID ()
})
}
func (s PhoneConnectionArray ) SortStableByID () PhoneConnectionArray {
return s .SortStable (func (a , b PhoneConnection ) bool {
return a .GetID () < b .GetID ()
})
}
func (s PhoneConnectionArray ) FillMap (to map [int64 ]PhoneConnection ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s PhoneConnectionArray ) ToMap () map [int64 ]PhoneConnection {
r := make (map [int64 ]PhoneConnection , len (s ))
s .FillMap (r )
return r
}
type PhoneConnectionWebrtcArray []PhoneConnectionWebrtc
func (s PhoneConnectionWebrtcArray ) Sort (less func (a , b PhoneConnectionWebrtc ) bool ) PhoneConnectionWebrtcArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s PhoneConnectionWebrtcArray ) SortStable (less func (a , b PhoneConnectionWebrtc ) bool ) PhoneConnectionWebrtcArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s PhoneConnectionWebrtcArray ) Retain (keep func (x PhoneConnectionWebrtc ) bool ) PhoneConnectionWebrtcArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s PhoneConnectionWebrtcArray ) First () (v PhoneConnectionWebrtc , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s PhoneConnectionWebrtcArray ) Last () (v PhoneConnectionWebrtc , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *PhoneConnectionWebrtcArray ) PopFirst () (v PhoneConnectionWebrtc , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero PhoneConnectionWebrtc
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *PhoneConnectionWebrtcArray ) Pop () (v PhoneConnectionWebrtc , 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 PhoneConnectionWebrtcArray ) SortByID () PhoneConnectionWebrtcArray {
return s .Sort (func (a , b PhoneConnectionWebrtc ) bool {
return a .GetID () < b .GetID ()
})
}
func (s PhoneConnectionWebrtcArray ) SortStableByID () PhoneConnectionWebrtcArray {
return s .SortStable (func (a , b PhoneConnectionWebrtc ) bool {
return a .GetID () < b .GetID ()
})
}
func (s PhoneConnectionWebrtcArray ) FillMap (to map [int64 ]PhoneConnectionWebrtc ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s PhoneConnectionWebrtcArray ) ToMap () map [int64 ]PhoneConnectionWebrtc {
r := make (map [int64 ]PhoneConnectionWebrtc , 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 .