text
stringlengths
14
410k
label
int32
0
9
private boolean r_Step_1c() { int v_1; // (, line 51 // [, line 52 ket = cursor; // or, line 52 lab0: do { v_1 = limit - cursor; lab1: do { ...
8
void pushSearchTask(File f) throws InterruptedException { taskQueue.push(new FileSearchBean(f)); }
0
public void reproduceAvg(int cutoff){ Random rand = new Random(); int numOffsprings = C(cutoff,2); if(numOffsprings + cutoff > population.length){ System.out.println("Invalid cutoff!"); return; } Stack<Cell> temp = new Stack<Cell>(); for(Cell c : p...
7
@Override public AbstractPlay mkRandom() { return everyPlay.get(rnd.nextInt(everyPlay.size())); }
0
public final T getNode(int x, int y) { if(x < 0 || x > width || y < 0 || y > height){ throw new IllegalArgumentException("X & Y must be more than 0, but less than w/h"); } return nodes[x][y]; }
4
public Symbol debug_parse() throws java.lang.Exception { /* the current action code */ int act; /* the Symbol/stack element returned by a reduce */ Symbol lhs_sym = null; /* information about production being reduced with */ short handle_size, lhs_sym_num; /* set up ...
7
public TPLogger(Logger logger) { this.logger = logger; this.logger.setLevel(Level.ALL); }
0
private void analysisInteraction() { Enumeration<PhysObject3D> e = world.getObjects(); int i = 0; PhysObject3D temp; while(e.hasMoreElements()) { temp = e.nextElement(); if(temp instanceof HasMassInterface) { gravityInteraction[gravityInteraction[numObjs]] = i; gravityInteraction[numObjs]++; i...
4
public static ArrayList<String> getInput(String filename) { ArrayList<String> entry = new ArrayList<String>(); try { BufferedReader reader = new BufferedReader(new FileReader(filename)); String line = reader.readLine(); while(line != null) { entry....
3
public void controlarComandoRecebido(Jogada jogada) throws PecaAlheiaException, MovimentoInvalidoException, CaminhoBloqueadoException, CasaVaziaException, CapturaInvalidaPecaInexistenteException, CapturaInvalidaPecaPropriaException { switch (jogada.getTipoJogada()) { case MOVIMENTO: ...
9
public static GameQueues getInstance(){ if(instance == null){ instance = new GameQueues(); } return instance; }
1
public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Triplet)) return false; @SuppressWarnings("unchecked") final Triplet triplet = (Triplet) o; if (first != null ? !first.equals(triplet.first) : triplet.first != null) return false; if (second != null ? !second.equals(tripl...
8
public List<Product> getProductsFromBasket(int basketId) { List<Product> list = null; Basket basket = null; try { beginTransaction(); basket = (Basket) session.get(Basket.class, basketId); list = basket.getProducts(); } catch (Exception e) { e.printStackTrace(); } finally { closeSession(); } ...
1
public void setBody(Body body) { if(this.body != null){ this.body.setUsed(false); } this.body = body; this.body.setUsed(true); }
1
protected static Set<Point> getSortedPointSet(Point[] points) { final Point lowest = getLowestPoint(points); if (lowest == null) { return null; } TreeSet<Point> set = new TreeSet<Point>(new Comparator<Point>() { @Override public int compare(Poi...
6
private static double toDouble(Object value) { if (value instanceof Number) { return ((Number)value).doubleValue(); } else if (value instanceof String) { return ScriptRuntime.toNumber((String)value); } else if (value instanceof Scriptable) { ...
9
public void mousePressed(int mx, int my, GUIComponent component) { if (component instanceof CardComponent && component.belongsTo(playersComponent) && ((CardComponent) component).getAssociatedPlayer() instanceof HumanPlayer) { if (selectedCardComponent != component && selectedCardComponent != null) {...
5
public String makeString(Double make){ if(make>=1000000000) { return df.format(make/1000000000)+"b"; } else if(make>=1000000) { return df.format(make/1000000)+"m"; } else if(make>=1000) { return df.format(make/1000)+"k"; } return df.format(make); }
3
public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MatrixSeries)) { return false; } MatrixSeries that = (MatrixSeries) obj; if (!(getRowCount() == that.getRowCount())) { return false; }...
7
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final WordCount other = (WordCount) obj; return Objects.equal(this.word, other.word); }
3
@Override public void sessionOpened(IoSession session) throws Exception { final String address = session.getRemoteAddress().toString().split(":")[0]; if (BlockedIP.contains(address)) { session.close(); return; } final Pair<Long, Byte> track = tracker.get(addr...
7
static private void validate(Team team) { if (team == null) { throw new IllegalArgumentException("team is null"); } if (team.getName() == null || team.getName().isEmpty()) { throw new ValidationException("no name"); } if (team.getCoach() == null || team.ge...
6
public static BigInteger nCrBigInt(int n, int r) { if (r > n || r < 0) { return BigInteger.ZERO; } if (r == 0 || r == n) { return BigInteger.ONE; } if (r > n / 2) { // As Pascal's triangle is horizontally symmetric, use that property to reduce the for-loop below r = n - r; } BigInteger valu...
6
public static char rightOf(char direction){ //determine the direction to the right of this one switch(direction){ case '1': return '4'; case '2': return'1'; case '3': return '2'; case '4': return '7'; case '6': return '3'; case '7': return '8'; case '8': return '9'; case '9': ...
8
public void assign(Rectangle rect, V value) { if (!split) { values.put(rect, value); color = true; return; } if (tl.intersects(rect)) { tl.assign(rect, value); } if (tr.intersect...
5
private void func_28214_a(File var1, String var2, File var3) { File var4 = new File(var1, var2); if(var4.exists() && !var4.isDirectory() && !var3.exists()) { var4.renameTo(var3); } }
3
private void inputHandling() { if(Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !spaceWasPressed){ Mouse.setCursorPosition(Display.getWidth()/2, Display.getHeight()/2); Mouse.setGrabbed(!Mouse.isGrabbed()); spaceWasPressed = true; } else if(!Keyboard.isKeyDown(Keyboard.KEY_SPACE)){ sp...
6
public static <E> Iterator<E> toIterator(Enumeration<E> enumeration) { return new EnumerationIterator<E>(enumeration); }
0
public static void main(String[] argsv) { // Setting op a bank. Bank christmasBank = new Bank(); christmasBank.addAccount(new BankAccount(BigInteger.valueOf(100))); christmasBank.addAccount(new BankAccount(BigInteger.valueOf(50), BigInteger.valueOf(-1000))); // Print the balanc...
1
private String readByteArray() { StringBuffer buf = new StringBuffer(); int count = 0; char w = (char) 0; // read individual bytes and format into a character array while ((this.loc < this.stream.length) && (this.stream[this.loc] != '>')) { char c = (char) this.stream...
9
public Map load(String name) throws MapNotFoundException { Map m = null; if(!mapMap.containsKey(name)){ throw new MapNotFoundException(); } else{ File f = new File(mapMap.get(name)); try { m = (Map) biIn.load(f); } catch (IO...
2
public static void manageStudents() { System.out.print("Do you want to add (0) or delete (1) a student ? "); int res = -1; while (res < 0 || res > 1) { Scanner sc = new Scanner(System.in); res = sc.nextInt(); } switch (res) { case 0: createStudent(); break; case 1: if (FileReadService.sL...
6
public void dumpExpression(TabbedPrintWriter writer) throws java.io.IOException { subExpressions[0].dumpExpression(writer, getPriority() + 1); writer.breakOp(); writer.print(getOperatorString()); writer.print(objectType ? "null" : "0"); }
1
public List listUsers() { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); List result = session.createQuery("from User u where u.username = :username and u.id = :id").setParameter("username","lisi").setParameter("id",2L).list(); sessio...
3
public static String[] getList(int pageNumber) { String[] line = new String[PAGE_LINES]; int temp = 0; if(pageNumber > 1) {temp = PAGE_LINES * (pageNumber - 1);} for(int i = 0; (i < PAGE_LINES); i++) { if(temp >= list.size()) break; line[i] = list.get(temp); temp++; } return line; }
3
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPainelMenu = new javax.swing.JPanel(); jInserir = new javax.swing.JButton(); jEditar = new javax.swing.JButton(); jExcluir = ...
4
public void acceptValuationVisitor(ValuationVisitor visitor) { PortfolioIterator iterator = new PortfolioIterator(); Investment i; while (iterator.hasNext()) { i = iterator.next(); if (i instanceof Bond) { visitor.visitBond((Bond) i); } else if (i instanceof Stock) { visitor.vi...
5
public static String getErrorMessage(String response) throws Exception { if (response == null || response.trim().length() == 0) { return "Null response from server"; } Document doc = stringToXmlDocument(response); return doc.getElementsByTagName("errortext").item(0).getTextContent().trim(); }
2
private void changeRoomIFN() { int doorId = room.getSquareValue(coord); if (room.isDoorLocked(doorId)) { return; } else if(doorId == -1) { System.out.println("Door id not found at coord " + coord); return; } Room nextRoom = room.getNei...
7
public int getVal() { return mySlider.getValue(); }
0
public Points getPoints() { return points; }
0
@Override public void run ( ) { final Vector<Character> chars = new Vector<Character> ( ) ; for ( int i = 1 ; i < this.inp.length ; i++ ) { for ( final char c : this.inp[ i ].toLowerCase ( ).toCharArray ( ) ) { chars.add ( c ) ; } } for ( final char c : chars ) { if ( c >= 'a' ...
7
public static PreciseDecimal parse(final String s) { int factor = 0; long base = 0; int i = 0; boolean fractional = false; final boolean neg; if (s.charAt(i) == '-') { neg = true; i++; } else { neg = false; } while (i < s.length()) { final char c = s.charAt(i++); if (c == '.') { fract...
9
protected static boolean checkResource(Resource resource) { boolean isValid; if (isValid = resource != null) { isValid = TYPES.contains(resource.getType()); isValid = isValid && resource.getProperty(NODES_PROPERTY) != null; isValid = isValid && resource.getProperty(US...
4
private void update() { checkXp(); for(int i = 0; i < bullets.size(); i++) { if(bullets.get(i).isDead()) { bullets.remove(i); } if(bullets.get(i) != null) { bullets.get(i).render(); } } if(isDead()) { killEntity(); } checkForKeyPress(); box.update(x,y,width,height...
4
private void displayCommand(String command) { String data = textArea.getText(); while (data.endsWith("\n")) data = data.substring(0, data.length()-1); int lastIndex = lastCommandOffset = data.lastIndexOf("\n"); lastCommandOffset++; data = data.substring(0,lastIndex+1) + command; textArea.setText(d...
1
public String compress(String html) { if(!enabled || html == null || html.length() == 0) { return html; } //calculate uncompressed statistics initStatistics(html); //preserved block containers List<String> condCommentBlocks = new ArrayList<String>(); List<String> preBlocks = new ArrayList<String>()...
3
public final void addObservable(PositionChangedObservable o) { if(o != null) observables.add(o); }
1
public void checkW(double[][] coord) { if (coord[0][3] == 0) { coord[0][3] = 1; } else if (coord[0][3] != 1) { coord[0][0] /= coord[0][3]; coord[0][1] /= coord[0][3]; coord[0][2] /= coord[0][3]; coord[0][3] /= coord[0][3]; } }
2
final private short determineElementCount() throws Exception { switch (type) { case BOOL: case SINT: case INT: case DINT: case BITS: case REAL: return (short) (data.capacity() / type.element_size); case STRUCT: { ...
8
public static String secondsToDHMSString(double seconds) { if (seconds < 60) { return doubleToString(seconds, 2, 2) + 's'; } long secs = (int) (seconds); long mins = secs / 60; long hours = mins / 60; long days = hours / 24; secs %= 60; mins %=...
7
public static double evaluateRecall(int k, HashMap<String, HashMap<Integer,Double>> relevance_judgments, String path){ double value = 0.0; int countRelevance = 0; try { BufferedReader reader = new BufferedReader(new FileReader(path)); ...
9
public boolean interrogateNewAgent_NETCAT_OLDER(BufferedReader brSocket) { try { String strThirdLine = brSocket.readLine(); if ((strThirdLine != null) && (strThirdLine.trim().equals(""))) { Drivers.sop("-->>> Almost there... Confidence level is 75% ..."); sendCommand_RAW(""...
8
public void tick() { for (int i = 0; i < entities.size(); i++) { entities.get(i).tick(); } }
1
public boolean rollback(){ if(isSetForCommitting()){ session.getTransaction().rollback(); return true; } return false; }
1
public void nextGeneration() { List<LightningSegment> newSegments = new ArrayList<LightningSegment>(); int size = segments.size(); for (int i = 0; i < size; i++) { LightningSegment lightningSegment = segments.get(i); if (getGeneration() == GameController.MAX_LIGHTNING_GENERATIONS) { segments.rem...
8
private void Remover_CampoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Remover_CampoActionPerformed try { if (NomeCampo_TextField2.getText().equals("")) { JOptionPane.showMessageDialog(null, "Indique qual o nome do campo a remover!", "Alerta!", JOptionPane.WARNI...
2
boolean traverseGroup(boolean next) { Control root = computeTabRoot(); Widget group = computeTabGroup(); Widget[] list = root.computeTabList(); int length = list.length; int index = 0; while (index < length) { if (list[index] == group) break; index++; } /* * It is possible (but unlikely), t...
8
public void removeAllPawns() { pawns.clear(); currentPawn = null; }
0
public void drawButton(Minecraft par1Minecraft, int par2, int par3) { if (this.drawButton) { FontRenderer var4 = par1Minecraft.fontRenderer; GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture("/gui/gui.png")); GL11.glColor4f(1.0F, 1.0F, 1...
6
public void endScene() { co.setX(350); co.setY(10); burnedVillage.setX(350); boolean newVillage = false; Image off = createImage(WIDTH,HEIGHT); Graphics second = off.getGraphics(); CloudObject text1 = new CloudObject(100,10,pane.getClass().getResou...
9
public boolean isTheirWin() { return (!theirSea.fleetDestroyed() && mySea.fleetDestroyed()); }
1
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); while ((line = in.readLine()) != null && line.length() != 0) { int n = Integer.parseInt(line.trim()); for (int i ...
6
@Override public boolean next() { if (brParser == null) { // this should not happen, throw exception throw new RuntimeException("No parser available to fetch row"); } if (getMetaData() == null) { setMetaData(((AbstractParser) brParser).getPzMetaData()); ...
3
public double standardizedItemMinimum(int index){ if(!this.dataPreprocessed)this.preprocessData(); if(index<1 || index>this.nItems)throw new IllegalArgumentException("The item index, " + index + ", must lie between 1 and the number of items," + this.nItems + ", inclusive"); if(!this.variancesCal...
4
@SuppressWarnings("unchecked") private static final Object[] decodeDictionary(byte[] bencoded_bytes, int offset) throws BencodingException { HashMap map = new HashMap(); ++offset; ByteBuffer info_hash_bytes = null; while(bencoded_bytes[offset] != (byte)'e') { //...
8
private int decimalDigits ( double d, boolean expo ) { if( d == 0.0 ) return 0; d = Math.abs( d ); int e = intDigits( d ); if( expo ) { d /= Math.pow(10, e-1); e = 1; } if( e >= digits ) return 0; int iD = Math.max(1, e); int dD = digits - e; if( !trailing && dD > 0 ) {...
7
public void work() { Iterator<ISystem> sysIter = systems.iterator(); updateTimer(); long now = now(); Collection<IEntity> entities = entitiesByID.values(); for (IEntity each : entities) { if (each.hasChanged()) { updateInfoPacks(each); ...
5
public static BigDecimal normalizeCycle( Cycle<Nucleotide, InteractionEdge> ac, boolean basepaironly) { List<Nucleotide> verts = ac.getVertexList(); LinkedList<Integer> tmpints = new LinkedList<Integer>(); for (Nucleotide aNuc : verts) { try { int nn = aNuc.getNormalizedNucleotide(); tmpints.add(nn)...
9
@Override public void bsp( BSPPeer<NullWritable, NullWritable, NullWritable, NullWritable, NullWritable> peer) throws IOException, SyncException, InterruptedException { int nbRowsBlocks = nbRowsA / blockSize; int nbColsBlocks = nbColsB / blockSize; int nbBlocks = nbRowsBlocks * nbColsBlocks; int b...
6
public boolean validate() { if (!HAS_DAY || !HAS_TIME || !HAS_NAME) { VALIDATED = false; return VALIDATED; } if (HAS_TEACHER == false) setTeacher("Unknown"); if (HAS_ROOM == false) setRoom("Unknown"); generatePID(); VALIDATED = true; return VALIDATED; }
5
public void wdgmsg(Widget sender, String msg, Object... args) { if(sender == cbtn) { wdgmsg("close"); } else { super.wdgmsg(sender, msg, args); } }
1
private List<SoftwareSystem> generateSystemsEP() { List<SoftwareSystem> systems = new ArrayList<>(); for (HardwareSystem hardwareSystem : project.getHardwareSystemsEP()) for (DeploymentAlternative deploymentAlternative : project.getDeploymentAlternatives()) systems.add(new SoftwareSystem(hardwareSystem, depl...
2
public static ArrayList<Packet> extractPacketsInfo(String file){ BufferedReader reader = null; ArrayList<String> linesList = new ArrayList<String>(); ArrayList<Packet> packetList = new ArrayList<Packet>(); try { reader = new BufferedReader(new FileReader(file)); String line2 = reader.readLine(); Str...
4
@Override public boolean supportsMoveability() {return false;}
0
@Override public Ability[] getTimsAdjResCast(Item I, int[] castMul) { Ability A; final Ability[] RET=new Ability[3]; // adj, res, cast castMul[0]=1; for(int i=0;i<I.numEffects();i++) { A=I.fetchEffect( i ); if(A instanceof TriggeredAffect) { final long flags=A.flags(); final int triggers=((...
9
public void testWithFieldAdded5() { TimeOfDay test = new TimeOfDay(10, 20, 30, 40); try { test.withFieldAdded(DurationFieldType.days(), 6); fail(); } catch (IllegalArgumentException ex) {} }
1
public static LinkedListNode findLoop(LinkedListNode head){ LinkedListNode fast=head; LinkedListNode slow=head; // boolean loop=false; while(fast != null && fast.next != null){ fast=fast.next.next; slow=slow.next; if(fast==slow){ // loop=true; break; } } if(fast == null || fast.next ...
6
public void pauseObjects(){ if (player1 != null) player1.pause(); if (player2 != null) player2.pause(); for (Asteroid asteroid: asteroids) asteroid.pause(); for (Bullet bullet: bullets) bullet.pause(); if (alienShip != null) alienShip.pause(); if (rogueSpaceship != null) rogueSpaceship.pau...
6
@SuppressWarnings("unchecked") @Override public int compare(Column column, Row one, Row two) { Object oneObj = one.getData(column); Object twoObj = two.getData(column); if (!(oneObj instanceof String) && oneObj.getClass() == twoObj.getClass() && oneObj instanceof Comparable<?>) { return ((Comparable<Object>)...
4
public double[] getInitConcns(){ if(!this.psi0set && !this.sigmaSet)unpack(); double[] conc = Conv.copy(this.initConcn); for(int i=0; i<this.numOfIons; i++)conc[i] *= 1e-3; return conc; }
3
public boolean isBlockedByTanq(int x, int y, int width, int height) { synchronized (tanqs) { for (Tanq t: tanqs) { if (t.isTouching(new Vector3D(x, y, 0), (int)Math.sqrt(width * width + height * height))) return true; } } return false; }
2
public void checkType(Symtab st) { exp1.setScope(scope); exp1.checkType(st); exp2.setScope(scope); exp2.checkType(st); if (!exp1.getType(st).equals("int") && !exp1.getType(st).equals("decimal")) { Main.error("type error in minus!"); } if (!exp2.getType(st).equals("int") && !exp2.getType(st).equ...
4
public void addItem(Time item) { if ((!items.contains(item)) && (!item.equals(emptyTime))) { items.add(0, item); } if (items.size() > maxItems) { items.remove(items.size() - 1); } }
3
private void setAttr(Attributes attr) { // atributo 'nome' if (attr.getIndex("nome") >= 0) { this.nome = attr.getValue("nome"); } else { System.out.println("BD: Faltando o atributo 'nome'"); } }
1
public void step() { log.debug("============== Stepping "+tam.getId()+" currentState "+currentState+ " ================"); switch (getState()) { case READ_ID: if(tam.isRobotPresent()){ // if there is a robot in the tam //try to read a value from it ...
9
public void deposit(BigInteger amount) throws IllegalArgumentException { if ( (amount == null) || (amount.compareTo(BigInteger.ZERO) <= 0) ) throw new IllegalArgumentException(); setBalance(this.getBalance().add(amount)); }
2
public QuadTreeNode getChild(Position pos){ switch (pos){ case northWest: return nw; case northEast: return ne; case southWest: return sw; case southEast: return se; default: return null; } }
4
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory, Object value) { // this local field is required to make sure exception block works with the same coercionRequired value // and it is not changed by another thread while setter is invoked boolean attemptedCoercion = co...
9
public CheckResultMessage checkSheetFormat() { return report.checkSheetFormat(); }
0
private boolean isPossibleToPlaceDiagRightAbove(int position, int dimension, int positionRightAbove) { return elementDiagonallyRightAbove(dimension, position, positionRightAbove) >= 0 && (elementDiagonallyRightAbove(dimension, position, positionRightAbove)) % dimension < dimension - 1; }
1
public static int mss(String dna1, String dna2, boolean print) { int[][] matrix = new int[dna2.length() + 1][dna1.length() + 1]; int i = 0, j = 0; for(;i<=dna2.length();i++) matrix[i][0] = i; for(;j<=dna1.length();j++) matrix[0][j] = j; for(i=1;i<=dna1.length();i++) { for(j=1;j<=dna2.length();j++) ...
8
public List<Group> getGroupList(int schedule) { List<Group> list = new ArrayList<Group>(); try { ResultSet rs = con.createStatement().executeQuery( "SELECT * FROM groups WHERE schedule=" + schedule ); while(rs.next()) { list.add(getGroupFromRS(rs)); } rs.close(); } catch (SQLExcepti...
2
public int[] molecularSizeDistrb(){ int maxSize=0; for (int i=0; i<bucket.size(); i++){ maxSize = (bucket.get(i).getSize() > maxSize)? bucket.get(i).getSize() : maxSize; } int[] sizeDistrb = new int[maxSize+1]; for (int i=1; i<bucket.size(); i++){ sizeDistrb[bucket...
3
public String getNick() { return _nick; }
0
public boolean setPath(String p) { boolean test = false; if (test || m_test) { System.out.println("FileManager :: setPath() BEGIN"); } m_path = p; if (test || m_test) { System.out.println("FileManager :: setPath() END"); } return true; }
4
public static void createNetGame(Socket Toserv, ObjectOutputStream out, ObjectInputStream in, String user) { try { AppGameContainer app = new AppGameContainer(new GameFrame(Toserv, out, in, user)); app.setDisplayMode(viewW, viewH, false); app.setVSy...
1
@Override public void lostOwnership(Clipboard clipboard, Transferable contents) { }
0
@SuppressWarnings("unchecked") @Override protected Class<? extends Number> translateReturnType(Class<?> clazz) { //no widening used for Minimum return (Class<? extends Number>) clazz; }
3
public Image loadImage(String image){ try { return Toolkit.getDefaultToolkit().createImage(image); } catch (Exception e) { e.printStackTrace(); } return null; }
1