//go:build !no_gotd_slices
// +build !no_gotd_slices

// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// PeerClassArray is adapter for slice of PeerClass.
type PeerClassArray []PeerClass

// Sort sorts slice of PeerClass.
func ( PeerClassArray) ( func(,  PeerClass) bool) PeerClassArray {
	sort.Slice(, func(,  int) bool {
		return ([], [])
	})
	return 
}

// SortStable sorts slice of PeerClass.
func ( PeerClassArray) ( func(,  PeerClass) bool) PeerClassArray {
	sort.SliceStable(, func(,  int) bool {
		return ([], [])
	})
	return 
}

// Retain filters in-place slice of PeerClass.
func ( PeerClassArray) ( func( PeerClass) bool) PeerClassArray {
	 := 0
	for ,  := range  {
		if () {
			[] = 
			++
		}
	}
	 = [:]

	return 
}

// First returns first element of slice (if exists).
func ( PeerClassArray) () ( PeerClass,  bool) {
	if len() < 1 {
		return
	}
	return [0], true
}

// Last returns last element of slice (if exists).
func ( PeerClassArray) () ( PeerClass,  bool) {
	if len() < 1 {
		return
	}
	return [len()-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func ( *PeerClassArray) () ( PeerClass,  bool) {
	if  == nil || len(*) < 1 {
		return
	}

	 := *
	 = [0]

	// Delete by index from SliceTricks.
	copy([0:], [1:])
	var  PeerClass
	[len()-1] = 
	 = [:len()-1]
	* = 

	return , true
}

// Pop returns last element of slice (if exists) and deletes it.
func ( *PeerClassArray) () ( PeerClass,  bool) {
	if  == nil || len(*) < 1 {
		return
	}

	 := *
	 = [len()-1]
	 = [:len()-1]
	* = 

	return , true
}

// AsPeerUser returns copy with only PeerUser constructors.
func ( PeerClassArray) () ( PeerUserArray) {
	for ,  := range  {
		,  := .(*PeerUser)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

// AsPeerChat returns copy with only PeerChat constructors.
func ( PeerClassArray) () ( PeerChatArray) {
	for ,  := range  {
		,  := .(*PeerChat)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

// AsPeerChannel returns copy with only PeerChannel constructors.
func ( PeerClassArray) () ( PeerChannelArray) {
	for ,  := range  {
		,  := .(*PeerChannel)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

// PeerUserArray is adapter for slice of PeerUser.
type PeerUserArray []PeerUser

// Sort sorts slice of PeerUser.
func ( PeerUserArray) ( func(,  PeerUser) bool) PeerUserArray {
	sort.Slice(, func(,  int) bool {
		return ([], [])
	})
	return 
}

// SortStable sorts slice of PeerUser.
func ( PeerUserArray) ( func(,  PeerUser) bool) PeerUserArray {
	sort.SliceStable(, func(,  int) bool {
		return ([], [])
	})
	return 
}

// Retain filters in-place slice of PeerUser.
func ( PeerUserArray) ( func( PeerUser) bool) PeerUserArray {
	 := 0
	for ,  := range  {
		if () {
			[] = 
			++
		}
	}
	 = [:]

	return 
}

// First returns first element of slice (if exists).
func ( PeerUserArray) () ( PeerUser,  bool) {
	if len() < 1 {
		return
	}
	return [0], true
}

// Last returns last element of slice (if exists).
func ( PeerUserArray) () ( PeerUser,  bool) {
	if len() < 1 {
		return
	}
	return [len()-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func ( *PeerUserArray) () ( PeerUser,  bool) {
	if  == nil || len(*) < 1 {
		return
	}

	 := *
	 = [0]

	// Delete by index from SliceTricks.
	copy([0:], [1:])
	var  PeerUser
	[len()-1] = 
	 = [:len()-1]
	* = 

	return , true
}

// Pop returns last element of slice (if exists) and deletes it.
func ( *PeerUserArray) () ( PeerUser,  bool) {
	if  == nil || len(*) < 1 {
		return
	}

	 := *
	 = [len()-1]
	 = [:len()-1]
	* = 

	return , true
}

// PeerChatArray is adapter for slice of PeerChat.
type PeerChatArray []PeerChat

// Sort sorts slice of PeerChat.
func ( PeerChatArray) ( func(,  PeerChat) bool) PeerChatArray {
	sort.Slice(, func(,  int) bool {
		return ([], [])
	})
	return 
}

// SortStable sorts slice of PeerChat.
func ( PeerChatArray) ( func(,  PeerChat) bool) PeerChatArray {
	sort.SliceStable(, func(,  int) bool {
		return ([], [])
	})
	return 
}

// Retain filters in-place slice of PeerChat.
func ( PeerChatArray) ( func( PeerChat) bool) PeerChatArray {
	 := 0
	for ,  := range  {
		if () {
			[] = 
			++
		}
	}
	 = [:]

	return 
}

// First returns first element of slice (if exists).
func ( PeerChatArray) () ( PeerChat,  bool) {
	if len() < 1 {
		return
	}
	return [0], true
}

// Last returns last element of slice (if exists).
func ( PeerChatArray) () ( PeerChat,  bool) {
	if len() < 1 {
		return
	}
	return [len()-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func ( *PeerChatArray) () ( PeerChat,  bool) {
	if  == nil || len(*) < 1 {
		return
	}

	 := *
	 = [0]

	// Delete by index from SliceTricks.
	copy([0:], [1:])
	var  PeerChat
	[len()-1] = 
	 = [:len()-1]
	* = 

	return , true
}

// Pop returns last element of slice (if exists) and deletes it.
func ( *PeerChatArray) () ( PeerChat,  bool) {
	if  == nil || len(*) < 1 {
		return
	}

	 := *
	 = [len()-1]
	 = [:len()-1]
	* = 

	return , true
}

// PeerChannelArray is adapter for slice of PeerChannel.
type PeerChannelArray []PeerChannel

// Sort sorts slice of PeerChannel.
func ( PeerChannelArray) ( func(,  PeerChannel) bool) PeerChannelArray {
	sort.Slice(, func(,  int) bool {
		return ([], [])
	})
	return 
}

// SortStable sorts slice of PeerChannel.
func ( PeerChannelArray) ( func(,  PeerChannel) bool) PeerChannelArray {
	sort.SliceStable(, func(,  int) bool {
		return ([], [])
	})
	return 
}

// Retain filters in-place slice of PeerChannel.
func ( PeerChannelArray) ( func( PeerChannel) bool) PeerChannelArray {
	 := 0
	for ,  := range  {
		if () {
			[] = 
			++
		}
	}
	 = [:]

	return 
}

// First returns first element of slice (if exists).
func ( PeerChannelArray) () ( PeerChannel,  bool) {
	if len() < 1 {
		return
	}
	return [0], true
}

// Last returns last element of slice (if exists).
func ( PeerChannelArray) () ( PeerChannel,  bool) {
	if len() < 1 {
		return
	}
	return [len()-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func ( *PeerChannelArray) () ( PeerChannel,  bool) {
	if  == nil || len(*) < 1 {
		return
	}

	 := *
	 = [0]

	// Delete by index from SliceTricks.
	copy([0:], [1:])
	var  PeerChannel
	[len()-1] = 
	 = [:len()-1]
	* = 

	return , true
}

// Pop returns last element of slice (if exists) and deletes it.
func ( *PeerChannelArray) () ( PeerChannel,  bool) {
	if  == nil || len(*) < 1 {
		return
	}

	 := *
	 = [len()-1]
	 = [:len()-1]
	* = 

	return , true
}