{"modulePath":"github.com/ulovecode/gods","version":"v1.12.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package arraylist\n\nPackage arraylist implements the array list.\n\nStructure is not thread safe.\n\nReference: [https://en.wikipedia.org/wiki/List\\_%28abstract\\_data\\_type%29](https://en.wikipedia.org/wiki/List_%28abstract_data_type%29)\n\n## Types\n\n```go\ntype Iterator struct {\n\t// contains filtered or unexported fields\n}\n```\nIterator holding the iterator's state\n\n```go\nfunc (iterator *Iterator) Begin()\n```\nBegin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.\n\n```go\nfunc (iterator *Iterator) End()\n```\nEnd moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.\n\n```go\nfunc (iterator *Iterator) First() bool\n```\nFirst moves the iterator to the first element and returns true if there was a first element in the container. If First() returns true, then first element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Index() int\n```\nIndex returns the current element's index. Does not modify the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Last() bool\n```\nLast moves the iterator to the last element and returns true if there was a last element in the container. If Last() returns true, then last element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Next() bool\n```\nNext moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's index and value can be retrieved by Index() and Value(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Prev() bool\n```\nPrev moves the iterator to the previous element and returns true if there was a previous element in the container. If Prev() returns true, then previous element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Value() interface{}\n```\nValue returns the current element's value. Does not modify the state of the iterator.\n\n```go\ntype List struct {\n\t// contains filtered or unexported fields\n}\n```\nList holds the elements in a slice\n\n```go\nfunc New(values ...interface{}) *List\n```\nNew instantiates a new list and adds the passed values, if any, to the list\n\n```go\nfunc (list *List) Add(values ...interface{})\n```\nAdd appends a value at the end of the list\n\n```go\nfunc (list *List) All(f func(index int, value interface{}) bool) bool\n```\nAll passes each element of the collection to the given function and returns true if the function returns true for all elements.\n\n```go\nfunc (list *List) Any(f func(index int, value interface{}) bool) bool\n```\nAny passes each element of the collection to the given function and returns true if the function ever returns true for any element.\n\n```go\nfunc (list *List) Clear()\n```\nClear removes all elements from the list.\n\n```go\nfunc (list *List) Contains(values ...interface{}) bool\n```\nContains checks 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.\n\n```go\nfunc (list *List) Each(f func(index int, value interface{}))\n```\nEach calls the given function once for each element, passing that element's index and value.\n\n```go\nfunc (list *List) Empty() bool\n```\nEmpty returns true if list does not contain any elements.\n\n```go\nfunc (list *List) Find(f func(index int, value interface{}) bool) (int, interface{})\n```\nFind 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.\n\n```go\nfunc (list *List) FromJSON(data []byte) error\n```\nFromJSON populates list's elements from the input JSON representation.\n\n```go\nfunc (list *List) Get(index int) (interface{}, bool)\n```\nGet 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.\n\n```go\nfunc (list *List) IndexOf(value interface{}) int\n```\nIndexOf returns index of provided element\n\n```go\nfunc (list *List) Insert(index int, values ...interface{})\n```\nInsert 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.\n\n```go\nfunc (list *List) Iterator() Iterator\n```\nIterator returns a stateful iterator whose values can be fetched by an index.\n\n```go\nfunc (list *List) Map(f func(index int, value interface{}) interface{}) *List\n```\nMap invokes the given function once for each element and returns a container containing the values returned by the given function.\n\n```go\nfunc (list *List) Remove(index int)\n```\nRemove removes the element at the given index from the list.\n\n```go\nfunc (list *List) Select(f func(index int, value interface{}) bool) *List\n```\nSelect returns a new container containing all elements for which the given function returns a true value.\n\n```go\nfunc (list *List) Set(index int, value interface{})\n```\nSet the value at specified index 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.\n\n```go\nfunc (list *List) Size() int\n```\nSize returns number of elements within the list.\n\n```go\nfunc (list *List) Sort(comparator utils.Comparator)\n```\nSort sorts values (in-place) using.\n\n```go\nfunc (list *List) String() string\n```\nString returns a string representation of container\n\n```go\nfunc (list *List) Swap(i, j int)\n```\nSwap swaps the two values at the specified positions.\n\n```go\nfunc (list *List) ToJSON() ([]byte, error)\n```\nToJSON outputs the JSON representation of list's elements.\n\n```go\nfunc (list *List) Values() []interface{}\n```\nValues returns all elements in the list.\n\n","path":"github.com/ulovecode/gods/lists/arraylist","name":"arraylist","synopsis":"Package arraylist implements the array list.","isRedistributable":true}
