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 any)
- func (da *DynamicArray) CheckRangeFromIndex(index int) error
- func (da *DynamicArray) Get(index int) (any, error)
- func (da *DynamicArray) GetData() []any
- func (da *DynamicArray) IsEmpty() bool
- func (da *DynamicArray) NewCapacity()
- func (da *DynamicArray) Put(index int, element any) 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 any)
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) (any, error)
Get function is return one element with the index of array
func (*DynamicArray) GetData ¶
func (da *DynamicArray) GetData() []any
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 any) 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