Class BiIterator<A,B>

java.lang.Object
com.landawn.abacus.util.BiIterator<A,B>
Type Parameters:
A -
B -
All Implemented Interfaces:
Immutable, Iterator<Pair<A,B>>

public abstract class BiIterator<A,B> extends Object
Since:
1.2.10
Author:
Haiyang Li
  • Constructor Details

    • BiIterator

      public BiIterator()
  • Method Details

    • empty

      public static <A, B> BiIterator<A,B> empty()
      Type Parameters:
      A -
      B -
      Returns:
    • of

      public static <K, V> BiIterator<K,V> of(Map<K,V> map)
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      map -
      Returns:
    • of

      public static <K, V> BiIterator<K,V> of(Iterator<Map.Entry<K,V>> iter)
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      iter -
      Returns:
    • generate

      public static <A, B> BiIterator<A,B> generate(Consumer<Pair<A,B>> output)
      Returns an infinite BiIterator.
      Type Parameters:
      A -
      B -
      Parameters:
      output - transfer the next values.
      Returns:
    • generate

      public static <A, B> BiIterator<A,B> generate(BooleanSupplier hasNext, Consumer<Pair<A,B>> output)
      Type Parameters:
      A -
      B -
      Parameters:
      hasNext -
      output -
      Returns:
    • generate

      public static <A, B> BiIterator<A,B> generate(int fromIndex, int toIndex, IndexedConsumer<Pair<A,B>> output)
      Type Parameters:
      A -
      B -
      Parameters:
      fromIndex -
      toIndex -
      output -
      Returns:
    • zip

      public static <A, B> BiIterator<A,B> zip(A[] a, B[] b)
      Type Parameters:
      A -
      B -
      Parameters:
      a -
      b -
      Returns:
    • zip

      public static <A, B> BiIterator<A,B> zip(A[] a, B[] b, A valueForNoneA, B valueForNoneB)
      Type Parameters:
      A -
      B -
      Parameters:
      a -
      b -
      valueForNoneA -
      valueForNoneB -
      Returns:
    • zip

      public static <A, B> BiIterator<A,B> zip(Collection<A> a, Collection<B> b)
      Type Parameters:
      A -
      B -
      Parameters:
      a -
      b -
      Returns:
    • zip

      public static <A, B> BiIterator<A,B> zip(Collection<A> a, Collection<B> b, A valueForNoneA, B valueForNoneB)
      Type Parameters:
      A -
      B -
      Parameters:
      a -
      b -
      valueForNoneA -
      valueForNoneB -
      Returns:
    • zip

      public static <A, B> BiIterator<A,B> zip(Iterator<A> iterA, Iterator<B> iterB)
      Type Parameters:
      A -
      B -
      Parameters:
      iterA -
      iterB -
      Returns:
    • zip

      public static <A, B> BiIterator<A,B> zip(Iterator<A> iterA, Iterator<B> iterB, A valueForNoneA, B valueForNoneB)
      Type Parameters:
      A -
      B -
      Parameters:
      iterA -
      iterB -
      valueForNoneA -
      valueForNoneB -
      Returns:
    • unzip

      public static <T, A, B> BiIterator<A,B> unzip(Iterator<? extends T> iter, BiConsumer<? super T,Pair<A,B>> unzip)
      Type Parameters:
      T -
      A -
      B -
      Parameters:
      iter -
      unzip - output parameter.
      Returns:
    • forEachRemaining

      public abstract <E extends Exception> void forEachRemaining(Throwables.BiConsumer<? super A,? super B,E> action) throws E
      For each remaining.
      Type Parameters:
      E -
      Parameters:
      action -
      Throws:
      E - the e
    • forEachRemaining

      @Deprecated public void forEachRemaining(Consumer<? super Pair<A,B>> action)
      Deprecated.
      It's preferred to call forEachRemaining(Try.BiConsumer) to avoid the create the unnecessary Pair Objects.
      Parameters:
      action -
    • map

      public abstract <R> ObjIterator<R> map(BiFunction<? super A,? super B,R> mapper)
      Type Parameters:
      R -
      Parameters:
      mapper -
      Returns:
    • stream

      public <R> Stream<R> stream(BiFunction<? super A,? super B,R> mapper)
      Type Parameters:
      R -
      Parameters:
      mapper -
      Returns:
    • toArray

      public Pair<A,B>[] toArray()
    • toArray

      public <T> T[] toArray(T[] a)
    • toList

      public List<Pair<A,B>> toList()
    • remove

      @Deprecated public void remove() throws UnsupportedOperationException
      Deprecated.
      - UnsupportedOperationException
      Specified by:
      remove in interface Iterator<T>
      Throws:
      UnsupportedOperationException
    • toSet

      public Set<Pair<A,B>> toSet()
    • toCollection

      public <C extends Collection<T>> C toCollection(Supplier<? extends C> supplier)
      Type Parameters:
      C -
      Parameters:
      supplier -
      Returns:
    • toImmutableList

      public ImmutableList<Pair<A,B>> toImmutableList()
    • toImmutableSet

      public ImmutableSet<Pair<A,B>> toImmutableSet()