list

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ArrayListCapacity int = 100
)

Functions

This section is empty.

Types

type Filterfunc added in v0.1.9

type Filterfunc[deepCopy IDeepCopy[T], T any] func(data deepCopy) bool

type IBaseList added in v0.1.9

type IBaseList[deepCopy IDeepCopy[T], T any] interface {
	// Add adds data to the end of the list
	Add(data deepCopy) (resultIndex int)
	// Remove removes data from the list and returns error if the data is not found
	Remove(data deepCopy) (removedIndex int, err error)
	// RemoveAtIndex removes data at the index, if the index is not valid then returns error
	RemoveAtIndex(index int) (data deepCopy, err error)
	// Count return the count of elements in the list
	Count() int
	// Get gets data at the index, if index is not valid then it returns error
	Get(index int) (data deepCopy, err error)
	// Set updates the data at the index, if index is not valid then returns error
	Set(index int, data deepCopy) error
	// Find helps to get the first occourance if the data that matches the input and returns index
	// if index is -1 then the data is not found
	Find(data deepCopy) (index int)
	// RemoveAll function removes al elements for which the f returns true,
	// this also returns all elements removed
	RemoveAll(f Filterfunc[deepCopy, T]) []deepCopy
}

type IDeepCopy

type IDeepCopy[T any] interface {
	*T
	// contains filtered or unexported methods
}

type IIndexedItratorList

type IIndexedItratorList[deepCopy IDeepCopy[T], T any] interface {
	IItratorList[deepCopy, T]
	// FindByIndexedKey get the first occourance if the data that matches according to the filter func and also returns index,
	// this helps in fast search ad it will do a binary search on the indexKey
	// this is similar to Non-Clustered Index in database
	FindByIndexedKey(indexKey string, key string) (data T, index int)
	// FindByIndexedKey get the first occourance if the data that matches according to the filter func and also returns index,
	// this helps in fast search ad it will do a binary search on the indexKey
	// this is similar to Non-Clustered Index in database
	FilterByIndexedKey(indexKey string, key string) []T
}

type IItratorList

type IItratorList[deepCopy IDeepCopy[T], T any] interface {
	IList[deepCopy, T]
	// Filter helps to get the all data that matches according to the filter func and also returns index
	Filter(f Filterfunc[deepCopy, T]) []deepCopy
	// DeepCopy this is used to create a copy of the list
	DeepCopy() []deepCopy
}

func InitArrayList added in v0.1.7

func InitArrayList[deepCopy IDeepCopy[T], T any](data ...deepCopy) IItratorList[deepCopy, T]

type IList

type IList[deepCopy IDeepCopy[T], T any] interface {
	IBaseList[deepCopy, T]
	// AddAtIndex adds data to the index in the list and shifts all data to right
	// if the index is out of bound then return error
	AddAtIndex(index int, data deepCopy) (err error)
}

func InitSingleLinkedList

func InitSingleLinkedList[deepCopy IDeepCopy[T], T any]() IList[deepCopy, T]

type ISortedItratorList added in v0.1.8

type ISortedItratorList[deepCopy IDeepCopy[T], T any] interface {
	IBaseList[deepCopy, T]
	// Filter helps to get the all data that matches according to the filter func and also returns index
	Filter(f Filterfunc[deepCopy, T]) []deepCopy
	// DeepCopy this is used to create a copy of the list
	DeepCopy() []deepCopy
}

func InitSortedList added in v0.1.8

func InitSortedList[deepCopy IDeepCopy[T], T any](lessFn Less[deepCopy, T]) ISortedItratorList[deepCopy, T]

type Less added in v0.1.8

type Less[deepCopy IDeepCopy[T], T any] func(left, right deepCopy) bool

type Mapfunc added in v0.1.9

type Mapfunc[T1 any, deepCopy1 IDeepCopy[T1], T2 any, deepCopy2 IDeepCopy[T2]] func(data deepCopy1) deepCopy2

Jump to

Keyboard shortcuts

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