IntersectionIterator.java

net.minecraft.client.searchtree.IntersectionIterator

信息

  • 全限定名:net.minecraft.client.searchtree.IntersectionIterator
  • 类型:public class
  • 包:net.minecraft.client.searchtree
  • 源码路径:src/main/java/net/minecraft/client/searchtree/IntersectionIterator.java
  • 起始行号:L12
  • 继承:AbstractIterator
  • 职责:

    TODO

字段/常量

  • firstIterator

    • 类型: PeekingIterator<T>
    • 修饰符: private final
    • 源码定位: L13
    • 说明:

      TODO

  • secondIterator

    • 类型: PeekingIterator<T>
    • 修饰符: private final
    • 源码定位: L14
    • 说明:

      TODO

  • comparator

    • 类型: Comparator<T>
    • 修饰符: private final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

构造器

public IntersectionIterator(Iterator<T> firstIterator, Iterator<T> secondIterator, Comparator<T> comparator) @ L17

  • 构造器名:IntersectionIterator
  • 源码定位:L17
  • 修饰符:public

参数:

  • firstIterator: Iterator
  • secondIterator: Iterator
  • comparator: Comparator

说明:

TODO

方法

下面的方法块按源码顺序生成。

protected T computeNext() @ L23

  • 方法名:computeNext
  • 源码定位:L23
  • 返回类型:T
  • 修饰符:protected

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class IntersectionIterator<T> extends AbstractIterator<T> {
    private final PeekingIterator<T> firstIterator;
    private final PeekingIterator<T> secondIterator;
    private final Comparator<T> comparator;
 
    public IntersectionIterator(Iterator<T> firstIterator, Iterator<T> secondIterator, Comparator<T> comparator) {
        this.firstIterator = Iterators.peekingIterator(firstIterator);
        this.secondIterator = Iterators.peekingIterator(secondIterator);
        this.comparator = comparator;
    }
 
    @Override
    protected T computeNext() {
        while (this.firstIterator.hasNext() && this.secondIterator.hasNext()) {
            int compare = this.comparator.compare(this.firstIterator.peek(), this.secondIterator.peek());
            if (compare == 0) {
                this.secondIterator.next();
                return this.firstIterator.next();
            }
 
            if (compare < 0) {
                this.firstIterator.next();
            } else {
                this.secondIterator.next();
            }
        }
 
        return this.endOfData();
    }
}

引用的其他类