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 ForumTopicClassArray []ForumTopicClass
func (s ForumTopicClassArray ) Sort (less func (a , b ForumTopicClass ) bool ) ForumTopicClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s ForumTopicClassArray ) SortStable (less func (a , b ForumTopicClass ) bool ) ForumTopicClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s ForumTopicClassArray ) Retain (keep func (x ForumTopicClass ) bool ) ForumTopicClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s ForumTopicClassArray ) First () (v ForumTopicClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s ForumTopicClassArray ) Last () (v ForumTopicClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *ForumTopicClassArray ) PopFirst () (v ForumTopicClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero ForumTopicClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *ForumTopicClassArray ) Pop () (v ForumTopicClass , 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 ForumTopicClassArray ) SortByID () ForumTopicClassArray {
return s .Sort (func (a , b ForumTopicClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s ForumTopicClassArray ) SortStableByID () ForumTopicClassArray {
return s .SortStable (func (a , b ForumTopicClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s ForumTopicClassArray ) FillForumTopicDeletedMap (to map [int ]*ForumTopicDeleted ) {
for _ , elem := range s {
value , ok := elem .(*ForumTopicDeleted )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s ForumTopicClassArray ) ForumTopicDeletedToMap () map [int ]*ForumTopicDeleted {
r := make (map [int ]*ForumTopicDeleted , len (s ))
s .FillForumTopicDeletedMap (r )
return r
}
func (s ForumTopicClassArray ) AsForumTopicDeleted () (to ForumTopicDeletedArray ) {
for _ , elem := range s {
value , ok := elem .(*ForumTopicDeleted )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s ForumTopicClassArray ) FillForumTopicMap (to map [int ]*ForumTopic ) {
for _ , elem := range s {
value , ok := elem .(*ForumTopic )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s ForumTopicClassArray ) ForumTopicToMap () map [int ]*ForumTopic {
r := make (map [int ]*ForumTopic , len (s ))
s .FillForumTopicMap (r )
return r
}
func (s ForumTopicClassArray ) AsForumTopic () (to ForumTopicArray ) {
for _ , elem := range s {
value , ok := elem .(*ForumTopic )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type ForumTopicDeletedArray []ForumTopicDeleted
func (s ForumTopicDeletedArray ) Sort (less func (a , b ForumTopicDeleted ) bool ) ForumTopicDeletedArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s ForumTopicDeletedArray ) SortStable (less func (a , b ForumTopicDeleted ) bool ) ForumTopicDeletedArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s ForumTopicDeletedArray ) Retain (keep func (x ForumTopicDeleted ) bool ) ForumTopicDeletedArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s ForumTopicDeletedArray ) First () (v ForumTopicDeleted , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s ForumTopicDeletedArray ) Last () (v ForumTopicDeleted , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *ForumTopicDeletedArray ) PopFirst () (v ForumTopicDeleted , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero ForumTopicDeleted
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *ForumTopicDeletedArray ) Pop () (v ForumTopicDeleted , 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 ForumTopicDeletedArray ) SortByID () ForumTopicDeletedArray {
return s .Sort (func (a , b ForumTopicDeleted ) bool {
return a .GetID () < b .GetID ()
})
}
func (s ForumTopicDeletedArray ) SortStableByID () ForumTopicDeletedArray {
return s .SortStable (func (a , b ForumTopicDeleted ) bool {
return a .GetID () < b .GetID ()
})
}
func (s ForumTopicDeletedArray ) FillMap (to map [int ]ForumTopicDeleted ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s ForumTopicDeletedArray ) ToMap () map [int ]ForumTopicDeleted {
r := make (map [int ]ForumTopicDeleted , len (s ))
s .FillMap (r )
return r
}
type ForumTopicArray []ForumTopic
func (s ForumTopicArray ) Sort (less func (a , b ForumTopic ) bool ) ForumTopicArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s ForumTopicArray ) SortStable (less func (a , b ForumTopic ) bool ) ForumTopicArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s ForumTopicArray ) Retain (keep func (x ForumTopic ) bool ) ForumTopicArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s ForumTopicArray ) First () (v ForumTopic , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s ForumTopicArray ) Last () (v ForumTopic , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *ForumTopicArray ) PopFirst () (v ForumTopic , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero ForumTopic
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *ForumTopicArray ) Pop () (v ForumTopic , 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 ForumTopicArray ) SortByID () ForumTopicArray {
return s .Sort (func (a , b ForumTopic ) bool {
return a .GetID () < b .GetID ()
})
}
func (s ForumTopicArray ) SortStableByID () ForumTopicArray {
return s .SortStable (func (a , b ForumTopic ) bool {
return a .GetID () < b .GetID ()
})
}
func (s ForumTopicArray ) SortByDate () ForumTopicArray {
return s .Sort (func (a , b ForumTopic ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s ForumTopicArray ) SortStableByDate () ForumTopicArray {
return s .SortStable (func (a , b ForumTopic ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s ForumTopicArray ) FillMap (to map [int ]ForumTopic ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s ForumTopicArray ) ToMap () map [int ]ForumTopic {
r := make (map [int ]ForumTopic , 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 .