(index int, value interface{})
| 64 | } |
| 65 | |
| 66 | func (s *Stack) Insert(index int, value interface{}) bool { |
| 67 | if index > s.Size()-1 || index < 0 { |
| 68 | return false |
| 69 | } |
| 70 | |
| 71 | lastArray := make([]interface{}, 0) |
| 72 | lastArray = append(lastArray, s.array[index:]...) |
| 73 | s.array = s.array[:index] |
| 74 | s.array = append(s.array, value) |
| 75 | s.array = append(s.array, lastArray...) |
| 76 | return true |
| 77 | } |
| 78 | |
| 79 | func (s *Stack) Top(i int) interface{} { |
| 80 | stackLen := s.Size() |