Put function is change/update the value in array with the index and new value
(index int, element any)
| 26 | |
| 27 | // Put function is change/update the value in array with the index and new value |
| 28 | func (da *DynamicArray) Put(index int, element any) error { |
| 29 | err := da.CheckRangeFromIndex(index) |
| 30 | |
| 31 | if err != nil { |
| 32 | return err |
| 33 | } |
| 34 | |
| 35 | da.ElementData[index] = element |
| 36 | |
| 37 | return nil |
| 38 | } |
| 39 | |
| 40 | // Add function is add new element to our array |
| 41 | func (da *DynamicArray) Add(element any) { |