/*******************************************************************************
 * Copyright (c) 2000, 2004 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 Corporation - initial API and implementation
 *******************************************************************************/
package net.sf.j2s.core.builder;

import org.eclipse.jdt.internal.core.util.SimpleSet;

public class WorkQueue {

private SimpleSet needsCompileList;
private SimpleSet compiledList;

public WorkQueue() {
	this.needsCompileList = new SimpleSet();
	this.compiledList = new SimpleSet();
}

public void add(SourceFile element) {
	needsCompileList.add(element);
}

public void addAll(SourceFile[] elements) {
	for (int i = 0, l = elements.length; i < l; i++)
		add(elements[i]);
}

public void clear() {
	this.needsCompileList.clear();
	this.compiledList.clear();
}	

public void finished(SourceFile element) {
	needsCompileList.remove(element);
	compiledList.add(element);
}

public boolean isCompiled(SourceFile element) {
	return compiledList.includes(element);
}

public boolean isWaiting(SourceFile element) {
	return needsCompileList.includes(element);
}

public String toString() {
	return "WorkQueue: " + needsCompileList; //$NON-NLS-1$
}
}
