blob: 3d0d54f5dbd3fdb1f7d531e53bb0a7780df92997 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro
* 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:
* Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.core.simple;
import java.util.Iterator;
/**
* Iterator of a singleton or an empty collection
*
* @author Andras Schmidt
*
*/
public class OneIterator<T> implements Iterator<T> {
T o;
/**
* Instantiate a iterator of a singleton or an empty collection
*
* @param o
* null: singleton colection, not null: collection that contains
* the given object
*/
public OneIterator(T o) {
this.o = o;
}
public boolean hasNext() {
return o != null;
}
public T next() {
T ret = o;
o = null;
return ret;
}
public void remove() {
}
}