Class AppendOnlyLinkedArrayList<T>

java.lang.Object
io.reactivex.rxjava3.internal.util.AppendOnlyLinkedArrayList<T>
Type Parameters:
T - the value type

public class AppendOnlyLinkedArrayList<T> extends Object
A linked-array-list implementation that only supports appending and consumption.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Predicate interface suppressing the exception.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final int
     
    (package private) final Object[]
     
    (package private) int
     
    (package private) Object[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty list with a per-link capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    <U> boolean
    accept(Observer<? super U> observer)
    Interprets the contents as NotificationLite objects and calls the appropriate Observer method.
    <U> boolean
    accept(org.reactivestreams.Subscriber<? super U> subscriber)
    Interprets the contents as NotificationLite objects and calls the appropriate Subscriber method.
    void
    add(T value)
    Append a non-null value to the list.
    void
    Loops over all elements of the array until a null element is encountered or the given predicate returns true.
    <S> void
    forEachWhile(S state, BiPredicate<? super S,? super T> consumer)
    Loops over all elements of the array until a null element is encountered or the given predicate returns true.
    void
    setFirst(T value)
    Set a value as the first element of the list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • capacity

      final int capacity
    • tail

      Object[] tail
    • offset

      int offset
  • Constructor Details

    • AppendOnlyLinkedArrayList

      public AppendOnlyLinkedArrayList(int capacity)
      Constructs an empty list with a per-link capacity.
      Parameters:
      capacity - the capacity of each link
  • Method Details

    • add

      public void add(T value)
      Append a non-null value to the list.

      Don't add null to the list!

      Parameters:
      value - the value to append
    • setFirst

      public void setFirst(T value)
      Set a value as the first element of the list.
      Parameters:
      value - the value to set
    • forEachWhile

      public void forEachWhile(AppendOnlyLinkedArrayList.NonThrowingPredicate<? super T> consumer)
      Loops over all elements of the array until a null element is encountered or the given predicate returns true.
      Parameters:
      consumer - the consumer of values that returns true if the forEach should terminate
    • accept

      public <U> boolean accept(org.reactivestreams.Subscriber<? super U> subscriber)
      Interprets the contents as NotificationLite objects and calls the appropriate Subscriber method.
      Type Parameters:
      U - the target type
      Parameters:
      subscriber - the subscriber to emit the events to
      Returns:
      true if a terminal event has been reached
    • accept

      public <U> boolean accept(Observer<? super U> observer)
      Interprets the contents as NotificationLite objects and calls the appropriate Observer method.
      Type Parameters:
      U - the target type
      Parameters:
      observer - the observer to emit the events to
      Returns:
      true if a terminal event has been reached
    • forEachWhile

      public <S> void forEachWhile(S state, BiPredicate<? super S,? super T> consumer) throws Throwable
      Loops over all elements of the array until a null element is encountered or the given predicate returns true.
      Type Parameters:
      S - the extra state type
      Parameters:
      state - the extra state passed into the consumer
      consumer - the consumer of values that returns true if the forEach should terminate
      Throws:
      Throwable - if the predicate throws