main.go 841 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package lists
  2. import (
  3. "surdeus.su/core/gods"
  4. "surdeus.su/core/gods/stacks"
  5. )
  6. // The interface all the lists must implement.
  7. type List[V any] interface {
  8. gods.Container[V]
  9. stacks.Stack[V]
  10. // Like push in stacks.
  11. Put(...V)
  12. // Get length of the list.
  13. Len() int
  14. // Get the value by index.
  15. Get(int) V
  16. // Delete the value by index.
  17. Del(int)
  18. // Change already existing value.
  19. Set(int, V)
  20. // Add the values to the end of the list.
  21. Add(...V)
  22. // Insert the value before the specified index.
  23. InsB(int, ...V)
  24. // Ansert values after the specified index.
  25. InsA(int, ...V)
  26. // Swap elements by indexes specified in arguments.
  27. Swap(i, j int)
  28. // Return channel with all the values.
  29. Chan() chan V
  30. // The sort function that gets the Less function as argument
  31. // and sorts the list corresponding to it.
  32. Sort(gods.LessFunc[V])
  33. }