001package org.clafer.collection; 002 003import gnu.trove.iterator.TIntIterator; 004import java.util.NoSuchElementException; 005 006/** 007 * An empty iterator. 008 * 009 * @author jimmy 010 */ 011public class EmptyIntIterator implements TIntIterator { 012 013 private static final EmptyIntIterator iterator = new EmptyIntIterator(); 014 015 private EmptyIntIterator() { 016 } 017 018 /** 019 * An iterator that is always empty. 020 * 021 * @return the empty iterator singleton 022 */ 023 public static EmptyIntIterator getIterator() { 024 return iterator; 025 } 026 027 /** {@inheritDoc} */ 028 @Override 029 public boolean hasNext() { 030 return false; 031 } 032 033 /** {@inheritDoc} */ 034 @Override 035 public int next() { 036 throw new NoSuchElementException(); 037 } 038 039 /** 040 * Not supported. 041 * 042 * @throws UnsupportedOperationException if invoked 043 */ 044 @Override 045 public void remove() { 046 throw new UnsupportedOperationException(); 047 } 048}