HyCodeYourTale
classpublicPriority 3

ForwardIntIterator

com.hypixel.hytale.builtin.hytalegenerator.iterators.ForwardIntIterator

implements IntIterator, Iterator

4

Methods

4

Public Methods

2

Fields

2

Constructors

Constructors

private
ForwardIntIterator()
public
ForwardIntIterator(int min, int maxExclusive)

Methods

Public Methods (4)

public
Integer getCurrent()
@Nonnull
public
boolean hasNext()
@Override
public
Integer next()
@Nonnull
public
int nextInt()

Fields

Private/Package Fields (2)

privateint current
privateint max

Inheritance

Parent
Current
Interface
Child

Use mouse wheel to zoom, drag to pan. Click nodes to navigate.

Source Code

package com.hypixel.hytale.builtin.hytalegenerator.iterators;

import it.unimi.dsi.fastutil.ints.IntIterator;
import java.util.Iterator;
import javax.annotation.Nonnull;

public class ForwardIntIterator implements IntIterator, Iterator<Integer> {
   private int max;
   private int current;

   public ForwardIntIterator(int min, int maxExclusive) {
      if (min > maxExclusive) {
         throw new IllegalArgumentException("Start greater than end.");
      } else {
         this.max = maxExclusive - 1;
         this.current = min - 1;
      }
   }

   private ForwardIntIterator() {
   }

   @Override
   public boolean hasNext() {
      return this.current < this.max;
   }

   public int nextInt() {
      return ++this.current;
   }

   @Nonnull
   public Integer next() {
      return ++this.current;
   }

   @Nonnull
   public Integer getCurrent() {
      return this.current;
   }

   @Nonnull
   public ForwardIntIterator clone() {
      ForwardIntIterator clone = new ForwardIntIterator();
      clone.current = this.current;
      clone.max = this.max;
      return clone;
   }
}