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 MessageClassArray []MessageClass
func (s MessageClassArray ) Sort (less func (a , b MessageClass ) bool ) MessageClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessageClassArray ) SortStable (less func (a , b MessageClass ) bool ) MessageClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessageClassArray ) Retain (keep func (x MessageClass ) bool ) MessageClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s MessageClassArray ) First () (v MessageClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s MessageClassArray ) Last () (v MessageClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *MessageClassArray ) PopFirst () (v MessageClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero MessageClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *MessageClassArray ) Pop () (v MessageClass , 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 MessageClassArray ) SortByID () MessageClassArray {
return s .Sort (func (a , b MessageClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s MessageClassArray ) SortStableByID () MessageClassArray {
return s .SortStable (func (a , b MessageClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s MessageClassArray ) FillMessageEmptyMap (to map [int ]*MessageEmpty ) {
for _ , elem := range s {
value , ok := elem .(*MessageEmpty )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s MessageClassArray ) MessageEmptyToMap () map [int ]*MessageEmpty {
r := make (map [int ]*MessageEmpty , len (s ))
s .FillMessageEmptyMap (r )
return r
}
func (s MessageClassArray ) AsMessageEmpty () (to MessageEmptyArray ) {
for _ , elem := range s {
value , ok := elem .(*MessageEmpty )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s MessageClassArray ) FillMessageMap (to map [int ]*Message ) {
for _ , elem := range s {
value , ok := elem .(*Message )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s MessageClassArray ) MessageToMap () map [int ]*Message {
r := make (map [int ]*Message , len (s ))
s .FillMessageMap (r )
return r
}
func (s MessageClassArray ) AsMessage () (to MessageArray ) {
for _ , elem := range s {
value , ok := elem .(*Message )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s MessageClassArray ) FillMessageServiceMap (to map [int ]*MessageService ) {
for _ , elem := range s {
value , ok := elem .(*MessageService )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s MessageClassArray ) MessageServiceToMap () map [int ]*MessageService {
r := make (map [int ]*MessageService , len (s ))
s .FillMessageServiceMap (r )
return r
}
func (s MessageClassArray ) AsMessageService () (to MessageServiceArray ) {
for _ , elem := range s {
value , ok := elem .(*MessageService )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s MessageClassArray ) FillNotEmptyMap (to map [int ]NotEmptyMessage ) {
for _ , elem := range s {
value , ok := elem .AsNotEmpty ()
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s MessageClassArray ) NotEmptyToMap () map [int ]NotEmptyMessage {
r := make (map [int ]NotEmptyMessage , len (s ))
s .FillNotEmptyMap (r )
return r
}
func (s MessageClassArray ) AppendOnlyNotEmpty (to []NotEmptyMessage ) []NotEmptyMessage {
for _ , elem := range s {
value , ok := elem .AsNotEmpty ()
if !ok {
continue
}
to = append (to , value )
}
return to
}
func (s MessageClassArray ) AsNotEmpty () (to []NotEmptyMessage ) {
return s .AppendOnlyNotEmpty (to )
}
func (s MessageClassArray ) FirstAsNotEmpty () (v NotEmptyMessage , ok bool ) {
value , ok := s .First ()
if !ok {
return
}
return value .AsNotEmpty ()
}
func (s MessageClassArray ) LastAsNotEmpty () (v NotEmptyMessage , ok bool ) {
value , ok := s .Last ()
if !ok {
return
}
return value .AsNotEmpty ()
}
func (s *MessageClassArray ) PopFirstAsNotEmpty () (v NotEmptyMessage , ok bool ) {
value , ok := s .PopFirst ()
if !ok {
return
}
return value .AsNotEmpty ()
}
func (s *MessageClassArray ) PopAsNotEmpty () (v NotEmptyMessage , ok bool ) {
value , ok := s .Pop ()
if !ok {
return
}
return value .AsNotEmpty ()
}
type MessageEmptyArray []MessageEmpty
func (s MessageEmptyArray ) Sort (less func (a , b MessageEmpty ) bool ) MessageEmptyArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessageEmptyArray ) SortStable (less func (a , b MessageEmpty ) bool ) MessageEmptyArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessageEmptyArray ) Retain (keep func (x MessageEmpty ) bool ) MessageEmptyArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s MessageEmptyArray ) First () (v MessageEmpty , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s MessageEmptyArray ) Last () (v MessageEmpty , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *MessageEmptyArray ) PopFirst () (v MessageEmpty , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero MessageEmpty
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *MessageEmptyArray ) Pop () (v MessageEmpty , 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 MessageEmptyArray ) SortByID () MessageEmptyArray {
return s .Sort (func (a , b MessageEmpty ) bool {
return a .GetID () < b .GetID ()
})
}
func (s MessageEmptyArray ) SortStableByID () MessageEmptyArray {
return s .SortStable (func (a , b MessageEmpty ) bool {
return a .GetID () < b .GetID ()
})
}
func (s MessageEmptyArray ) FillMap (to map [int ]MessageEmpty ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s MessageEmptyArray ) ToMap () map [int ]MessageEmpty {
r := make (map [int ]MessageEmpty , len (s ))
s .FillMap (r )
return r
}
type MessageArray []Message
func (s MessageArray ) Sort (less func (a , b Message ) bool ) MessageArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessageArray ) SortStable (less func (a , b Message ) bool ) MessageArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessageArray ) Retain (keep func (x Message ) bool ) MessageArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s MessageArray ) First () (v Message , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s MessageArray ) Last () (v Message , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *MessageArray ) PopFirst () (v Message , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero Message
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *MessageArray ) Pop () (v Message , 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 MessageArray ) SortByID () MessageArray {
return s .Sort (func (a , b Message ) bool {
return a .GetID () < b .GetID ()
})
}
func (s MessageArray ) SortStableByID () MessageArray {
return s .SortStable (func (a , b Message ) bool {
return a .GetID () < b .GetID ()
})
}
func (s MessageArray ) SortByDate () MessageArray {
return s .Sort (func (a , b Message ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessageArray ) SortStableByDate () MessageArray {
return s .SortStable (func (a , b Message ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessageArray ) FillMap (to map [int ]Message ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s MessageArray ) ToMap () map [int ]Message {
r := make (map [int ]Message , len (s ))
s .FillMap (r )
return r
}
type MessageServiceArray []MessageService
func (s MessageServiceArray ) Sort (less func (a , b MessageService ) bool ) MessageServiceArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessageServiceArray ) SortStable (less func (a , b MessageService ) bool ) MessageServiceArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessageServiceArray ) Retain (keep func (x MessageService ) bool ) MessageServiceArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s MessageServiceArray ) First () (v MessageService , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s MessageServiceArray ) Last () (v MessageService , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *MessageServiceArray ) PopFirst () (v MessageService , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero MessageService
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *MessageServiceArray ) Pop () (v MessageService , 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 MessageServiceArray ) SortByID () MessageServiceArray {
return s .Sort (func (a , b MessageService ) bool {
return a .GetID () < b .GetID ()
})
}
func (s MessageServiceArray ) SortStableByID () MessageServiceArray {
return s .SortStable (func (a , b MessageService ) bool {
return a .GetID () < b .GetID ()
})
}
func (s MessageServiceArray ) SortByDate () MessageServiceArray {
return s .Sort (func (a , b MessageService ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessageServiceArray ) SortStableByDate () MessageServiceArray {
return s .SortStable (func (a , b MessageService ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessageServiceArray ) FillMap (to map [int ]MessageService ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s MessageServiceArray ) ToMap () map [int ]MessageService {
r := make (map [int ]MessageService , 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 .