gods/lists/main.go

42 lines
850 B
Go
Raw Normal View History

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