Interface MultiReaderList<T>

All Superinterfaces:
Cloneable, Collection<T>, InternalIterable<T>, Iterable<T>, List<T>, ListIterable<T>, MutableCollection<T>, MutableList<T>, OrderedIterable<T>, ReversibleIterable<T>, RichIterable<T>

public interface MultiReaderList<T> extends MutableList<T>
A MultiReaderList provides thread-safe iteration for a list through methods withReadLockAndDelegate() and withWriteLockAndDelegate().
Since:
10.0.
  • Method Details

    • withReadLockAndDelegate

      void withReadLockAndDelegate(Procedure<? super MutableList<T>> procedure)
    • withWriteLockAndDelegate

      void withWriteLockAndDelegate(Procedure<? super MutableList<T>> procedure)
    • newEmpty

      MultiReaderList<T> newEmpty()
      Description copied from interface: MutableCollection
      Creates a new empty mutable version of the same collection type. For example, if this instance is a FastList, this method will return a new empty FastList. If the class of this instance is immutable or fixed size (i.e. SingletonList) then a mutable alternative to the class will be provided.
      Specified by:
      newEmpty in interface MutableCollection<T>
      Specified by:
      newEmpty in interface MutableList<T>
    • clone

      MultiReaderList<T> clone()
      Specified by:
      clone in interface MutableList<T>
    • subList

      MultiReaderList<T> subList(int fromIndex, int toIndex)
      Specified by:
      subList in interface List<T>
      Specified by:
      subList in interface ListIterable<T>
      Specified by:
      subList in interface MutableList<T>
      See Also:
    • with

      default MultiReaderList<T> with(T element)
      Description copied from interface: MutableCollection
      This method allows mutable and fixed size collections the ability to add 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 element 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.with("1");
       list = list.with("2");
       return list;
       
      In the case of FixedSizeCollection a new instance of MutableCollection will be returned by with, 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 add on itself.
      Specified by:
      with in interface MutableCollection<T>
      Specified by:
      with in interface MutableList<T>
      See Also:
    • without

      default MultiReaderList<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 MutableCollection<T>
      Specified by:
      without in interface MutableList<T>
      See Also:
    • withAll

      default MultiReaderList<T> withAll(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 MutableCollection<T>
      Specified by:
      withAll in interface MutableList<T>
      See Also:
    • withoutAll

      default MultiReaderList<T> withoutAll(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 MutableCollection<T>
      Specified by:
      withoutAll in interface MutableList<T>
      See Also:
    • tap

      default MultiReaderList<T> tap(Procedure<? super T> procedure)
      Description copied from interface: RichIterable
      Executes the Procedure for each element in the iterable and returns this.

      Example using a Java 8 lambda expression:

       RichIterable<Person> tapped =
           people.tap(person -> LOGGER.info(person.getName()));
       
      Specified by:
      tap in interface ListIterable<T>
      Specified by:
      tap in interface MutableCollection<T>
      Specified by:
      tap in interface MutableList<T>
      Specified by:
      tap in interface OrderedIterable<T>
      Specified by:
      tap in interface ReversibleIterable<T>
      Specified by:
      tap in interface RichIterable<T>
      See Also:
    • sortThis

      default MultiReaderList<T> sortThis(Comparator<? super T> comparator)
      Description copied from interface: MutableList
      Sorts the internal data structure of this list and returns the list itself as a convenience.
      Specified by:
      sortThis in interface MutableList<T>
    • sortThis

      default MultiReaderList<T> sortThis()
      Description copied from interface: MutableList
      Sorts the internal data structure of this list and returns the list itself as a convenience.
      Specified by:
      sortThis in interface MutableList<T>
    • sortThisBy

      <V extends Comparable<? super V>> MultiReaderList<T> sortThisBy(Function<? super T,? extends V> function)
      Description copied from interface: MutableList
      Sorts the internal data structure of this list based on the natural order of the attribute returned by function.
      Specified by:
      sortThisBy in interface MutableList<T>
    • sortThisByInt

      MultiReaderList<T> sortThisByInt(IntFunction<? super T> function)
      Specified by:
      sortThisByInt in interface MutableList<T>
    • sortThisByBoolean

      MultiReaderList<T> sortThisByBoolean(BooleanFunction<? super T> function)
      Specified by:
      sortThisByBoolean in interface MutableList<T>
    • sortThisByChar

      MultiReaderList<T> sortThisByChar(CharFunction<? super T> function)
      Specified by:
      sortThisByChar in interface MutableList<T>
    • sortThisByByte

      MultiReaderList<T> sortThisByByte(ByteFunction<? super T> function)
      Specified by:
      sortThisByByte in interface MutableList<T>
    • sortThisByShort

      MultiReaderList<T> sortThisByShort(ShortFunction<? super T> function)
      Specified by:
      sortThisByShort in interface MutableList<T>
    • sortThisByFloat

      MultiReaderList<T> sortThisByFloat(FloatFunction<? super T> function)
      Specified by:
      sortThisByFloat in interface MutableList<T>
    • sortThisByLong

      MultiReaderList<T> sortThisByLong(LongFunction<? super T> function)
      Specified by:
      sortThisByLong in interface MutableList<T>
    • sortThisByDouble

      MultiReaderList<T> sortThisByDouble(DoubleFunction<? super T> function)
      Specified by:
      sortThisByDouble in interface MutableList<T>
    • reverseThis

      MultiReaderList<T> reverseThis()
      Description copied from interface: MutableList
      Mutates this list by reversing its order and returns the current list as a result.
      Specified by:
      reverseThis in interface MutableList<T>
    • shuffleThis

      MultiReaderList<T> shuffleThis()
      Description copied from interface: MutableList
      Mutates this list by shuffling its elements.
      Specified by:
      shuffleThis in interface MutableList<T>
    • shuffleThis

      MultiReaderList<T> shuffleThis(Random random)
      Description copied from interface: MutableList
      Mutates this list by shuffling its elements using the specified random.
      Specified by:
      shuffleThis in interface MutableList<T>