arraylist

package
v0.0.0-...-08da8a6 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package arraylist contains an array list implementation following the java's implementation of its ArrayList. It bascially starts with an slice of capcity of 10, and dynamically extend the size of this slice as the array list grow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayList

type ArrayList struct {
	Comparator shared.Comparator
	// contains filtered or unexported fields
}

func New

func New(comparator shared.Comparator) *ArrayList

New creates a new array list with given comparator

func (*ArrayList) Add

func (a *ArrayList) Add(index int, element interface{}) error

Add adds an element in front of the given index in the array list

func (*ArrayList) Append

func (a *ArrayList) Append(element interface{})

Append appends an element to the end of the array list

func (*ArrayList) Clear

func (a *ArrayList) Clear()

Clear clears the array list

func (*ArrayList) Contains

func (a *ArrayList) Contains(element interface{}) bool

Contains checks whether the array list contains an element

func (*ArrayList) Get

func (a *ArrayList) Get(index int) (interface{}, error)

Get gets element at given index

func (*ArrayList) GetIndexOf

func (a *ArrayList) GetIndexOf(element interface{}) (int, error)

GetIndexOf gets index of an element

func (*ArrayList) GetSize

func (a *ArrayList) GetSize() int

GetSize gets the size of the array list

func (*ArrayList) Iterator

func (a *ArrayList) Iterator() *Iterator

Iterator gets the iterator

func (*ArrayList) Remove

func (a *ArrayList) Remove(element interface{}) error

Remove removes an element from the array list

func (*ArrayList) RemoveAt

func (a *ArrayList) RemoveAt(index int) error

RemoveAt removes an element at given index

func (*ArrayList) Set

func (a *ArrayList) Set(index int, element interface{}) error

Set sets element at given index

func (*ArrayList) ToSlice

func (a *ArrayList) ToSlice() []interface{}

ToSlice returns the array list as a slice

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

Iterator defines an iterator for the array list

func (*Iterator) Begin

func (i *Iterator) Begin()

Begin resets the iterator to the beginning, use Next() to move to its first element.

func (*Iterator) End

func (i *Iterator) End()

End moves the iterator to the end, use Prev() to move to its last element.

func (*Iterator) Next

func (i *Iterator) Next() bool

Next moves the iterator to the next value, return false if there's no next value.

func (*Iterator) Prev

func (i *Iterator) Prev() bool

Prev moves the iterator to the previous value, return false if there's no previous value.

func (*Iterator) Value

func (i *Iterator) Value() interface{}

Value gets the value of element the iterator is pointing at.

Jump to

Keyboard shortcuts

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