text
stringlengths
14
410k
label
int32
0
9
public boolean hitRight() { if(nextX() >= xMin+xMax) return true; return false; }
1
private void updateForces() { keyForce.set(0.0, 0.0); if (up && !down) { keyForce.offset(0, SPEED); } else if (down && !up) { keyForce.offset(0, -SPEED); } if (left && !right) { keyForce.offset(-SPEED, 0); ...
8
@Override public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors erros = new ActionErrors(); if(contato.getNome() == null || contato.getNome().isEmpty()) { erros.add("nome", new ActionMessage("erro.campoNome")); } if(contato.getEndereco() == null || contato.getE...
6
public void testWithField3() { YearMonthDay test = new YearMonthDay(2004, 6, 9); try { test.withField(DateTimeFieldType.hourOfDay(), 6); fail(); } catch (IllegalArgumentException ex) {} }
1
private void readConfig() { Properties p = new Properties(); try { p.load(this.getClass().getClassLoader().getResourceAsStream("application.properties")); clientVersion = p.getProperty("version"); } catch (IOException e) { log.error(e.getMessage()); } }
1
public void run(){ try{ String msgIn = ""; //initialize board for(i=0; i<4; i++){ for(j=0; j<10; j++){ this.board[i][j] = new Character(); } } while(true){ msgIn = conn.getMessage(); if(msgIn.equals("DONE")){ //get player's board receiveBoard(conn, this.board, playerNum)...
7
@Override public boolean supportsAttributes() {return true;}
0
private void turnAction(Player user, TurnData data) { synchronized(turnThread) { if(!user.isTurnEnd()) { if(data.isTurnAction()) { if(user.getThrewDice() < 3) { user.move(); } else { user.setPosition(jail); user.setInJail(true); user.setTurnEnd(true); turnThread.notify()...
3
public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL) { pressed = false; } }
1
public int getIndexOfChild(Object parent, Object child) { TreeElement[] childrens = getChildrens((TreeElement) parent); int i = Arrays.binarySearch(childrens, child); if (i >= 0) return i; throw new NoSuchElementException(((TreeElement) parent).getFullName() + "." + child); }
1
public static void main(String[] args) { final Conditions conditions = new Conditions(); new Thread(new Runnable() { @Override public void run() { for (int i = 0; i < 10; i++) { conditions.put(i); } } }).st...
6
public static void main(String[] args) { String inputGenomeFilePath; int kmerLength, kmerOverlapLength, deBruijnGraphDegree; if (args.length == 4) { inputGenomeFilePath = args[0]; if(!doesFileExist(inputGenomeFilePath)) { System.out.println("Invalid input genome file path!"); printClosingAppMessage(...
8
public Login(LoginMessage loginMessage,String ipaddress){ this.sequence_Id =loginMessage.getSequence_Id(); this.Account = loginMessage.getClientID(); this.Version = loginMessage.getClientVersion(); this.LoginMode = loginMessage.getLoginMode(); this.ipaddress = ipaddress; this.timestamp = l...
0
public int getPopulationSize() {return population.size();}
0
public static boolean isReservedNot(String candidate) { int START_STATE = 0; int TERMINAL_STATE = 3; char next; if (candidate.length()!=3){ return false; } int state = START_STATE; for (int i = 0; i < candidate.length(); i++) ...
9
public void paint1(Graphics g) { if (carro != null && popo != null) { g.drawImage(carro.getImagen(), carro.getPosX(), carro.getPosY(), this); if (choco) { popo.setMovimiento(false); choco = false; } g.drawImage(pajaro.getImagen(), ...
9
public UserRole login(String userName, String password) { UserRole userRole = null; String query = "SELECT * FROM USER_ROLE WHERE USERNAME=? AND PASSWORD=?"; try { PreparedStatement statement = connection.prepareStatement(query); statement.setString(1, userName); ...
2
@Override public String getMCstring(){ String s = ""; for (int i = 0; i < mc.length; i++) { if(mc[i] == true) s = s.concat("1"); else s = s.concat("0"); if (i == 5 || i == 10 || i == 15) s = s.concat(" "); } ...
5
public void run() { boolean properConnect = true; boolean initName = false; try { inClient = new BufferedReader(new InputStreamReader(connect.getInputStream())); outClient = new DataOutputStream(connect.getOutputStream()); } catch(IOException e) { System.out.println("Could not establish proper IO at...
9
public static boolean writeFile(String filePath, String file) { //Declares new Buffered Writer object BufferedWriter writer = null; File textFile = new File(filePath); try { //Sets the value of the buffered writer object, including the name of the output file writer = new BufferedWriter(new FileWriter(...
3
public static void main(String[] args) { // TODO Auto-generated method stub if(args.length<4) { System.err.println("Argument error"); System.err.println("Argument: input_file output_file uni_gram_file bi_tri_gram"); System.exit(1); } SVMExtractor se=new SVMExtractor(args[2],args[3]); try ...
4
private static int format(final StringBuilder sb, final String s, int lineLength) { if (s.isEmpty()) { return 0; } int l = lineLength; final String[] parts = s.split(" "); boolean front = sb.length() != 0; for (final String part : parts) { if ((l > 0) && ((l + part.length() + 1) >= Main.MAX_LENGTH...
5
public static String readFile(String name) { StringBuilder b = new StringBuilder(); try { BufferedReader r = new BufferedReader(new FileReader(name)); String line; while ((line = r.readLine()) != null) { b.append(line).append('\n'); } ...
2
private static void imprimir_lexema(Token token, int i) { String lexema = token.getLexema(); //Formateamos de manera legible el EOF if (token.getLexema().contains("\uffff") ) { lexema = "eof"; } //Formateamos de manera legible el salto de línea if (to...
5
public void addClickableFunction(final JFrame frame, int xLoc, int yLoc,int width, int height, final String type){ JLabel label = new JLabel(); label.setBounds(xLoc, yLoc, width, height); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if(type.e...
5
private static void sellToStation(AIPlayer player) { Station station = player.getCurrentStar().getStation(); CargoHoldComponent hold = player.getShip().getCargoHold().get(); // find best value item to sell that player has in cargo and wasn't just // bought if (hold.getCargoSpace...
8
void guess(int a, int b){ for (int i = 0; i < checkSet.length; i++) { if (!checkSet[i]) { continue; } int count = 0; for (int j = 0; j < checkSet.length; j++) { if (checkSet[j]) { count++; ...
6
public void applyBridgeMode(int x, int y) { Ground tile = groundArray[0][x][y]; for (int z = 0; z < 3; z++) { Ground _tile = groundArray[z][x][y] = groundArray[z + 1][x][y]; if (_tile != null) { _tile.z--; for (int e = 0; e < _tile.entityCount; e++) { InteractiveObject entity = _tile.interactiveO...
7
public ROb<CompanyPerson> registerRelation (Long personCedule, Long companyId, String rolPerson, String passwordCompany){ System.out.println("++++++++++++ Registar relacion: Me han invocado"); ROb<CompanyPerson> rob = new ROb<CompanyPerson>(); try{ Person person = (Person) personFaca...
5
public void setClick(int ttype, String tid, int twhichone) { type=ttype; id=tid; whichOne=twhichone; }
0
public int findRightPositionOf(int i) { for (int j = i; j < this.permutArray.length; j++) { if (permutArray[j] == i || -permutArray[j] == i) { return j; } } return 0; }
3
public int getLevel() { if(level < 1) { level = 1; } return level; }
1
private void startButtonActionPerformed() { startPressed = true; final LogArtisanWorkshopOptions options = script.options; options.status = "Setup finished"; //Context.get().getScriptHandler().log.info("Mode: " + tabbedPane.getTitleAt(tabbedPane.getSelectedIndex())); String s = tabbedPane.getTitleAt(tabbedPa...
5
private String[] quoteAwareLineSplit(String line) { boolean ignoreCommas = false; // used when quotes are found StringBuffer buff = new StringBuffer(); List<String> data = new ArrayList<String>(); char prevChar = 0; for (int i = 0; i < line.length(); i++) { if (line.charAt(i) == '\"') { ignoreCommas...
7
@Override public void setDef(String value) {this.def = value;}
0
private void doubleClick(MouseEvent e) { System.out.println("DOUBLE CLICK"); if (clickedOnDeck(e)) { if (!game.getDeck().isEmpty()) { Card toSendUp = game.getDeck().peek(); int pileIndex = pileIndexToSendTo(toSendUp); if (pileIndex != -1) { ...
5
@Override public void rawUpdate() throws Throwable { if (this.isPaused() || this.tasks.isEmpty()) { Thread.sleep(1L); return; } for (Task t : this.tasks) { if (t.completeTask()) { this.tasks.remove(t); } } }
4
private Direction getDirection(String inputCommand) { Keys key = Keys.valueOf(inputCommand); switch(key) { case UP: return Direction.NORTH; case DOWN: return Direction.SOUTH; case LEFT: return Direction.WEST; case RIGHT: return Direction.EAST; de...
4
PageUnitGUI() { final JFrame jf = new JFrame("PageUnit Runner"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container cp = new JPanel(); jf.add(cp, BorderLayout.CENTER); cp.setLayout(new FlowLayout()); cp.add(new JLabel("PageUnit Test File:")); final JTextField tf = new JTextField(20); ...
6
public static boolean checkSpare(Frame frame) throws UnexpectedTypeException { Integer firstScore = frame.getScore(ScoreType.FIRST); Integer secondScore = frame.getScore(ScoreType.SECOND); if(firstScore == null || secondScore == null) { return false; } if((firstScore + secondScore) == IConstants.FRAME_PE...
3
public void zerarQuantidadeVendido(){ for (Produto p : produtos) { p.setQuantidedeVendido(0.0); } }
1
public static boolean validChoice(int row, int column) { boolean isValid = true; if (row < 0 || row > 2 || column < 0 || column > 2) { isValid = false; } else if (board[row][column] != '.') { isValid = false; } return isValid; }
5
@Override public void setDescription(String description) { this.description = description; }
0
boolean isExist(char[][] matrix, boolean[][] flag, int i, int j, String word) { if (word.equals("")) return true; char x = word.charAt(0); word = word.substring(1); for (int k = 0; k < 4; k++) { int m = i + d[k][0]; int n = j + d[k][1]; if (isValid(matrix, m, n) && matrix[m][n] == x && !flag[m][n]) ...
6
private static void calcPercentages() { percentages = new ArrayList<Float>(); long sum = 0; for (Long l : sums) { sum += l; } for (int i = 0; i < sums.size(); i++) { percentages.add(((float)sums.get(i))/((float)sum)); } }
2
public void shoot() { this.performance = this.performance -1; if (this.hasArrow){ this.setArrow(false); this.performance = this.performance -10; } }
1
private void jump(int S) { Color playerColor = _board[S].getColor(); if (_board[S].getSpots() > neighbors(S) && getWinner() == null) { _board[S].setSpots(1); if (col(S) < size()) { jumpAddSpot(playerColor, row(S), col(S) + 1); } if (row(S) ...
6
Set(LegacyRegister[] regs) { registerSet = new HashSet(2 * regs.length); for (int cntr = 0; cntr < regs.length; cntr++) { registerSet.add(regs[cntr]); } StringBuffer buf = new StringBuffer("{"); for (int cntr = 0; cntr < regs.length; cntr++) {...
8
static final void method358(int i, int i_3_, int i_4_, int i_5_, int i_6_, int i_7_, int i_8_) { if (i_8_ != -29494) amountClanChatUsers = 32; if (((Class348_Sub51) BitmapTable.aClass348_Sub51_3959) .aClass239_Sub26_7272.method1838(-32350) != 0 && i != 0 && Message.anInt2021 < 50 && (i_7_ ^ 0xffffffff...
5
private static Product ProductObject(ResultSet rs) { Product newProduct = null; try { newProduct = new Product(rs.getInt(rs.getMetaData().getColumnName(1)), rs.getString(rs.getMetaData().getColumnName(2)), rs.getS...
1
static boolean hascontained(ArrayList<Pair> list, Pair pr) { for (int j=0; j<list.size(); j++){ if (list.get(j).equals(pr)) { return true; } } return false; }
2
public boolean isEmpty() { return first == null; }
0
public void parseExpression(CharSequence expression, Handler handler) { Matcher matcherMeta = EXPR_META.matcher(expression); if(matcherMeta.find()) { Map<String,String> meta = new HashMap<String, String>(); String inlined = matcherMeta.group(1); parseStyles(meta, inli...
3
@Override public void nextCard(){ CardImpl nextCard = null; int boxToCheck = this.curBox; boolean firstLoop = true; while (nextCard == null){ nextCard = this.model.getTopic().getRandomCard(boxToCheck); if (firstLoop){ boxToCheck = 0; firstLoop = false; } else { boxToCheck +=1; } if (...
3
private boolean func_151636_a(int[] p_151636_1_, int[] p_151636_2_, int p_151636_3_, int p_151636_4_, int p_151636_5_, int p_151636_6_, int p_151636_7_, int p_151636_8_) { if (!compareBiomesById(p_151636_6_, p_151636_7_)) { return false; } else { int k...
5
static int[] heapSort(int[] A){ TreeSet<Integer> heap = new TreeSet<Integer>(); int[] ret = new int[A.length]; for(int i=0;i<A.length;i++){ heap.add(A[i]); } for(int i=0;i<A.length;i++){ ret[i]=heap.pollFirst(); } return ret; }
2
public void visitExprStmt(final ExprStmt stmt) { if (stmt.expr == from) { stmt.expr = (Expr) to; ((Expr) to).setParent(stmt); } else { stmt.visitChildren(this); } }
1
public int[] getInts(int par1, int par2, int par3, int par4) { int i = par1 - 1; int j = par2 - 1; int k = par3 + 2; int l = par4 + 2; int ai[] = parent.getInts(i, j, k, l); int ai1[] = IntCache.getIntCache(par3 * par4); for (int i1 = 0; i1 < par4; i1++) ...
8
@Override public void getOptions() { for (Component p : getParent().getComponents()) { if (p instanceof OptionsPanel) { matrixOn = ((OptionsPanel) p).isMatrixOn(); type = ((OptionsPanel) p).getType(); } } if (matrixOn) { st...
3
public void extendSchema() { // Recursive method to add 1-1 Relationships from vicinity up to a // defined level System.out.println("Extending schema..."); logger.info("Extending schema"); for (Table table : schema.getTables()) { Set<ColumnFamily> extendedColumnFamilies = extendAndMerge(table, 1, "",...
9
protected void performChoice(int choice) { if (choice == 1) { HMMDefaultsMenu menu = new HMMDefaultsMenu(); menu.run(); } else if (choice == 2) { HMMConstructionMenu menu = new HMMConstructionMenu(); menu.run(); hmm = menu.getHMM(); } else if (choice == 3) { if (this.hmm != null) { HMMUp...
9
@Override public String toString() { final StringBuilder sb = new StringBuilder("Student{"); sb.append("number='").append(number).append('\''); sb.append(", scores=").append(scores); sb.append('}'); return sb.toString(); }
0
static String[] loadPlayerNames(String txtPath) { ArrayList<String> namelist = new ArrayList<String>(); try { // get file of players BufferedReader in = new BufferedReader(new FileReader(new File(txtPath))); String line; while ( (line = in.readLine()) != n...
3
public void list() { //get all values for(Exit e:exits.values()) { //get pairs of keys and values for (Entry<String, Exit> entry : exits.entrySet()) { //if key is equal to the value if (e.equals(entry.getValue())) { if(e.isVisible())//and is visible System.out.println(...
8
public char getWinner() { char result; if(gameOver) return winner; int blackCount=0; int whiteCount=0; if(surrendering){ for(char c : grid) { if(c=='B') blackCount++; if(c=='W') whiteCount++; } if(blackCount>whiteCount) setWinner('B'); else if(whiteCount>blackCoun...
7
public void compute() { if (opponent == null) return; // Calculate the relative velocity between ourselves and the opponent // This is called the closing velocity. Vector3D velocityClosing = Vector3D.subtract(opponent.getVelocityVector(), getVelocityVector()); System.out.println("velocityClosing = " + ...
3
@Test public void testNeighbour() { // test Parameters n = getSettings().getParameters().neighbour(); assertNotNull(n); assertTrue( "The neighbour of current Settings must not be the same object as Settings. - Expecting a slightly changed CLONE!", !n.equals(getSettings().getParameters())); // assert ...
7
private void save() { if (script == null) { return; } final Properties settings = new Properties(); LinkedHashMap<Integer, List<String>> map = getTabContents(1); JsonObject object = new JsonObject(); int i = 1; for (Map.Entry<Integer, List<String>> entry : map.entrySet()) { JsonArray values = new ...
5
@Override public String toString() { return String.valueOf(name); }
0
public void start() throws LWJGLException { Display.create(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1); glMatrixMode(GL_MODELVIEW); glEnable(GL_ALPHA_TEST); //glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, ...
8
private static void testBoxAddPosition(State state, Queue<State> nodes, Position player, int boxX, int boxY, int boxX2, int boxY2, Direction move, int index) { if (state.isFree(boxX, boxY) && state.isFree(boxX2, boxY2)) { Position boxPos = state.boxes.get(index); Result resul...
4
public static CommonClassLib getInstance() { if (commonClassLib == null) { commonClassLib = new CommonClassLib(); } return commonClassLib; }
1
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // COLLECTIONS (START) if (qName.equalsIgnoreCase("collections")) { readCollections = true; } // COLLECTIONS :: COLLECTION (START) else if (readCollections && qName.equalsIgnoreCase("...
9
public static boolean isLatinLetterOrDigit(char c) { return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'); }
5
public int getMaxRange(String minMatch, String maxMatch, int dataContentLength) { if (maxMatch != null) { if (minMatch == null) { return dataContentLength; } else { return Integer.parseInt(maxMatch) + 1; } } else { return dataContentLength; } }
2
public boolean isNan() { return Double.isNaN(re) || Double.isNaN(im); }
1
public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("We are going to calculate Pie using the Leibniz formula."); System.out.print("How many terms do you wish to use? "); int termsCount = s.nextInt(); int terms...
2
public BufferedImage getImage(int animation){ if(this.animation != animation){ this.animation = animation; index = 0; lastChange = System.currentTimeMillis(); } else if(System.currentTimeMillis() > lastChange + delay[animation]){ lastChange += delay[animation]; index = (index + 1) % length[animation]...
2
public boolean canInfo(CommandSender sender) { if ( sender instanceof Player ) { return this.hasPermission((Player)sender, "SheepFeed.info"); } return true; // can info from console }
1
public void run() { long lastTime = System.nanoTime(); long timer = System.currentTimeMillis(); final double ns = 1000000000.0 / 60.0; double delta = 0; int frames = 0; int updates = 0; requestFocus(); while (running) { int missedUpdates = 0; int missedRenders = 0; long now = System.nanoTime()...
5
public static String getExecTime() { return String.format("%.3f", (float)(new Date().getTime() - startedAt.getTime()) / 1000); }
0
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PersonAnnotated person2 = (PersonAnnotated) o; if (age != person2.age) return false; if (firstName != null ? !firstName.equals(person2.firstNam...
8
public static byte[] Xdecode(String base64) { // how many padding digits? int pad = 0; for (int i = base64.length() - 1; base64.charAt(i) == '='; i--) pad++; // we know know the lenght of the target byte array. int length = base64.length() * 6 / 8 - pad; byte[...
4
public void playSong(Song song) throws NetworkException { ApiMusicImpl apiMusic = Controller.getInstance().getApiMusic(); ApiProfileImpl apiProfile = ApiProfileImpl.getApiProfile(); SongLibrary localSongLibrary = ApiProfileImpl.getApiProfile().getSongLibrary(); SongLoader songLoader = ne...
5
public static void main(String[] args) { char letter[] = { 'a', 'b', 'c', 'd', 'e', 'f' }; double frequency[] = { 0.45, 0.13, 0.12, 0.16, 0.09, 0.05 }; PrefixTree pt = new PrefixTree(letter, frequency); for (int i = 0; i < letter.length; i++) System.out.println(letter[i] + " : " + pt.getCode(letter[i])); ...
1
public void decoder(int[] octets_data){ }
0
@Override public ArrayList<String> getColumnsNames() throws Exception { ArrayList<String> alColumns = null; try { oMysql.conexion(enumTipoConexion); alColumns = oMysql.getColumnsName("cliente", Conexion.getDatabaseName()); oMysql.desconexion(); } catch (E...
1
@Override public boolean equals(final Object o) { if (!(o instanceof Color)) return false; final Color c = (Color) o; return r == c.r && g == c.g && b == c.b; }
3
public int getNumberResourcesType(String str) { if (str == null || str.equals("DESERT")) return 0; return resources.get(str).intValue(); }
2
private void btn_GuardarEnunciadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_GuardarEnunciadoActionPerformed Autor autor1 = new Autor(); autor1.setCodigo((cbAutor.getSelectedIndex() +1)); en1.setAutor(autor1); Area area = new Area(); area.setCodigo(cb_L...
8
public Destination destination(String s) { // Local inner class class PDestination implements Destination { private String label; private PDestination(String whereTo) { label = whereTo; } public String readLabel() { return label; } } return new PDestination(s); }
0
public void actionPerformed(ActionEvent e) { if(e.getSource()==timerRandOper) { cleanList(Schedule.completeList); cleanList(deadList); int i=0; int m=(int)(Math.random()*3); if(m==0) i=1; switch (i) {...
8
@Override public void onDisable() { try { TreasureManager.getInstance().savePossibleTreasure(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { TreasureManager.getInstance().saveTreasureSpots(); } catch (IOException e) { // TODO Auto-gen...
2
private void initializeRocks() { for(int i = 0; i < 250; i++) { Point point = getRandomLocationOnGrid(525); if(model.getElements().contains(new Rectangle(point.x, point.y, GameModel.UNIT, GameModel.UNIT))) { i++; continue; } else { model.addRock(point); } } int UNIT4 = GameModel.UNIT ...
2
public void run() { projectileDie(); characterDie(); collision(); for (int i = 0; i < characters.size(); i++) { characters.get(i).move(); } for (int i = 0; i < projectiles.size(); i++) { projectiles.get(i).move(); } if (!characters.contains(player)) { JOptionPane.showMessageDialog(null, ...
8
public static int findNewLine(byte[] arr, int offset) { int len = arr.length - 1; int i = offset; for (; i < len; i++) if (arr[i] == (byte) '\r' && arr[i + 1] == (byte) '\n') return i; return i;// the end of input will be handled like newline }
3
private static HashMap<Integer, Integer> mapCorners(char[] state) { HashMap<Integer, Integer> result = new HashMap<Integer, Integer>(); int[][] corners = Cube.CORNERS; HashMap<String, Integer> goalCorners = initGoalCorners(); for(int j = 0; j < corners.length; j++) { String needle = ""; for (int s : corne...
2
public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); fillDP(); d: do { line = br.readLine(); if (line == null || line.length() == 0) break d; int n = Integer...
4
public void search(CharSequence text, int start, WordDic wdic, List<ViterbiNode> result) { final char ch = text.charAt(start); final CharCategory.Category ct = category.category(ch); if(result.isEmpty()==false && ct.invoke==false) return; final boolean isSpace = ct.id==spaceId; final int limit = Math.min(t...
9
public static Connection getConnection() throws SQLException, IOException { Properties props = new Properties(); FileInputStream in = null; try { in = new FileInputStream("C:\\JavaProjects\\TelephoneBook-v2\\src\\com\\woolfer\\telephonebook\\db\\database.properties"); props.load(in); ...
5