Class PersistentVector<E>

    • Method Detail

      • empty

        public static <T> PersistentVector<T> empty()
        Returns the empty ImList (there only needs to be one)
      • emptyMutable

        public static <T> PersistentVector.MutVector<T> emptyMutable()
        Returns a new mutable vector. For some reason calling empty().mutable() sometimes requires an explicit type parameter in Java, so this convenience method works around that.
      • get

        public E get​(int i)
        Returns the item specified by the given index.
        Specified by:
        get in interface List<E>
      • replace

        @NotNull
        public @NotNull PersistentVector<E> replace​(int i,
                                                    E val)
        Replace the item at the given index. Note: i.replace(i.size(), o) used to be equivalent to i.concat(o), but it probably won't be for the RRB tree implementation, so this will change too.
        Specified by:
        replace in interface BaseList<E>
        Specified by:
        replace in interface ImList<E>
        Parameters:
        i - the index where the value should be stored.
        val - the value to store
        Returns:
        a new ImList with the replaced item
      • size

        public int size()
        Returns the number of items in this collection or iterable.
        Specified by:
        size in interface Collection<E>
        Specified by:
        size in interface List<E>
        Specified by:
        size in interface Sized
      • append

        @NotNull
        public @NotNull PersistentVector<E> append​(E val)
        Inserts a new item at the end of the vector
        Specified by:
        append in interface BaseList<E>
        Specified by:
        append in interface ImList<E>
        Parameters:
        val - the value to insert
        Returns:
        a new Vecsicle with the additional item.
      • appendWhen

        @NotNull
        public @NotNull PersistentVector<E> appendWhen​(@NotNull
                                                       @NotNull Fn0<Boolean> test,
                                                       E e)
        Adds one item to the end of the ImList.
        Specified by:
        appendWhen in interface BaseList<E>
        Specified by:
        appendWhen in interface ImList<E>
        e - the value to insert
        Returns:
        a new ImList with the additional item at the end.
      • concat

        @NotNull
        public @NotNull PersistentVector<E> concat​(@Nullable
                                                   @Nullable Iterable<? extends E> items)
        Efficiently adds items to the end of this PersistentVector.
        Specified by:
        concat in interface BaseList<E>
        Specified by:
        concat in interface ImList<E>
        Specified by:
        concat in interface Transformable<E>
        Specified by:
        concat in interface UnmodIterable<E>
        Parameters:
        items - the values to insert
        Returns:
        a new PersistentVector with the additional items at the end.