Documentation
¶
Index ¶
- type ArrayList
- func (al *ArrayList[T]) Add(element T)
- func (al *ArrayList[T]) AddAll(elements ...T)
- func (al *ArrayList[T]) AddAt(index int64, element T) error
- func (al *ArrayList[T]) Clear()
- func (al *ArrayList[T]) Clone() List[T]
- func (al *ArrayList[T]) Contains(element T) bool
- func (al *ArrayList[T]) ContainsAll(elements ...T) bool
- func (al *ArrayList[T]) DescendingIterator() iterator.Iterator[T]
- func (al *ArrayList[T]) Filter(predicate predicate.Predicate[T]) List[T]
- func (al *ArrayList[T]) FindFirst(predicate predicate.Predicate[T]) (T, error)
- func (al *ArrayList[T]) Get(index int64) (T, error)
- func (al *ArrayList[T]) IndexOf(element T) int64
- func (al *ArrayList[T]) IsEmpty() bool
- func (al *ArrayList[T]) Iterator() iterator.Iterator[T]
- func (al *ArrayList[T]) LastIndexOf(element T) int64
- func (al *ArrayList[T]) Remove(element T) error
- func (al *ArrayList[T]) RemoveAll(l ...T) error
- func (al *ArrayList[T]) RemoveAt(index int64) (T, error)
- func (al *ArrayList[T]) RemoveIf(predicate predicate.Predicate[T]) error
- func (al *ArrayList[T]) RemoveRange(from, to int64) error
- func (al *ArrayList[T]) Replace(old, new T) error
- func (al *ArrayList[T]) ReplaceAll(uo operator.UnaryOperator[T])
- func (al *ArrayList[T]) RetainAll(l ...T) error
- func (al *ArrayList[T]) Set(index int64, element T) (T, error)
- func (al *ArrayList[T]) Size() int64
- func (al *ArrayList[T]) Sort(c comparator.Comparator[T])
- func (al *ArrayList[T]) SubList(start int64, end int64) (List[T], error)
- type LinkedList
- func (ll *LinkedList[T]) Add(element T)
- func (ll *LinkedList[T]) AddAll(elements ...T)
- func (ll *LinkedList[T]) AddAt(index int64, element T) error
- func (ll *LinkedList[T]) AddFirst(element T)
- func (ll *LinkedList[T]) AddLast(element T)
- func (ll *LinkedList[T]) Clear()
- func (ll *LinkedList[T]) Clone() List[T]
- func (ll *LinkedList[T]) Contains(element T) bool
- func (ll *LinkedList[T]) ContainsAll(elements ...T) bool
- func (ll *LinkedList[T]) DescendingIterator() iterator.Iterator[T]
- func (ll *LinkedList[T]) Filter(predicate predicate.Predicate[T]) List[T]
- func (ll *LinkedList[T]) FindFirst(predicate predicate.Predicate[T]) (T, error)
- func (ll *LinkedList[T]) Get(index int64) (T, error)
- func (ll *LinkedList[T]) GetFirst() (T, error)
- func (ll *LinkedList[T]) GetLast() (T, error)
- func (ll *LinkedList[T]) IndexOf(element T) int64
- func (ll *LinkedList[T]) IsEmpty() bool
- func (ll *LinkedList[T]) Iterator() iterator.Iterator[T]
- func (ll *LinkedList[T]) LastIndexOf(element T) int64
- func (ll *LinkedList[T]) Remove(element T) error
- func (ll *LinkedList[T]) RemoveAll(elements ...T) error
- func (ll *LinkedList[T]) RemoveAt(index int64) (T, error)
- func (ll *LinkedList[T]) RemoveFirst() (T, error)
- func (ll *LinkedList[T]) RemoveFirstOccurrence(element T) error
- func (ll *LinkedList[T]) RemoveLast() (T, error)
- func (ll *LinkedList[T]) RemoveLastOccurrence(element T) (bool, error)
- func (ll *LinkedList[T]) Replace(old, new T) error
- func (ll *LinkedList[T]) ReplaceAll(uo operator.UnaryOperator[T])
- func (ll *LinkedList[T]) RetainAll(elements ...T) error
- func (ll *LinkedList[T]) Set(index int64, element T) (T, error)
- func (ll *LinkedList[T]) Size() int64
- func (ll *LinkedList[T]) Sort(c comparator.Comparator[T])
- func (ll *LinkedList[T]) SubList(start int64, end int64) (List[T], error)
- func (ll *LinkedList[T]) ToArrayList() *ArrayList[T]
- type List
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayList ¶
type ArrayList[T comparable] struct { // contains filtered or unexported fields }
func NewArrayList ¶
func NewArrayList[T comparable](elements ...T) *ArrayList[T]
func (*ArrayList[T]) AddAll ¶
func (al *ArrayList[T]) AddAll(elements ...T)
TODO: SHOULD IT FAIL WHEN ARGS ARE EMPTY?
func (*ArrayList[T]) Clear ¶
func (al *ArrayList[T]) Clear()
TODO: SHOULD WE JUST RESET THE SIZE OR ALSO RE-INITIALIZE THE DATA TO CLAIM UNUSED SPACE?
func (*ArrayList[T]) ContainsAll ¶
func (*ArrayList[T]) DescendingIterator ¶
func (*ArrayList[T]) LastIndexOf ¶
func (*ArrayList[T]) RemoveRange ¶
func (*ArrayList[T]) ReplaceAll ¶
func (al *ArrayList[T]) ReplaceAll(uo operator.UnaryOperator[T])
func (*ArrayList[T]) Sort ¶
func (al *ArrayList[T]) Sort(c comparator.Comparator[T])
type LinkedList ¶
type LinkedList[T comparable] struct { // contains filtered or unexported fields }
func NewLinkedList ¶
func NewLinkedList[T comparable](elements ...T) *LinkedList[T]
func (*LinkedList[T]) Add ¶
func (ll *LinkedList[T]) Add(element T)
func (*LinkedList[T]) AddAll ¶
func (ll *LinkedList[T]) AddAll(elements ...T)
TODO: SHOULD IT FAIL WHEN ARGS ARE EMPTY
func (*LinkedList[T]) AddAt ¶
func (ll *LinkedList[T]) AddAt(index int64, element T) error
func (*LinkedList[T]) AddFirst ¶
func (ll *LinkedList[T]) AddFirst(element T)
func (*LinkedList[T]) AddLast ¶
func (ll *LinkedList[T]) AddLast(element T)
func (*LinkedList[T]) Clear ¶
func (ll *LinkedList[T]) Clear()
func (*LinkedList[T]) Clone ¶
func (ll *LinkedList[T]) Clone() List[T]
func (*LinkedList[T]) Contains ¶
func (ll *LinkedList[T]) Contains(element T) bool
func (*LinkedList[T]) ContainsAll ¶
func (ll *LinkedList[T]) ContainsAll(elements ...T) bool
func (*LinkedList[T]) DescendingIterator ¶
func (ll *LinkedList[T]) DescendingIterator() iterator.Iterator[T]
func (*LinkedList[T]) Filter ¶
func (ll *LinkedList[T]) Filter(predicate predicate.Predicate[T]) List[T]
func (*LinkedList[T]) FindFirst ¶
func (ll *LinkedList[T]) FindFirst(predicate predicate.Predicate[T]) (T, error)
TODO: ADD TEST
func (*LinkedList[T]) Get ¶
func (ll *LinkedList[T]) Get(index int64) (T, error)
func (*LinkedList[T]) GetFirst ¶
func (ll *LinkedList[T]) GetFirst() (T, error)
func (*LinkedList[T]) GetLast ¶
func (ll *LinkedList[T]) GetLast() (T, error)
func (*LinkedList[T]) IndexOf ¶
func (ll *LinkedList[T]) IndexOf(element T) int64
func (*LinkedList[T]) IsEmpty ¶
func (ll *LinkedList[T]) IsEmpty() bool
func (*LinkedList[T]) Iterator ¶
func (ll *LinkedList[T]) Iterator() iterator.Iterator[T]
func (*LinkedList[T]) LastIndexOf ¶
func (ll *LinkedList[T]) LastIndexOf(element T) int64
TODO: OPTIMIZE, MAKE IT SHORT
func (*LinkedList[T]) Remove ¶
func (ll *LinkedList[T]) Remove(element T) error
func (*LinkedList[T]) RemoveAll ¶
func (ll *LinkedList[T]) RemoveAll(elements ...T) error
TODO: SHOULD IT FAIL OR NOT WHEN ARG LIST IS EMPTY
func (*LinkedList[T]) RemoveAt ¶
func (ll *LinkedList[T]) RemoveAt(index int64) (T, error)
func (*LinkedList[T]) RemoveFirst ¶
func (ll *LinkedList[T]) RemoveFirst() (T, error)
func (*LinkedList[T]) RemoveFirstOccurrence ¶
func (ll *LinkedList[T]) RemoveFirstOccurrence(element T) error
func (*LinkedList[T]) RemoveLast ¶
func (ll *LinkedList[T]) RemoveLast() (T, error)
func (*LinkedList[T]) RemoveLastOccurrence ¶
func (ll *LinkedList[T]) RemoveLastOccurrence(element T) (bool, error)
func (*LinkedList[T]) Replace ¶
func (ll *LinkedList[T]) Replace(old, new T) error
func (*LinkedList[T]) ReplaceAll ¶
func (ll *LinkedList[T]) ReplaceAll(uo operator.UnaryOperator[T])
func (*LinkedList[T]) RetainAll ¶
func (ll *LinkedList[T]) RetainAll(elements ...T) error
func (*LinkedList[T]) Set ¶
func (ll *LinkedList[T]) Set(index int64, element T) (T, error)
func (*LinkedList[T]) Size ¶
func (ll *LinkedList[T]) Size() int64
func (*LinkedList[T]) Sort ¶
func (ll *LinkedList[T]) Sort(c comparator.Comparator[T])
TODO: CHANGE TO LINKED LIST MERGE SORT
func (*LinkedList[T]) SubList ¶
func (ll *LinkedList[T]) SubList(start int64, end int64) (List[T], error)
TODO: OPTIMIZE
func (*LinkedList[T]) ToArrayList ¶
func (ll *LinkedList[T]) ToArrayList() *ArrayList[T]
type List ¶
type List[T comparable] interface { /* adds an element in the list if the list is empty and the type was never set then the elements type becomes the type of the list. params: e: element to add to list. returns: error: returns type mismatch error when the element to add is of different then what was set for list. */ Add(e T) /* adds an element at an specified index in the list the index has to be between 0 and (size of list - 1) if the list is empty and type was never set and the index is 0 then the elements type becomes the type of the list. params: i: index at which element is supposed to be added. e: element to add to list. returns: error: returns indexOutOfBoundError if the index is < 0 or >= size or type mismatch error when the element to add is of different then what was set for list. */ AddAt(i int64, e T) error /* adds all the element specified in the list if the list is empty and type was never set then first elements type becomes the type of the list. params: l: list of elements to be added to list. returns: error: returns generic error if all element are not of same type or type mismatch error when the any of the element to add is of different then what was set for list. */ AddAll(l ...T) /* clears the content of list. */ Clear() /* return an new object that is the clone of current list or an error if the clone fails. */ Clone() List[T] /* use to check if the element is present in the list. params: e: the element to be searched in list. returns: bool: returns true if the element is present in the list. error: returns generic error if list is empty type mismatch error when the element to search is of different then what was set for list. */ Contains(e T) bool /* use to check if multiple elements are present in the list. params: l: the elements to be checked in list. returns: bool: returns true if all the elements are present in the list, else false. error: returns generic error if list is empty type mismatch error when the any of the element to search is of different then what was set for list. */ ContainsAll(l ...T) bool /* returns an element at a specified index. params: i: the index corresponding to which element has to be returned. returns: interface: returns the element at the specified index if the index is valid. */ Get(i int64) (T, error) Filter(predicate predicate.Predicate[T]) List[T] FindFirst(predicate predicate.Predicate[T]) (T, error) /* returns the index of an specified element. params: e: the element whose index is desired. returns: int: the index of the element if present else -1. error: returns generic error if the list is empty or type mismatch error if the element to be searched is of different type than what was set for the list, or generic error if the element is not found. */ IndexOf(e T) int64 /* returns true if the list is empty else false. */ IsEmpty() bool /* returns an iterator for the list. */ Iterator() iterator.Iterator[T] /* returns a descending iterator for the list. */ DescendingIterator() iterator.Iterator[T] /* returns the last index for the element. params: e: the element whose last index is desired. returns: int: the index of the last element if present else -1. error: returns generic error if the list is empty or type mismatch error if the element to be searched is of different type than what was set for the list, or generic error if the element is not found. */ LastIndexOf(e T) int64 /* use to remove and element from the list. params: e: the element to be removed. returns: bool: return true if the element was removed else false. error: generic error is the list is empty or, type mismatch error if the element to be removed is of different type than what was set for the list, or generic error if the element was not found in the list. */ Remove(e T) error /* use to remove and element at a specified index. params: i: the index corresponding to which element has to be removed. returns: bool: return true if the element was removed at the specified index else false. error: generic error is the list is empty or, indexOutOfBound error if the specified index is invalid. */ RemoveAt(i int64) (T, error) /* use to remove all the elements specified, if the element is not present in the list it is ignored. params: l: elements which are supposed to be removed. returns: bool: returns true if the elements were removed, else false. error: returns generic error if the list is empty, or type mismatch error if any element is of different type then what was set for the list. */ RemoveAll(l ...T) error /* replace and given value with another one. params: old: the value to be replaced. new: the value to replace with. error: return error if the list is empty or if the element is not found or if type mismatch. */ Replace(old, new T) error /* runs and function over all the element in the list, eg inc operator to increment all the elements of an integer list. params: uo: the function to be applied on every element of the list. */ ReplaceAll(uo operator.UnaryOperator[T]) /* use to retain all the elements specified, other elements are removed for the list, if the element is not present in the list it is ignored. params: l: elements to retain. returns: bool: returns true if only element specified were retained else false. error: returns generic error if the list is empty, or type mismatch error if any element is of different type then what was set for the list. */ RetainAll(l ...T) error /* use to set an given element at a specified index. params: i: index at which the element has to be set. e: the element to set. returns: interface: returns the element if set was successful else nil. error: returns generic error if the list is empty or, return indexOutOfBound error if the specified index is invalid or, return type mismatch error if the elements type is different than one set for the list. */ Set(i int64, e T) (T, error) /* returns the count of number of elements in the list. */ Size() int64 /* sorts the list based on the comparator specified. */ Sort(c comparator.Comparator[T]) /* returns an sublist starting for index s to index e-1 params: s: the start index for sublist. e: the end index for sublist, end index is 1 less than specified. returns: List: the sublist starting form s to e-1 from original list. error: returns generic error is end index is smaller than start or, returns indexOutOfBound error if either s or e is invalid index or, returns error if creation or adding to list fails */ SubList(s int64, e int64) (List[T], error) }
Click to show internal directories.
Click to hide internal directories.