Klasse BooleanIterators

java.lang.Object
speiger.src.collections.booleans.utils.BooleanIterators

public class BooleanIterators extends Object
A Helper class for Iterators
  • Konstruktordetails

    • BooleanIterators

      public BooleanIterators()
  • Methodendetails

    • empty

      public static speiger.src.collections.booleans.utils.BooleanIterators.EmptyIterator empty()
      Returns a Immutable EmptyIterator instance that is automatically casted.
      Gibt zurück:
      an empty iterator
    • invert

      Inverter function for Bidirectional Iterators
      Parameter:
      it - the iterator that should be inverted
      Gibt zurück:
      a Inverted Bidirectional Iterator. If it was inverted then it just gives back the original reference
    • invert

      public static BooleanListIterator invert(BooleanListIterator it)
      Inverter function for List Iterators
      Parameter:
      it - the iterator that should be inverted
      Gibt zurück:
      a Inverted List Iterator. If it was inverted then it just gives back the original reference
    • unmodifiable

      public static BooleanIterator unmodifiable(BooleanIterator iterator)
      Returns a Immutable Iterator instance based on the instance given.
      Parameter:
      iterator - that should be made immutable/unmodifiable
      Gibt zurück:
      a unmodifiable iterator wrapper. If the Iterator already a unmodifiable wrapper then it just returns itself.
    • unmodifiable

      public static BooleanBidirectionalIterator unmodifiable(BooleanBidirectionalIterator iterator)
      Returns a Immutable Iterator instance based on the instance given.
      Parameter:
      iterator - that should be made immutable/unmodifiable
      Gibt zurück:
      a unmodifiable iterator wrapper. If the Iterator already a unmodifiable wrapper then it just returns itself.
    • unmodifiable

      public static BooleanListIterator unmodifiable(BooleanListIterator iterator)
      Returns a Immutable ListIterator instance based on the instance given.
      Parameter:
      iterator - that should be made immutable/unmodifiable
      Gibt zurück:
      a unmodifiable listiterator wrapper. If the ListIterator already a unmodifiable wrapper then it just returns itself.
    • map

      public static <E> ObjectIterator<E> map(Iterator<? extends Boolean> iterator, BooleanFunction<E> mapper)
      A Helper function that maps a Java-Iterator into a new Type.
      Typparameter:
      E - The return type.
      Parameter:
      iterator - that should be mapped
      mapper - the function that decides what the result turns into.
      Gibt zurück:
      a iterator that is mapped to a new result
    • map

      public static <E> ObjectIterator<E> map(BooleanIterator iterator, BooleanFunction<E> mapper)
      A Helper function that maps a Iterator into a new Type.
      Typparameter:
      E - The return type.
      Parameter:
      iterator - that should be mapped
      mapper - the function that decides what the result turns into.
      Gibt zurück:
      a iterator that is mapped to a new result
    • flatMap

      public static <E, V extends Iterable<E>> ObjectIterator<E> flatMap(Iterator<? extends Boolean> iterator, BooleanFunction<V> mapper)
      A Helper function that flatMaps a Java-Iterator into a new Type.
      Typparameter:
      E - The return type.
      V - The return type supplier.
      Parameter:
      iterator - that should be flatMapped
      mapper - the function that decides what the result turns into.
      Gibt zurück:
      a iterator that is flatMapped to a new result
    • flatMap

      public static <E, V extends Iterable<E>> ObjectIterator<E> flatMap(BooleanIterator iterator, BooleanFunction<V> mapper)
      A Helper function that flatMaps a Iterator into a new Type.
      Typparameter:
      E - The return type.
      V - The return type supplier.
      Parameter:
      iterator - that should be flatMapped
      mapper - the function that decides what the result turns into.
      Gibt zurück:
      a iterator that is flatMapped to a new result
    • arrayFlatMap

      public static <E> ObjectIterator<E> arrayFlatMap(Iterator<? extends Boolean> iterator, BooleanFunction<E[]> mapper)
      A Helper function that flatMaps a Java-Iterator into a new Type.
      Typparameter:
      E - The return type.
      Parameter:
      iterator - that should be flatMapped
      mapper - the function that decides what the result turns into.
      Gibt zurück:
      a iterator that is flatMapped to a new result
    • arrayFlatMap

      public static <E> ObjectIterator<E> arrayFlatMap(BooleanIterator iterator, BooleanFunction<E[]> mapper)
      A Helper function that flatMaps a Iterator into a new Type.
      Typparameter:
      E - The return type.
      Parameter:
      iterator - that should be flatMapped
      mapper - the function that decides what the result turns into.
      Gibt zurück:
      a iterator that is flatMapped to a new result
    • filter

      public static BooleanIterator filter(Iterator<? extends Boolean> iterator, BooleanPredicate filter)
      A Helper function that filters out all desired elements from a Java-Iterator
      Parameter:
      iterator - that should be filtered.
      filter - the filter that decides that should be let through
      Gibt zurück:
      a filtered iterator
    • filter

      public static BooleanIterator filter(BooleanIterator iterator, BooleanPredicate filter)
      A Helper function that filters out all desired elements
      Parameter:
      iterator - that should be filtered.
      filter - the filter that decides that should be let through
      Gibt zurück:
      a filtered iterator
    • distinct

      public static BooleanIterator distinct(BooleanIterator iterator)
      A Helper function that filters out all duplicated elements.
      Parameter:
      iterator - that should be distinct
      Gibt zurück:
      a distinct iterator
    • distinct

      public static BooleanIterator distinct(Iterator<? extends Boolean> iterator)
      A Helper function that filters out all duplicated elements from a Java Iterator.
      Parameter:
      iterator - that should be distinct
      Gibt zurück:
      a distinct iterator
    • repeat

      public static BooleanIterator repeat(BooleanIterator iterator, int repeats)
      A Helper function that repeats the Iterator a specific amount of times
      Parameter:
      iterator - that should be repeated
      repeats - the amount of times the iterator should be repeated
      Gibt zurück:
      a repeating iterator
    • repeat

      public static BooleanIterator repeat(Iterator<? extends Boolean> iterator, int repeats)
      A Helper function that repeats the Iterator a specific amount of times from a Java Iterator
      Parameter:
      iterator - that should be repeated
      repeats - the amount of times the iterator should be repeated
      Gibt zurück:
      a repeating iterator
    • infinite

      public static BooleanIterator infinite(BooleanIterator iterator)
      A Helper function that creates a infinitely looping iterator
      Parameter:
      iterator - that should be looping infinitely
      Gibt zurück:
      a infinitely looping iterator
    • infinite

      public static BooleanIterator infinite(Iterator<? extends Boolean> iterator)
      A Helper function that creates a infinitely looping iterator from a Java Iterator
      Parameter:
      iterator - that should be looping infinitely
      Gibt zurück:
      a infinitely looping iterator
    • limit

      public static BooleanIterator limit(BooleanIterator iterator, long limit)
      A Helper function that hard limits the Iterator to a specific size
      Parameter:
      iterator - that should be limited
      limit - the amount of elements it should be limited to
      Gibt zurück:
      a limited iterator
    • limit

      public static BooleanIterator limit(Iterator<? extends Boolean> iterator, long limit)
      A Helper function that hard limits the Iterator to a specific size from a Java Iterator
      Parameter:
      iterator - that should be limited
      limit - the amount of elements it should be limited to
      Gibt zurück:
      a limited iterator
    • sorted

      public static BooleanIterator sorted(BooleanIterator iterator, BooleanComparator sorter)
      A Helper function that sorts the Iterator beforehand. This operation is heavily hurting performance because it rebuilds the entire iterator and then sorts it.
      Parameter:
      iterator - that should be sorted.
      sorter - the sorter of the iterator. Can be null.
      Gibt zurück:
      a new sorted iterator
    • sorted

      public static BooleanIterator sorted(Iterator<? extends Boolean> iterator, BooleanComparator sorter)
      A Helper function that sorts the Iterator beforehand from a Java Iterator. This operation is heavily hurting performance because it rebuilds the entire iterator and then sorts it.
      Parameter:
      iterator - that should be sorted.
      sorter - the sorter of the iterator. Can be null.
      Gibt zurück:
      a new sorted iterator
    • peek

      public static BooleanIterator peek(BooleanIterator iterator, BooleanConsumer action)
      A Helper function that allows to preview the result of a Iterator.
      Parameter:
      iterator - that should be peeked at
      action - callback that receives the value before the iterator returns it
      Gibt zurück:
      a peeked iterator
    • peek

      public static BooleanIterator peek(Iterator<? extends Boolean> iterator, BooleanConsumer action)
      A Helper function that allows to preview the result of a Iterator from a Java Iterator
      Parameter:
      iterator - that should be peeked at
      action - callback that receives the value before the iterator returns it
      Gibt zurück:
      a peeked iterator
    • wrap

      public static BooleanIterator wrap(Iterator<? extends Boolean> iterator)
      Helper function to convert a Object Iterator into a Primitive Iterator
      Parameter:
      iterator - that should be converted to a unboxing iterator
      Gibt zurück:
      a primitive iterator
    • wrap

      public static speiger.src.collections.booleans.utils.BooleanIterators.ArrayIterator wrap(boolean... a)
      Returns a Array Wrapping iterator
      Parameter:
      a - the array that should be wrapped
      Gibt zurück:
      a Iterator that is wrapping a array.
    • wrap

      public static speiger.src.collections.booleans.utils.BooleanIterators.ArrayIterator wrap(boolean[] a, int start, int end)
      Returns a Array Wrapping iterator
      Parameter:
      a - the array that should be wrapped.
      start - the index to be started from.
      end - the index that should be ended.
      Gibt zurück:
      a Iterator that is wrapping a array.
    • unwrap

      public static int unwrap(boolean[] a, Iterator<? extends Boolean> i)
      Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      Gibt zurück:
      the amount of elements that were inserted into the array.
    • unwrap

      public static int unwrap(boolean[] a, Iterator<? extends Boolean> i, int offset)
      Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      offset - the array offset where the start should be
      Gibt zurück:
      the amount of elements that were inserted into the array.
    • unwrap

      public static int unwrap(boolean[] a, Iterator<? extends Boolean> i, int offset, int max)
      Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      offset - the array offset where the start should be
      max - the maximum values that should be extracted from the source
      Gibt zurück:
      the amount of elements that were inserted into the array.
      Löst aus:
      IllegalStateException - if max is smaller the 0 or if the maximum index is larger then the array
    • unwrap

      public static int unwrap(boolean[] a, BooleanIterator i)
      A Primitive iterator variant of the BooleanIterators unwrap function Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      Gibt zurück:
      the amount of elements that were inserted into the array.
    • unwrap

      public static int unwrap(boolean[] a, BooleanIterator i, int offset)
      A Primitive iterator variant of the BooleanIterators unwrap function Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      offset - the array offset where the start should be
      Gibt zurück:
      the amount of elements that were inserted into the array.
    • unwrap

      public static int unwrap(boolean[] a, BooleanIterator i, int offset, int max)
      A Primitive iterator variant of the BooleanIterators unwrap function Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      offset - the array offset where the start should be
      max - the maximum values that should be extracted from the source
      Gibt zurück:
      the amount of elements that were inserted into the array.
      Löst aus:
      IllegalStateException - if max is smaller the 0 or if the maximum index is larger then the array
    • unwrap

      public static int unwrap(Boolean[] a, BooleanIterator i)
      A Function to convert a Primitive Iterator to a Object array. Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      Gibt zurück:
      the amount of elements that were inserted into the array.
    • unwrap

      public static int unwrap(Boolean[] a, BooleanIterator i, int offset)
      A Function to convert a Primitive Iterator to a Object array. Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      offset - the array offset where the start should be
      Gibt zurück:
      the amount of elements that were inserted into the array.
    • unwrap

      public static int unwrap(Boolean[] a, BooleanIterator i, int offset, int max)
      A Function to convert a Primitive Iterator to a Object array. Iterates over a iterator and inserts the values into the array and returns the amount that was inserted
      Parameter:
      a - where the elements should be inserted
      i - the source iterator
      offset - the array offset where the start should be
      max - the maximum values that should be extracted from the source
      Gibt zurück:
      the amount of elements that were inserted into the array.
      Löst aus:
      IllegalStateException - if max is smaller the 0 or if the maximum index is larger then the array
    • pour

      public static BooleanList pour(BooleanIterator iter)
      A Helper function to pours all elements of a Iterator into a List
      Parameter:
      iter - the elements that should be poured into list.
      Gibt zurück:
      A list of all elements of the Iterator
    • pour

      public static BooleanList pour(BooleanIterator iter, int max)
      A Helper function to pours all elements of a Iterator into a List
      Parameter:
      iter - the elements that should be poured into list.
      max - the maximum amount of elements that should be collected
      Gibt zurück:
      A list of all requested elements of the Iterator
    • pour

      public static int pour(BooleanIterator iter, BooleanCollection c)
      A Helper function to pours all elements of a Iterator into a Collection
      Parameter:
      iter - the elements that should be poured into list.
      c - the collection where the elements should be poured into
      Gibt zurück:
      the amount of elements that were added
    • pour

      public static int pour(BooleanIterator iter, BooleanCollection c, int max)
      A Helper function to pours all elements of a Iterator into a Collection
      Parameter:
      iter - the elements that should be poured into list.
      c - the collection where the elements should be poured into
      max - the maximum amount of elements that should be collected
      Gibt zurück:
      the amount of elements that were added
    • concat

      public static BooleanIterator concat(BooleanIterator... array)
      Helper Iterator that concats other iterators together
      Parameter:
      array - the Iterators that should be concatenated
      Gibt zurück:
      iterator of the inputted iterators
    • concat

      public static BooleanIterator concat(BooleanIterator[] array, int offset, int length)
      Helper Iterator that concats other iterators together
      Parameter:
      array - the Iterators that should be concatenated
      offset - where to start within the array
      length - the length of the array
      Gibt zurück:
      iterator of the inputted iterators