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 StoryItemClassArray []StoryItemClass
func (s StoryItemClassArray ) Sort (less func (a , b StoryItemClass ) bool ) StoryItemClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s StoryItemClassArray ) SortStable (less func (a , b StoryItemClass ) bool ) StoryItemClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s StoryItemClassArray ) Retain (keep func (x StoryItemClass ) bool ) StoryItemClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s StoryItemClassArray ) First () (v StoryItemClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s StoryItemClassArray ) Last () (v StoryItemClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *StoryItemClassArray ) PopFirst () (v StoryItemClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero StoryItemClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *StoryItemClassArray ) Pop () (v StoryItemClass , 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 StoryItemClassArray ) SortByID () StoryItemClassArray {
return s .Sort (func (a , b StoryItemClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s StoryItemClassArray ) SortStableByID () StoryItemClassArray {
return s .SortStable (func (a , b StoryItemClass ) bool {
return a .GetID () < b .GetID ()
})
}
func (s StoryItemClassArray ) FillStoryItemDeletedMap (to map [int ]*StoryItemDeleted ) {
for _ , elem := range s {
value , ok := elem .(*StoryItemDeleted )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s StoryItemClassArray ) StoryItemDeletedToMap () map [int ]*StoryItemDeleted {
r := make (map [int ]*StoryItemDeleted , len (s ))
s .FillStoryItemDeletedMap (r )
return r
}
func (s StoryItemClassArray ) AsStoryItemDeleted () (to StoryItemDeletedArray ) {
for _ , elem := range s {
value , ok := elem .(*StoryItemDeleted )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s StoryItemClassArray ) FillStoryItemSkippedMap (to map [int ]*StoryItemSkipped ) {
for _ , elem := range s {
value , ok := elem .(*StoryItemSkipped )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s StoryItemClassArray ) StoryItemSkippedToMap () map [int ]*StoryItemSkipped {
r := make (map [int ]*StoryItemSkipped , len (s ))
s .FillStoryItemSkippedMap (r )
return r
}
func (s StoryItemClassArray ) AsStoryItemSkipped () (to StoryItemSkippedArray ) {
for _ , elem := range s {
value , ok := elem .(*StoryItemSkipped )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s StoryItemClassArray ) FillStoryItemMap (to map [int ]*StoryItem ) {
for _ , elem := range s {
value , ok := elem .(*StoryItem )
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s StoryItemClassArray ) StoryItemToMap () map [int ]*StoryItem {
r := make (map [int ]*StoryItem , len (s ))
s .FillStoryItemMap (r )
return r
}
func (s StoryItemClassArray ) AsStoryItem () (to StoryItemArray ) {
for _ , elem := range s {
value , ok := elem .(*StoryItem )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type StoryItemDeletedArray []StoryItemDeleted
func (s StoryItemDeletedArray ) Sort (less func (a , b StoryItemDeleted ) bool ) StoryItemDeletedArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s StoryItemDeletedArray ) SortStable (less func (a , b StoryItemDeleted ) bool ) StoryItemDeletedArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s StoryItemDeletedArray ) Retain (keep func (x StoryItemDeleted ) bool ) StoryItemDeletedArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s StoryItemDeletedArray ) First () (v StoryItemDeleted , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s StoryItemDeletedArray ) Last () (v StoryItemDeleted , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *StoryItemDeletedArray ) PopFirst () (v StoryItemDeleted , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero StoryItemDeleted
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *StoryItemDeletedArray ) Pop () (v StoryItemDeleted , 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 StoryItemDeletedArray ) SortByID () StoryItemDeletedArray {
return s .Sort (func (a , b StoryItemDeleted ) bool {
return a .GetID () < b .GetID ()
})
}
func (s StoryItemDeletedArray ) SortStableByID () StoryItemDeletedArray {
return s .SortStable (func (a , b StoryItemDeleted ) bool {
return a .GetID () < b .GetID ()
})
}
func (s StoryItemDeletedArray ) FillMap (to map [int ]StoryItemDeleted ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s StoryItemDeletedArray ) ToMap () map [int ]StoryItemDeleted {
r := make (map [int ]StoryItemDeleted , len (s ))
s .FillMap (r )
return r
}
type StoryItemSkippedArray []StoryItemSkipped
func (s StoryItemSkippedArray ) Sort (less func (a , b StoryItemSkipped ) bool ) StoryItemSkippedArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s StoryItemSkippedArray ) SortStable (less func (a , b StoryItemSkipped ) bool ) StoryItemSkippedArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s StoryItemSkippedArray ) Retain (keep func (x StoryItemSkipped ) bool ) StoryItemSkippedArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s StoryItemSkippedArray ) First () (v StoryItemSkipped , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s StoryItemSkippedArray ) Last () (v StoryItemSkipped , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *StoryItemSkippedArray ) PopFirst () (v StoryItemSkipped , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero StoryItemSkipped
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *StoryItemSkippedArray ) Pop () (v StoryItemSkipped , 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 StoryItemSkippedArray ) SortByID () StoryItemSkippedArray {
return s .Sort (func (a , b StoryItemSkipped ) bool {
return a .GetID () < b .GetID ()
})
}
func (s StoryItemSkippedArray ) SortStableByID () StoryItemSkippedArray {
return s .SortStable (func (a , b StoryItemSkipped ) bool {
return a .GetID () < b .GetID ()
})
}
func (s StoryItemSkippedArray ) SortByDate () StoryItemSkippedArray {
return s .Sort (func (a , b StoryItemSkipped ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s StoryItemSkippedArray ) SortStableByDate () StoryItemSkippedArray {
return s .SortStable (func (a , b StoryItemSkipped ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s StoryItemSkippedArray ) FillMap (to map [int ]StoryItemSkipped ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s StoryItemSkippedArray ) ToMap () map [int ]StoryItemSkipped {
r := make (map [int ]StoryItemSkipped , len (s ))
s .FillMap (r )
return r
}
type StoryItemArray []StoryItem
func (s StoryItemArray ) Sort (less func (a , b StoryItem ) bool ) StoryItemArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s StoryItemArray ) SortStable (less func (a , b StoryItem ) bool ) StoryItemArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s StoryItemArray ) Retain (keep func (x StoryItem ) bool ) StoryItemArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s StoryItemArray ) First () (v StoryItem , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s StoryItemArray ) Last () (v StoryItem , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *StoryItemArray ) PopFirst () (v StoryItem , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero StoryItem
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *StoryItemArray ) Pop () (v StoryItem , 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 StoryItemArray ) SortByID () StoryItemArray {
return s .Sort (func (a , b StoryItem ) bool {
return a .GetID () < b .GetID ()
})
}
func (s StoryItemArray ) SortStableByID () StoryItemArray {
return s .SortStable (func (a , b StoryItem ) bool {
return a .GetID () < b .GetID ()
})
}
func (s StoryItemArray ) SortByDate () StoryItemArray {
return s .Sort (func (a , b StoryItem ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s StoryItemArray ) SortStableByDate () StoryItemArray {
return s .SortStable (func (a , b StoryItem ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s StoryItemArray ) FillMap (to map [int ]StoryItem ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s StoryItemArray ) ToMap () map [int ]StoryItem {
r := make (map [int ]StoryItem , 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 .