dynamicarray

package
v3.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamicArray

type DynamicArray struct {
	Size        int
	Capacity    int
	ElementData []any
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL