1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-22 23:40:08 -08:00

Switch all uses of *List, *Map to just List and Map.

This commit is contained in:
Danila Fedorin 2017-07-27 18:19:12 -07:00
parent bc23b8dbda
commit d9df565a42
8 changed files with 27 additions and 22 deletions

View File

@ -54,7 +54,7 @@ public class Lexer<T> {
/**
* The registered patterns.
*/
private HashMap<PatternEntry<T>, Pattern<T>> patterns;
private Map<PatternEntry<T>, Pattern<T>> patterns;
/**
* Creates a new lexer with no registered patterns.
@ -127,7 +127,7 @@ public class Lexer<T> {
* @param compare the comparator used to sort matches by their IDs.
* @return the resulting list of matches, in order, or null on error.
*/
public ArrayList<Match<T>> lexAll(String from, int startAt, Comparator<T> compare){
public List<Match<T>> lexAll(String from, int startAt, Comparator<T> compare){
int index = startAt;
ArrayList<Match<T>> matches = new ArrayList<>();
Match<T> lastMatch = null;

View File

@ -2,6 +2,7 @@ package org.nwapw.abacus.lexing.pattern;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
import java.util.function.Function;
@ -32,7 +33,7 @@ public class Pattern<T> {
* A map of regex operator to functions that modify a PatternChain
* with the appropriate operation.
*/
private HashMap<Character, Function<PatternChain<T>, PatternChain<T>>> operations =
private Map<Character, Function<PatternChain<T>, PatternChain<T>>> operations =
new HashMap<Character, Function<PatternChain<T>, PatternChain<T>>>() {{
put('+', Pattern.this::transformPlus);
put('*', Pattern.this::transformStar);

View File

@ -3,6 +3,7 @@ package org.nwapw.abacus.lexing.pattern;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
/**
* A base class for a pattern node. Provides all functions
@ -16,7 +17,7 @@ public class PatternNode<T> {
* The set of states to which the lexer should continue
* should this node be correctly matched.
*/
protected HashSet<PatternNode<T>> outputStates;
protected Set<PatternNode<T>> outputStates;
/**
* Creates a new pattern node.

View File

@ -4,6 +4,7 @@ import org.nwapw.abacus.function.Function;
import org.nwapw.abacus.function.Operator;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
@ -18,11 +19,11 @@ public abstract class Plugin {
/**
* A hash map of functions mapped to their string names.
*/
private HashMap<String, Function> functions;
private Map<String, Function> functions;
/**
* A hash map of operators mapped to their string names.
*/
private HashMap<String, Operator> operators;
private Map<String, Operator> operators;
/**
* The plugin manager in which to search for functions
* not inside this package,

View File

@ -15,29 +15,29 @@ public class PluginManager {
/**
* A list of loaded plugins.
*/
private ArrayList<Plugin> plugins;
private List<Plugin> plugins;
/**
* List of functions that have been cached,
* that is, found in a plugin and returned.
*/
private HashMap<String, Function> cachedFunctions;
private Map<String, Function> cachedFunctions;
/**
* List of operators tha have been cached,
* that is, found in a plugin and returned.
*/
private HashMap<String, Operator> cachedOperators;
private Map<String, Operator> cachedOperators;
/**
* List of all functions loaded by the plugins.
*/
private HashSet<String> allFunctions;
private Set<String> allFunctions;
/**
* List of all operators loaded by the plugins.
*/
private HashSet<String> allOperators;
private Set<String> allOperators;
/**
* The list of plugin listeners attached to this instance.
*/
private HashSet<PluginListener> listeners;
private Set<PluginListener> listeners;
/**
* Creates a new plugin manager.
@ -155,7 +155,7 @@ public class PluginManager {
* Gets all the functions loaded by the Plugin Manager.
* @return the set of all functions that were loaded.
*/
public HashSet<String> getAllFunctions() {
public Set<String> getAllFunctions() {
return allFunctions;
}
@ -163,7 +163,7 @@ public class PluginManager {
* Gets all the operators loaded by the Plugin Manager.
* @return the set of all operators that were loaded.
*/
public HashSet<String> getAllOperators() {
public Set<String> getAllOperators() {
return allOperators;
}

View File

@ -1,6 +1,7 @@
package org.nwapw.abacus.tree;
import java.util.ArrayList;
import java.util.List;
/**
* A node that represents a function call.
@ -14,7 +15,7 @@ public class FunctionNode extends TreeNode {
/**
* The list of arguments to the function.
*/
private ArrayList<TreeNode> children;
private List<TreeNode> children;
/**
* Creates a function node with no function.

View File

@ -19,11 +19,11 @@ public class TreeBuilder {
/**
* The map of operator precedences.
*/
private HashMap<String, Integer> precedenceMap;
private Map<String, Integer> precedenceMap;
/**
* The map of operator associativity.
*/
private HashMap<String, OperatorAssociativity> associativityMap;
private Map<String, OperatorAssociativity> associativityMap;
/**
* Comparator used to sort token types.
@ -70,7 +70,7 @@ public class TreeBuilder {
* @param string the string to tokenize.
* @return the list of tokens produced.
*/
public ArrayList<Match<TokenType>> tokenize(String string){
public List<Match<TokenType>> tokenize(String string){
return lexer.lexAll(string, 0, tokenSorter);
}
@ -80,7 +80,7 @@ public class TreeBuilder {
* @param from the tokens to be rearranged.
* @return the resulting list of rearranged tokens.
*/
public ArrayList<Match<TokenType>> intoPostfix(String source, ArrayList<Match<TokenType>> from){
public List<Match<TokenType>> intoPostfix(String source, List<Match<TokenType>> from){
ArrayList<Match<TokenType>> output = new ArrayList<>();
Stack<Match<TokenType>> tokenStack = new Stack<>();
while(!from.isEmpty()){
@ -138,7 +138,7 @@ public class TreeBuilder {
* @param matches the list of tokens from the source string.
* @return the construct tree expression.
*/
public TreeNode fromStringRecursive(String source, ArrayList<Match<TokenType>> matches){
public TreeNode fromStringRecursive(String source, List<Match<TokenType>> matches){
if(matches.size() == 0) return null;
Match<TokenType> match = matches.remove(0);
TokenType matchType = match.getType();
@ -170,7 +170,7 @@ public class TreeBuilder {
* @return the resulting tree.
*/
public TreeNode fromString(String string){
ArrayList<Match<TokenType>> matches = tokenize(string);
List<Match<TokenType>> matches = tokenize(string);
if(matches == null) return null;
matches.removeIf(m -> m.getType() == TokenType.WHITESPACE);
matches = intoPostfix(string, matches);

View File

@ -6,6 +6,7 @@ import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import java.util.ArrayList;
import java.util.List;
/**
* A table model to store data about the history of inputs
@ -57,7 +58,7 @@ public class HistoryTableModel extends AbstractTableModel {
/**
* The list of entries.
*/
ArrayList<HistoryEntry> entries;
List<HistoryEntry> entries;
/**
* Creates a new empty history table model