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

net.sourceforge.plantuml.version.IteratorCounter2Impl Maven / Gradle / Ivy

There is a newer version: 1.2024.8
Show newest version
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.version;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import net.sourceforge.plantuml.text.StringLocated;

public class IteratorCounter2Impl implements IteratorCounter2 {

	private List data;
	private List trace;
	private int nb;

	public void copyStateFrom(IteratorCounter2 other) {
		final IteratorCounter2Impl source = (IteratorCounter2Impl) other;
		this.nb = source.nb;
		this.data = source.data;
		this.trace = source.trace;
	}

	public IteratorCounter2Impl(List data) {
		this(data, 0, new ArrayList());
	}

	private IteratorCounter2Impl(List data, int nb, List trace) {
		this.data = data;
		this.nb = nb;
		this.trace = trace;
	}

	public IteratorCounter2 cloneMe() {
		return new IteratorCounter2Impl(data, nb, new ArrayList<>(trace));
	}

	public int currentNum() {
		return nb;
	}

	public boolean hasNext() {
		return nb < data.size();
	}

	public StringLocated next() {
		final StringLocated result = data.get(nb);
		nb++;
		trace.add(result);
		return result;
	}

	public StringLocated peek() {
		return data.get(nb);
	}

	public StringLocated peekPrevious() {
		if (nb == 0) {
			return null;
		}
		return data.get(nb - 1);
	}

	public void remove() {
		throw new UnsupportedOperationException();
	}

	public final List getTrace() {
		return Collections.unmodifiableList(trace);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy