/** * @param path path to first element * @param pathTo path to second element * @return environment in which the generic parameters in the path to the first element are bound * to those in the path to the second element, or null type on error */ public static ResolvedName mapGenericParameters( final Deque<? extends INamedElement> path, final Deque<? extends INamedElement> pathTo) { // Construct an environment in which the current function's generic parameters // are bound to those of the eventual override. final Deque<List<? extends ResolvedName>> tableau = new LinkedList<>(ResolvedName.fromNamedElement(path.getLast()).tableau()); final Iterator<? extends INamedElement> pathIt = path.descendingIterator(); while (pathIt.hasNext()) { pathIt.next(); tableau.removeLast(); } CachedIterator<? extends INamedElement> itPathTo = null; CachedIterator<? extends IGenericParameter> itGPTo = null; boolean end = false; { // Initialise iterators into direct override's generic parameters. boolean foundValid = false; itPathTo = Iterators.cached(pathTo.iterator()); while (!foundValid && itPathTo.hasItem()) { itGPTo = Iterators.cached(itPathTo.item().genericParameters().iterator()); while (!foundValid && itGPTo.hasItem()) { foundValid = true; if (!foundValid) itGPTo.next(); } if (!foundValid) itPathTo.next(); } if (!foundValid) end = true; } for (final INamedElement elt : path) { final List<ResolvedName> row = new ArrayList<>(); for (@SuppressWarnings("unused") final IGenericParameter genericParameter : elt.genericParameters()) { if (end) return null; row.add(ResolvedName.fromNamedElement(itGPTo.item())); { // Increment iterators into direct override's generic parameters. boolean init = true; boolean foundValid = false; if (!init) itPathTo = Iterators.cached(pathTo.iterator()); while (!foundValid && itPathTo.hasItem()) { if (!init) itGPTo = Iterators.cached(itPathTo.item().genericParameters().iterator()); while (!foundValid && itGPTo.hasItem()) { if (!init) foundValid = true; init = false; if (!foundValid) itGPTo.next(); } if (!foundValid) itPathTo.next(); } if (!foundValid) end = true; } } tableau.add(row); } if (!end) return null; return ResolvedName.newNameReference(path.getLast(), tableau); }
private void prune() { // Remove all values that are too old TimeInterval periodAllowed = cachedPeriod.before(buffer.getLast().getTimestamp()); while (!buffer.isEmpty() && !periodAllowed.contains(buffer.getFirst().getTimestamp())) { // Discard value buffer.removeFirst(); } }
private void reloadGame() { if (!isReload) return; score = 0; isReload = false; isEnd = false; feedCounter1 = 0; feedCounter2 = 0; List<Rectangle> rectangleList = new ArrayList<>(rectangles); for (Rectangle r : rectangleList) group.getChildren().remove(r); regimeRectangle.setX(-20); Deque<Block> blocksTemp = new ArrayDeque<>(); Deque<Rectangle> rectanglesTemp = new ArrayDeque<>(); head = new Block(100, 150); tale = new Block(90, 150); if (inputDirection != 3) { blocksTemp.push(tale); blocksTemp.push(head); rectanglesTemp.push(new Rectangle(tale.getX(), tale.getY(), 10, 10)); rectanglesTemp.push(new Rectangle(head.getX(), head.getY(), 10, 10)); } else { blocksTemp.push(head); blocksTemp.push(tale); rectanglesTemp.push(new Rectangle(head.getX(), head.getY(), 10, 10)); rectanglesTemp.push(new Rectangle(tale.getX(), tale.getY(), 10, 10)); } blocks = blocksTemp; rectangles = rectanglesTemp; group.getChildren().add(rectangles.getFirst()); group.getChildren().add(rectangles.getLast()); timer.cancel(); timer = null; timer = new Timer(); timer.schedule( new TimerTask() { @Override public void run() { Platform.runLater(() -> play()); } }, 1, 100); }
/** * Runs the server. The server will wait for some match info (which specifies the teams and set of * maps to run) and then begin running matches. */ public void run() { int aWins = 0, bWins = 0; while (!matches.isEmpty()) { Match match = matches.peek(); if (!finished.isEmpty()) match.setInitialTeamMemory(finished.getLast().getComputedTeamMemory()); try { debug("running match " + match); match.initialize(); runMatch(match, proxyWriter); finished.add(match); matches.remove(match); if (match.getWinner() == Team.A) aWins++; else if (match.getWinner() == Team.B) bWins++; match.finish(); // Allow best of three scrimmages -- single game scrims should still work fine // TODO:This "win mode" should probably be something from the database if (mode == Mode.TOURNAMENT || mode == Mode.SCRIMMAGE) { if (aWins == 2 || bWins == 2) break; } } catch (Exception e) { ErrorReporter.report(e); error("couldn't run match: "); this.state = State.ERROR; } } proxyWriter.terminate(); }
private CommitLogSegment currentSegment() { return segments.getLast(); }
public ExecutionInfo getExecutionInfo() { return infos.getLast(); }