12345678910111213141516171819202122232425262728293031323334353637 |
- package node
- func arrayDelete[T any](stack *[]T, pos int) (T, bool) {
-
- var result T
-
- if pos < 0 || pos > len(*stack) {
- return result, false
- }
- result = (*stack)[pos]
- copy((*stack)[pos:], (*stack)[pos+1:])
-
-
- *stack = (*stack)[:len(*stack)-1]
- return result, true
- }
- func arrayPop[T any](stack *[]T, count int) bool {
-
- if count < 0 || count > len(*stack) {
- return false
- }
- copy((*stack)[0:], (*stack)[count:])
-
-
- *stack = (*stack)[:len(*stack)-count]
- return true
- }
|