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 MessagePeerVoteClassArray []MessagePeerVoteClass
func (s MessagePeerVoteClassArray ) Sort (less func (a , b MessagePeerVoteClass ) bool ) MessagePeerVoteClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessagePeerVoteClassArray ) SortStable (less func (a , b MessagePeerVoteClass ) bool ) MessagePeerVoteClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessagePeerVoteClassArray ) Retain (keep func (x MessagePeerVoteClass ) bool ) MessagePeerVoteClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s MessagePeerVoteClassArray ) First () (v MessagePeerVoteClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s MessagePeerVoteClassArray ) Last () (v MessagePeerVoteClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *MessagePeerVoteClassArray ) PopFirst () (v MessagePeerVoteClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero MessagePeerVoteClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *MessagePeerVoteClassArray ) Pop () (v MessagePeerVoteClass , 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 MessagePeerVoteClassArray ) SortByDate () MessagePeerVoteClassArray {
return s .Sort (func (a , b MessagePeerVoteClass ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessagePeerVoteClassArray ) SortStableByDate () MessagePeerVoteClassArray {
return s .SortStable (func (a , b MessagePeerVoteClass ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessagePeerVoteClassArray ) AsMessagePeerVote () (to MessagePeerVoteArray ) {
for _ , elem := range s {
value , ok := elem .(*MessagePeerVote )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s MessagePeerVoteClassArray ) AsMessagePeerVoteInputOption () (to MessagePeerVoteInputOptionArray ) {
for _ , elem := range s {
value , ok := elem .(*MessagePeerVoteInputOption )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s MessagePeerVoteClassArray ) AsMessagePeerVoteMultiple () (to MessagePeerVoteMultipleArray ) {
for _ , elem := range s {
value , ok := elem .(*MessagePeerVoteMultiple )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type MessagePeerVoteArray []MessagePeerVote
func (s MessagePeerVoteArray ) Sort (less func (a , b MessagePeerVote ) bool ) MessagePeerVoteArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessagePeerVoteArray ) SortStable (less func (a , b MessagePeerVote ) bool ) MessagePeerVoteArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessagePeerVoteArray ) Retain (keep func (x MessagePeerVote ) bool ) MessagePeerVoteArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s MessagePeerVoteArray ) First () (v MessagePeerVote , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s MessagePeerVoteArray ) Last () (v MessagePeerVote , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *MessagePeerVoteArray ) PopFirst () (v MessagePeerVote , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero MessagePeerVote
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *MessagePeerVoteArray ) Pop () (v MessagePeerVote , 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 MessagePeerVoteArray ) SortByDate () MessagePeerVoteArray {
return s .Sort (func (a , b MessagePeerVote ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessagePeerVoteArray ) SortStableByDate () MessagePeerVoteArray {
return s .SortStable (func (a , b MessagePeerVote ) bool {
return a .GetDate () < b .GetDate ()
})
}
type MessagePeerVoteInputOptionArray []MessagePeerVoteInputOption
func (s MessagePeerVoteInputOptionArray ) Sort (less func (a , b MessagePeerVoteInputOption ) bool ) MessagePeerVoteInputOptionArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessagePeerVoteInputOptionArray ) SortStable (less func (a , b MessagePeerVoteInputOption ) bool ) MessagePeerVoteInputOptionArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessagePeerVoteInputOptionArray ) Retain (keep func (x MessagePeerVoteInputOption ) bool ) MessagePeerVoteInputOptionArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s MessagePeerVoteInputOptionArray ) First () (v MessagePeerVoteInputOption , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s MessagePeerVoteInputOptionArray ) Last () (v MessagePeerVoteInputOption , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *MessagePeerVoteInputOptionArray ) PopFirst () (v MessagePeerVoteInputOption , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero MessagePeerVoteInputOption
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *MessagePeerVoteInputOptionArray ) Pop () (v MessagePeerVoteInputOption , 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 MessagePeerVoteInputOptionArray ) SortByDate () MessagePeerVoteInputOptionArray {
return s .Sort (func (a , b MessagePeerVoteInputOption ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessagePeerVoteInputOptionArray ) SortStableByDate () MessagePeerVoteInputOptionArray {
return s .SortStable (func (a , b MessagePeerVoteInputOption ) bool {
return a .GetDate () < b .GetDate ()
})
}
type MessagePeerVoteMultipleArray []MessagePeerVoteMultiple
func (s MessagePeerVoteMultipleArray ) Sort (less func (a , b MessagePeerVoteMultiple ) bool ) MessagePeerVoteMultipleArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessagePeerVoteMultipleArray ) SortStable (less func (a , b MessagePeerVoteMultiple ) bool ) MessagePeerVoteMultipleArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s MessagePeerVoteMultipleArray ) Retain (keep func (x MessagePeerVoteMultiple ) bool ) MessagePeerVoteMultipleArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s MessagePeerVoteMultipleArray ) First () (v MessagePeerVoteMultiple , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s MessagePeerVoteMultipleArray ) Last () (v MessagePeerVoteMultiple , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *MessagePeerVoteMultipleArray ) PopFirst () (v MessagePeerVoteMultiple , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero MessagePeerVoteMultiple
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *MessagePeerVoteMultipleArray ) Pop () (v MessagePeerVoteMultiple , 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 MessagePeerVoteMultipleArray ) SortByDate () MessagePeerVoteMultipleArray {
return s .Sort (func (a , b MessagePeerVoteMultiple ) bool {
return a .GetDate () < b .GetDate ()
})
}
func (s MessagePeerVoteMultipleArray ) SortStableByDate () MessagePeerVoteMultipleArray {
return s .SortStable (func (a , b MessagePeerVoteMultiple ) bool {
return a .GetDate () < b .GetDate ()
})
}
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 .