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, IntObjConsumer<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(Iterable<A> a, Iterable<B> b)
      Type Parameters:
      A -
      B -
      Parameters:
      a -
      b -
      Returns:
    • zip

      public static <A, B> BiIterator<A,B> zip(Iterable<A> a, Iterable<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(Iterable<? extends T> iter, BiConsumer<? super T,Pair<A,B>> unzipFunc)
      Type Parameters:
      T -
      A -
      B -
      Parameters:
      iter -
      unzipFunc - output parameter.
      Returns:
    • unzip

      public static <T, A, B> BiIterator<A,B> unzip(Iterator<? extends T> iter, BiConsumer<? super T,Pair<A,B>> unzipFunc)
      Type Parameters:
      T -
      A -
      B -
      Parameters:
      iter -
      unzipFunc - 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 -
    • skip

      public BiIterator<A,B> skip(long n)
      Parameters:
      n -
      Returns:
    • limit

      public BiIterator<A,B> limit(long count)
      Parameters:
      count -
      Returns:
    • filter

      public BiIterator<A,B> filter(BiPredicate<? super A,? super B> predicate)
      Parameters:
      predicate -
      Returns:
    • map

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

      public u.Optional<Pair<A,B>> first()
      Returns:
    • last

      public u.Optional<Pair<A,B>> last()
      Returns:
    • stream

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

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

      @Deprecated public <T> T[] toArray(T[] a)
      Deprecated.
      Type Parameters:
      T -
      Parameters:
      a -
      Returns:
    • toList

      public List<Pair<A,B>> toList()
      Returns:
    • 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()
      Returns:
    • 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()
      Returns:
    • toImmutableSet

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