Class AbstractMemoryEfficientMutableList<T>

    • Constructor Detail

      • AbstractMemoryEfficientMutableList

        public AbstractMemoryEfficientMutableList()
    • Method Detail

      • add

        public void add​(int index,
                        T element)
        Specified by:
        add in interface java.util.List<T>
      • addAll

        public boolean addAll​(java.util.Collection<? extends T> collection)
        Specified by:
        addAll in interface java.util.Collection<T>
        Specified by:
        addAll in interface FixedSizeCollection<T>
        Specified by:
        addAll in interface java.util.List<T>
        Overrides:
        addAll in class AbstractMutableCollection<T>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends T> collection)
        Specified by:
        addAll in interface java.util.List<T>
      • remove

        public T remove​(int index)
        Specified by:
        remove in interface java.util.List<T>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> collection)
        Specified by:
        removeAll in interface java.util.Collection<T>
        Specified by:
        removeAll in interface FixedSizeCollection<T>
        Specified by:
        removeAll in interface java.util.List<T>
        Overrides:
        removeAll in class AbstractMutableList<T>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> collection)
        Specified by:
        retainAll in interface java.util.Collection<T>
        Specified by:
        retainAll in interface FixedSizeCollection<T>
        Specified by:
        retainAll in interface java.util.List<T>
        Overrides:
        retainAll in class AbstractMutableList<T>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<T>
        Specified by:
        clear in interface FixedSizeCollection<T>
        Specified by:
        clear in interface java.util.List<T>
      • sort

        public void sort​(java.util.Comparator<? super T> comparator)
        This method checks if comparator is null and use a ComparableComparator if it is.
        Specified by:
        sort in interface java.util.List<T>
        Since:
        10.0
      • insertionSort

        private void insertionSort​(java.util.Comparator<? super T> comparator)
      • isPreviousGreaterThanCurrent

        private boolean isPreviousGreaterThanCurrent​(java.util.Comparator<? super T> comparator,
                                                     int index)
      • without

        public MutableList<T> without​(T element)
        Description copied from interface: MutableCollection
        This method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
         MutableCollection<String> list = list.without("1");
         list = list.without("2");
         return list;
         
        In the case of FixedSizeCollection a new instance of MutableCollection will be returned by without, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling remove on itself.
        Specified by:
        without in interface FixedSizeCollection<T>
        Specified by:
        without in interface FixedSizeList<T>
        Specified by:
        without in interface MutableCollection<T>
        Specified by:
        without in interface MutableList<T>
        See Also:
        Collection.remove(Object)
      • withAll

        public MutableList<T> withAll​(java.lang.Iterable<? extends T> elements)
        Description copied from interface: MutableCollection
        This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
         MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));
         
        In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling addAll on itself.
        Specified by:
        withAll in interface FixedSizeCollection<T>
        Specified by:
        withAll in interface FixedSizeList<T>
        Specified by:
        withAll in interface MutableCollection<T>
        Specified by:
        withAll in interface MutableList<T>
        See Also:
        Collection.addAll(Collection)
      • withoutAll

        public MutableList<T> withoutAll​(java.lang.Iterable<? extends T> elements)
        Description copied from interface: MutableCollection
        This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
         MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));
         
        In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withoutAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling removeAll on itself.
        Specified by:
        withoutAll in interface FixedSizeCollection<T>
        Specified by:
        withoutAll in interface FixedSizeList<T>
        Specified by:
        withoutAll in interface MutableCollection<T>
        Specified by:
        withoutAll in interface MutableList<T>
        See Also:
        Collection.removeAll(Collection)