Class LinkedNode<T>

  • Type Parameters:
    T - The type of values stored in the list.
    All Implemented Interfaces:
    Iterable<T>

    public final class LinkedNode<T>
    extends Object
    implements Iterable<T>
    A very simple, immutable data structure to represent singly linked lists.
    • Field Detail

      • value

        public final T value
    • Method Detail

      • of

        public static <T> LinkedNode<T> of​(T value)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • stream

        public Stream<T> stream()
      • findAndReverse

        public Optional<LinkedNode<T>> findAndReverse​(Predicate<T> valuePredicate)
        Parameters:
        valuePredicate - A predicate to apply to node values.
        Returns:
        An optional containing the path from the found node to the current head, i.e. a reversed list of all values from the first node to match the given predicate to the current head (note: the list is purposely in reversed order compared to this), or an empty optional if no matching value was found.