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

// InputDocumentClassArray is adapter for slice of InputDocumentClass.
type InputDocumentClassArray []InputDocumentClass

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

// AsInputDocument returns copy with only InputDocument constructors.
func ( InputDocumentClassArray) () ( InputDocumentArray) {
	for ,  := range  {
		,  := .(*InputDocument)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

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

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

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

	return 
}

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

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

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

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

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

// InputDocumentArray is adapter for slice of InputDocument.
type InputDocumentArray []InputDocument

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

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

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

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

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