public int against(String team1, String team2) { if (!teamID.contains(team1) || !teamID.contains(team2)) throw new java.lang.IllegalArgumentException("Wrong team name input in against function"); int id1 = teamID.get(team1); int id2 = teamID.get(team2); return teamInfo[id1][id2 + 3]; }
public SymbolGraph(String filename, String delimiter) { st = new ST<String, Integer>(); // First pass builds the index by reading strings to associate // distinct strings with an index In in = new In(filename); while (in.hasNextLine()) { String[] a = in.readLine().split(delimiter); for (int i = 0; i < a.length; i++) { if (!st.contains(a[i])) st.put(a[i], st.size()); } } // inverted index to get string keys in an aray keys = new String[st.size()]; for (String name : st.keys()) { keys[st.get(name)] = name; } // second pass builds the graph by connecting first vertex on each // line to all others G = new Graph(st.size()); in = new In(filename); while (in.hasNextLine()) { String[] a = in.readLine().split(delimiter); int v = st.get(a[0]); for (int i = 1; i < a.length; i++) { int w = st.get(a[i]); G.addEdge(v, w); } } }
public int remaining(String team) { int index = 2; if (teamID.contains(team)) { int id = teamID.get(team); return teamInfo[id][index]; } else { throw new java.lang.IllegalArgumentException("Wrong team name input:" + team); } }
public int losses(String team) // number of losses for given team { int index = 1; if (teamID.contains(team)) { int id = teamID.get(team); return teamInfo[id][index]; } else { throw new java.lang.IllegalArgumentException("Wrong team name input:" + team); } }
// return st[i] public double get(int i) { if (i < 0 || i >= N) throw new RuntimeException("Illegal index"); if (st.contains(i)) return st.get(i); else return 0.0; }
public boolean contains(String s) { return st.contains(s); }