Class IList<E>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int TRANSFER_COPY  
      private static int TRANSFER_MOVE  
      private static int TRANSFER_REMOVE  
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      IList()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, E elem)
      Inserts the specified element at the specified position in this list.
      boolean add​(E elem)  
      boolean addAll​(int index, java.util.Collection<? extends E> coll)
      Inserts all of the elements in the specified collection into this list, starting at the specified position.
      boolean addAll​(int index, IList<? extends E> list)
      Inserts all of the elements in the specified list into this list, starting at the specified position.
      boolean addAll​(java.util.Collection<? extends E> coll)
      Adds all of the elements in the specified collection into this list.
      boolean addAll​(IList<? extends E> list)
      Adds all of the elements in the specified list into this list.
      boolean addArray​(int index, E... elems)
      Inserts the specified elements into this list, starting at the specified position.
      boolean addArray​(int index, E[] elems, int offset, int length)  
      boolean addArray​(E... elems)
      Adds all specified elements into this list.
      boolean addArray​(E[] elems, int offset, int length)  
      void addFirst​(E elem)
      See Deque.addFirst(E)
      boolean addIfAbsent​(E elem)
      Add elements to the end if it is not already contained in the list.
      void addLast​(E elem)
      See Deque.addLast(E)
      boolean addMult​(int index, int len, E elem)
      Inserts element multiple time to list, starting at the specified position.
      boolean addMult​(int len, E elem)
      Adds element multiple time to list.
      java.util.Deque<E> asDeque()  
      protected IListable<? extends E> asIListable​(java.util.Collection<? extends E> coll)
      Return correct IListable for passed collection.
      abstract <K> int binarySearch​(int index, int len, K key, java.util.Comparator<? super K> comparator)
      Searches the specified range for an object using the binary search algorithm.
      <K> int binarySearch​(K key, java.util.Comparator<? super K> comparator)
      Searches the specified range for an object using the binary* search algorithm.
      abstract int capacity()
      Returns capacity of this list.
      protected void checkIndex​(int index)
      Check that specified index is valid for getting/setting elements.
      protected void checkIndexAdd​(int index)
      Check that specified index is valid for adding elements.
      protected void checkLength​(int len)
      Check that specified length is valid (>= 0).
      protected void checkLengths​(int len1, int len2)
      Check that both specified lengths are valid (>= 0) and equal.
      protected void checkNonNull​(java.lang.Object obj)
      Check that object is not null.
      protected void checkRange​(int index, int len)
      Check that specified range is valid.
      void clear()  
      IList<E> clone()
      Returns a shallow copy of this list.
      boolean contains​(java.lang.Object elem)  
      boolean containsAll​(java.util.Collection<?> coll)  
      boolean containsAny​(java.util.Collection<?> coll)
      Returns true if any of the elements of the specified collection is contained in the list.
      boolean containsIf​(java.util.function.Predicate<? super E> predicate)
      Determines whether the list contains a matching element.
      abstract IList<E> copy()
      Returns a shallow copy of this list.
      void copy​(int srcIndex, int dstIndex, int len)
      Copy specified elements.
      int count​(E elem)
      Counts how many times the specified element is contained in the list.
      int countIf​(java.util.function.Predicate<? super E> predicate)
      Counts how many elements in the list match the predicate.
      IList<E> crop()
      Returns a copy this list but without elements.
      java.util.Iterator<E> descendingIterator()
      See Deque.descendingIterator()
      protected abstract boolean doAdd​(int index, E elem)
      Helper method for adding an element to the list.
      protected boolean doAddAll​(int index, IListable<? extends E> list)
      Helper method for adding multiple elements to the list.
      protected abstract void doAssign​(IList<E> that)
      Assign this list the content of the that list.
      protected void doClear()  
      protected abstract void doClone​(IList<E> that)
      Initialize this object after the bitwise copy has been made by Object.clone().
      protected abstract IList<E> doCreate​(int capacity)
      Create list with specified capacity.
      protected <T> T[] doCreateArray​(java.lang.Class<T> clazz, int len)
      Create array.
      protected abstract void doEnsureCapacity​(int minCapacity)
      Increases the capacity of this list instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
      protected abstract E doGet​(int index)
      Helper method for getting an element from the list.
      protected <T> void doGetAll​(T[] array, int index, int len)
      Helper method to fill the specified elements in an array.
      protected int doIndexOf​(java.lang.Object elem, int fromIndex)
      Returns the index of the first occurrence of the specified element in this list, starting the search at the specified position.
      protected int doIndexOfIf​(java.util.function.Predicate<? super E> predicate, int fromIndex)
      Returns the index of the first element which matches the specified predicate in this list, starting the search at the specified position.
      protected void doInitAll​(IListable<? extends E> list)  
      protected int doLastIndexOf​(java.lang.Object elem, int fromIndex)
      Returns the index of the last occurrence of the specified element in this list, starting the search at the specified position.
      protected int doLastIndexOfIf​(java.util.function.Predicate<? super E> predicate, int fromIndex)
      Returns the index of the last occurrence of the specified element in this list, starting the search at the specified position.
      protected void doModify()
      This method is called internally before elements are allocated or freed.
      protected void doPutAll​(int index, IListable<? extends E> list)  
      protected abstract E doRemove​(int index)
      Helper method to remove an element.
      protected void doRemoveAll​(int index, int len)
      Remove specified range of elements from list.
      protected boolean doReplace​(int index, int len, IListable<? extends E> list)  
      protected abstract E doReSet​(int index, E elem)
      Sets an element at specified position.
      protected void doRotate​(int index, int len, int distance)
      Internal method to rotate specified elements in the list.
      protected abstract E doSet​(int index, E elem)
      Helper method for setting an element in the list.
      (package private) void doTransfer​(int transferMode, int srcIndex, int srcLen, IList<? super E> dst, int dstIndex, int dstLen)  
      (package private) void doTransferSwap​(int srcIndex, IList<E> dst, int dstIndex, int len)  
      void drag​(int srcIndex, int dstIndex, int len)
      Drag specified elements.
      E element()
      See Deque.element()
      void ensureCapacity​(int minCapacity)
      Increases the capacity of this instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
      boolean equals​(java.lang.Object obj)  
      (package private) static boolean equalsElem​(java.lang.Object elem1, java.lang.Object elem2)
      Helper function to check two elements stored in the list for equality.
      IList<E> extract​(int index, int len)
      Removes specified range of elements from list and return them.
      IList<E> extractIf​(java.util.function.Predicate<? super E> predicate)
      Removes and returns all elements in the list which match the predicate.
      void fill​(E elem)
      Fill list.
      IList<E> filter​(java.util.function.Predicate<? super E> predicate)
      Create a new list by applying the specified filter to all elements.
      <R> IList<R> filterMap​(java.util.function.Predicate<E> filter, java.util.function.Function<E,​R> func)
      Create a new list by applying the specified filter first and then the mapping function to all elements selected.
      <R,​C extends java.util.Collection<R>>
      IList<R>
      flatMap​(java.util.function.Function<E,​C> func)
      Create a new list by applying the specified mapping function to all elements.
      E get​(int index)
      Return element at specified position
      IList<E> getAll​(int index, int len)
      Returns specified range of elements from list.
      IList<E> getAll​(E elem)
      Returns all elements in the list equal to the specified element.
      protected abstract E getDefaultElem()  
      java.util.Set<E> getDistinct()
      Returns distinct elements in the list.
      E getFirst()
      Returns the first element stored in the collection.
      E getFirstOrNull()
      Returns the first element stored in the collection.
      E getIf​(java.util.function.Predicate<? super E> predicate)
      Get first element in the list which matches the predicate.
      E getLast()
      See Deque.getLast()
      E getLastOrNull()
      Returns the last element stored in the list.
      E getSingle()
      Returns the only element stored in the collection.
      E getSingleOrNull()
      Returns the only element stored in the collection or null if the collection is empty.
      int hashCode()  
      (package private) static int hashCodeElem​(java.lang.Object elem)
      Helper method to calculate hash code of a element stored in the list.
      abstract IList<E> immutableList()
      Returns an immutable copy of this list.
      int indexOf​(java.lang.Object elem)  
      int indexOf​(java.lang.Object elem, int fromIndex)
      Returns the index of the first occurrence of the specified element in this list, starting the search at the specified position.
      int indexOfIf​(java.util.function.Predicate<? super E> predicate)
      Returns the index of the first element which matches the specified predicate in this list.
      int indexOfIf​(java.util.function.Predicate<? super E> predicate, int fromIndex)
      Returns the index of the first element which matches the specified predicate in this list, starting the search at the specified position.
      void initAll​(java.util.Collection<? extends E> coll)
      Initializes the list so it will afterwards only contain the elements of the collection.
      void initAll​(IList<? extends E> list)
      Initializes the list so it will afterwards only contain the elements of the collection.
      void initArray​(E... elems)
      Initializes the list so it will afterwards only contain the elements of the array.
      void initMult​(int len, E elem)
      Initializes the list so it will afterwards have a size of len and contain only the element elem.
      boolean isEmpty()  
      abstract boolean isReadOnly()
      Returns true if this list is either unmodifiable or immutable, false otherwise.
      java.util.Iterator<E> iterator()  
      int lastIndexOf​(java.lang.Object elem)  
      int lastIndexOf​(java.lang.Object elem, int fromIndex)
      Returns the index of the last occurrence of the specified element in this list, starting the search at the specified position.
      int lastIndexOfIf​(java.util.function.Predicate<? super E> predicate)
      Returns the index of the last element which matches the specified predicate in this list.
      int lastIndexOfIf​(java.util.function.Predicate<? super E> predicate, int fromIndex)
      Returns the index of the last occurrence of the specified element in this list, starting the search at the specified position.
      java.util.ListIterator<E> listIterator()  
      java.util.ListIterator<E> listIterator​(int index)  
      <R> IList<R> map​(java.util.function.Function<E,​R> func)
      Create a new list by applying the specified mapping function to all elements.
      <R> IList<R> mapFilter​(java.util.function.Function<E,​R> func, java.util.function.Predicate<R> filter)
      Create a new list by applying the specified mapping function to all elements and then filtering it.
      void move​(int srcIndex, int dstIndex, int len)
      Move specified elements.
      boolean offer​(E elem)
      See Deque.offer(E)
      boolean offerFirst​(E elem)
      See Deque.offerFirst(E)
      boolean offerLast​(E elem)
      See Deque.offerLast(E)
      E peek()
      See Deque.peek()
      E peekFirst()
      See Deque.peekFirst()
      E peekLast()
      See Deque.peekLast()
      E poll()
      See Deque.poll()
      E pollFirst()
      See Deque.pollFirst()
      E pollLast()
      See Deque.pollLast()
      E pop()
      See Deque.pop()
      void push​(E elem)
      See Deque.push(E)
      E put​(int index, E elem)
      Sets or adds the element.
      void putAll​(int index, java.util.Collection<? extends E> coll)
      Set or add the specified elements.
      void putAll​(int index, IList<? extends E> list)
      Set or add the specified elements.
      void putArray​(int index, E... elems)
      Set or add the specified elements.
      void putMult​(int index, int len, E elem)
      Set or add the specified element multiple times.
      E remove()
      See Deque.remove()
      E remove​(int index)  
      void remove​(int index, int len)
      Remove specified range of elements from list.
      boolean remove​(java.lang.Object elem)  
      IList<E> removeAll​(E elem)
      Removes all equal elements.
      boolean removeAll​(java.util.Collection<?> coll)  
      boolean removeAll​(IList<?> coll)  
      E removeFirst()
      See Deque.removeFirst()
      boolean removeFirstOccurrence​(java.lang.Object elem)
      See Deque.removeFirstOccurrence(java.lang.Object)
      boolean removeIf​(java.util.function.Predicate<? super E> predicate)
      Removes all elements in the list which match the predicate.
      E removeLast()
      See Deque.removeLast()
      boolean removeLastOccurrence​(java.lang.Object elem)
      See Deque.removeLastOccurrence(java.lang.Object)
      protected void replace​(int index, int len, IListable<? extends E> list)  
      void replaceAll​(int index, int len, java.util.Collection<? extends E> coll)
      Replaces the specified range with new elements.
      void replaceAll​(int index, int len, IList<? extends E> list)
      Replaces the specified range with new elements.
      void replaceArray​(int index, int len, E... elems)
      Replaces the specified range with new elements.
      void replaceMult​(int index, int len, int numElems, E elem)
      Replaces the specified range with new elements.
      void resize​(int len, E elem)
      Resizes the list so it will afterwards have a size of len.
      void retain​(int index, int len)
      Retain specified range of elements from list, the other elements are removed.
      boolean retainAll​(java.util.Collection<?> coll)  
      boolean retainAll​(IList<?> coll)  
      boolean retainIf​(java.util.function.Predicate<? super E> predicate)
      Retains all elements in the list which match the predicate.
      void reverse()
      Reverses the order of all elements in the specified list.
      void reverse​(int index, int len)
      Reverses the order of the specified elements in the list.
      void rotate​(int distance)
      Rotate specified elements in the list.
      void rotate​(int index, int len, int distance)
      Rotate specified elements in the list.
      E set​(int index, E elem)  
      void setAll​(int index, java.util.Collection<? extends E> coll)
      Sets the specified elements.
      void setAll​(int index, IList<? extends E> list)
      Sets the specified elements.
      void setArray​(int index, E... elems)
      Sets the specified elements.
      void setArray​(int index, E[] elems, int offset, int length)  
      void setMult​(int index, int len, E elem)
      Sets the element multiple times.
      abstract int size()
      Return size of list
      abstract void sort​(int index, int len, java.util.Comparator<? super E> comparator)
      Sort specified elements in the list using the specified comparator.
      void sort​(java.util.Comparator<? super E> comparator)
      Sort elements in the list using the specified comparator.
      void swap​(int index1, int index2, int len)
      Swap the specified elements in the list.
      java.lang.Object[] toArray()  
      java.lang.Object[] toArray​(int index, int len)
      Returns an array containing the specified elements in this list.
      <T> T[] toArray​(java.lang.Class<T> clazz)
      Returns an array containing the elements in this list.
      <T> T[] toArray​(java.lang.Class<T> clazz, int index, int len)
      Returns an array containing the specified elements in this list.
      (package private) static java.lang.Object[] toArray​(java.util.Collection<?> coll)
      Copies the collection values into an array.
      <T> T[] toArray​(T[] array)  
      <T> T[] toArray​(T[] array, int index, int len)
      Returns an array containing the specified elements in this list.
      java.lang.String toString()  
      static <E> void transferCopy​(IList<E> src, int srcIndex, int srcLen, IList<? super E> dst, int dstIndex, int dstLen)
      Copies elements from one list to another.
      static <E> void transferMove​(IList<E> src, int srcIndex, int srcLen, IList<? super E> dst, int dstIndex, int dstLen)
      Moves elements from one list to another by setting it to null in the source list.
      static <E> void transferRemove​(IList<E> src, int srcIndex, int srcLen, IList<? super E> dst, int dstIndex, int dstLen)
      Moves elements from one list to another by removing it from the source list.
      static <E> void transferSwap​(IList<E> src, int srcIndex, IList<E> dst, int dstIndex, int len)
      Swaps elements from two lists.
      void transform​(java.util.function.UnaryOperator<E> op)
      Change the list by applying the specified operator to all elements.
      IList<E> transformedList​(java.util.function.UnaryOperator<E> op)
      Create a new list by applying the specified transforming operator to all elements.
      abstract void trimToSize()
      An application can use this operation to minimize the storage of an instance.
      abstract IList<E> unmodifiableList()
      Returns an unmodifiable view of this list.
      • Methods inherited from class java.util.AbstractList

        removeRange, subList
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        replaceAll, spliterator, subList
    • Constructor Detail

      • IList

        public IList()
    • Method Detail

      • asDeque

        public java.util.Deque<E> asDeque()
        Returns:
        list of IList as Deque
      • toArray

        static java.lang.Object[] toArray​(java.util.Collection<?> coll)
        Copies the collection values into an array.
        Parameters:
        coll - collection of values
        Returns:
        array containing the collection values
      • copy

        public abstract IList<E> copy()
        Returns a shallow copy of this list. The new list will contain the same elements as the source list, i.e. the elements themselves are not copied. The capacity of the list will be set to the number of elements, i.e. size and capacity are equal. This returned list will be modifiable, i.e. a read-only list will be copied and be modifiable again.
        Specified by:
        copy in interface ICollection<E>
        Returns:
        a modifiable copy of this list
      • clone

        public IList<E> clone()
        Returns a shallow copy of this list. The new list will contain the same elements as the source list, i.e. the elements themselves are not copied. The capacity of the list will be set to the number of elements, i.e. size and capacity are equal. If the list is read-only, the same list is returned without change. Use copy() to .
        Overrides:
        clone in class java.lang.Object
        Returns:
        a modifiable copy of this list
      • crop

        public IList<E> crop()
        Returns a copy this list but without elements. The new list will have the same type as this list.
        Specified by:
        crop in interface ICollection<E>
        Returns:
        an empty copy of this list
      • isReadOnly

        public abstract boolean isReadOnly()
        Returns true if this list is either unmodifiable or immutable, false otherwise.
      • unmodifiableList

        public abstract IList<E> unmodifiableList()
        Returns an unmodifiable view of this list. This method allows modules to provide users with "read-only" access to internal lists, where changes made to the original list are visible as query operations on the returned list "read through" to the specified list. Attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException. If this list is already unmodifiable, it is returned unchanged. See immutableList() to get an immutable copy of a list.
        Returns:
        an unmodifiable view of the specified list
      • immutableList

        public abstract IList<E> immutableList()
        Returns an immutable copy of this list. The returned list is independent from the original list, i.e. changes done later are not seen. Attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException. If this list is already immutable, it is returned unchanged. See unmodifiableList() to get unmodifiable view of a list.
        Returns:
        an immutable copy of the specified list
      • doClone

        protected abstract void doClone​(IList<E> that)
        Initialize this object after the bitwise copy has been made by Object.clone().
        Parameters:
        that - source object
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.List<E>
        Overrides:
        clear in class java.util.AbstractList<E>
      • doClear

        protected void doClear()
      • resize

        public void resize​(int len,
                           E elem)
        Resizes the list so it will afterwards have a size of len. If the list must grow, the specified element elem will be used for filling.
        Parameters:
        len - new size of list
        elem - element which will be used for extending the list
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • size

        public abstract int size()
        Description copied from interface: IListable
        Return size of list
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface IListable<E>
        Specified by:
        size in interface java.util.List<E>
        Specified by:
        size in class java.util.AbstractCollection<E>
      • capacity

        public abstract int capacity()
        Returns capacity of this list. Note that two lists are considered equal even if they have a distinct capacity. Also the capacity can be changed by operations like clone() etc.
        Returns:
        capacity of this list
      • get

        public E get​(int index)
        Description copied from interface: IListable
        Return element at specified position
        Specified by:
        get in interface IListable<E>
        Specified by:
        get in interface java.util.List<E>
        Specified by:
        get in class java.util.AbstractList<E>
      • doGet

        protected abstract E doGet​(int index)
        Helper method for getting an element from the list. This is the only method which really gets an element. Override if you need to validity checks before getting.
        Parameters:
        index - index of element to return
        Returns:
        the element at the specified position in this list
      • doSet

        protected abstract E doSet​(int index,
                                   E elem)
        Helper method for setting an element in the list. This is the only method which really sets an element. Override if you need to validity checks before setting.
        Parameters:
        index - index where element will be placed
        elem - element to set
        Returns:
        old element which was at the position
      • set

        public E set​(int index,
                     E elem)
        Specified by:
        set in interface java.util.List<E>
        Overrides:
        set in class java.util.AbstractList<E>
      • put

        public E put​(int index,
                     E elem)
        Sets or adds the element. If the index is smaller than the size of the list, the existing element is replaced. If the index equals the size of the list, the element is added.
        Parameters:
        index - index where element will be placed
        elem - element to put
        Returns:
        old element if an element was replaced, null if the element was added
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size())
      • doReSet

        protected abstract E doReSet​(int index,
                                     E elem)
        Sets an element at specified position. This method is used internally if existing elements will be moved etc. Override if you need to validity checks.
        Parameters:
        index - index where element will be placed
        elem - element to set
        Returns:
        old element which was at the position
      • getDefaultElem

        protected abstract E getDefaultElem()
      • doModify

        protected void doModify()
        This method is called internally before elements are allocated or freed. Override if you need to validity checks.
      • add

        public boolean add​(E elem)
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.AbstractList<E>
      • add

        public void add​(int index,
                        E elem)
        Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.AbstractList<E>
        Parameters:
        index - index at which the specified element is to be inserted
        elem - element to be inserted
        Throws:
        java.lang.IndexOutOfBoundsException
      • doAdd

        protected abstract boolean doAdd​(int index,
                                         E elem)
        Helper method for adding an element to the list. This is the only method which really adds an element. Override if you need to validity checks before adding.
        Parameters:
        index - index where element should be added (-1 means it is up to the implementation to choose the index)
        elem - element to add
        Returns:
        true if element has been added, false otherwise
      • remove

        public E remove​(int index)
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class java.util.AbstractList<E>
      • doRemove

        protected abstract E doRemove​(int index)
        Helper method to remove an element. This is the only method which really removes an element. Override if you need to validity checks before removing.
        Parameters:
        index - index of element to remove
        Returns:
        removed element
      • ensureCapacity

        public void ensureCapacity​(int minCapacity)
        Increases the capacity of this instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
        Parameters:
        minCapacity - the desired minimum capacity
      • doEnsureCapacity

        protected abstract void doEnsureCapacity​(int minCapacity)
        Increases the capacity of this list instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
        Parameters:
        minCapacity - the desired minimum capacity
      • trimToSize

        public abstract void trimToSize()
        An application can use this operation to minimize the storage of an instance.
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface java.util.List<E>
        Overrides:
        equals in class java.util.AbstractList<E>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<E>
        Specified by:
        hashCode in interface java.util.List<E>
        Overrides:
        hashCode in class java.util.AbstractList<E>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractCollection<E>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface java.util.List<E>
        Overrides:
        isEmpty in class java.util.AbstractCollection<E>
      • equalsElem

        static boolean equalsElem​(java.lang.Object elem1,
                                  java.lang.Object elem2)
        Helper function to check two elements stored in the list for equality.
        Parameters:
        elem1 - first element
        elem2 - second element
        Returns:
        true if the elements are equal, otherwise false
      • hashCodeElem

        static int hashCodeElem​(java.lang.Object elem)
        Helper method to calculate hash code of a element stored in the list.
        Parameters:
        elem - element
        Returns:
        hash code for element
      • count

        public int count​(E elem)
        Counts how many times the specified element is contained in the list.
        Parameters:
        elem - element to count
        Returns:
        count how many times the specified element is contained in the list
      • countIf

        public int countIf​(java.util.function.Predicate<? super E> predicate)
        Description copied from interface: ICollection
        Counts how many elements in the list match the predicate.
        Specified by:
        countIf in interface ICollection<E>
        Parameters:
        predicate - a predicate which returns true for elements to be counted
        Returns:
        count how many elements in the list match the predicate
      • getSingle

        public E getSingle()
        Description copied from interface: ICollection
        Returns the only element stored in the collection. If the collection size is not 1, a NoSuchElementException is thrown.
        Specified by:
        getSingle in interface ICollection<E>
        Returns:
        only element stored in the collection
      • getSingleOrNull

        public E getSingleOrNull()
        Description copied from interface: ICollection
        Returns the only element stored in the collection or null if the collection is empty. If the collection's size is greater than 1, a NoSuchElementException is thrown.
        Specified by:
        getSingleOrNull in interface ICollection<E>
        Returns:
        only element stored in the collection or null if empty
      • getAll

        public IList<E> getAll​(E elem)
        Returns all elements in the list equal to the specified element.
        Parameters:
        elem - element to look for
        Returns:
        all elements in the list equal to the specified element
      • getIf

        public E getIf​(java.util.function.Predicate<? super E> predicate)
        Get first element in the list which matches the predicate.
        Specified by:
        getIf in interface ICollection<E>
        Parameters:
        predicate - a predicate which returns true for elements to be selected
        Returns:
        first element matching the predicate, null otherwise
      • getDistinct

        public java.util.Set<E> getDistinct()
        Returns distinct elements in the list.
        Returns:
        distinct elements in the list
      • map

        public <R> IList<R> map​(java.util.function.Function<E,​R> func)
        Description copied from interface: ICollection
        Create a new list by applying the specified mapping function to all elements. The returned list is of type IList, typically GapList unless the original type is BigList.
        Specified by:
        map in interface ICollection<E>
        Parameters:
        func - mapping function
        Returns:
        created list
      • flatMap

        public <R,​C extends java.util.Collection<R>> IList<R> flatMap​(java.util.function.Function<E,​C> func)
        Description copied from interface: ICollection
        Create a new list by applying the specified mapping function to all elements. The returned list is of type IList, typically GapList unless the original type is BigList.
        Specified by:
        flatMap in interface ICollection<E>
        Parameters:
        func - mapping function
        Returns:
        created list
      • mapFilter

        public <R> IList<R> mapFilter​(java.util.function.Function<E,​R> func,
                                      java.util.function.Predicate<R> filter)
        Description copied from interface: ICollection
        Create a new list by applying the specified mapping function to all elements and then filtering it. The returned list is of type IList, typically GapList unless the original type is BigList.
        Specified by:
        mapFilter in interface ICollection<E>
        Parameters:
        func - mapping function
        filter - filter predicate
        Returns:
        created list
      • filterMap

        public <R> IList<R> filterMap​(java.util.function.Predicate<E> filter,
                                      java.util.function.Function<E,​R> func)
        Description copied from interface: ICollection
        Create a new list by applying the specified filter first and then the mapping function to all elements selected. The returned list is of type IList, typically GapList unless the original type is BigList.
        Specified by:
        filterMap in interface ICollection<E>
        Parameters:
        filter - filter predicate
        func - mapping function
        Returns:
        created list
      • transformedList

        public IList<E> transformedList​(java.util.function.UnaryOperator<E> op)
        Create a new list by applying the specified transforming operator to all elements.
        Parameters:
        op - transforming operator
        Returns:
        created list
      • transform

        public void transform​(java.util.function.UnaryOperator<E> op)
        Change the list by applying the specified operator to all elements.
        Parameters:
        op - transforming operator
      • filter

        public IList<E> filter​(java.util.function.Predicate<? super E> predicate)
        Create a new list by applying the specified filter to all elements. Only element which are allowed by the predicate are copied to the new list.
        Specified by:
        filter in interface ICollection<E>
        Parameters:
        predicate - predicate used for filtering
        Returns:
        created list
      • retainIf

        public boolean retainIf​(java.util.function.Predicate<? super E> predicate)
        Retains all elements in the list which match the predicate.
        Parameters:
        predicate - a predicate which returns true for elements to be retained
        Returns:
        true if the list was changed
      • removeIf

        public boolean removeIf​(java.util.function.Predicate<? super E> predicate)
        Removes all elements in the list which match the predicate.
        Specified by:
        removeIf in interface java.util.Collection<E>
        Parameters:
        predicate - a predicate which returns true for elements to be removed
        Returns:
        true if the list was changed
      • extractIf

        public IList<E> extractIf​(java.util.function.Predicate<? super E> predicate)
        Removes and returns all elements in the list which match the predicate.
        Parameters:
        predicate - predicate
        Returns:
        elements which have been removed from the list
      • indexOf

        public int indexOf​(java.lang.Object elem)
        Specified by:
        indexOf in interface java.util.List<E>
        Overrides:
        indexOf in class java.util.AbstractList<E>
      • indexOf

        public int indexOf​(java.lang.Object elem,
                           int fromIndex)
        Returns the index of the first occurrence of the specified element in this list, starting the search at the specified position. If the element is not found, -1 is returned.
        Parameters:
        elem - element to search for
        fromIndex - start index for search
        Returns:
        the index of the first occurrence of the specified element in this list that is greater than or equal to fromIndex, or -1 if this list does not contain the element
        See Also:
        indexOf(Object)
      • doIndexOf

        protected int doIndexOf​(java.lang.Object elem,
                                int fromIndex)
        Returns the index of the first occurrence of the specified element in this list, starting the search at the specified position. If the element is not found, -1 is returned.
      • indexOfIf

        public int indexOfIf​(java.util.function.Predicate<? super E> predicate)
        Returns the index of the first element which matches the specified predicate in this list. If no such element is not found, -1 is returned.
        Parameters:
        predicate - predicate used to search for the element
        Returns:
        the index of the first element which matches the specified predicate, or -1 if not found
        See Also:
        indexOf(Object)
      • indexOfIf

        public int indexOfIf​(java.util.function.Predicate<? super E> predicate,
                             int fromIndex)
        Returns the index of the first element which matches the specified predicate in this list, starting the search at the specified position. If no such element is not found, -1 is returned.
        Parameters:
        predicate - predicate used to search for the element
        Returns:
        the index of the first element which matches the specified predicate, or -1 if not found
        See Also:
        indexOf(Object)
      • doIndexOfIf

        protected int doIndexOfIf​(java.util.function.Predicate<? super E> predicate,
                                  int fromIndex)
        Returns the index of the first element which matches the specified predicate in this list, starting the search at the specified position. If no such element is not found, -1 is returned.
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object elem)
        Specified by:
        lastIndexOf in interface java.util.List<E>
        Overrides:
        lastIndexOf in class java.util.AbstractList<E>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object elem,
                               int fromIndex)
        Returns the index of the last occurrence of the specified element in this list, starting the search at the specified position. If the element is not found, -1 is returned.
        Parameters:
        elem - element to search for
        fromIndex - start index for search
        Returns:
        the index of the last occurrence of the specified element in this list that is less than or equal to fromIndex, or -1 if this list does not contain the element
        See Also:
        lastIndexOf(Object)
      • doLastIndexOf

        protected int doLastIndexOf​(java.lang.Object elem,
                                    int fromIndex)
        Returns the index of the last occurrence of the specified element in this list, starting the search at the specified position. If the element is not found, -1 is returned.
      • lastIndexOfIf

        public int lastIndexOfIf​(java.util.function.Predicate<? super E> predicate)
        Returns the index of the last element which matches the specified predicate in this list. If no such element is not found, -1 is returned.
        Parameters:
        predicate - predicate used to search for the element
        Returns:
        the index of the last element which matches the specified predicate, or -1 if not found
        See Also:
        lastIndexOf(Object)
      • lastIndexOfIf

        public int lastIndexOfIf​(java.util.function.Predicate<? super E> predicate,
                                 int fromIndex)
        Returns the index of the last occurrence of the specified element in this list, starting the search at the specified position. If the element is not found, -1 is returned.
        Parameters:
        predicate - predicate used to search for the element
        fromIndex - start index for search
        Returns:
        the index of the last occurrence of the specified element in this list that is less than or equal to fromIndex, or -1 if this list does not contain the element
        See Also:
        lastIndexOf(Object)
      • doLastIndexOfIf

        protected int doLastIndexOfIf​(java.util.function.Predicate<? super E> predicate,
                                      int fromIndex)
        Returns the index of the last occurrence of the specified element in this list, starting the search at the specified position. If the element is not found, -1 is returned.
      • remove

        public boolean remove​(java.lang.Object elem)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class java.util.AbstractCollection<E>
      • contains

        public boolean contains​(java.lang.Object elem)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.List<E>
        Overrides:
        contains in class java.util.AbstractCollection<E>
      • containsIf

        public boolean containsIf​(java.util.function.Predicate<? super E> predicate)
        Determines whether the list contains a matching element.
        Specified by:
        containsIf in interface ICollection<E>
        Parameters:
        predicate - predicate used to search element
        Returns:
        true if the list contains a matching element, false otherwise
      • addIfAbsent

        public boolean addIfAbsent​(E elem)
        Add elements to the end if it is not already contained in the list.
        Parameters:
        elem - element to add
        Returns:
        true if element has been added, false if not
      • containsAny

        public boolean containsAny​(java.util.Collection<?> coll)
        Returns true if any of the elements of the specified collection is contained in the list.
        Parameters:
        coll - collection with elements to be contained
        Returns:
        true if any element is contained, false otherwise
      • containsAll

        public boolean containsAll​(java.util.Collection<?> coll)
        Specified by:
        containsAll in interface java.util.Collection<E>
        Specified by:
        containsAll in interface java.util.List<E>
        Overrides:
        containsAll in class java.util.AbstractCollection<E>
      • removeAll

        public IList<E> removeAll​(E elem)
        Removes all equal elements.
        Parameters:
        elem - element
        Returns:
        removed equal elements (never null)
      • removeAll

        public boolean removeAll​(java.util.Collection<?> coll)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface java.util.List<E>
        Overrides:
        removeAll in class java.util.AbstractCollection<E>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> coll)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface java.util.List<E>
        Overrides:
        retainAll in class java.util.AbstractCollection<E>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
      • toArray

        public <T> T[] toArray​(T[] array)
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
      • toArray

        public <T> T[] toArray​(java.lang.Class<T> clazz)
        Returns an array containing the elements in this list.
        Parameters:
        clazz - class for array elements
        Returns:
        array containing the specified elements
      • toArray

        public java.lang.Object[] toArray​(int index,
                                          int len)
        Returns an array containing the specified elements in this list.
        Parameters:
        index - index of first element to copy
        len - number of elements to copy
        Returns:
        array containing the specified elements
        See Also:
        List.toArray()
      • toArray

        public <T> T[] toArray​(T[] array,
                               int index,
                               int len)
        Returns an array containing the specified elements in this list.
        Parameters:
        array - the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
        index - index of first element to copy
        len - number of elements to copy
        Returns:
        array containing the specified elements
        See Also:
        List.toArray(Object[])
      • toArray

        public <T> T[] toArray​(java.lang.Class<T> clazz,
                               int index,
                               int len)
        Returns an array containing the specified elements in this list.
        Parameters:
        clazz - class for array elements
        index - index of first element to copy
        len - number of elements to copy
        Returns:
        array containing the specified elements
      • doCreateArray

        protected <T> T[] doCreateArray​(java.lang.Class<T> clazz,
                                        int len)
        Create array.
        Parameters:
        clazz - class for array elements
        len - array length
        Returns:
        created array
      • doGetAll

        protected <T> void doGetAll​(T[] array,
                                    int index,
                                    int len)
        Helper method to fill the specified elements in an array.
        Type Parameters:
        T - type of elements stored in the list
        Parameters:
        array - array to store the list elements
        index - index of first element to copy
        len - number of elements to copy
      • doAddAll

        protected boolean doAddAll​(int index,
                                   IListable<? extends E> list)
        Helper method for adding multiple elements to the list. This default implementation calls doAdd() for adding each element.
        Parameters:
        index - index where element should be added (-1 is valid for adding at the end)
        list - list with elements to add
        Returns:
        true if elements have been added, false otherwise
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.List<E>
        Overrides:
        iterator in class java.util.AbstractList<E>
      • listIterator

        public java.util.ListIterator<E> listIterator()
        Specified by:
        listIterator in interface java.util.List<E>
        Overrides:
        listIterator in class java.util.AbstractList<E>
      • listIterator

        public java.util.ListIterator<E> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<E>
        Overrides:
        listIterator in class java.util.AbstractList<E>
      • descendingIterator

        public java.util.Iterator<E> descendingIterator()
        See Deque.descendingIterator()
      • peek

        public E peek()
        See Deque.peek()
      • element

        public E element()
        See Deque.element()
      • poll

        public E poll()
        See Deque.poll()
      • remove

        public E remove()
        See Deque.remove()
      • offer

        public boolean offer​(E elem)
        See Deque.offer(E)
      • getFirst

        public E getFirst()
        Description copied from interface: ICollection
        Returns the first element stored in the collection. If the collection is empty, a NoSuchElementException is thrown.
        Specified by:
        getFirst in interface ICollection<E>
        Returns:
        first element stored in the collection
      • getFirstOrNull

        public E getFirstOrNull()
        Description copied from interface: ICollection
        Returns the first element stored in the collection. If the collection is empty, null is returned.
        Specified by:
        getFirstOrNull in interface ICollection<E>
        Returns:
        first element stored in the collection or null if empty
      • getLast

        public E getLast()
        See Deque.getLast()
      • getLastOrNull

        public E getLastOrNull()
        Returns the last element stored in the list. If the list is empty, null is returned.
        Returns:
        last element stored in the list or null if empty
      • addFirst

        public void addFirst​(E elem)
        See Deque.addFirst(E)
      • addLast

        public void addLast​(E elem)
        See Deque.addLast(E)
      • removeFirst

        public E removeFirst()
        See Deque.removeFirst()
      • removeLast

        public E removeLast()
        See Deque.removeLast()
      • offerFirst

        public boolean offerFirst​(E elem)
        See Deque.offerFirst(E)
      • offerLast

        public boolean offerLast​(E elem)
        See Deque.offerLast(E)
      • peekFirst

        public E peekFirst()
        See Deque.peekFirst()
      • peekLast

        public E peekLast()
        See Deque.peekLast()
      • pollFirst

        public E pollFirst()
        See Deque.pollFirst()
      • pollLast

        public E pollLast()
        See Deque.pollLast()
      • pop

        public E pop()
        See Deque.pop()
      • push

        public void push​(E elem)
        See Deque.push(E)
      • removeFirstOccurrence

        public boolean removeFirstOccurrence​(java.lang.Object elem)
        See Deque.removeFirstOccurrence(java.lang.Object)
      • removeLastOccurrence

        public boolean removeLastOccurrence​(java.lang.Object elem)
        See Deque.removeLastOccurrence(java.lang.Object)
      • transferCopy

        public static <E> void transferCopy​(IList<E> src,
                                            int srcIndex,
                                            int srcLen,
                                            IList<? super E> dst,
                                            int dstIndex,
                                            int dstLen)
        Copies elements from one list to another. Elements and size of source list do not change. The elements in the specified range in the destination list are removed and the elements specified to be copied are inserted. If source and destination list are identical, the method behaves like copy(int, int, int).
        Type Parameters:
        E - type of elements stored in the list
        Parameters:
        src - source list
        srcIndex - index of first element in source list
        srcLen - number of elements to copy
        dst - destination list
        dstIndex - index of first element in destination list
        dstLen - number of elements to replace in destination list
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • transferMove

        public static <E> void transferMove​(IList<E> src,
                                            int srcIndex,
                                            int srcLen,
                                            IList<? super E> dst,
                                            int dstIndex,
                                            int dstLen)
        Moves elements from one list to another by setting it to null in the source list. Elements in the source range are set to null, but size of source list does not change. The elements in the specified range in the destination list are removed and the elements specified to be moved are inserted. If source and destination list are identical, the method behaves like move(int, int, int).
        Type Parameters:
        E - type of elements stored in the list
        Parameters:
        src - source list
        srcIndex - index of first element in source list
        srcLen - number of elements to copy
        dst - destination list
        dstIndex - index of first element in destination list
        dstLen - number of elements to replace in destination list
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • transferRemove

        public static <E> void transferRemove​(IList<E> src,
                                              int srcIndex,
                                              int srcLen,
                                              IList<? super E> dst,
                                              int dstIndex,
                                              int dstLen)
        Moves elements from one list to another by removing it from the source list. So the size of source list will change. The elements in the specified range in the destination list are removed and the elements specified to be moved are inserted. If source and destination list are identical, the method behaves like drag(int, int, int).
        Type Parameters:
        E - type of elements stored in the list
        Parameters:
        src - source list
        srcIndex - index of first element in source list
        srcLen - number of elements to copy
        dst - destination list
        dstIndex - index of first element in destination list
        dstLen - number of elements to replace in destination list
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • doTransfer

        void doTransfer​(int transferMode,
                        int srcIndex,
                        int srcLen,
                        IList<? super E> dst,
                        int dstIndex,
                        int dstLen)
      • transferSwap

        public static <E> void transferSwap​(IList<E> src,
                                            int srcIndex,
                                            IList<E> dst,
                                            int dstIndex,
                                            int len)
        Swaps elements from two lists. The size of both source and destination list do not change. If source and destination list are identical, the method behaves like swap(int, int, int).
        Type Parameters:
        E - type of elements stored in the list
        Parameters:
        src - first list
        srcIndex - index of first element in first list
        dst - second list
        dstIndex - index of first element in second list
        len - number of elements to swap
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • doTransferSwap

        void doTransferSwap​(int srcIndex,
                            IList<E> dst,
                            int dstIndex,
                            int len)
      • doCreate

        protected abstract IList<E> doCreate​(int capacity)
        Create list with specified capacity.
        Parameters:
        capacity - initial capacity (use -1 for default capacity)
        Returns:
        created list
      • doAssign

        protected abstract void doAssign​(IList<E> that)
        Assign this list the content of the that list. This is done by bitwise copying so the that list should not be used afterwards.
        Parameters:
        that - list to copy content from
      • getAll

        public IList<E> getAll​(int index,
                               int len)
        Returns specified range of elements from list.
        Parameters:
        index - index of first element to retrieve
        len - number of elements to retrieve
        Returns:
        list containing the specified range of elements
      • extract

        public IList<E> extract​(int index,
                                int len)
        Removes specified range of elements from list and return them.
        Parameters:
        index - index of first element to retrieve
        len - number of elements to retrieve
        Returns:
        list containing the specified range of elements
      • retain

        public void retain​(int index,
                           int len)
        Retain specified range of elements from list, the other elements are removed.
        Parameters:
        index - index of first element to retain
        len - number of elements to retain
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • remove

        public void remove​(int index,
                           int len)
        Remove specified range of elements from list.
        Parameters:
        index - index of first element to remove
        len - number of elements to remove
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • doRemoveAll

        protected void doRemoveAll​(int index,
                                   int len)
        Remove specified range of elements from list.
        Parameters:
        index - index of first element to remove
        len - number of elements to remove
      • addAll

        public boolean addAll​(IList<? extends E> list)
        Adds all of the elements in the specified list into this list.
        Parameters:
        list - collection containing elements to be added to this list
        Returns:
        true if this list changed as a result of the call
        Throws:
        java.lang.NullPointerException - if the specified list is null
      • addAll

        public boolean addAll​(int index,
                              IList<? extends E> list)
        Inserts all of the elements in the specified list into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices).
        Parameters:
        index - index at which to insert the first element from the specified collection
        list - list containing elements to be inserted into this list
        Returns:
        true if this list changed as a result of the call
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is invalid
        java.lang.NullPointerException - if the specified collection is null
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> coll)
        Adds all of the elements in the specified collection into this list. The new elements will appear in the list in the order that they are returned by the specified collection's iterator.
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.AbstractCollection<E>
        Parameters:
        coll - collection containing elements to be added to this list
        Returns:
        true if this list changed as a result of the call
        Throws:
        java.lang.NullPointerException - if the specified collection is null
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends E> coll)
        Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.AbstractList<E>
        Parameters:
        index - index at which to insert the first element from the specified collection
        coll - collection containing elements to be inserted into this list
        Returns:
        true if this list changed as a result of the call
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is invalid
        java.lang.NullPointerException - if the specified collection is null
      • addArray

        public boolean addArray​(E... elems)
        Adds all specified elements into this list.
        Parameters:
        elems - elements to be added to this list
        Returns:
        true if this list changed as a result of the call
      • addArray

        public boolean addArray​(E[] elems,
                                int offset,
                                int length)
      • addArray

        public boolean addArray​(int index,
                                E[] elems,
                                int offset,
                                int length)
      • addArray

        public boolean addArray​(int index,
                                E... elems)
        Inserts the specified elements into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices).
        Parameters:
        index - index at which to insert the first element from the specified collection
        elems - elements to be inserted into this list
        Returns:
        true if this list changed as a result of the call
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is invalid
      • addMult

        public boolean addMult​(int len,
                               E elem)
        Adds element multiple time to list.
        Parameters:
        elem - element to be added to this list
        Returns:
        true if this list changed as a result of the call
      • addMult

        public boolean addMult​(int index,
                               int len,
                               E elem)
        Inserts element multiple time to list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices).
        Parameters:
        index - index at which to insert the first element from the specified collection
        elem - element to be inserted into this list
        Returns:
        true if this list changed as a result of the call
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is invalid
      • setAll

        public void setAll​(int index,
                           IList<? extends E> list)
        Sets the specified elements.
        Parameters:
        index - index of first element to set
        list - list with elements to set
      • setAll

        public void setAll​(int index,
                           java.util.Collection<? extends E> coll)
        Sets the specified elements.
        Parameters:
        index - index of first element to set
        coll - collection with elements to set
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • setArray

        public void setArray​(int index,
                             E... elems)
        Sets the specified elements.
        Parameters:
        index - index of first element to set
        elems - array with elements to set
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • setArray

        public void setArray​(int index,
                             E[] elems,
                             int offset,
                             int length)
      • setMult

        public void setMult​(int index,
                            int len,
                            E elem)
        Sets the element multiple times.
        Parameters:
        index - index of first element to set
        elem - element to set
      • putAll

        public void putAll​(int index,
                           IList<? extends E> list)
        Set or add the specified elements.
        Parameters:
        index - index of first element to set or add
        list - list with elements to set or add
      • putAll

        public void putAll​(int index,
                           java.util.Collection<? extends E> coll)
        Set or add the specified elements. If the index is smaller than the size of the list, the existing element is replaced. If the index equals the size of the list, the element is added.
        Parameters:
        index - index of first element to set or add
        coll - collection with elements to set or add
      • doPutAll

        protected void doPutAll​(int index,
                                IListable<? extends E> list)
      • putArray

        public void putArray​(int index,
                             E... elems)
        Set or add the specified elements. If the index is smaller than the size of the list, the existing element is replaced. If the index equals the size of the list, the element is added.
        Parameters:
        index - index of first element to set or add
        elems - array with elements to set or add
      • putMult

        public void putMult​(int index,
                            int len,
                            E elem)
        Set or add the specified element multiple times. If the index is smaller than the size of the list, the existing element is replaced. If the index equals the size of the list, the element is added.
        Parameters:
        index - index of first element to set or add
        len - element to set or add
      • initAll

        public void initAll​(IList<? extends E> list)
        Initializes the list so it will afterwards only contain the elements of the collection. The list will grow or shrink as needed.
        Parameters:
        list - list with elements
        Throws:
        java.lang.IndexOutOfBoundsException - if the length is invalid
      • doInitAll

        protected void doInitAll​(IListable<? extends E> list)
      • initAll

        public void initAll​(java.util.Collection<? extends E> coll)
        Initializes the list so it will afterwards only contain the elements of the collection. The list will grow or shrink as needed.
        Parameters:
        coll - collection with elements
        Throws:
        java.lang.IndexOutOfBoundsException - if the length is invalid
      • asIListable

        protected IListable<? extends E> asIListable​(java.util.Collection<? extends E> coll)
        Return correct IListable for passed collection.
      • initArray

        public void initArray​(E... elems)
        Initializes the list so it will afterwards only contain the elements of the array. The list will grow or shrink as needed.
        Parameters:
        elems - array with elements
        Throws:
        java.lang.IndexOutOfBoundsException - if the length is invalid
      • initMult

        public void initMult​(int len,
                             E elem)
        Initializes the list so it will afterwards have a size of len and contain only the element elem. The list will grow or shrink as needed.
        Parameters:
        len - length of list
        elem - element which the list will contain
        Throws:
        java.lang.IndexOutOfBoundsException - if the length is invalid
      • replaceAll

        public void replaceAll​(int index,
                               int len,
                               java.util.Collection<? extends E> coll)
        Replaces the specified range with new elements. This method is very powerful as it offers the functionality of many other methods which are therefore only offered for convenience:
        - addAll(index, list): replaceAll(index, 0, list)
        - setAll(index, list): replaceAll(index, list.size(), list)
        - putAll(index, list): replaceAll(index, -1, list)
        - initAll(list) : replaceAll(0, this.size(), list)
        - remove(index, list): replaceAll(index, list.size(), null)
        Parameters:
        index - index of first element to replace, use -1 for the position after the last element (this.size())
        len - number of elements to replace, use -1 for getting behavior of putAll()
        coll - collection with elements which replace the old elements, use null if elements should only be removed
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • replaceArray

        public void replaceArray​(int index,
                                 int len,
                                 E... elems)
        Replaces the specified range with new elements. This method is very powerful as it offers the functionality of many other methods which are therefore only offered for convenience:
        - addAll(index, list): replaceAll(index, 0, list)
        - setAll(index, list): replaceAll(index, list.size(), list)
        - putAll(index, list): replaceAll(index, -1, list)
        - initAll(list) : replaceAll(0, this.size(), list)
        - remove(index, list): replaceAll(index, list.size(), null)
        Parameters:
        index - index of first element to replace, use -1 for the position after the last element (this.size())
        len - number of elements to replace, use -1 for getting behavior of putAll()
        elems - array with elements which replace the old elements, use null if elements should only be removed
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • replaceMult

        public void replaceMult​(int index,
                                int len,
                                int numElems,
                                E elem)
        Replaces the specified range with new elements. This method is very powerful as it offers the functionality of many other methods which are therefore only offered for convenience:
        - addAll(index, list): replaceAll(index, 0, list)
        - setAll(index, list): replaceAll(index, list.size(), list)
        - putAll(index, list): replaceAll(index, -1, list)
        - initAll(list) : replaceAll(0, this.size(), list)
        - remove(index, list): replaceAll(index, list.size(), null)
        Parameters:
        index - index of first element to replace, use -1 for the position after the last element (this.size())
        len - number of elements to replace, use -1 for getting behavior of putAll()
        numElems - number of time element has to be added
        elem - element to add
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • replaceAll

        public void replaceAll​(int index,
                               int len,
                               IList<? extends E> list)
        Replaces the specified range with new elements. This method is very powerful as it offers the functionality of many other methods which are therefore only offered for convenience:
        - addAll(index, list): replaceAll(index, 0, list)
        - setAll(index, list): replaceAll(index, list.size(), list)
        - putAll(index, list): replaceAll(index, -1, list)
        - initAll(list) : replaceAll(0, this.size(), list)
        - remove(index, list): replaceAll(index, list.size(), null)
        Parameters:
        index - index of first element to replace, use -1 for the position after the last element (this.size())
        len - number of elements to replace, use -1 for getting behavior of putAll()
        list - list with elements which replace the old elements, use null if elements should only be removed
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
      • replace

        protected void replace​(int index,
                               int len,
                               IListable<? extends E> list)
      • doReplace

        protected boolean doReplace​(int index,
                                    int len,
                                    IListable<? extends E> list)
      • fill

        public void fill​(E elem)
        Fill list.
        Parameters:
        elem - element used for filling
      • copy

        public void copy​(int srcIndex,
                         int dstIndex,
                         int len)
        Copy specified elements. Source and destination ranges may overlap. The size of the list does not change.
        Parameters:
        srcIndex - index of first source element to copy
        dstIndex - index of first destination element to copy
        len - number of elements to copy
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • move

        public void move​(int srcIndex,
                         int dstIndex,
                         int len)
        Move specified elements. Source and destination ranges may overlap. The elements which are moved away are set to null, so the size of the list does not change.
        Parameters:
        srcIndex - index of first source element to move
        dstIndex - index of first destination element to move
        len - number of elements to move
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • drag

        public void drag​(int srcIndex,
                         int dstIndex,
                         int len)
        Drag specified elements. Source and destination ranges may overlap. The size of the list does not change and it contains the same elements as before, but in changed order.
        Parameters:
        srcIndex - index of first source element to move
        dstIndex - index of first destination element to move
        len - number of elements to move
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • swap

        public void swap​(int index1,
                         int index2,
                         int len)
        Swap the specified elements in the list.
        Parameters:
        index1 - index of first element in first range to swap
        index2 - index of first element in second range to swap
        len - number of elements to swap
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • reverse

        public void reverse()
        Reverses the order of all elements in the specified list.
      • reverse

        public void reverse​(int index,
                            int len)
        Reverses the order of the specified elements in the list.
        Parameters:
        index - index of first element to reverse
        len - number of elements to reverse
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • rotate

        public void rotate​(int distance)
        Rotate specified elements in the list. The distance argument can be positive or negative: If it is positive, the elements are moved towards the end, if negative, the elements are moved toward the beginning, if distance is 0, the list is not changed.
        Parameters:
        distance - distance to move the elements
      • rotate

        public void rotate​(int index,
                           int len,
                           int distance)
        Rotate specified elements in the list. The distance argument can be positive or negative: If it is positive, the elements are moved towards the end, if negative, the elements are moved toward the beginning, if distance is 0, the list is not changed.
        Parameters:
        index - index of first element to rotate
        len - number of elements to rotate
        distance - distance to move the elements
        Throws:
        java.lang.IndexOutOfBoundsException - if the ranges are invalid
      • doRotate

        protected void doRotate​(int index,
                                int len,
                                int distance)
        Internal method to rotate specified elements in the list. The distance argument can be positive or negative: If it is positive, the elements are moved towards the end, if negative, the elements are moved toward the beginning, if distance is 0, the list is not changed.
        Parameters:
        index - index of first element to rotate
        len - number of elements to rotate
        distance - distance to move the elements
      • sort

        public void sort​(java.util.Comparator<? super E> comparator)
        Sort elements in the list using the specified comparator.
        Specified by:
        sort in interface java.util.List<E>
        Parameters:
        comparator - comparator to use for sorting (null means the elements natural ordering should be used)
        See Also:
        Arrays.sort(int[])
      • sort

        public abstract void sort​(int index,
                                  int len,
                                  java.util.Comparator<? super E> comparator)
        Sort specified elements in the list using the specified comparator.
        Parameters:
        index - index of first element to sort
        len - number of elements to sort
        comparator - comparator to use for sorting (null means the elements natural ordering should be used)
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
        See Also:
        Arrays.sort(int[])
      • binarySearch

        public <K> int binarySearch​(K key,
                                    java.util.Comparator<? super K> comparator)
        Searches the specified range for an object using the binary* search algorithm.

        Note that the method is defined to work with an arbitrary type <K>. This allows to search directly for a key field in the object without the need to construct an object containing the key:

        
         persons.binarySearch("john", new SearchByName());
         
         class SearchByName implements Comparator<Object> {
        	 public int compare(Object o1, Object o2) {
        	   String s1 = (o1 instanceof String) ? (String) o1 : ((Name) o1).getName();
        	   String s2 = (o2 instanceof String) ? (String) o2 : ((Name) o2).getName();
        	   return s1.compareTo(s2);
        	 }
         }
         
        Parameters:
        key - the value to be searched for
        comparator - the comparator by which the list is ordered. A null value indicates that the elements' natural ordering should be used.
        Returns:
        index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
        See Also:
        Arrays.binarySearch(long[], long)
      • binarySearch

        public abstract <K> int binarySearch​(int index,
                                             int len,
                                             K key,
                                             java.util.Comparator<? super K> comparator)
        Searches the specified range for an object using the binary search algorithm.

        Note that the method is defined to work with an arbitrary type <K>. This allows to search directly for a key field in the object without the need to construct an object containing the key:

        
         persons.binarySearch("john", new SearchByName());
         
         class SearchByName implements Comparator<Object> {
        	 public int compare(Object o1, Object o2) {
        	   String s1 = (o1 instanceof String) ? (String) o1 : ((Name) o1).getName();
        	   String s2 = (o2 instanceof String) ? (String) o2 : ((Name) o2).getName();
        	   return s1.compareTo(s2);
        	 }
         }
         /
        Parameters:
        index - index of first element to search
        len - number of elements to search
        key - the value to be searched for
        comparator - the comparator by which the list is ordered. A null value indicates that the elements' natural ordering should be used.
        Returns:
        index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
        Throws:
        java.lang.IndexOutOfBoundsException - if the range is invalid
        See Also:
        Arrays.binarySearch(long[], long)
      • checkIndex

        protected void checkIndex​(int index)
        Check that specified index is valid for getting/setting elements.
        Parameters:
        index - index to check
        Throws:
        java.lang.IndexOutOfBoundsException - if index is invalid
      • checkIndexAdd

        protected void checkIndexAdd​(int index)
        Check that specified index is valid for adding elements.
        Parameters:
        index - index to check
        Throws:
        java.lang.IndexOutOfBoundsException - if index is invalid
      • checkRange

        protected void checkRange​(int index,
                                  int len)
        Check that specified range is valid.
        Parameters:
        index - start index of range to check
        len - number of elements in range to check
        Throws:
        java.lang.IndexOutOfBoundsException - if index is invalid
      • checkLength

        protected void checkLength​(int len)
        Check that specified length is valid (>= 0).
        Parameters:
        len - length to check
        Throws:
        java.lang.IndexOutOfBoundsException - if length is invalid
      • checkLengths

        protected void checkLengths​(int len1,
                                    int len2)
        Check that both specified lengths are valid (>= 0) and equal.
        Parameters:
        len1 - length to check
        len2 - length to check
        Throws:
        java.lang.IndexOutOfBoundsException - if lengths are invalid
      • checkNonNull

        protected void checkNonNull​(java.lang.Object obj)
        Check that object is not null.
        Parameters:
        obj - object to check
        Throws:
        java.lang.NullPointerException - if object is null