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 UpdatesClassArray []UpdatesClass
func (s UpdatesClassArray ) Sort (less func (a , b UpdatesClass ) bool ) UpdatesClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdatesClassArray ) SortStable (less func (a , b UpdatesClass ) bool ) UpdatesClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdatesClassArray ) Retain (keep func (x UpdatesClass ) bool ) UpdatesClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s UpdatesClassArray ) First () (v UpdatesClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s UpdatesClassArray ) Last () (v UpdatesClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *UpdatesClassArray ) PopFirst () (v UpdatesClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero UpdatesClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *UpdatesClassArray ) Pop () (v UpdatesClass , 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 UpdatesClassArray ) AsUpdateShortMessage () (to UpdateShortMessageArray ) {
for _ , elem := range s {
value , ok := elem .(*UpdateShortMessage )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s UpdatesClassArray ) AsUpdateShortChatMessage () (to UpdateShortChatMessageArray ) {
for _ , elem := range s {
value , ok := elem .(*UpdateShortChatMessage )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s UpdatesClassArray ) AsUpdateShort () (to UpdateShortArray ) {
for _ , elem := range s {
value , ok := elem .(*UpdateShort )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s UpdatesClassArray ) AsUpdatesCombined () (to UpdatesCombinedArray ) {
for _ , elem := range s {
value , ok := elem .(*UpdatesCombined )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s UpdatesClassArray ) AsUpdates () (to UpdatesArray ) {
for _ , elem := range s {
value , ok := elem .(*Updates )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s UpdatesClassArray ) AsUpdateShortSentMessage () (to UpdateShortSentMessageArray ) {
for _ , elem := range s {
value , ok := elem .(*UpdateShortSentMessage )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type UpdateShortMessageArray []UpdateShortMessage
func (s UpdateShortMessageArray ) Sort (less func (a , b UpdateShortMessage ) bool ) UpdateShortMessageArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdateShortMessageArray ) SortStable (less func (a , b UpdateShortMessage ) bool ) UpdateShortMessageArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdateShortMessageArray ) Retain (keep func (x UpdateShortMessage ) bool ) UpdateShortMessageArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s UpdateShortMessageArray ) First () (v UpdateShortMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s UpdateShortMessageArray ) Last () (v UpdateShortMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *UpdateShortMessageArray ) PopFirst () (v UpdateShortMessage , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero UpdateShortMessage
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *UpdateShortMessageArray ) Pop () (v UpdateShortMessage , 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 UpdateShortMessageArray ) SortByID () UpdateShortMessageArray {
return s .Sort (func (a , b UpdateShortMessage ) bool {
return a .GetID () < b .GetID ()
})
}
func (s UpdateShortMessageArray ) SortStableByID () UpdateShortMessageArray {
return s .SortStable (func (a , b UpdateShortMessage ) bool {
return a .GetID () < b .GetID ()
})
}
func (s UpdateShortMessageArray ) SortByDate () UpdateShortMessageArray {
return s .Sort (func (a , b UpdateShortMessage ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdateShortMessageArray ) SortStableByDate () UpdateShortMessageArray {
return s .SortStable (func (a , b UpdateShortMessage ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdateShortMessageArray ) FillMap (to map [int ]UpdateShortMessage ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s UpdateShortMessageArray ) ToMap () map [int ]UpdateShortMessage {
r := make (map [int ]UpdateShortMessage , len (s ))
s .FillMap (r )
return r
}
type UpdateShortChatMessageArray []UpdateShortChatMessage
func (s UpdateShortChatMessageArray ) Sort (less func (a , b UpdateShortChatMessage ) bool ) UpdateShortChatMessageArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdateShortChatMessageArray ) SortStable (less func (a , b UpdateShortChatMessage ) bool ) UpdateShortChatMessageArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdateShortChatMessageArray ) Retain (keep func (x UpdateShortChatMessage ) bool ) UpdateShortChatMessageArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s UpdateShortChatMessageArray ) First () (v UpdateShortChatMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s UpdateShortChatMessageArray ) Last () (v UpdateShortChatMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *UpdateShortChatMessageArray ) PopFirst () (v UpdateShortChatMessage , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero UpdateShortChatMessage
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *UpdateShortChatMessageArray ) Pop () (v UpdateShortChatMessage , 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 UpdateShortChatMessageArray ) SortByID () UpdateShortChatMessageArray {
return s .Sort (func (a , b UpdateShortChatMessage ) bool {
return a .GetID () < b .GetID ()
})
}
func (s UpdateShortChatMessageArray ) SortStableByID () UpdateShortChatMessageArray {
return s .SortStable (func (a , b UpdateShortChatMessage ) bool {
return a .GetID () < b .GetID ()
})
}
func (s UpdateShortChatMessageArray ) SortByDate () UpdateShortChatMessageArray {
return s .Sort (func (a , b UpdateShortChatMessage ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdateShortChatMessageArray ) SortStableByDate () UpdateShortChatMessageArray {
return s .SortStable (func (a , b UpdateShortChatMessage ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdateShortChatMessageArray ) FillMap (to map [int ]UpdateShortChatMessage ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s UpdateShortChatMessageArray ) ToMap () map [int ]UpdateShortChatMessage {
r := make (map [int ]UpdateShortChatMessage , len (s ))
s .FillMap (r )
return r
}
type UpdateShortArray []UpdateShort
func (s UpdateShortArray ) Sort (less func (a , b UpdateShort ) bool ) UpdateShortArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdateShortArray ) SortStable (less func (a , b UpdateShort ) bool ) UpdateShortArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdateShortArray ) Retain (keep func (x UpdateShort ) bool ) UpdateShortArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s UpdateShortArray ) First () (v UpdateShort , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s UpdateShortArray ) Last () (v UpdateShort , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *UpdateShortArray ) PopFirst () (v UpdateShort , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero UpdateShort
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *UpdateShortArray ) Pop () (v UpdateShort , 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 UpdateShortArray ) SortByDate () UpdateShortArray {
return s .Sort (func (a , b UpdateShort ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdateShortArray ) SortStableByDate () UpdateShortArray {
return s .SortStable (func (a , b UpdateShort ) bool {
return a .GetDate () < b .GetDate ()
})
}
type UpdatesCombinedArray []UpdatesCombined
func (s UpdatesCombinedArray ) Sort (less func (a , b UpdatesCombined ) bool ) UpdatesCombinedArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdatesCombinedArray ) SortStable (less func (a , b UpdatesCombined ) bool ) UpdatesCombinedArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdatesCombinedArray ) Retain (keep func (x UpdatesCombined ) bool ) UpdatesCombinedArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s UpdatesCombinedArray ) First () (v UpdatesCombined , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s UpdatesCombinedArray ) Last () (v UpdatesCombined , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *UpdatesCombinedArray ) PopFirst () (v UpdatesCombined , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero UpdatesCombined
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *UpdatesCombinedArray ) Pop () (v UpdatesCombined , 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 UpdatesCombinedArray ) SortByDate () UpdatesCombinedArray {
return s .Sort (func (a , b UpdatesCombined ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdatesCombinedArray ) SortStableByDate () UpdatesCombinedArray {
return s .SortStable (func (a , b UpdatesCombined ) bool {
return a .GetDate () < b .GetDate ()
})
}
type UpdatesArray []Updates
func (s UpdatesArray ) Sort (less func (a , b Updates ) bool ) UpdatesArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdatesArray ) SortStable (less func (a , b Updates ) bool ) UpdatesArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdatesArray ) Retain (keep func (x Updates ) bool ) UpdatesArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s UpdatesArray ) First () (v Updates , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s UpdatesArray ) Last () (v Updates , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *UpdatesArray ) PopFirst () (v Updates , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero Updates
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *UpdatesArray ) Pop () (v Updates , 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 UpdatesArray ) SortByDate () UpdatesArray {
return s .Sort (func (a , b Updates ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdatesArray ) SortStableByDate () UpdatesArray {
return s .SortStable (func (a , b Updates ) bool {
return a .GetDate () < b .GetDate ()
})
}
type UpdateShortSentMessageArray []UpdateShortSentMessage
func (s UpdateShortSentMessageArray ) Sort (less func (a , b UpdateShortSentMessage ) bool ) UpdateShortSentMessageArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdateShortSentMessageArray ) SortStable (less func (a , b UpdateShortSentMessage ) bool ) UpdateShortSentMessageArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s UpdateShortSentMessageArray ) Retain (keep func (x UpdateShortSentMessage ) bool ) UpdateShortSentMessageArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s UpdateShortSentMessageArray ) First () (v UpdateShortSentMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s UpdateShortSentMessageArray ) Last () (v UpdateShortSentMessage , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *UpdateShortSentMessageArray ) PopFirst () (v UpdateShortSentMessage , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero UpdateShortSentMessage
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *UpdateShortSentMessageArray ) Pop () (v UpdateShortSentMessage , 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 UpdateShortSentMessageArray ) SortByID () UpdateShortSentMessageArray {
return s .Sort (func (a , b UpdateShortSentMessage ) bool {
return a .GetID () < b .GetID ()
})
}
func (s UpdateShortSentMessageArray ) SortStableByID () UpdateShortSentMessageArray {
return s .SortStable (func (a , b UpdateShortSentMessage ) bool {
return a .GetID () < b .GetID ()
})
}
func (s UpdateShortSentMessageArray ) SortByDate () UpdateShortSentMessageArray {
return s .Sort (func (a , b UpdateShortSentMessage ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdateShortSentMessageArray ) SortStableByDate () UpdateShortSentMessageArray {
return s .SortStable (func (a , b UpdateShortSentMessage ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s UpdateShortSentMessageArray ) FillMap (to map [int ]UpdateShortSentMessage ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s UpdateShortSentMessageArray ) ToMap () map [int ]UpdateShortSentMessage {
r := make (map [int ]UpdateShortSentMessage , 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 .