generics

package
v0.0.51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomSlice added in v0.0.47

type CustomSlice interface {
	// interface restricting the type to the custom slices
	// that are defined within this document.
	SearchableStringSlice | SearchableInt32Slice | SearchableInt64Slice | SearchableIntSlice
}

type Int32Object

type Int32Object interface {
	// generic definition of an int32 object. this
	// interface includes int32 and int32 slices.
	SearchableInt32 | SearchableInt32Slice
}

type Int64Object

type Int64Object interface {
	// generic definition of an int64 object. this
	// interface includes int64 and int64 slices.
	SearchableInt64 | SearchableInt64Slice
}

type IntObject added in v0.0.46

type IntObject interface {
	// generic definition of an int object. this
	// interface includes int and int slices.
	SearchableInt | SearchableIntSlice
}

type SearchObject

type SearchObject[T SearchType, O SearchObjectTypes] interface {
	// function designed to append to a
	// SearchObjectType.
	Append(T) O
	// function designed to clear/reset the object
	// to the value it is when initialized. for
	// slices, it will remove all elements from
	// the slice, it will zero out a string, and
	// set numbers to 0.
	//
	// example call:
	//
	//	searchableint32 = searchableint32.Clear()
	Clear() O
	// function that determines whether the
	// value passed in is within the searcher
	// object. if it does not exist, an error
	// will be returned.
	In(T) error
	// function that determines the index of
	// the passed in value. if it is not found
	// an error will be returned along with a
	// negative number.
	IndexOf(T) (int, error)
	// function designed to get the length of the object.
	Length() int
	// function designed to return the string
	// representstion of the given object.
	String() string
}

generic definition of a SearchObject. this outlines the functions a struct must have for it to be considered this type of generic.

type SearchObjectTypes

type SearchObjectTypes interface {
	// interface outlining the various types of SearchObjects
	// that exist. this is used in the definition of the
	// SearchObject interface to make it generic.
	StringTypes | Int32Object | Int64Object | IntObject
}

type SearchType

type SearchType interface {
	// type definition outlining the type of search
	// available for the given object. this will apply
	// to SearchableStrings, SearchableStringSlices,
	// SearchableInt32s, SearchableInt32Slices, SearchableInt64s,
	// and SearchableInt64Slices.
	//
	// this allows all custom types listed above to share
	// the same basic functionality and interfaces.
	int | int32 | int64 | string
}

type SearchableInt added in v0.0.46

type SearchableInt int

definition of a custom type of int that fits a SearchableObject definition.

func NewSearchableInt added in v0.0.46

func NewSearchableInt() *SearchableInt

function designed to create and initialize a new searchable int.

func (SearchableInt) Append added in v0.0.46

func (si SearchableInt) Append(target int) (newslice SearchableInt)

function designed to append a new int to an existing slice of int.

func (SearchableInt) Clear added in v0.0.48

func (si SearchableInt) Clear() SearchableInt

function designed to reset the object to the state it is when initialized. this will set numbers to zero.

func (SearchableInt) In added in v0.0.46

func (si SearchableInt) In(target int) (err error)

function designed to determine if the given int is in the int.

func (SearchableInt) IndexOf added in v0.0.46

func (si SearchableInt) IndexOf(target int) (idx int, err error)

function designed to get the index of the given int in the int.

func (SearchableInt) Length added in v0.0.47

func (si SearchableInt) Length() (count int)

function designed to return the length of the object. this will loop throught the object and iterate a counter, returning the number of elements present in the string representation of the object.

func (SearchableInt) String added in v0.0.46

func (si SearchableInt) String() string

function designed to return the string representation of the given searchable int.

type SearchableInt32

type SearchableInt32 int32

definition of a custom type of int32 that fits a SearchableObject definition.

func NewSearchableInt32 added in v0.0.46

func NewSearchableInt32() *SearchableInt32

function designed to create and initialize a new searchable int32.

func (SearchableInt32) Append added in v0.0.46

func (si32 SearchableInt32) Append(target int32) (newslice SearchableInt32)

function designed to append a new int32 to an existing slice of int32.

func (SearchableInt32) Clear added in v0.0.48

func (si32 SearchableInt32) Clear() SearchableInt32

function designed to reset the object to the state it is when initialized. this will set numbers to zero.

func (SearchableInt32) In added in v0.0.46

func (si32 SearchableInt32) In(target int32) (err error)

function designed to determine if the given int32 is in the int32.

func (SearchableInt32) IndexOf added in v0.0.46

func (si32 SearchableInt32) IndexOf(target int32) (idx int, err error)

function designed to get the index of the given int32 in the int32.

func (SearchableInt32) Length added in v0.0.47

func (si32 SearchableInt32) Length() (count int)

function designed to return the length of the object. this will loop throught the object and iterate a counter, returning the number of elements present in the string representation of the object.

func (SearchableInt32) String added in v0.0.46

func (si32 SearchableInt32) String() string

function designed to return the string representation of the given searchable int32.

type SearchableInt32Slice

type SearchableInt32Slice []int32

definition of a custom type of int32 slice that fits a SearchableObject definition.

func NewSearchableInt32Slice added in v0.0.46

func NewSearchableInt32Slice() *SearchableInt32Slice

function designed to create and initialize a new searchable int32 slice.

func (SearchableInt32Slice) Append

func (si32 SearchableInt32Slice) Append(target int32) (newslice SearchableInt32Slice)

function designed to append a new int32 to an existing slice of int32.

func (SearchableInt32Slice) Clear added in v0.0.48

function designed to clear the slice and return an empty slice.

func (SearchableInt32Slice) Combine added in v0.0.47

func (si32 SearchableInt32Slice) Combine(target SearchableInt32Slice) (newslice SearchableInt32Slice)

function designed to combine two SearchableInt32Slices. this will append the entire target slice to the one it it being combined with.

func (SearchableInt32Slice) In

func (si32 SearchableInt32Slice) In(target int32) (err error)

function designed to determine if the given int32 is in the int32 slice.

func (SearchableInt32Slice) IndexOf

func (si32 SearchableInt32Slice) IndexOf(target int32) (idx int, err error)

function designed to get the index of the given int32 in the int32 slice.

func (SearchableInt32Slice) Length added in v0.0.47

func (si32 SearchableInt32Slice) Length() (count int)

function designed to return the length of the array/slice. this will loop throught the slice and iterate a counter, returning the number of elements present in the slice.

func (SearchableInt32Slice) String

func (si32 SearchableInt32Slice) String() string

function designed to return the string representation of the given int32 slice.

type SearchableInt64

type SearchableInt64 int64

definition of a custom type of int64 that fits a SearchableObject definition.

func NewSearchableInt64 added in v0.0.46

func NewSearchableInt64() *SearchableInt64

function designed to create and initialize a new searchable int64.

func (SearchableInt64) Append added in v0.0.46

func (si64 SearchableInt64) Append(target int64) (newslice SearchableInt64)

function designed to append a new int64 to an existing slice of int64.

func (SearchableInt64) Clear added in v0.0.48

func (si64 SearchableInt64) Clear() SearchableInt64

function designed to reset the object to the state it is when initialized. this will set numbers to zero.

func (SearchableInt64) In added in v0.0.46

func (si64 SearchableInt64) In(target int64) (err error)

function designed to determine if the given int64 is in the int64.

func (SearchableInt64) IndexOf added in v0.0.46

func (si64 SearchableInt64) IndexOf(target int64) (idx int, err error)

function designed to get the index of the given int64 in the int64.

func (SearchableInt64) Length added in v0.0.47

func (si64 SearchableInt64) Length() (count int)

function designed to return the length of the object. this will loop throught the object and iterate a counter, returning the number of elements present in the string representation of the object.

func (SearchableInt64) String added in v0.0.46

func (si64 SearchableInt64) String() string

function designed to return the string representation of the given searchable int64.

type SearchableInt64Slice

type SearchableInt64Slice []int64

definition of a custom type of int32 slice that fits a SearchableObject definition.

func NewSearchableInt64Slice added in v0.0.46

func NewSearchableInt64Slice() *SearchableInt64Slice

function designed to create and initialize a new searchable int64 slice.

func (SearchableInt64Slice) Append

func (si64 SearchableInt64Slice) Append(target int64) (newslice SearchableInt64Slice)

function designed to append a new int64 to an existing slice of int64.

func (SearchableInt64Slice) Clear added in v0.0.48

function designed to clear the slice and return an empty slice.

func (SearchableInt64Slice) Combine added in v0.0.47

func (si64 SearchableInt64Slice) Combine(target SearchableInt64Slice) (newslice SearchableInt64Slice)

function designed to combine two SearchableInt64Slices. this will append the entire target slice to the one it it being combined with.

func (SearchableInt64Slice) In

func (si64 SearchableInt64Slice) In(target int64) (err error)

function designed to determine if the given int64 is in the int64 slice.

func (SearchableInt64Slice) IndexOf

func (si64 SearchableInt64Slice) IndexOf(target int64) (idx int, err error)

function designed to get the index of the given int64 in the int64 slice.

func (SearchableInt64Slice) Length added in v0.0.47

func (si64 SearchableInt64Slice) Length() (count int)

function designed to return the length of the array/slice. this will loop throught the slice and iterate a counter, returning the number of elements present in the slice.

func (SearchableInt64Slice) String

func (si64 SearchableInt64Slice) String() string

function designed to return the string representation of the given int64 slice.

type SearchableIntSlice

type SearchableIntSlice []int

definition of a custom type of int slice that fits a SearchableObject definition.

func (SearchableIntSlice) Append

func (si SearchableIntSlice) Append(target int) (newslice SearchableIntSlice)

function designed to append a new int to an existing slice of int.

func (SearchableIntSlice) Clear added in v0.0.48

function designed to clear the slice and return an empty slice.

func (SearchableIntSlice) Combine added in v0.0.47

func (si SearchableIntSlice) Combine(target SearchableIntSlice) (newslice SearchableIntSlice)

function designed to combine two SearchableIntSlices. this will append the entire target slice to the one it it being combined with.

func (SearchableIntSlice) In

func (si SearchableIntSlice) In(target int) (err error)

function designed to determine if the given int is in the int slice.

func (SearchableIntSlice) IndexOf

func (si SearchableIntSlice) IndexOf(target int) (idx int, err error)

function designed to get the index of the given int in the int slice.

func (SearchableIntSlice) Length added in v0.0.47

func (si SearchableIntSlice) Length() (count int)

function designed to return the length of the array/slice. this will loop throught the slice and iterate a counter, returning the number of elements present in the slice.

func (SearchableIntSlice) String

func (si SearchableIntSlice) String() string

function designed to return the string representation of the given searchable int slice.

type SearchableString

type SearchableString string

definition of a custom type of string that fits a SearchableObject definition.

func NewSearchableString added in v0.0.46

func NewSearchableString() *SearchableString

function designed to create and initialize a new searchable string.

func (SearchableString) Append

func (ss SearchableString) Append(target rune) (newslice SearchableString)

function designed to append a string to the string.

func (SearchableString) AppendString

func (ss SearchableString) AppendString(target string) (newslice SearchableString)

function designed to append a string to the string.

func (SearchableString) Clear added in v0.0.48

function designed to reset the object to the state it is when initialized. this will set strings to "".

func (SearchableString) In

func (ss SearchableString) In(target rune) (err error)

function designed to search through a searchablestring and determine if the target rune (char) is in it.

func (SearchableString) IndexOf

func (ss SearchableString) IndexOf(target rune) (idx int, err error)

function designed to find the index of a given char.

func (SearchableString) Length added in v0.0.47

func (ss SearchableString) Length() (count int)

function designed to return the length of the object. this will loop throught the object and iterate a counter, returning the number of elements present in the string representation of the object.

func (SearchableString) String

func (ss SearchableString) String() string

type SearchableStringSlice

type SearchableStringSlice []string

definition of a custom type of string slice that fits a SearchableObject definition.

func NewSearchableStringSlice added in v0.0.46

func NewSearchableStringSlice() *SearchableStringSlice

function designed to create and initialize a new searchable string slice.

func (SearchableStringSlice) Append

func (ss SearchableStringSlice) Append(target string) (newslice SearchableStringSlice)

function designed to append a string to the string slice.

func (SearchableStringSlice) AppendChar

func (ss SearchableStringSlice) AppendChar(target rune) (newslice SearchableStringSlice)

function designed to append a char to the string slice.

func (SearchableStringSlice) Clear added in v0.0.48

function designed to clear the slice and return an empty slice.

func (SearchableStringSlice) Combine added in v0.0.47

function designed to combine two SearchableStringSlice. this will append the entire target slice to the one it it being combined with.

func (SearchableStringSlice) In

func (ss SearchableStringSlice) In(target string) (err error)

function designed to search through a searchablestring and determine if the target string is in it.

func (SearchableStringSlice) IndexOf

func (ss SearchableStringSlice) IndexOf(target string) (idx int, err error)

function designed to find the index of a given string.

func (SearchableStringSlice) Length added in v0.0.47

func (ss SearchableStringSlice) Length() (count int)

function designed to return the length of the array/slice. this will loop throught the slice and iterate a counter, returning the number of elements present in the slice.

func (SearchableStringSlice) Sort

function designed to sort the SearchableStringSlice alphabetically.

func (SearchableStringSlice) String

func (ss SearchableStringSlice) String() string

function designed to return the string representation of the SearchableStringSlice.

type SpecialSlice added in v0.0.47

type SpecialSlice[T CustomSlice] interface {
	// function designed to combine two custom slices.
	// this will append the target object to the object
	// calling the Combine function.
	Combine(T) T
}

generic definition of a slice that has certain, custom functions attached to it.

type StringTypes

type StringTypes interface {
	// generic used to restrict the types that are attached
	// to this type to string and string slice.
	SearchableString | SearchableStringSlice
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL