Class AppendOnlyLinkedArrayList<T>

  • Type Parameters:
    T - the value type

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

      Fields 
      Modifier and Type Field Description
      (package private) int capacity  
      (package private) java.lang.Object[] head  
      (package private) int offset  
      (package private) java.lang.Object[] tail  
    • Constructor Summary

      Constructors 
      Constructor Description
      AppendOnlyLinkedArrayList​(int capacity)
      Constructs an empty list with a per-link capacity.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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 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.
      <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 Detail

      • capacity

        final int capacity
      • head

        final java.lang.Object[] head
      • tail

        java.lang.Object[] tail
      • offset

        int offset
    • Constructor Detail

      • AppendOnlyLinkedArrayList

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

      • 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 java.lang.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:
        java.lang.Throwable - if the predicate throws