Java Iterator from createIntegerIterator(int start)

Here you can find the source of createIntegerIterator(int start)

Description

create Integer Iterator

License

Open Source License

Declaration

public static Iterable<Integer> createIntegerIterator(int start) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Iterator;

public class Main {
    public static Iterable<Integer> createIntegerIterator(int start) {
        return new Iterable<Integer>() {
            @Override//from  ww w  .  ja  va2  s  . c o  m
            public Iterator<Integer> iterator() {
                return new Iterator<Integer>() {
                    private int counter = start;

                    @Override
                    public boolean hasNext() {
                        return counter < Integer.MAX_VALUE;
                    }

                    @Override
                    public Integer next() {
                        return counter++;
                    }

                };
            }
        };
    }
}

Related

  1. createIterable(final Iterator src)
  2. get(Iterator iterator, int position)
  3. getAll(Iterator it)
  4. getAt(Iterator it, int pos)