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

// DocumentClassArray is adapter for slice of DocumentClass.
type DocumentClassArray []DocumentClass

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

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

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

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

// DocumentEmptyToMap collects only DocumentEmpty constructors to map.
func ( DocumentClassArray) () map[int64]*DocumentEmpty {
	 := make(map[int64]*DocumentEmpty, len())
	.FillDocumentEmptyMap()
	return 
}

// AsDocumentEmpty returns copy with only DocumentEmpty constructors.
func ( DocumentClassArray) () ( DocumentEmptyArray) {
	for ,  := range  {
		,  := .(*DocumentEmpty)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

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

// DocumentToMap collects only Document constructors to map.
func ( DocumentClassArray) () map[int64]*Document {
	 := make(map[int64]*Document, len())
	.FillDocumentMap()
	return 
}

// AsDocument returns copy with only Document constructors.
func ( DocumentClassArray) () ( DocumentArray) {
	for ,  := range  {
		,  := .(*Document)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

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

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

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

	return 
}

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

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

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

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

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

// DocumentEmptyArray is adapter for slice of DocumentEmpty.
type DocumentEmptyArray []DocumentEmpty

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

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

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

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

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

// DocumentArray is adapter for slice of Document.
type DocumentArray []Document

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

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

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

// SortByDate sorts slice of Document by Date.
func ( DocumentArray) () DocumentArray {
	return .Sort(func(,  Document) bool {
		return .GetDate() < .GetDate()
	})
}

// SortStableByDate sorts slice of Document by Date.
func ( DocumentArray) () DocumentArray {
	return .SortStable(func(,  Document) bool {
		return .GetDate() < .GetDate()
	})
}

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

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