Skip to content

Commit

Permalink
Switch all uses of *List, *Map to just List and Map.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanilaFe committed Jul 28, 2017
1 parent f119f19 commit 2cc4bd1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/org/nwapw/abacus/lexing/Lexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public boolean equals(Object obj) {
/**
* 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.
Expand Down Expand Up @@ -127,7 +127,7 @@ public Match<T> lexOne(String from, int startAt, Comparator<T> compare){
* @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;
Expand Down
3 changes: 2 additions & 1 deletion src/org/nwapw/abacus/lexing/pattern/Pattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
import java.util.function.Function;

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/org/nwapw/abacus/lexing/pattern/PatternNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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
Expand All @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/org/nwapw/abacus/plugin/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.nwapw.abacus.function.Operator;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
Expand All @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions src/org/nwapw/abacus/plugin/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -155,15 +155,15 @@ public void reload(){
* 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;
}

/**
* 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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/org/nwapw/abacus/tree/FunctionNode.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.nwapw.abacus.tree;

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

/**
* A node that represents a function call.
Expand All @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions src/org/nwapw/abacus/tree/TreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -70,7 +70,7 @@ public void registerOperator(String operator, int precedence, OperatorAssociativ
* @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);
}

Expand All @@ -80,7 +80,7 @@ public ArrayList<Match<TokenType>> tokenize(String string){
* @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()){
Expand Down Expand Up @@ -138,7 +138,7 @@ public ArrayList<Match<TokenType>> intoPostfix(String source, ArrayList<Match<To
* @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();
Expand Down Expand Up @@ -170,7 +170,7 @@ public TreeNode fromStringRecursive(String source, ArrayList<Match<TokenType>> m
* @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);
Expand Down
3 changes: 2 additions & 1 deletion src/org/nwapw/abacus/window/HistoryTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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
Expand Down Expand Up @@ -57,7 +58,7 @@ Object nthValue(int n){
/**
* The list of entries.
*/
ArrayList<HistoryEntry> entries;
List<HistoryEntry> entries;

/**
* Creates a new empty history table model
Expand Down

0 comments on commit 2cc4bd1

Please sign in to comment.