Move from list to linked set for order conservation and use efficiency

This commit is contained in:
Emmanuel Bigeon 2018-10-11 11:33:15 -04:00
parent 438727e7b9
commit f8da1c0119

View File

@ -35,8 +35,8 @@ package net.bigeon.gclc.command;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import java.util.ArrayList; import java.util.LinkedHashSet;
import java.util.List; import java.util.Set;
import net.bigeon.gclc.exception.CommandRunException; import net.bigeon.gclc.exception.CommandRunException;
import net.bigeon.gclc.exception.InvalidCommandName; import net.bigeon.gclc.exception.InvalidCommandName;
@ -49,16 +49,19 @@ import net.bigeon.gclc.manager.ConsoleOutput;
* @author Emmanuel BIGEON */ * @author Emmanuel BIGEON */
public class CommandProvider implements ICommandProvider { public class CommandProvider implements ICommandProvider {
/** The minus character. */ /** The minus character. */
private static final String MINUS = "-"; //$NON-NLS-1$ private static final String MINUS = "-"; //$NON-NLS-1$
/** The space character. */ /** The space character. */
private static final String SPACE = " "; //$NON-NLS-1$ private static final String SPACE = " "; //$NON-NLS-1$
/** The commands map. */ /** The commands set.
protected final List<ICommand> commands; * <p>
* The insertion order is conserved through the use of a
* {@link LinkedHashSet}. */
protected final Set<ICommand> commands;
/** Create a command provider. */ /** Create a command provider. */
public CommandProvider() { public CommandProvider() {
super(); super();
commands = new ArrayList<>(); commands = new LinkedHashSet<>();
} }
/** Test the command name validity. /** Test the command name validity.