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 DialogFilterClassArray []DialogFilterClass
func (s DialogFilterClassArray ) Sort (less func (a , b DialogFilterClass ) bool ) DialogFilterClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s DialogFilterClassArray ) SortStable (less func (a , b DialogFilterClass ) bool ) DialogFilterClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s DialogFilterClassArray ) Retain (keep func (x DialogFilterClass ) bool ) DialogFilterClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s DialogFilterClassArray ) First () (v DialogFilterClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s DialogFilterClassArray ) Last () (v DialogFilterClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *DialogFilterClassArray ) PopFirst () (v DialogFilterClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero DialogFilterClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *DialogFilterClassArray ) Pop () (v DialogFilterClass , 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 DialogFilterClassArray ) AsDialogFilter () (to DialogFilterArray ) {
for _ , elem := range s {
value , ok := elem .(*DialogFilter )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s DialogFilterClassArray ) AsDialogFilterChatlist () (to DialogFilterChatlistArray ) {
for _ , elem := range s {
value , ok := elem .(*DialogFilterChatlist )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type DialogFilterArray []DialogFilter
func (s DialogFilterArray ) Sort (less func (a , b DialogFilter ) bool ) DialogFilterArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s DialogFilterArray ) SortStable (less func (a , b DialogFilter ) bool ) DialogFilterArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s DialogFilterArray ) Retain (keep func (x DialogFilter ) bool ) DialogFilterArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s DialogFilterArray ) First () (v DialogFilter , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s DialogFilterArray ) Last () (v DialogFilter , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *DialogFilterArray ) PopFirst () (v DialogFilter , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero DialogFilter
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *DialogFilterArray ) Pop () (v DialogFilter , 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 DialogFilterArray ) SortByID () DialogFilterArray {
return s .Sort (func (a , b DialogFilter ) bool {
return a .GetID () < b .GetID ()
})
}
func (s DialogFilterArray ) SortStableByID () DialogFilterArray {
return s .SortStable (func (a , b DialogFilter ) bool {
return a .GetID () < b .GetID ()
})
}
func (s DialogFilterArray ) FillMap (to map [int ]DialogFilter ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s DialogFilterArray ) ToMap () map [int ]DialogFilter {
r := make (map [int ]DialogFilter , len (s ))
s .FillMap (r )
return r
}
type DialogFilterChatlistArray []DialogFilterChatlist
func (s DialogFilterChatlistArray ) Sort (less func (a , b DialogFilterChatlist ) bool ) DialogFilterChatlistArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s DialogFilterChatlistArray ) SortStable (less func (a , b DialogFilterChatlist ) bool ) DialogFilterChatlistArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s DialogFilterChatlistArray ) Retain (keep func (x DialogFilterChatlist ) bool ) DialogFilterChatlistArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s DialogFilterChatlistArray ) First () (v DialogFilterChatlist , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s DialogFilterChatlistArray ) Last () (v DialogFilterChatlist , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *DialogFilterChatlistArray ) PopFirst () (v DialogFilterChatlist , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero DialogFilterChatlist
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *DialogFilterChatlistArray ) Pop () (v DialogFilterChatlist , 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 DialogFilterChatlistArray ) SortByID () DialogFilterChatlistArray {
return s .Sort (func (a , b DialogFilterChatlist ) bool {
return a .GetID () < b .GetID ()
})
}
func (s DialogFilterChatlistArray ) SortStableByID () DialogFilterChatlistArray {
return s .SortStable (func (a , b DialogFilterChatlist ) bool {
return a .GetID () < b .GetID ()
})
}
func (s DialogFilterChatlistArray ) FillMap (to map [int ]DialogFilterChatlist ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s DialogFilterChatlistArray ) ToMap () map [int ]DialogFilterChatlist {
r := make (map [int ]DialogFilterChatlist , 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 .