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

// MessageClassArray is adapter for slice of MessageClass.
type MessageClassArray []MessageClass

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

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

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

// FillMessageEmptyMap fills only MessageEmpty constructors to given map.
func ( MessageClassArray) ( map[int]*MessageEmpty) {
	for ,  := range  {
		,  := .(*MessageEmpty)
		if ! {
			continue
		}
		[.GetID()] = 
	}
}

// MessageEmptyToMap collects only MessageEmpty constructors to map.
func ( MessageClassArray) () map[int]*MessageEmpty {
	 := make(map[int]*MessageEmpty, len())
	.FillMessageEmptyMap()
	return 
}

// AsMessageEmpty returns copy with only MessageEmpty constructors.
func ( MessageClassArray) () ( MessageEmptyArray) {
	for ,  := range  {
		,  := .(*MessageEmpty)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

// FillMessageMap fills only Message constructors to given map.
func ( MessageClassArray) ( map[int]*Message) {
	for ,  := range  {
		,  := .(*Message)
		if ! {
			continue
		}
		[.GetID()] = 
	}
}

// MessageToMap collects only Message constructors to map.
func ( MessageClassArray) () map[int]*Message {
	 := make(map[int]*Message, len())
	.FillMessageMap()
	return 
}

// AsMessage returns copy with only Message constructors.
func ( MessageClassArray) () ( MessageArray) {
	for ,  := range  {
		,  := .(*Message)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

// FillMessageServiceMap fills only MessageService constructors to given map.
func ( MessageClassArray) ( map[int]*MessageService) {
	for ,  := range  {
		,  := .(*MessageService)
		if ! {
			continue
		}
		[.GetID()] = 
	}
}

// MessageServiceToMap collects only MessageService constructors to map.
func ( MessageClassArray) () map[int]*MessageService {
	 := make(map[int]*MessageService, len())
	.FillMessageServiceMap()
	return 
}

// AsMessageService returns copy with only MessageService constructors.
func ( MessageClassArray) () ( MessageServiceArray) {
	for ,  := range  {
		,  := .(*MessageService)
		if ! {
			continue
		}
		 = append(, *)
	}

	return 
}

// FillNotEmptyMap fills only NotEmpty constructors to given map.
func ( MessageClassArray) ( map[int]NotEmptyMessage) {
	for ,  := range  {
		,  := .AsNotEmpty()
		if ! {
			continue
		}
		[.GetID()] = 
	}
}

// NotEmptyToMap collects only NotEmpty constructors to map.
func ( MessageClassArray) () map[int]NotEmptyMessage {
	 := make(map[int]NotEmptyMessage, len())
	.FillNotEmptyMap()
	return 
}

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

	return 
}

// AsNotEmpty returns copy with only NotEmpty constructors.
func ( MessageClassArray) () ( []NotEmptyMessage) {
	return .AppendOnlyNotEmpty()
}

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

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

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

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

// MessageEmptyArray is adapter for slice of MessageEmpty.
type MessageEmptyArray []MessageEmpty

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

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

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

// FillMap fills constructors to given map.
func ( MessageEmptyArray) ( map[int]MessageEmpty) {
	for ,  := range  {
		[.GetID()] = 
	}
}

// ToMap collects constructors to map.
func ( MessageEmptyArray) () map[int]MessageEmpty {
	 := make(map[int]MessageEmpty, len())
	.FillMap()
	return 
}

// MessageArray is adapter for slice of Message.
type MessageArray []Message

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

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

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

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

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

// FillMap fills constructors to given map.
func ( MessageArray) ( map[int]Message) {
	for ,  := range  {
		[.GetID()] = 
	}
}

// ToMap collects constructors to map.
func ( MessageArray) () map[int]Message {
	 := make(map[int]Message, len())
	.FillMap()
	return 
}

// MessageServiceArray is adapter for slice of MessageService.
type MessageServiceArray []MessageService

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

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

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

	return 
}

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

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

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

	 := *
	 = [0]

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

	return , true
}

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

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

	return , true
}

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

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

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

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

// FillMap fills constructors to given map.
func ( MessageServiceArray) ( map[int]MessageService) {
	for ,  := range  {
		[.GetID()] = 
	}
}

// ToMap collects constructors to map.
func ( MessageServiceArray) () map[int]MessageService {
	 := make(map[int]MessageService, len())
	.FillMap()
	return 
}