gods/lists/main.go
2023-11-12 12:33:46 +03:00

40 lines
849 B
Go

package lists
import (
"github.com/omnipunk/gods"
"github.com/omnipunk/gods/stacks"
)
// The interface all the lists must implement.
type List[V any] interface {
gods.Container[V]
stacks.Stack[V]
// Like push in stacks.
Put(...V)
// Get length of the list.
Len() int
// Get the value by index.
Get(int) V
// Delete the value by index.
Del(int)
// Change already existing value.
Set(int, V)
// Add the values to the end of the list.
Add(...V)
// Insert the value before the specified index.
InsB(int, ...V)
// Ansert values after the specified index.
InsA(int, ...V)
// Swap elements by indexes specified in arguments.
Swap(i, j int)
// Return channel with all the values.
Chan() chan V
// The sort function that gets the Less function as argument
// and sorts the list corresponding to it.
Sort(gods.LessFunc[V])
}