/* This file is part of SableCC ( http://sablecc.org ).
 * 
 * See the NOTICE file distributed with this work for copyright information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.sablecc.sablecc.util;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import org.sablecc.sablecc.exception.InternalException;

public class WorkSet<T> {

    private final Set<T> done = new HashSet<T>();

    private final LinkedHashSet<T> toDo = new LinkedHashSet<T>();

    public boolean hasNext() {

        return !this.toDo.isEmpty();
    }

    public T next() {

        T next = this.toDo.iterator().next();

        this.toDo.remove(next);
        this.done.add(next);

        return next;
    }

    public void add(
            T element) {

        if (element == null) {
            throw new InternalException("element may not be null");
        }

        if (!this.done.contains(element)) {
            this.toDo.add(element);
        }
    }
}

@@ -901,357 +901,989 @@
     
-private final Set%3CT%3E done = new HashSet%3CT%3E();%0A%0A    private final LinkedHashSet%3CT%3E toDo = new LinkedHashSet%3CT%3E();%0A%0A    public boolean hasNext() %7B%0A%0A        return !this.toDo.isEmpty();%0A    %7D%0A%0A    public T next() %7B%0A%0A        T next = this.toDo.iterator().next();%0A%0A        this.toDo.remove(next);%0A        this.done.add(next);%0A%0A        return next;%0A    %7D%0A
+/** The list of the elements already treated. */%0A    private final Set%3CT%3E done = new HashSet%3CT%3E();%0A%0A    /** The list of the elements left to be treated. */%0A    private final LinkedHashSet%3CT%3E toDo = new LinkedHashSet%3CT%3E();%0A%0A    /**%0A     * Indicates if an element has a next one.%0A     * %0A     * @return boolean a boolean value indicating whether the element has a next%0A     *         one or not.%0A     */%0A    public boolean hasNext() %7B%0A%0A        return !this.toDo.isEmpty();%0A    %7D%0A%0A    /**%0A     * Treats a new element, adding it to the done list.%0A     * %0A     * @return T the treated element.%0A     */%0A    public T next() %7B%0A%0A        T next = this.toDo.iterator().next();%0A%0A        this.toDo.remove(next);%0A        this.done.add(next);%0A%0A        return next;%0A    %7D%0A%0A    /**%0A     * Adds a new element to be treated.%0A     * %0A     * @param element%0A     *            the new element to be treated.%0A     * @throws InternalException%0A     *             if the element is %3Ccode%3Enull%3C/code%3E.%0A     */
 %0A   

Add javadoc comments.