//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{}
)

// UserClassArray is adapter for slice of UserClass.
type UserClassArray []UserClass

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

// SortByID sorts slice of UserClass by ID.
func ( UserClassArray) () UserClassArray {
	return .Sort(func(,  UserClass) bool {
		return .GetID() < .GetID()
	})
}

// SortStableByID sorts slice of UserClass by ID.
func ( UserClassArray) () UserClassArray {
	return .SortStable(func(,  UserClass) bool {
		return .GetID() < .GetID()
	})
}

// FillUserEmptyMap fills only UserEmpty constructors to given map.
func ( UserClassArray) ( map[int64]*UserEmpty) {
	for ,  := range  {
		,  := .(*UserEmpty)
		if ! {
			continue
		}
		[.GetID()] = 
	}
}

// UserEmptyToMap collects only UserEmpty constructors to map.
func ( UserClassArray) () map[int64]*UserEmpty {
	 := make(map[int64]*UserEmpty, len())
	.FillUserEmptyMap()
	return 
}

// AsUserEmpty returns copy with only UserEmpty constructors.
func ( UserClassArray) () ( UserEmptyArray) {
	for ,  := range  {
		,  := .(*UserEmpty)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

// FillUserMap fills only User constructors to given map.
func ( UserClassArray) ( map[int64]*User) {
	for ,  := range  {
		,  := .(*User)
		if ! {
			continue
		}
		[.GetID()] = 
	}
}

// UserToMap collects only User constructors to map.
func ( UserClassArray) () map[int64]*User {
	 := make(map[int64]*User, len())
	.FillUserMap()
	return 
}

// AsUser returns copy with only User constructors.
func ( UserClassArray) () ( UserArray) {
	for ,  := range  {
		,  := .(*User)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

// FillNotEmptyMap fills only NotEmpty constructors to given map.
func ( UserClassArray) ( map[int64]*User) {
	for ,  := range  {
		,  := .AsNotEmpty()
		if ! {
			continue
		}
		[.GetID()] = 
	}
}

// NotEmptyToMap collects only NotEmpty constructors to map.
func ( UserClassArray) () map[int64]*User {
	 := make(map[int64]*User, len())
	.FillNotEmptyMap()
	return 
}

// AppendOnlyNotEmpty appends only NotEmpty constructors to
// given slice.
func ( UserClassArray) ( []*User) []*User {
	for ,  := range  {
		,  := .AsNotEmpty()
		if ! {
			continue
		}
		 = append(, )
	}

	return 
}

// AsNotEmpty returns copy with only NotEmpty constructors.
func ( UserClassArray) () ( []*User) {
	return .AppendOnlyNotEmpty()
}

// FirstAsNotEmpty returns first element of slice (if exists).
func ( UserClassArray) () ( *User,  bool) {
	,  := .First()
	if ! {
		return
	}
	return .AsNotEmpty()
}

// LastAsNotEmpty returns last element of slice (if exists).
func ( UserClassArray) () ( *User,  bool) {
	,  := .Last()
	if ! {
		return
	}
	return .AsNotEmpty()
}

// PopFirstAsNotEmpty returns element of slice (if exists).
func ( *UserClassArray) () ( *User,  bool) {
	,  := .PopFirst()
	if ! {
		return
	}
	return .AsNotEmpty()
}

// PopAsNotEmpty returns element of slice (if exists).
func ( *UserClassArray) () ( *User,  bool) {
	,  := .Pop()
	if ! {
		return
	}
	return .AsNotEmpty()
}

// UserEmptyArray is adapter for slice of UserEmpty.
type UserEmptyArray []UserEmpty

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

// SortByID sorts slice of UserEmpty by ID.
func ( UserEmptyArray) () UserEmptyArray {
	return .Sort(func(,  UserEmpty) bool {
		return .GetID() < .GetID()
	})
}

// SortStableByID sorts slice of UserEmpty by ID.
func ( UserEmptyArray) () UserEmptyArray {
	return .SortStable(func(,  UserEmpty) bool {
		return .GetID() < .GetID()
	})
}

// FillMap fills constructors to given map.
func ( UserEmptyArray) ( map[int64]UserEmpty) {
	for ,  := range  {
		[.GetID()] = 
	}
}

// ToMap collects constructors to map.
func ( UserEmptyArray) () map[int64]UserEmpty {
	 := make(map[int64]UserEmpty, len())
	.FillMap()
	return 
}

// UserArray is adapter for slice of User.
type UserArray []User

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

// SortByID sorts slice of User by ID.
func ( UserArray) () UserArray {
	return .Sort(func(,  User) bool {
		return .GetID() < .GetID()
	})
}

// SortStableByID sorts slice of User by ID.
func ( UserArray) () UserArray {
	return .SortStable(func(,  User) bool {
		return .GetID() < .GetID()
	})
}

// FillMap fills constructors to given map.
func ( UserArray) ( map[int64]User) {
	for ,  := range  {
		[.GetID()] = 
	}
}

// ToMap collects constructors to map.
func ( UserArray) () map[int64]User {
	 := make(map[int64]User, len())
	.FillMap()
	return 
}