Documentation
¶
Overview ¶
Package dynamicarray A dynamic array is quite similar to a regular array, but its Size is modifiable during program runtime, very similar to how a slice in Go works. The implementation is for educational purposes and explains how one might go about implementing their own version of slices.
For more details check out those links below here: GeeksForGeeks article : https://www.geeksforgeeks.org/how-do-dynamic-arrays-work/ Go blog: https://blog.golang.org/slices-intro Go blog: https://blog.golang.org/slices authors [Wesllhey Holanda](https://github.com/wesllhey), [Milad](https://github.com/miraddo) see dynamicarray.go, dynamicarray_test.go
Index ¶
- type DynamicArray
- func (da *DynamicArray) Add(element interface{})
- func (da *DynamicArray) CheckRangeFromIndex(index int) error
- func (da *DynamicArray) Get(index int) (interface{}, error)
- func (da *DynamicArray) GetData() []interface{}
- func (da *DynamicArray) IsEmpty() bool
- func (da *DynamicArray) NewCapacity()
- func (da *DynamicArray) Put(index int, element interface{}) error
- func (da *DynamicArray) Remove(index int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynamicArray ¶
DynamicArray structure
func (*DynamicArray) Add ¶
func (da *DynamicArray) Add(element interface{})
Add function is add new element to our array
func (*DynamicArray) CheckRangeFromIndex ¶
func (da *DynamicArray) CheckRangeFromIndex(index int) error
CheckRangeFromIndex function it will check the range from the index
func (*DynamicArray) Get ¶
func (da *DynamicArray) Get(index int) (interface{}, error)
Get function is return one element with the index of array
func (*DynamicArray) GetData ¶
func (da *DynamicArray) GetData() []interface{}
GetData function return all value of array
func (*DynamicArray) IsEmpty ¶
func (da *DynamicArray) IsEmpty() bool
IsEmpty function is check that the array has value or not
func (*DynamicArray) NewCapacity ¶
func (da *DynamicArray) NewCapacity()
NewCapacity function increase the Capacity
func (*DynamicArray) Put ¶
func (da *DynamicArray) Put(index int, element interface{}) error
Put function is change/update the value in array with the index and new value
func (*DynamicArray) Remove ¶
func (da *DynamicArray) Remove(index int) error
Remove function is remove an element with the index