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 WebPageClassArray []WebPageClass
func (s WebPageClassArray ) Sort (less func (a , b WebPageClass ) bool ) WebPageClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPageClassArray ) SortStable (less func (a , b WebPageClass ) bool ) WebPageClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPageClassArray ) Retain (keep func (x WebPageClass ) bool ) WebPageClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s WebPageClassArray ) First () (v WebPageClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s WebPageClassArray ) Last () (v WebPageClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *WebPageClassArray ) PopFirst () (v WebPageClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero WebPageClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *WebPageClassArray ) Pop () (v WebPageClass , 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 WebPageClassArray ) AsWebPageEmpty () (to WebPageEmptyArray ) {
for _ , elem := range s {
value , ok := elem .(*WebPageEmpty )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s WebPageClassArray ) AsWebPagePending () (to WebPagePendingArray ) {
for _ , elem := range s {
value , ok := elem .(*WebPagePending )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s WebPageClassArray ) AsWebPage () (to WebPageArray ) {
for _ , elem := range s {
value , ok := elem .(*WebPage )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s WebPageClassArray ) AsWebPageNotModified () (to WebPageNotModifiedArray ) {
for _ , elem := range s {
value , ok := elem .(*WebPageNotModified )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s WebPageClassArray ) FillModifiedMap (to map [int64 ]ModifiedWebPage ) {
for _ , elem := range s {
value , ok := elem .AsModified ()
if !ok {
continue
}
to [value .GetID ()] = value
}
}
func (s WebPageClassArray ) ModifiedToMap () map [int64 ]ModifiedWebPage {
r := make (map [int64 ]ModifiedWebPage , len (s ))
s .FillModifiedMap (r )
return r
}
func (s WebPageClassArray ) AppendOnlyModified (to []ModifiedWebPage ) []ModifiedWebPage {
for _ , elem := range s {
value , ok := elem .AsModified ()
if !ok {
continue
}
to = append (to , value )
}
return to
}
func (s WebPageClassArray ) AsModified () (to []ModifiedWebPage ) {
return s .AppendOnlyModified (to )
}
func (s WebPageClassArray ) FirstAsModified () (v ModifiedWebPage , ok bool ) {
value , ok := s .First ()
if !ok {
return
}
return value .AsModified ()
}
func (s WebPageClassArray ) LastAsModified () (v ModifiedWebPage , ok bool ) {
value , ok := s .Last ()
if !ok {
return
}
return value .AsModified ()
}
func (s *WebPageClassArray ) PopFirstAsModified () (v ModifiedWebPage , ok bool ) {
value , ok := s .PopFirst ()
if !ok {
return
}
return value .AsModified ()
}
func (s *WebPageClassArray ) PopAsModified () (v ModifiedWebPage , ok bool ) {
value , ok := s .Pop ()
if !ok {
return
}
return value .AsModified ()
}
type WebPageEmptyArray []WebPageEmpty
func (s WebPageEmptyArray ) Sort (less func (a , b WebPageEmpty ) bool ) WebPageEmptyArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPageEmptyArray ) SortStable (less func (a , b WebPageEmpty ) bool ) WebPageEmptyArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPageEmptyArray ) Retain (keep func (x WebPageEmpty ) bool ) WebPageEmptyArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s WebPageEmptyArray ) First () (v WebPageEmpty , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s WebPageEmptyArray ) Last () (v WebPageEmpty , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *WebPageEmptyArray ) PopFirst () (v WebPageEmpty , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero WebPageEmpty
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *WebPageEmptyArray ) Pop () (v WebPageEmpty , 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 WebPageEmptyArray ) SortByID () WebPageEmptyArray {
return s .Sort (func (a , b WebPageEmpty ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WebPageEmptyArray ) SortStableByID () WebPageEmptyArray {
return s .SortStable (func (a , b WebPageEmpty ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WebPageEmptyArray ) FillMap (to map [int64 ]WebPageEmpty ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s WebPageEmptyArray ) ToMap () map [int64 ]WebPageEmpty {
r := make (map [int64 ]WebPageEmpty , len (s ))
s .FillMap (r )
return r
}
type WebPagePendingArray []WebPagePending
func (s WebPagePendingArray ) Sort (less func (a , b WebPagePending ) bool ) WebPagePendingArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPagePendingArray ) SortStable (less func (a , b WebPagePending ) bool ) WebPagePendingArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPagePendingArray ) Retain (keep func (x WebPagePending ) bool ) WebPagePendingArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s WebPagePendingArray ) First () (v WebPagePending , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s WebPagePendingArray ) Last () (v WebPagePending , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *WebPagePendingArray ) PopFirst () (v WebPagePending , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero WebPagePending
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *WebPagePendingArray ) Pop () (v WebPagePending , 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 WebPagePendingArray ) SortByID () WebPagePendingArray {
return s .Sort (func (a , b WebPagePending ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WebPagePendingArray ) SortStableByID () WebPagePendingArray {
return s .SortStable (func (a , b WebPagePending ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WebPagePendingArray ) SortByDate () WebPagePendingArray {
return s .Sort (func (a , b WebPagePending ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s WebPagePendingArray ) SortStableByDate () WebPagePendingArray {
return s .SortStable (func (a , b WebPagePending ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s WebPagePendingArray ) FillMap (to map [int64 ]WebPagePending ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s WebPagePendingArray ) ToMap () map [int64 ]WebPagePending {
r := make (map [int64 ]WebPagePending , len (s ))
s .FillMap (r )
return r
}
type WebPageArray []WebPage
func (s WebPageArray ) Sort (less func (a , b WebPage ) bool ) WebPageArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPageArray ) SortStable (less func (a , b WebPage ) bool ) WebPageArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPageArray ) Retain (keep func (x WebPage ) bool ) WebPageArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s WebPageArray ) First () (v WebPage , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s WebPageArray ) Last () (v WebPage , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *WebPageArray ) PopFirst () (v WebPage , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero WebPage
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *WebPageArray ) Pop () (v WebPage , 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 WebPageArray ) SortByID () WebPageArray {
return s .Sort (func (a , b WebPage ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WebPageArray ) SortStableByID () WebPageArray {
return s .SortStable (func (a , b WebPage ) bool {
return a .GetID () < b .GetID ()
})
}
func (s WebPageArray ) FillMap (to map [int64 ]WebPage ) {
for _ , value := range s {
to [value .GetID ()] = value
}
}
func (s WebPageArray ) ToMap () map [int64 ]WebPage {
r := make (map [int64 ]WebPage , len (s ))
s .FillMap (r )
return r
}
type WebPageNotModifiedArray []WebPageNotModified
func (s WebPageNotModifiedArray ) Sort (less func (a , b WebPageNotModified ) bool ) WebPageNotModifiedArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPageNotModifiedArray ) SortStable (less func (a , b WebPageNotModified ) bool ) WebPageNotModifiedArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s WebPageNotModifiedArray ) Retain (keep func (x WebPageNotModified ) bool ) WebPageNotModifiedArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s WebPageNotModifiedArray ) First () (v WebPageNotModified , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s WebPageNotModifiedArray ) Last () (v WebPageNotModified , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *WebPageNotModifiedArray ) PopFirst () (v WebPageNotModified , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero WebPageNotModified
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *WebPageNotModifiedArray ) Pop () (v WebPageNotModified , 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
}
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 .