text
stringlengths
14
410k
label
int32
0
9
private static void splitReciprocal(final double in[], final double result[]) { final double b = 1.0/4194304.0; final double a = 1.0 - b; if (in[0] == 0.0) { in[0] = in[1]; in[1] = 0.0; } result[0] = a / in[0]; result[1] = (b*in[0]-a*in[1]) / (in...
3
public static void main(String[] args) { log = new Log(); options = new OptionParser(); options.parse(args); log.setPath(options.logPath); // if files == null -> read from stdin List<File> files = options.getFiles(); List<IREntry> irEntries = new ArrayList<IREntry>(); try { IRProcessor irProcessor ...
7
@Override public After after(final Promise<?>... promises) { checkInTask(); final List<Task<?>> tmpPredecessorTasks = new ArrayList<Task<?>>(); for (Promise<?> promise : promises) { if (promise instanceof Task) { tmpPredecessorTasks.add((Task<?>) promise); } } fina...
9
private static Integer getLocationCategory(Measurement m) { if (m == null || m.getId() == null) return -1; Fingerprint f = HomeFactory.getFingerprintHome().getByMeasurementId(m.getId()); if (f != null) { Location l = (Location) f.getLocation(); if (l != null && l.getId() != null) { return Categ...
5
public void gatherContextInformation(String triggerMessage) { // Decode trigger message and get: // (A) user presence (key: user_presence) // (B) tags related to specific contextual situations that require specific recommendations // (e.g. "humidRoom" -> "open window" (key: room_airquality); // "noMovement" -...
7
@Override public void execute() { if(cheminsAvant == null){ if(chemins != null){ cheminsAvant = new LinkedList<>(); for(Chemin Ch : chemins){ cheminsAvant.add(new Chemin(Ch)); } } ...
9
private int[] GetWiredsInSquare(int[] Pos) { int p_count = count; int[] Wireds = new int[MAX_WIREDS_PER_ROOM]; int cur = 0; for (int i = 0; i < p_count; i++) { if (WiredPos[i][0] == Pos[0]) { if (WiredPos[i][1] == Pos[1]) ...
3
public static String reverseWords(char[] input) { int left = 0; int right = input.length-1; //reverse the complete string first while(left < right) { //swap left and right swap(input, left++, right--); } left = 0; // now run till left is l...
8
public boolean checkRight(Tetromino current, int x, int y, int orientation) { boolean result = true; int col = x-1; int width = current.getTiles()[0].length == 9 ? 3 : 4; // get width (3 or 4) of piece width = current.getTiles()[0].length == 4 ? 2 : width; if(col - current.bufferRight(orientation) > (9-width-...
3
@Override public boolean execute() { Boolean val = true; try { List<Font> fonts = new ArrayList<Font>(); for (int i = this.startFrom; i <= this.endAt; i++) { Font previousFont = this.document.getChildren().get(i) .getFont(); Font newFont = new Font(previousFont.getName(), previousFont.get...
2
public static Score[] getHighscores(){ Score[] scores = new Score[Config.HIGHSCORES_COUNT]; try { if (Pang.game.haveToBeOffline) {throw (new java.net.ConnectException());} Socket socket = new Socket(Config.HOST_NAME, Config.PORT_NUMBER); OutputStream os = socket.getOutputStream(); ...
8
public void createFromXML(NodeList options) { Node n = options.item(0); while(n != null) { if(n.getNodeType() == Node.ELEMENT_NODE) { if(n.getNodeName().equalsIgnoreCase("soundVolume")) { soundVolume = Float.parseFloat(n.getFirstChild().getNodeValue()); ...
4
static void init() { try{ p = new PrintWriter("bitvals.txt"); } catch (Exception e) { System.out.println("Can't open the file"); } try{ u = new URL("https://coinbase.com/api/v1/prices/buy"); } catch (Exception e) { System.out.println("URL ain't right"); } try{ h = (HttpURLConnection...
6
public void initiateCloaking() { cloakedBlocks.clear(); BlockFace facing = getDirection(machineLocation.getBlock()); Vector miningOffset = getCloakingOffset(facing); Location startingPos = machineLocation.getBlock().getLocation().add( (int)miningOffset.getX(), (int)miningOffset.getY(), (int)miningOff...
4
public static Shape getWallShadow(Point2D source, Line2D wall, double panelWidth, double panelHeight) { final Path2D shadow = new Path2D.Double(); final LineEquation eq = new LineEquation(wall); final boolean clockwise = eq.getRelativePostion(source); final Point2D p1 = clockwise ? wall...
3
public void doUpdating(){ if (shouldBeUpdated()){ update(); } if (isDraggable()){ doMouseDraggingCheck(); } for (Runnable r : runList){ r.run(); } for (VGuiBase parent : childs) { if (parent.shouldBeUpdated()) { ...
5
static int recursiveFactorial(int a){ if(a == 1){ return 1; } return a * recursiveFactorial(a-1); }
1
@Override public void actionPerformed(ActionEvent e) { if(connect == e.getSource()) { connect(); } if(leave == e.getSource()) { leave(); } if(quit == e.getSource()){ leave(); close(); System.exit(0); } /* * If the user pressed enter in the message text box. */ ...
8
private static int hex2int(char c) { int nybble; if (c >= '0' && c <= '9') { nybble = c - '0'; } else if (c >= 'a' && c <= 'f') { nybble = 10 + c - 'a'; } else if (c >= 'A' && c <= 'F') { nybble = 10 + c - 'A'; } else { throw new Il...
6
public static void load(File file) { YamlConfiguration config = new YamlConfiguration(); try { config.load(file); Major.add("Dollar"); Major.add("Dollars"); BankMajor.add("Dollar"); BankMajor.add("Dollars"); Minor.add("Coin"); Minor.add("Coins"); BankMinor.add("Coin"); BankMinor.add("Coi...
3
public BigramHiddenMarkovModel(Corpus corpus) { this.vocabSize = corpus.getVocabularySize(); this.numSentences = corpus.getNumSentences(); this.tagBigrams = new HashMap<String, Map<String,Integer>>(); this.tagToToken = new HashMap<String, Map<String,Integer>>(); this.probabilityMatrix = new ArrayList<double[]...
9
private void giveBirth(List<Actor> newFoxes) { // New foxes are born into adjacent locations. // Get a list of adjacent free locations. Field field = getField(); List<Location> free = field.getFreeAdjacentLocations(getLocation()); int births = breed(); for(int b = 0; ...
2
private void placeChargedIdentityDiscs() { // Calculate the middle position of the grid Position middle = new Position(grid.width / 2, grid.height / 2); // Generate all the surrounding positions List<Position> positions = grid.getPositionsAround(middle); Random random = new Random(); while (positions....
3
@Override public void update(Observable o, Object arg) { System.out.println(boardToString()); if (boardModel.getGameWon() || boardModel.getGameLost()) { //check win and loss conditions //set up a window with message for each possible game outcome if (boardModel.getGameLost()) { System.out.println("Yo...
8
protected JacksonJsonProvider getJsonProvider() { if (delegate != null) { return delegate; } synchronized (this) { if (delegate != null) { return delegate; } for (Object o : application.getSingletons()) { if (o instanceof JacksonJsonProvider) { delegate = ...
4
void writeAVLMassData(FileOutputStream fos) { PrintStream ps = new PrintStream(fos); String lunit = "0.01 m"; if(this.getLengthUnit().equals("m")) lunit = "1 m"; else if(this.getLengthUnit().equals("in")) lunit = UnitConversor.INCHES_TO_METERS + " m"; String munit = "0.001 kg";...
6
public void literal() { if(have(Token.Kind.INTEGER)){ expectRetrieve(Token.Kind.INTEGER); } else if(have(Token.Kind.FLOAT)){ expectRetrieve(Token.Kind.FLOAT); } else if(have(Token.Kind.TRUE)){ expectRetrieve(Token.Kind.TRUE); } else if(have(Token.Kind.FALSE)){ expectRetrieve(Token.Kind.FALSE)...
4
public void run() { long currentTime = System.currentTimeMillis(); //mark things as deletable if they have not been updated //in timeFail milliseconds for(String key: this.gs.getMembershipList().getKeys()) { long compareTime = this.gs.getMembershipList().getMember(key).getTimeStamp(); //mark as deletable...
7
@Override public boolean isMoveValid(int srcRow, int srcCol, int destRow, int destCol) { // TODO Auto-generated method stub boolean result = false; if( ((destRow == (srcRow - (srcRow - destRow))) && (destCol == srcCol)) || //up ((destRow == (srcRow + (srcRow - destRow))) && (destCol == srcCol)) || ...
8
private void insertSubLCommandInfo(final SubLCommandInfo subLCommandInfo) { //// Preconditions assert subLCommandInfo != null : "subLCommandInfo must not be null"; assert mostTimeConsumingSubLCommandInfos != null : "mostTimeConsumingSubLCommandInfos must not be null"; assert MOST_TIME_CONSUMING_API_REQ...
4
protected int getNeighbor(int cellId, Directions dir) { if (cellId > countCells() - 1) { return countCells() - 1; } if (cellId < 0) { return 0; } Vector<Integer> sortedNeighbors = getSortedNeighbors(cellId); if (dir == Directions.none) { ...
3
public void parse(Node n){ if (null != n){ NodeList _list = n.getChildNodes(); String idstr = n.getAttributes().getNamedItem("id").getNodeValue(); id = Integer.parseInt(idstr); for (int i=0;i<_list.getLength();i++){ String name = _list.item(i).getNodeName(); NodeList _l = _list.item(i).getChildNod...
9
private Keycode convertKeycode(int extendedKeycode) { switch (extendedKeycode) { case 65: // 'A' case 37: // Arrow Left return Keycode.LEFT; case 68: // 'D' case 39: // Arrow Right return Keycode.RIGHT; case 87: // 'W' case 38: // Arrow Up return Keycode.UP; case 83: // 'S' case 4...
9
public void testGetField() { Partial test = createHourMinPartial(COPTIC_PARIS); assertSame(CopticChronology.getInstanceUTC().hourOfDay(), test.getField(0)); assertSame(CopticChronology.getInstanceUTC().minuteOfHour(), test.getField(1)); try { test.getField(-1); } catc...
2
public static String unescapeHTML(String text) { text = StringTools.replace(text,"&amp;","&"); text = StringTools.replace(text,"&lt;","<"); text = StringTools.replace(text,"&gt;",">"); text = StringTools.replace(text,"&quot;","\""); return text; }
0
public Object[][] consultarProgramas(String codigo, String nombre, String nivel, String creditos) { //<editor-fold defaultstate="collapsed" desc="consultarProgramas()"> if (!creditos.isEmpty()) { try { Integer.parseInt(creditos); } catch (NumberFormatException num...
3
public AlumnoBean get(AlumnoBean oAlumnoBean) throws Exception { if (oAlumnoBean.getId() > 0) { try { oMysql.conexion(enumTipoConexion); if (!oMysql.existsOne("alumno", oAlumnoBean.getId())) { oAlumnoBean.setId(0); } else { ...
4
public List<JSONArray> extractFromCrawler(Path file, String[] related) { List<JSONArray> results = new ArrayList<JSONArray>(); String name = "" + file; boolean cont; try { Object obj = parser.parse(new FileReader(name)); JSONObject jsonObject = (JSONObject) obj; JSONArray docs = (JSONArray)jsonO...
8
public static <E> boolean structurallyEquivalent(Dendrogram<E> dendrogram1, Dendrogram<E> dendrogram2) { if (dendrogram1 instanceof LeafDendrogram) { if (!(dendrogram2 instanceof LeafDendrogram)) return false; ...
8
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed // Pick Up boolean resPicked=false; for(Reservation r:reservations){ if(r.getMember().getFirstName().trim().equals(jTextField32.getText().trim().s...
8
public Boolean getBooleanItem(String... names) throws ReaderException { if (getItem(names).toString() == "true" || getItem(names).toString() == "false") { return Boolean.parseBoolean(getItem(names).toString()); } else { throw new ReaderException("No key exists with this type, keys: " + _parseMessage(names) + ...
2
public final GalaxyXLinkingParser.assignment_statement_return assignment_statement() throws RecognitionException { GalaxyXLinkingParser.assignment_statement_return retval = new GalaxyXLinkingParser.assignment_statement_return(); retval.start = input.LT(1); int assignment_statement_StartIndex = i...
8
public boolean isEqual(Cluster c) { if(!name.equals(c.getName())) return false; if(c.getNumberOfPoints() != points.size()) return false; for(int i = 0; i < points.size(); i++) { if(!points.get(i).isEqual(c.getPointAt(i))) return false; } if(!centoid.isEqual(c.getCentoid())) return false; ...
5
public Match(int width, int height, int playerCount, int unitCount, int abilityCount) { MatchCommandListener commandListener = new MatchCommandListener(this); board = new Board(width, height, commandListener); panel = new MatchPanel(commandListener, commandListener, board); this.players = new Player[playerCo...
3
public boolean ModificarActividad(Actividad p){ if (p!=null) { cx.Modificar(p); return true; }else { return false; } }
1
public PropQuad(PropQuad parent, Rectangle2D container, ArrayList<Entity> props, ArrayList<Rectangle2D> rects, ArrayList<Rectangle2D> flatRects) { this.parent = parent; this.container = container; for(int x = 0; x<props.size(); x++) { if(container.intersects(props.get(x).getBox())) { this.props.add(props.g...
9
public SpinningWheel(int x, int y, int size, int delay) { for(int i = 0; i < images.length; i++) { images[i] = Utilities.resizeImage(size, size, "resources/InfiniteProgress_" + i + ".png"); currentImage = images[0]; } this.setBounds(x, y, images[0].getWidth(null), images[0].getHeight(null)); timer = new T...
2
public void sendState(sharedstate.SharedState state) throws Exception { System.out.println("Sending state"); if (!connected) { byte[] sendBuffer = ("type:connect\nid:" + state.getMyId() + "\n").getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendBuffer, sendBuffer.length, ip, port); sock.send(se...
3
public FeedManager(){ loadListbox(); this.setPreferredSize(new Dimension(500,255)); this.setResizable(false); this.setSize(500, 500); ActionListener action = (ActionEvent e) -> { if(null != e.getActionCommand()){ switch (e.getActionCommand()) { ...
4
@Override public int compare(Tile o1, Tile o2) { if (o1.getPriority() == Tile.Priority.Low && o2.getPriority() == Tile.Priority.High) { return 1; } if (o1.getPriority() == Tile.Priority.High && o2.getPriority() == Tile.Priority.Low) { return -1; } return 0; }
4
private void updateTable(){ _files = new ArrayList<File>(); _dirs = new ArrayList<File>(); int rowCount=_tablemodel.getRowCount(); for (int i = rowCount - 1;i >= 0;i--) { _tablemodel.removeRow(i); } File folder = new File(_currentpath); ...
9
private boolean accepts(final String[] lines) { for (int i = 0; i <= 3; i++) if (this.text[i] != null && !this.text[i].matcher(lines[i]).find()) return false; return true; }
3
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ExpressionNode that = (ExpressionNode) o; if (left != null ? !left.equals(that.left) : that.left != null) return false; if (right != null ? !ri...
9
public boolean checkUniqueNickname(String nickname){ boolean isUnique = false; try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); String url = "jdbc:derby:" + DBName; Connection connection = DriverManager.getConnection(url); Statement statement = connection.createStatement(); String sqlStat...
1
@Test public void test_removeAllPawns(){ assertNotNull(board); assertEquals(numberOfPawns, board.numberOfPawns()); Pawn pawn1 = new Pawn('l', 3,4, board); Pawn pawn2 = new Pawn('m', 2,3, board); board.addPawn(pawn1); board.addPawn(pawn2); board.removeAllPawn...
0
public void inscrireJoueurs() { Scanner sc = new Scanner(System.in); System.out.println("Entrez le nombre de joueurs :"); int NbJoueurs; if(this.isDetermine()){NbJoueurs = 4;} else{NbJoueurs = sc.nextInt();} if(NbJoueurs < 2){NbJoueurs...
4
public boolean isRunActive(boolean quiet) { try { URL url = new URL(HTTP_DATA_SERVER + "status"); String reply = _readText(url.openStream()).trim(); Document document = _documentBuilder.parse(new InputSource(new StringReader(reply))); NodeList nlist = document.getElementsByTagNam...
6
public static void main(String[] args) { new DataType(4); }
0
public Player findPlayer(String name) { Player toreturn = null; for (int i = 0; i < players.size(); i++) { if (name.equals(players.get(i).username)) return players.get(i); else if (players.get(i).username.indexOf(name) != -1 && toreturn == null) toreturn = players.get(i); else if (players.get(i).us...
6
void updateVerticalBar () { if (drawCount > 0) return; ScrollBar vBar = getVerticalBar (); if (vBar == null) return; int pageSize = (clientArea.height - getHeaderHeight ()) / itemHeight; int maximum = Math.max (1, itemsCount); /* setting a value of 0 here is ignored */ if (maximum != vBar.getMaximum ()) { vBar...
6
* @param options * @param legaloptionsAtypes * @param coercionerrorP * @param allowotherkeysP * @return PropertyList */ public static PropertyList parseOptions(Stella_Object options, Cons legaloptionsAtypes, boolean coercionerrorP, boolean allowotherkeysP) { { PropertyList self000 = PropertyList.ne...
9
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (args[0].equalsIgnoreCase("create")) { if (!sender.hasPermission("scrollteleportation.create")) { sender.sendMessage(ChatColor.RED + "You are not allowed to create scrolls"); return true; } if (!(...
7
public void aniadirSeg (int numSeg) { if (numSeg>=0) { seg+=numSeg; if (this.getSeg()>=60) { int acum=this.getSeg()/60; this.setSeg(seg%=60); min+=acum; if(this.ge...
4
void parseAttDef(String elementName) throws java.lang.Exception { String name; int type; String enum_ = null; // Read the attribute name. name = readNmtoken(true); // Read the attribute type. requireWhitespace(); type = readAttType(); // Get...
2
public static void main(String args[]){ barcos = new ArrayList<Barco>(); int op; do{ System.out.println("\n\nMENU PRINCIPAL"); System.out.println("1- Agregar Barco"); System.out.println("2- Agregar Elemento"); System.out.println("3- Vaciar...
7
public Object nextEntity(char ampersand) throws JSONException { StringBuffer sb = new StringBuffer(); for (;;) { char c = next(); if (Character.isLetterOrDigit(c) || c == '#') { sb.append(Character.toLowerCase(c)); } else if (c == ';') { ...
5
public boolean getBoolean(int index) throws JSONException { Object object = this.get(index); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String) object) .equalsIgnoreCase("false"))) { return false; } else if (object.equal...
6
void run() { Vertex[] vertices = new Vertex[SIZE * SIZE]; for (int x = 0; x < SIZE; x++) { for (int y = 0; y < SIZE; y++) { vertices[index(x, y)] = new Vertex(x, y); } } for (int x = 0; x < SIZE; x++) { for (int y = 0; y < SIZE; y++) { Vertex v = vertices[index(x, y)]; // add left if ...
9
public int checkELU() { if(cornerMap.get("E").equals("E") && cornerMap.get("L").equals("L") && cornerMap.get("U").equals("U")) { return SOLVED; } if(cornerMap.get("E").equals("U") && cornerMap.get("L").equals("E") && cornerMap.get("U").equals("L")) { return CW; } if(cornerMap.get("E...
9
public Items() { }
0
public static void main(String[] args) { long startTimeMillis = System.currentTimeMillis(); int[] factorials = new int[10]; factorials[0] = factorials[1] = 1; for (int i = 2; i < factorials.length; i++) factorials[i] = factorials[i - 1] * i; int[] lengths = new int[1000000]; for (int i = 0; i < lengths....
7
public static String request(String url) { CloseableHttpClient httpclient = HttpClients.createDefault(); CloseableHttpResponse response = null; StringBuilder builder = new StringBuilder(); StringBuilder reqUrl = new StringBuilder(); reqUrl.append(URL); reqUrl.append(url); reqUrl.append("&key="); reqUrl...
6
private float[] getComputedWindow() { int ix = (blockFlag ? 4 : 0) + (previousWindowFlag ? 2 : 0) + (nextWindowFlag ? 1 : 0); float[] w = windows[ix]; if (w == null) { w = new float[n]; for (int i = 0; i < leftN; i++) { float x = (float) ((i + .5) / leftN...
7
private void oilResatBuffer(CPRect srcRect, CPRect dstRect, int[] buffer, int w, int alpha1, int color1) { if (alpha1 <= 0) { return; } int by = srcRect.top; for (int j = dstRect.top; j < dstRect.bottom; j++, by++) { int srcOffset = srcRect.left + by * w; int dstOffset = dstRect.left + j * widt...
4
public static int verify(InputStream stream) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(stream)); int lineNum = 0; String prev = ""; while(true) { lineNum++; String line = in.readLine(); if(line == null) break; if(line.length() == 0) continue; //t...
4
public void addNeighbors(int x, int y, int z, BlockType blockType){ if (!blockType.isTransparent()) return; if (getVisited(x - 1, y, z) == NOT_VISITED) { queue.add(new Point3D(x - 1,y, z)); setVisited(x-1, y, z, QUEUED); } if (getVisited(x + 1, y, z) == NOT_VISITED) { queue.add(new Point3D(x + 1,...
7
@Override public Dimension getPreferredSize() { List<Column> columns = mOwner.getModel().getColumns(); boolean drawDividers = mOwner.shouldDrawColumnDividers(); Insets insets = getInsets(); Dimension size = new Dimension(insets.left + insets.right, 0); ArrayList<Column> changed = new ArrayList<>(); for (Co...
6
public Map getHeaders() { Map lisOfHeader=new LinkedHashMap(); FileInputStream file = null; try { try { file = new FileInputStream(new File("C:\\AEM-CQ-Automation\\AEM-CQ-Automation\\Ford\\ExcelToXml.xlsx")); ...
9
private void waitForThread() { if ((this.thread != null) && this.thread.isAlive()) { try { this.thread.join(); } catch (final InterruptedException e) { e.printStackTrace(); } } }
3
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
6
public static EntityFilter from(ConfigurationSection section) throws InvalidConfigurationException { EntityFilter filter = new EntityFilter(); for (String key : section.getKeys(false)) { String value = section.getString(key); boolean include; if (value.equalsIgnoreCase("ignore")) include = false; ...
9
@Before public void setUp() { this._instance = new ChristmasDay(); this._years = new LinkedList<Integer>(); for (int year = 1974; year < 2021; year++) this._years.add(year); this._ChristmasDayUnitedKingdoms = new HashMap<Integer, GregorianCalendar>(); for (int yea...
8
public void paint(Graphics g) { Font font=g.getFont(); if(fontSize==-1) fontSize=font.getSize(); if(font.getSize()!=fontSize) font=font.deriveFont(fontSize); font=new Font("sansserif",Font.PLAIN,fontSize); g.setFont(font); FontMetrics fm=getFontMetrics(font); Rectangle2D titleRect=fm.getStringB...
9
private static void makeDefaults(String filename, Server server, Properties p) { //TODO Fill in all defaults server.Log("System config not found..creating.."); p.addSetting("Server-Name", "[GGS] Default Server"); p.addSetting("WOM-Alternate-Name", "[GGS] Default Server"); p.addSetting("MOTD", "Welcome!"); p...
2
public static void main (String[] args){ int ss = 0; int sum = 0; for (int i=1;i<=100;i++){ sum+=i; ss+=i*i; } System.out.println(sum*sum - ss); }
1
public void buyObjective() { if (this.game.chestOpen && this.chestWood >= 50 && this.chestStone >= 30) { // build objective // end game this.chestWood -= 50; this.chestStone -= 30; System.out.println("juhuu gewonnen!"); this.game.house = true; } }
3
public int getIndexSize (int loc) { // System.out.println("Getting size of index at "+loc); int hold = pos; pos = loc; int count = readInt (2); if (count <= 0) { return 2; } int encsz = readByte (); if (encsz < 1 || encsz > 4) { thr...
3
public void flushInputStream(byte buf[], int len) throws IOException { int i = 0; if (closed) { return; } int k; for (; len > 0; len -= k) { k = inputStream.read(buf, i, len); if (k <= 0) { throw new IOException("EOF"); } i += k; } }
3
public int uniquePaths(int m, int n) { // A[i][j] = A[i-1][j] + A[i][j-1] int[][] A = new int[m][n]; for( int i = 0; i < m; i++ ) A[i][0] = 1; for( int j = 1; j < n; j++ ) A[0][j] = 1; for( int i = 1; i < m; i++ ) { for( int j = 1; j < n; j++ ) { A[i...
4
public Transition copy(State from, State to) { return new VDGTransition(from, to); }
0
@Override public void execute(CommandSender sender, String worldName, List<String> args) { this.sender = sender; if (worldName == null) { error("No world given."); reply("Usage: /gworld listplayers <worldname>"); } else if (!hasWorld(worldName)) { reply("World not found: " + worldName); } else { ...
4
public void initSimulationPanel() { if (results == null) return; int maxPeopleEating = Integer.MIN_VALUE; int maxPeopleFinished = Integer.MIN_VALUE; int maxPeopleInFoodQueue = Integer.MIN_VALUE; int maxPeopleInTableQueue = Integer.MIN_VALUE; int actualPeopleEating; int actualPeopleFinished; int actualPe...
6
private static byte method513(char c) { if (c >= 'a' && c <= 'z') return (byte) ((c - 97) + 1); if (c == '\'') return 28; if (c >= '0' && c <= '9') return (byte) ((c - 48) + 29); else return 27; }
5
public int singleNumber(int[] A) { int res = 0; for(int i = 0; i < 32; ++i){ int bit = 1 << i; int count = 0; for(int a : A){ count += (a&bit) >> i; } res |= (count%3) << i; } return res; }
2
public EncryptedDataType createEncryptedDataType() { return new EncryptedDataType(); }
0
public void run() { try { // reader for incoming messages initialization ObjectInputStream objIn = new ObjectInputStream(clientSocket.getInputStream()); // wait for a request CAMessage received = (CAMessage)objIn.readObject(); ...
4
@Override public BakingActionResult checkActionIsApplicableInState(State state, String[] params) { BakingActionResult superResult = super.checkActionIsApplicableInState(state, params); if (!superResult.getIsSuccess()) { return superResult; } String agentName = params[0]; ObjectInstance agent = stat...
9
public static String convertResourcePathToClassName(String resourcePath) { Assert.notNull(resourcePath, "Resource path must not be null"); return resourcePath.replace('/', '.'); }
0
public void setDefault(FileProtocol defaultProtocol) { this.defaultProtocol = defaultProtocol; }
0
public void draw() { //Buffer for manual double buffering BufferedImage buffer = new BufferedImage(GraphicsMain.WIDTH, GraphicsMain.HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gBuffer = (Graphics2D)buffer.getGraphics(); drawGround(gBuffer); drawWorld(gBuffer); g.drawImage(buffer, 0, 0, GraphicsMain.WI...
0