Documentation ¶
Index ¶
- Constants
- type Iterator
- type List
- func (list *List) Add(values ...interface{})
- func (list *List) All(f func(index int, value interface{}) bool) bool
- func (list *List) Any(f func(index int, value interface{}) bool) bool
- func (list *List) Clear()
- func (list *List) Contains(values ...interface{}) bool
- func (list *List) Each(f func(index int, value interface{}))
- func (list *List) Empty() bool
- func (list *List) Find(f func(index int, value interface{}) bool) (int, interface{})
- func (list *List) Get(index int) (interface{}, bool)
- func (list *List) Insert(index int, values ...interface{})
- func (list *List) Iterator() Iterator
- func (list *List) Map(f func(index int, value interface{}) interface{}) *List
- func (list *List) Remove(index int)
- func (list *List) Select(f func(index int, value interface{}) bool) *List
- func (list *List) Size() int
- func (list *List) Sort(comparator utils.Comparator)
- func (list *List) String() string
- func (list *List) Swap(i, j int)
- func (list *List) Values() []interface{}
Constants ¶
const ( GROWTH_FACTOR = float32(2.0) // growth by 100% SHRINK_FACTOR = float32(0.25) // shrink when size is 25% of capacity (0 means never shrink) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
func (*Iterator) Index ¶
Returns the current element's index. Does not modify the state of the iterator.
type List ¶
type List struct {
// contains filtered or unexported fields
}
func (*List) Add ¶
func (list *List) Add(values ...interface{})
Appends a value at the end of the list
func (*List) All ¶
Passes each element of the collection to the given function and returns true if the function returns true for all elements.
func (*List) Any ¶
Passes each element of the collection to the given function and returns true if the function ever returns true for any element.
func (*List) Contains ¶
Check if elements (one or more) are present in the set. All elements have to be present in the set for the method to return true. Performance time complexity of n^2. Returns true if no arguments are passed at all, i.e. set is always super-set of empty set.
func (*List) Each ¶
Calls the given function once for each element, passing that element's index and value.
func (*List) Find ¶
Passes each element of the container to the given function and returns the first (index,value) for which the function is true or -1,nil otherwise if no element matches the criteria.
func (*List) Get ¶
Returns the element at index. Second return parameter is true if index is within bounds of the array and array is not empty, otherwise false.
func (*List) Insert ¶
Inserts values at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Does not do anything if position is negative or bigger than list's size Note: position equal to list's size is valid, i.e. append.
func (*List) Map ¶
Invokes the given function once for each element and returns a container containing the values returned by the given function.
func (*List) Select ¶
Returns a new container containing all elements for which the given function returns a true value.
func (*List) Sort ¶
func (list *List) Sort(comparator utils.Comparator)
Sorts values (in-place) using timsort.