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 RichTextClassArray []RichTextClass
func (s RichTextClassArray ) Sort (less func (a , b RichTextClass ) bool ) RichTextClassArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s RichTextClassArray ) SortStable (less func (a , b RichTextClass ) bool ) RichTextClassArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s RichTextClassArray ) Retain (keep func (x RichTextClass ) bool ) RichTextClassArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s RichTextClassArray ) First () (v RichTextClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s RichTextClassArray ) Last () (v RichTextClass , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *RichTextClassArray ) PopFirst () (v RichTextClass , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero RichTextClass
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *RichTextClassArray ) Pop () (v RichTextClass , 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 RichTextClassArray ) AsTextPlain () (to TextPlainArray ) {
for _ , elem := range s {
value , ok := elem .(*TextPlain )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextBold () (to TextBoldArray ) {
for _ , elem := range s {
value , ok := elem .(*TextBold )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextItalic () (to TextItalicArray ) {
for _ , elem := range s {
value , ok := elem .(*TextItalic )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextUnderline () (to TextUnderlineArray ) {
for _ , elem := range s {
value , ok := elem .(*TextUnderline )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextStrike () (to TextStrikeArray ) {
for _ , elem := range s {
value , ok := elem .(*TextStrike )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextFixed () (to TextFixedArray ) {
for _ , elem := range s {
value , ok := elem .(*TextFixed )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextURL () (to TextURLArray ) {
for _ , elem := range s {
value , ok := elem .(*TextURL )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextEmail () (to TextEmailArray ) {
for _ , elem := range s {
value , ok := elem .(*TextEmail )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextConcat () (to TextConcatArray ) {
for _ , elem := range s {
value , ok := elem .(*TextConcat )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextSubscript () (to TextSubscriptArray ) {
for _ , elem := range s {
value , ok := elem .(*TextSubscript )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextSuperscript () (to TextSuperscriptArray ) {
for _ , elem := range s {
value , ok := elem .(*TextSuperscript )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextMarked () (to TextMarkedArray ) {
for _ , elem := range s {
value , ok := elem .(*TextMarked )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextPhone () (to TextPhoneArray ) {
for _ , elem := range s {
value , ok := elem .(*TextPhone )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextImage () (to TextImageArray ) {
for _ , elem := range s {
value , ok := elem .(*TextImage )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
func (s RichTextClassArray ) AsTextAnchor () (to TextAnchorArray ) {
for _ , elem := range s {
value , ok := elem .(*TextAnchor )
if !ok {
continue
}
to = append (to , *value )
}
return to
}
type TextPlainArray []TextPlain
func (s TextPlainArray ) Sort (less func (a , b TextPlain ) bool ) TextPlainArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextPlainArray ) SortStable (less func (a , b TextPlain ) bool ) TextPlainArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextPlainArray ) Retain (keep func (x TextPlain ) bool ) TextPlainArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextPlainArray ) First () (v TextPlain , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextPlainArray ) Last () (v TextPlain , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextPlainArray ) PopFirst () (v TextPlain , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextPlain
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextPlainArray ) Pop () (v TextPlain , 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
}
type TextBoldArray []TextBold
func (s TextBoldArray ) Sort (less func (a , b TextBold ) bool ) TextBoldArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextBoldArray ) SortStable (less func (a , b TextBold ) bool ) TextBoldArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextBoldArray ) Retain (keep func (x TextBold ) bool ) TextBoldArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextBoldArray ) First () (v TextBold , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextBoldArray ) Last () (v TextBold , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextBoldArray ) PopFirst () (v TextBold , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextBold
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextBoldArray ) Pop () (v TextBold , 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
}
type TextItalicArray []TextItalic
func (s TextItalicArray ) Sort (less func (a , b TextItalic ) bool ) TextItalicArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextItalicArray ) SortStable (less func (a , b TextItalic ) bool ) TextItalicArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextItalicArray ) Retain (keep func (x TextItalic ) bool ) TextItalicArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextItalicArray ) First () (v TextItalic , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextItalicArray ) Last () (v TextItalic , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextItalicArray ) PopFirst () (v TextItalic , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextItalic
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextItalicArray ) Pop () (v TextItalic , 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
}
type TextUnderlineArray []TextUnderline
func (s TextUnderlineArray ) Sort (less func (a , b TextUnderline ) bool ) TextUnderlineArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextUnderlineArray ) SortStable (less func (a , b TextUnderline ) bool ) TextUnderlineArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextUnderlineArray ) Retain (keep func (x TextUnderline ) bool ) TextUnderlineArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextUnderlineArray ) First () (v TextUnderline , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextUnderlineArray ) Last () (v TextUnderline , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextUnderlineArray ) PopFirst () (v TextUnderline , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextUnderline
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextUnderlineArray ) Pop () (v TextUnderline , 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
}
type TextStrikeArray []TextStrike
func (s TextStrikeArray ) Sort (less func (a , b TextStrike ) bool ) TextStrikeArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextStrikeArray ) SortStable (less func (a , b TextStrike ) bool ) TextStrikeArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextStrikeArray ) Retain (keep func (x TextStrike ) bool ) TextStrikeArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextStrikeArray ) First () (v TextStrike , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextStrikeArray ) Last () (v TextStrike , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextStrikeArray ) PopFirst () (v TextStrike , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextStrike
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextStrikeArray ) Pop () (v TextStrike , 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
}
type TextFixedArray []TextFixed
func (s TextFixedArray ) Sort (less func (a , b TextFixed ) bool ) TextFixedArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextFixedArray ) SortStable (less func (a , b TextFixed ) bool ) TextFixedArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextFixedArray ) Retain (keep func (x TextFixed ) bool ) TextFixedArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextFixedArray ) First () (v TextFixed , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextFixedArray ) Last () (v TextFixed , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextFixedArray ) PopFirst () (v TextFixed , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextFixed
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextFixedArray ) Pop () (v TextFixed , 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
}
type TextURLArray []TextURL
func (s TextURLArray ) Sort (less func (a , b TextURL ) bool ) TextURLArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextURLArray ) SortStable (less func (a , b TextURL ) bool ) TextURLArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextURLArray ) Retain (keep func (x TextURL ) bool ) TextURLArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextURLArray ) First () (v TextURL , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextURLArray ) Last () (v TextURL , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextURLArray ) PopFirst () (v TextURL , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextURL
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextURLArray ) Pop () (v TextURL , 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
}
type TextEmailArray []TextEmail
func (s TextEmailArray ) Sort (less func (a , b TextEmail ) bool ) TextEmailArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextEmailArray ) SortStable (less func (a , b TextEmail ) bool ) TextEmailArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextEmailArray ) Retain (keep func (x TextEmail ) bool ) TextEmailArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextEmailArray ) First () (v TextEmail , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextEmailArray ) Last () (v TextEmail , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextEmailArray ) PopFirst () (v TextEmail , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextEmail
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextEmailArray ) Pop () (v TextEmail , 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
}
type TextConcatArray []TextConcat
func (s TextConcatArray ) Sort (less func (a , b TextConcat ) bool ) TextConcatArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextConcatArray ) SortStable (less func (a , b TextConcat ) bool ) TextConcatArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextConcatArray ) Retain (keep func (x TextConcat ) bool ) TextConcatArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextConcatArray ) First () (v TextConcat , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextConcatArray ) Last () (v TextConcat , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextConcatArray ) PopFirst () (v TextConcat , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextConcat
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextConcatArray ) Pop () (v TextConcat , 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
}
type TextSubscriptArray []TextSubscript
func (s TextSubscriptArray ) Sort (less func (a , b TextSubscript ) bool ) TextSubscriptArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextSubscriptArray ) SortStable (less func (a , b TextSubscript ) bool ) TextSubscriptArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextSubscriptArray ) Retain (keep func (x TextSubscript ) bool ) TextSubscriptArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextSubscriptArray ) First () (v TextSubscript , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextSubscriptArray ) Last () (v TextSubscript , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextSubscriptArray ) PopFirst () (v TextSubscript , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextSubscript
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextSubscriptArray ) Pop () (v TextSubscript , 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
}
type TextSuperscriptArray []TextSuperscript
func (s TextSuperscriptArray ) Sort (less func (a , b TextSuperscript ) bool ) TextSuperscriptArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextSuperscriptArray ) SortStable (less func (a , b TextSuperscript ) bool ) TextSuperscriptArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextSuperscriptArray ) Retain (keep func (x TextSuperscript ) bool ) TextSuperscriptArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextSuperscriptArray ) First () (v TextSuperscript , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextSuperscriptArray ) Last () (v TextSuperscript , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextSuperscriptArray ) PopFirst () (v TextSuperscript , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextSuperscript
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextSuperscriptArray ) Pop () (v TextSuperscript , 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
}
type TextMarkedArray []TextMarked
func (s TextMarkedArray ) Sort (less func (a , b TextMarked ) bool ) TextMarkedArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextMarkedArray ) SortStable (less func (a , b TextMarked ) bool ) TextMarkedArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextMarkedArray ) Retain (keep func (x TextMarked ) bool ) TextMarkedArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextMarkedArray ) First () (v TextMarked , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextMarkedArray ) Last () (v TextMarked , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextMarkedArray ) PopFirst () (v TextMarked , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextMarked
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextMarkedArray ) Pop () (v TextMarked , 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
}
type TextPhoneArray []TextPhone
func (s TextPhoneArray ) Sort (less func (a , b TextPhone ) bool ) TextPhoneArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextPhoneArray ) SortStable (less func (a , b TextPhone ) bool ) TextPhoneArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextPhoneArray ) Retain (keep func (x TextPhone ) bool ) TextPhoneArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextPhoneArray ) First () (v TextPhone , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextPhoneArray ) Last () (v TextPhone , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextPhoneArray ) PopFirst () (v TextPhone , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextPhone
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextPhoneArray ) Pop () (v TextPhone , 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
}
type TextImageArray []TextImage
func (s TextImageArray ) Sort (less func (a , b TextImage ) bool ) TextImageArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextImageArray ) SortStable (less func (a , b TextImage ) bool ) TextImageArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextImageArray ) Retain (keep func (x TextImage ) bool ) TextImageArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextImageArray ) First () (v TextImage , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextImageArray ) Last () (v TextImage , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextImageArray ) PopFirst () (v TextImage , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextImage
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextImageArray ) Pop () (v TextImage , 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
}
type TextAnchorArray []TextAnchor
func (s TextAnchorArray ) Sort (less func (a , b TextAnchor ) bool ) TextAnchorArray {
sort .Slice (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextAnchorArray ) SortStable (less func (a , b TextAnchor ) bool ) TextAnchorArray {
sort .SliceStable (s , func (i , j int ) bool {
return less (s [i ], s [j ])
})
return s
}
func (s TextAnchorArray ) Retain (keep func (x TextAnchor ) bool ) TextAnchorArray {
n := 0
for _ , x := range s {
if keep (x ) {
s [n ] = x
n ++
}
}
s = s [:n ]
return s
}
func (s TextAnchorArray ) First () (v TextAnchor , ok bool ) {
if len (s ) < 1 {
return
}
return s [0 ], true
}
func (s TextAnchorArray ) Last () (v TextAnchor , ok bool ) {
if len (s ) < 1 {
return
}
return s [len (s )-1 ], true
}
func (s *TextAnchorArray ) PopFirst () (v TextAnchor , ok bool ) {
if s == nil || len (*s ) < 1 {
return
}
a := *s
v = a [0 ]
copy (a [0 :], a [1 :])
var zero TextAnchor
a [len (a )-1 ] = zero
a = a [:len (a )-1 ]
*s = a
return v , true
}
func (s *TextAnchorArray ) Pop () (v TextAnchor , 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 .