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 ¶
- type ArrayList
- func (a *ArrayList) Add(index int, element interface{}) error
- func (a *ArrayList) Append(element interface{})
- func (a *ArrayList) Clear()
- func (a *ArrayList) Contains(element interface{}) bool
- func (a *ArrayList) Get(index int) (interface{}, error)
- func (a *ArrayList) GetIndexOf(element interface{}) (int, error)
- func (a *ArrayList) GetSize() int
- func (a *ArrayList) Iterator() *Iterator
- func (a *ArrayList) Remove(element interface{}) error
- func (a *ArrayList) RemoveAt(index int) error
- func (a *ArrayList) Set(index int, element interface{}) error
- func (a *ArrayList) ToSlice() []interface{}
- type Iterator
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) Append ¶
func (a *ArrayList) Append(element interface{})
Append appends an element to the end of the array list
func (*ArrayList) GetIndexOf ¶
GetIndexOf gets index of an element
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 ¶
Next moves the iterator to the next value, return false if there's no next value.