Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 40b1874fdebecdae841768de06e0d11a6123d8d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*******************************************************************************
 * Copyright (c) 2002, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Rational Software - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.internal.core.parser;

import java.util.Iterator;
import java.util.NoSuchElementException;


public final class EmptyIterator<T> implements Iterator<T> 
{

	public static final EmptyIterator<?> EMPTY_ITERATOR = new EmptyIterator<Object>();
	
	@SuppressWarnings("unchecked")
	public static <T> EmptyIterator<T> empty() {
		return (EmptyIterator<T>) EMPTY_ITERATOR;
	}
	
	private EmptyIterator()
	{
	}
	
    /* (non-Javadoc)
     * @see java.util.Iterator#hasNext()
     */
    public final boolean hasNext()
    {
        return false;
    }

    /* (non-Javadoc)
     * @see java.util.Iterator#next()
     */
    public final T next()
    {
        throw new NoSuchElementException();
    }

    /* (non-Javadoc)
     * @see java.util.Iterator#remove()
     */
    public final void remove()
    {
		throw new UnsupportedOperationException();          
    }
	
}

Back to the top