All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.security.fences.util.CountingIterable Maven / Gradle / Ivy

There is a newer version: 1.9-beta
Show newest version
package com.google.security.fences.util;

import java.util.Iterator;

import com.google.common.base.Preconditions;

/**
 * Each integer between two end-points in natural order once.
 */
public final class CountingIterable implements Iterable {
  private final int leftInclusive;
  private final int rightExclusive;

  CountingIterable(int leftInclusive, int rightExclusive) {
    Preconditions.checkArgument(leftInclusive <= rightExclusive);
    this.leftInclusive = leftInclusive;
    this.rightExclusive = rightExclusive;
  }

  public Iterator iterator() {
    return new CountingIterator(leftInclusive, rightExclusive);
  }

  @Override
  public String toString() {
    return "[" + leftInclusive + ".." + rightExclusive + ")";
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy