Package arc.struct

Class DelayedRemovalSeq<T>

java.lang.Object
arc.struct.Seq<T>
arc.struct.DelayedRemovalSeq<T>
All Implemented Interfaces:
Eachable<T>, Iterable<T>

public class DelayedRemovalSeq<T> extends Seq<T>
Queues any removals done after begin() is called to occur once end() is called. This can allow code out of your control to remove items without affecting iteration. Between begin and end, most mutator methods will throw IllegalStateException. Only remove(int), remove(Object, boolean), removeRange(int, int), clear(), and add methods are allowed.

Code using this class must not rely on items being removed immediately. Consider using SnapshotSeq if this is a problem.

  • Constructor Details

    • DelayedRemovalSeq

      public DelayedRemovalSeq()
    • DelayedRemovalSeq

      public DelayedRemovalSeq(Seq<? extends T> array)
    • DelayedRemovalSeq

      public DelayedRemovalSeq(boolean ordered, int capacity, Class<?> arrayType)
    • DelayedRemovalSeq

      public DelayedRemovalSeq(boolean ordered, int capacity)
    • DelayedRemovalSeq

      public DelayedRemovalSeq(boolean ordered, T[] array, int startIndex, int count)
    • DelayedRemovalSeq

      public DelayedRemovalSeq(Class<?> arrayType)
    • DelayedRemovalSeq

      public DelayedRemovalSeq(int capacity)
    • DelayedRemovalSeq

      public DelayedRemovalSeq(T[] array)
  • Method Details

    • with

      public static <T> DelayedRemovalSeq<T> with(T... array)
      See Also:
    • begin

      public void begin()
    • end

      public void end()
    • remove

      public boolean remove(T value, boolean identity)
      Description copied from class: Seq
      Removes the first instance of the specified value in the array.
      Overrides:
      remove in class Seq<T>
      Parameters:
      value - May be null.
      identity - If true, == comparison will be used. If false, .equals() comparison will be used.
      Returns:
      true if value was found and removed, false otherwise
    • remove

      public T remove(int index)
      Description copied from class: Seq
      Removes and returns the item at the specified index.
      Overrides:
      remove in class Seq<T>
    • removeRange

      public void removeRange(int start, int end)
      Description copied from class: Seq
      Removes the items between the specified indices, inclusive.
      Overrides:
      removeRange in class Seq<T>
    • clear

      public Seq<T> clear()
      Overrides:
      clear in class Seq<T>
    • set

      public void set(int index, T value)
      Overrides:
      set in class Seq<T>
    • insert

      public void insert(int index, T value)
      Overrides:
      insert in class Seq<T>
    • swap

      public void swap(int first, int second)
      Overrides:
      swap in class Seq<T>
    • pop

      public T pop()
      Description copied from class: Seq
      Removes and returns the last item.
      Overrides:
      pop in class Seq<T>
    • sort

      public Seq<T> sort()
      Description copied from class: Seq
      Sorts this array. The array elements must implement Comparable. This method is not thread safe (uses Sort.instance()).
      Overrides:
      sort in class Seq<T>
    • sort

      public Seq<T> sort(Comparator<? super T> comparator)
      Description copied from class: Seq
      Sorts the array. This method is not thread safe (uses Sort.instance()).
      Overrides:
      sort in class Seq<T>
    • reverse

      public Seq<T> reverse()
      Overrides:
      reverse in class Seq<T>
    • shuffle

      public Seq<T> shuffle()
      Overrides:
      shuffle in class Seq<T>
    • truncate

      public void truncate(int newSize)
      Description copied from class: Seq
      Reduces the size of the array to the specified size. If the array is already smaller than the specified size, no action is taken.
      Overrides:
      truncate in class Seq<T>
    • setSize

      public T[] setSize(int newSize)
      Description copied from class: Seq
      Sets the array size, leaving any values beyond the current size null.
      Overrides:
      setSize in class Seq<T>
      Returns:
      Seq.items