MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Put

Method Put

structure/dynamicarray/dynamicarray.go:28–38  ·  view source on GitHub ↗

Put function is change/update the value in array with the index and new value

(index int, element any)

Source from the content-addressed store, hash-verified

26
27// Put function is change/update the value in array with the index and new value
28func (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
41func (da *DynamicArray) Add(element any) {

Callers 1

TestDynamicArrayFunction · 0.95

Calls 1

CheckRangeFromIndexMethod · 0.95

Tested by 1

TestDynamicArrayFunction · 0.76