text
stringlengths
14
410k
label
int32
0
9
public void clickOnMouseLeftButton(Field logicField, GraphicCell gCell, GraphicField gField) { // GraphicCell graphicCell1 = gCell; if (ActionCounters.getCounter() < GraphicField.NUMBER_OF_CELL && !Field.gameOver) { Cell[][] array = logicField.getArray(); Cell cell = array[gCell.getgX()][gCell....
6
public String parseToString(SecondaryStructure ss1, SecondaryStructure ss2, Geometry gg) { //return information needed in appropriate manner String stRes = cutToSize(gg.getStart(), 12); String endRes = cutToSize(gg.getEnd(), 10); String type = ""; if(ss1.getSSType().equals("S")) { type += "B"; } if(ss1.getSSTyp...
6
public void onRobotDeath(RobotDeathEvent event) { // If the robot that has died was our target, remove it as the target if (event.getName().equals(Observer.TARGET)) { Observer.TARGET = null; } }
1
public void endNode() { depth-- ; Node node = (Node)elementStack.pop(); if (node.clazz != null && node.isCollection) { if (node.fieldAlready) { readyForNewLine = true; } finishTag(); writer.write("]"); } else if (tagIsEmpty)...
9
public static void UpperProducer(){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try{ conn.setAutoCommit(false); PreparedStatement st...
4
@Test public void testSizeOfListInFile() throws IOException { cm.addFutureMeeting(contacts, new GregorianCalendar(2015,3,2)); cm.addNewPastMeeting(contacts, new GregorianCalendar(2013,5,3), "meeting"); ObjectInputStream ois = new ObjectInputStream(new FileInputStream("contacts.txt")); List inputData = null; ...
1
protected static boolean compareBiomesById(final int p_151616_0_, final int p_151616_1_) { if (p_151616_0_ == p_151616_1_) { return true; } else if (p_151616_0_ != BiomeGenBase.mesaPlateau_F.biomeID && p_151616_0_ != BiomeGenBase.mesaPlateau.biomeID) { ...
7
@Override public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case 0: return nameList.get(rowIndex); case 1: return regDateList.get(rowIndex); case 2: return lastLogDateList.get(rowIndex); ...
4
* @param active Whether or not the active version of the color is needed. * @return The foreground color. */ public static Color getListForeground(boolean selected, boolean active) { if (selected) { Color color = UIManager.getColor("List.selectionForeground"); //$NON-NLS-1$ if (!active) { Color backgro...
4
public String getStudentType(Student student) { if (student.getCategory() == Student.Category.PRIMARIA) return "PRIMARIA"; else return "INFANTIL"; }
1
static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double)o).isInfinite() || ((Double)o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); ...
7
private void updateSet(String line) { if(line.equalsIgnoreCase("SpriteSet")) currentSet = Types.VGDL_SPRITE_SET; if(line.equalsIgnoreCase("InteractionSet")) currentSet = Types.VGDL_INTERACTION_SET; if(line.equalsIgnoreCase("LevelMapping")) currentSet = Typ...
4
protected int widestDim(double[][] nodeRanges, double[][] universe) { final int classIdx = m_Instances.classIndex(); double widest = 0.0; int w = -1; if (m_NormalizeNodeWidth) { for (int i = 0; i < nodeRanges.length; i++) { double newWidest = nodeRanges[i][WIDTH] / universe[i][WIDTH]; ...
7
private static int[] getNextArray (String pattern) { int size = pattern.length(); int[] next = new int[size]; next[0] = -1; // initialize nxet[0] = -1 if (size == 1) { return next; } next[1] = 0; // if the length of pattern > 1, initialize next[1] = 0; int j = 1; int k = next[1]; while (j < si...
4
public ResourceType getResourceTypeByName(String name) { ResourceType resourceType = null; for (int i = 0; i < resourceTypes.size(); i++) { resourceType = resourceTypes.get(i); if (resourceType.getName().equals(name)) { return resourceType; } ...
2
public void setComment(String comment) { this.comment = comment; }
0
public Tile[][] generateZBlock() { Tile[][] piece = new Tile[3][2]; for (int i = 0; i < piece.length; i++) for (int j = 0; j < piece[i].length; j++) { if ((i == 0 && j==0) || (i==1) || (i==2 && j==1))...
7
public static void main(String args[]) throws Exception { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ String input = null; try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); input = br.readLine(); } catch ...
8
@Override public void toString(String indent, StringBuilder buffer) { int len = this.tags.size(); buffer.append("{ "); for (Map.Entry<String, NamedBinaryTag> entry : this.getValue().entrySet()) { buffer.append(entry.getKey()).append(": ").append(", "); } if (len > 0) { buffer.replace(buffer.leng...
2
protected void handlePixelValue() { System.out.println("PIXEL VALUE"); BufferedImage img = this.getBufferedImage(); int displayPixel = 0; switch (displayedToolIndex) { case 1: displayPixel = img.getRGB((int)cover.getStartPoint().getX(), (int)cover.getStartPoint().getY()); break; case 2: int red=...
5
public void writeTermsToFile(String strNumber, Hashtable<String, Double> oTermVsTFIDF) throws IOException { String strKey = null; Double maxValue = Double.MIN_VALUE; String strTerms = ""; int len = oTermVsTFIDF.size() < 5 ? oTermVsTFIDF.size() : 5; for (int i = 0; i < len; ++i) { for (Map.Entry<Strin...
7
public byte [] readControl (byte type, byte request, short value, short index, short length) throws IOException { byte data [] = new byte [length & 0xffff]; int status; if (length >= MAX_CONTROL_LENGTH || (type & ControlMessage.DIR_TO_HOST) == 0) throw new IllegalArgumentException (); if (Wind...
5
@Test public void testTotalwithRemoveEveryThing(){ for (int i=0;i<3;i++){ Main.addToTable(originalItemList.get(i), 2); } for (int i=0;i<3;i++){ Main.removeFromTable(0); } assertEquals(0, Main.getTotal()); }
2
@Override public Map<String, String> obtainUserRecord(String username) { Map<String, String> userRecord = new HashMap<String, String>(); // Find an user record in the entity bean User, passing a primary key of // username. User user = emgr.find(entity.User.class, username); // Determine whether the user exi...
1
public void addConfirmedUser(long uid) { if(!this.isRemoving()) return; this.aWaitingId.remove(uid); if(this.aWaitingId.size()<=0) { this.finalizeRemovalWithoutChecking(); } else { try { this.save(); } catch (SQLException e) { e.printStackTrace(); } } }
3
public void DBReadAllRooms(RoomnumberSet set) { final List<String> newAreasToCreate=new Vector<String>(); if(set==null) DBReadAllAreas(); if(CMLib.map().numAreas()==0) return; final RoomnumberSet unloadedRooms=(RoomnumberSet)CMClass.getCommon("DefaultRoomnumberSet"); final Map<String,Room> rooms=DBRea...
9
@EventHandler(priority = EventPriority.NORMAL) public void onDamage(EntityDamageEvent event) { if (event.getEntity() instanceof Player && event.getCause() != DamageCause.VOID && event.getCause() != DamageCause.LAVA && event.getCause() != DamageCause.FIRE) { Player player = (Player) event.getEntity(); if (B...
5
@Override public List<IProducto> filtrarProductos(List<IProducto> productos) { Boolean hubo_coincidencias = true; List<IProducto> prodsAplican = new ArrayList<IProducto>(); // productos que coinciden con un registro de la oferta List<IProducto> productos_encontrados = new ArrayList<IProducto>(); // copia ...
7
public void populateRestaurantPriceMap(int restaurantId, String[] inputTokens) { Restaurant res = restaurantMap.get(restaurantId); boolean checkFlag = true; int tokensLength = inputTokens.length; for (int i = 1; i < tokensLength; i++) { String item = inputTokens[i].trim(); Float price; if (res.checkIte...
8
private static int findMatchingParenthesis(String regex, int index) { int count = 0; for (int i = index + 1; i < regex.length(); ++i) { if (count == 0 && regex.charAt(i) == ')') return i; else if (regex.charAt(i) == '(') ++count; else if (regex.charAt(i) == ')') --count; } return -1; }
5
private void readStudentList(File file) { BufferedReader FILE; try { String currentLine; FILE = new BufferedReader(new FileReader(file)); while ((currentLine = FILE.readLine()) != null) { String[] arg = currentLine.split(","); Student newStudent = new Student(Integer.parseInt(arg[0])); newSt...
7
private void voegOpdrachtToeAanQuiz() { try { if (!isToegevoegdeOpdracht(quiz.getOpdrachten(), quizWijzigenView .getListOpdrachten().getSelectedValue())) { for (Opdracht opdracht : opdrachtCatalogus.getOpdrachten()) { if (opdracht.equals(quizWijzigenView.getListOpdrachten() .getSelectedValue()...
5
public Set<String> getDownloadFileTypes(){ return this.downloadFileTypes; }
0
public SQLPermissionGroup(String n) { super(n); }
0
public void apply() { if (mStrategy != null) { mStrategy.findElement(); } }
1
@Override public void Borrar(Object value) { Session session = null; try { Liga ejecutivo = (Liga) value; session = NewHibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.delete(ejecutivo); session.getTransa...
2
public static byte toByte(Object object) { if (object instanceof Number) { return ((Number) object).byteValue(); } try { return Byte.valueOf(object.toString()); } catch (NumberFormatException e) { } catch (NullPointerException e) { } retur...
3
public void write8bytes(long n) throws IOException { long b0 = n & 0xff; long b1 = (n & 0xff00) >> 8; long b2 = (n & 0xff0000) >> 16; long b3 = (n & 0xff000000) >>> 24; long b4 = (n & 0xff00000000L) >> 32; long b5 = (n & 0xff0000000000L) >> 40; long b6 = (n & 0xff000000000000L) >> 48; long b7 = (n & 0xf...
1
public int[] generate(int nplayers, int bowlsize) { Random random = new Random(); int nfruits = nplayers * bowlsize; int left = nfruits; int[] dist = new int[12]; for (int i = 1; i < 11; i++) { int cnt = random.nextInt(left); dist[i] = cnt; ...
1
public void actionPerformed (ActionEvent ev) { //System.out.println(ev.getActionCommand()); // Clic BOUTON "Source" if (ev.getActionCommand().equals(txtBtSource)) {actionBtSource();} // Clic BOUTON "Dest" else if (ev.getActionCommand().equals(txtBtDest)) {actionBtDest();} // Action sur BT START ...
8
public void addPayment() { this.setTotal(this.getTotal()+this.calcPayment()); }
0
private static float pointIntersectsCircleOuterDetection( float pointX, float pointY, float speedX, float speedY, float radius, float outerCenterX, float outerCenterY, float outerRadius) { // Rearrange the parameters to form the quadratic equation double offsetPointX = pointX - oute...
5
public void visitForceChildren(final TreeVisitor visitor) { if (visitor.reverse()) { index.visit(visitor); array.visit(visitor); } else { array.visit(visitor); index.visit(visitor); } }
1
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
protected void setup() { if(log.isLoggable(Logger.INFO)) log.log(Logger.INFO, "Hello World! This is Agent '" + getLocalName() + "'!"); world = new World(); new WumpusGUI(this).setVisible(true); dfd = new DFAgentDescription(); dfd.setName(this.getAID()); /* * Der Agen...
7
protected boolean isInt(Object obj) { return (obj != null && obj instanceof Integer); }
1
public void addProduct(Product p) { this.products.put(p.getCode(), p); }
0
public static int search_var_by_name(Variable_table variable_table, String name) { int num = variable_table.variable_name.size(); for (int i = 0; i < num; i++) { if (variable_table.variable_name.get(i).toString().equals(name)) { return i; } } retur...
2
public void setDatetime(Date datetime) { this.datetime = datetime; }
0
private void performDelete(Node z) { // create a node pointer y Node y; // if z has no left or right subtree if (z.left == null || z.right == null) { // set y to z y = z; } else { // set y as the successor of z y = successor(z); } // create a node pointer x Node x; // if y has a left subt...
7
public static String propertiesToString(BaseProperties props){ ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { props.store(baos, null); } catch (IOException e) { LOG.error("Caught IOException while trying to flush properties: " + e.getLocalizedMessage() + ...
1
@Test public void addsAndPopsLikeAGoodStack() { assertTrue(stack.pop() == 1 && stack.pop() == 11 && stack.pop() == 3 && stack.pop() == 2); }
3
Transaction openWrite(Transaction me) { boolean cacheHit = false; // already open for read? // not in a transaction if (me == null) { // restore object if latest writer aborted if (writer.isAborted()) { rVersion.recover(); writer = Transaction.COMMITTED; } return null; ...
8
public synchronized static LinkedList<Theater> getAllTheaters(int zone){ if(theaters.size() == 0) return null; LinkedList<Theater> result = new LinkedList<Theater>(); for(Theater t : theaters) if(t.getZone() == zone) result.add(t); if(result.size() == 0) return null; return result; }
4
public void CheckDyeCape() { boolean GoOn = true; int CapeXP = 0; int NewCape = -1; switch (useitems[0]) { case 1763: //red dye NewCape = 1007; CapeXP = 2; case 1767: //blue dye NewCape = 1021; CapeXP = 2; case 1765: //yellow dye NewCape = 1023; CapeXP = 2; case 1771: //green...
7
public void clearLevel(int no) { for (int i=0; i<height; ++i) { for (int j=0; j<width; ++j) { stack[i][j].setLayer(no, null); } } }
2
@Override public String getDesc() { return "HolyCrossAttack"; }
0
public void setFunApellidos(String funApellidos) { this.funApellidos = funApellidos; }
0
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); // Invoke the painter for the background if (painter != null) { Dimension d = getSize(); Graphics2D g2 = (Graphics2D) g; g2.setPaint(painter); g2.fill( new Rectangle(0, 0, d.width, d.height) ); } // Draw the im...
7
public boolean isAnyLiquid(AxisAlignedBB par1AxisAlignedBB) { int var2 = MathHelper.floor_double(par1AxisAlignedBB.minX); int var3 = MathHelper.floor_double(par1AxisAlignedBB.maxX + 1.0D); int var4 = MathHelper.floor_double(par1AxisAlignedBB.minY); int var5 = MathHelper.floor_double(...
8
private void factor() { int n = R.numRows(); // Internal CRS matrix storage int[] colind = R.getColumnIndices(); int[] rowptr = R.getRowPointers(); double[] data = R.getData(); // Temporary storage of a dense row double[] Rk = new double[n]; // Find the...
8
private void drawCloudMap(Graphics graphics) { BufferedImage buffer = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); Graphics gr = buffer.getGraphics(); for (int x = 0; x < mapWidth; x++) { for (int y = 0; y < mapHeight; y++) { double emptyAverage = 1; for (int t = 0; t < c...
9
public static String getMergeSql(String table, String colnames, String keynames) { StringBuilder sb = new StringBuilder(); sb.append("MERGE INTO " + table + " a "); sb.append(" USING (SELECT "); String[] colnamelist = colnames.split(","); for (int i = 0; i < colnamelist.length; i++) { String col = colnamel...
9
public void SetMaximumPassenger(int maximumPassenger) { if(maximumPassenger > this.maximumPassenger) this.maximumPassenger = maximumPassenger; }
1
public void deadRemoval() { ArrayList<Integer> dead = new ArrayList<Integer>(); int i = 0; for (Asteroid a : asteroids) { if (!a.getAlive()) { dead.add(i); } i++; } i = 0; for (int d : dead) { asteroids.remov...
7
public void actionPerformed(ActionEvent e) { String nick = GUIMain.userList.getSelectedValue().toString(); if (nick.startsWith("@")) { nick = nick.replace("@", ""); } else if (nick.startsWith("$")) { nick = nick.replace("$",...
5
public static void insertCarte(Carte carte) { PreparedStatement stat; try { stat = ConnexionDB.getConnection().prepareStatement("insert into carte (serialNumber) values (?)"); stat.setString(1, carte.getSerialNumber()); stat.executeUpdate(); } catch (SQLEx...
2
public void initializeConverter(Automaton automaton) { MAP = new HashMap(); State[] states = automaton.getStates(); State initialState = automaton.getInitialState(); // Do the variables. VARIABLE = new LinkedList(); for (char c = 'A'; c <= 'Z'; c++) VARIABLE.add("" + c); // Map the initial state to S. ...
3
@Override public void setNull(int intId, String strTabla, String strCampo) throws Exception { Statement oStatement; try { oStatement = (Statement) oConexionMySQL.createStatement(); String strSQL = "UPDATE " + strTabla + " SET " + strCampo + " = null WHERE id = " + Integer.toS...
1
private ServiceManager() { }
0
public RuleBased(GenData gen) throws IOException{ this.data = gen; writer = new BufferedWriter(new FileWriter("featureMatrix.txt")); y = new BufferedWriter(new FileWriter("label.txt")); for(User u:data.userMap.values()){ u.addDiffFeature(); for(int i=0; i<featuresize; i++){ if...
6
public boolean isIn(double x1, double y1){ if ((x <= x1) && (x1 <= (x + length)) && (y <= y1) && (y1 <= (y + height)) ){ return true; }else return false; }
4
public void AddPoint(double x, double y, int index) { if (index > PointArray.length - 1) { index = PointArray.length; } else if (index < 0) { index = 0; } double temp[] = new double[PointArray.length + 2]; for (int i = 0; i <= temp.length - 1; i++) { ...
6
private void lifeCycle() { String s = ""; int attempt_number = 0; do { try { s = readInput(); if (s.length()==0) { break; } action(s); attempt_number++; } catch (IOException e) { e.printStackTrace(); } } while (attempt_number<=VALUE_ITERATIONS_NUMBER-1); ...
3
private String fontTypeToString(int fontType) { if (fontType == FONT_OPEN_TYPE) { return "Open Type Font"; } else if (fontType == FONT_TRUE_TYPE) { return "True Type Font"; } else if (fontType == FONT_TYPE_0) { return "Type 0 Font"; } else if (fontTyp...
5
@Override public String toString() { StringBuilder buf1 = new StringBuilder(); if (isPrinter()) { for (MoneyPrinter printer : printers) { buf1.append(printer.toString()); } } StringBuilder buf2 = new StringBuilder(); if (isParser()) { ...
9
public void update() { shift = (int) (Math.random()*4); if (Math.random() < .5) { for (int i = 0; i < shift;i++) { if (!collisionCheck(getX() + 1,getY())) addX(1); else break; } }else { for (int ...
9
public void cal(int x, int y, int m, int n, int[][] matrix) { if (n <= 0 || m <= 0) return; for (int i = 0; i < n; i++) res.add(matrix[x][i + y]); for (int i = 1; i < m; i++) res.add(matrix[x + i][y + n - 1]); for (int i = 1; i < n; i++) if (x + m - 1 ...
9
public void broadCast(String s){ for (BTHandler h:this.handler){ h.send(s.getBytes()); } }
1
public int getExperience() { return experience; }
0
public String toString() { switch (typecode) { case TC_LONG: return "long"; case TC_FLOAT: return "float"; case TC_DOUBLE: return "double"; case TC_NULL: return "null"; case TC_VOID: return "void"; case TC_UNKNOWN: return "<unknown>"; case TC_ERROR: default: return "<error>"; } ...
7
private boolean onJonkinMuunPalikanVieressa(Sijainti sijainti) { if(palikat.isEmpty()) return true; for(Palikka palikka : palikat) if(palikka != null && onVieressa(((TetriminoPalikka)palikka).sijainti(), sijainti)) return true; return false; ...
4
public void build() { for (Field f : this.bagFields) { try { Object value = f.get(this); if (value != null) { ResourceBag.class.cast(value).build(); } } catch (IllegalAccessException e) { throw new Runtim...
3
private Node fixUp(Node h) { if (isRedNode(h.right)) h = rotateLeft(h); if (isRedNode(h.left) && isRedNode(h.left.left)) h = rotateRight(h); if (isRedNode(h.left) && isRedNode(h.right)) flipColors(h); return h; }
5
public void listenSocket() { try { server = new ServerSocket( 80 ); } catch( IOException e ) { System.out.println( "Could not listen on port 80" ); System.exit( -1 ); } while( true ) { try { client = server.accept(); } catch( IOException e ) { System.out.println( "Accep...
6
public String getTripFrom() { if (river == null) return "<?>"; return river.getTripFrom(); }
1
@Override protected DataSet doParse() { try { return doFixedLengthFile(getDataSourceReader()); } catch (final IOException e) { LOGGER.error("error accessing/reading data", e); } return null; }
1
public void computeLCS() { int diag = 0; for (int i = 1; i < seq1.length; i++) { diag = 0; for (int j = 1; j < seq2.length; j++) { diag = length[j]; if (seq1[i] == seq2[j]) { length[j] = length[j] + 1; } else...
4
public void setMusicLoudness(MusicLoudness musicLoudness) { this.musicLoudness = musicLoudness; }
0
private void setStationType(Player player) { // List<TicketType> ticketTypes = new ArrayList<TicketType>(); // gets all the possible edges the player can transverse given their current node and loops through them for (Edge a : player.getNodeNeighbours()) { // adds each edge type to the ticketTypes list if...
7
public boolean intersectsBelow(RPChromosomeRegion testRegion) { // Only need to test if some part of this region is below and some within test region. if (startChromID < testRegion.startChromID || (startChromID == testRegion.startChromID && startBase < testRegion.startBase)) { ...
6
static final void method3012(int i, int i_44_, int i_45_, int i_46_, int i_47_, byte i_48_, int i_49_, int i_50_) { anInt6918++; int i_51_ = 0; int i_52_ = i; int i_53_ = 0; int i_54_ = -i_50_ + i_45_; int i_55_ = -i_50_ + i; int i_56_ = i_45_ * i_45_; int i_57_ = i * i; int i_58_ = i_54_ * i_54_; int i_...
9
public CompilationUnit getCompilationUnit(Lexer lexer) { for (CompilationUnit unit: units) { if (unit.getLexer().equals(lexer)) return unit; } return null; }
2
public static HttpServletRequest addBill(HttpServletRequest request){ Models.DatabaseModel.Bill bill = new Models.DatabaseModel.Bill(); Models.DatabaseModel.Patient patient = new Models.DatabaseModel.Patient(); int patientID; if (request.getParameter("patientID") == null){ pa...
1
public static String encryptMD5(String pwd) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(pwd.getBytes()); StringBuffer stringBuffer = new StringBuffer(); int n; byte[] b = md.digest(); for (int i = 0; i < b.length; i++) { n = b[i]; if (n < 0) { ...
4
public Chromo<T> getFittestChromo() { return new Chromo<>(fittestChromo.getGenes(), fittestChromo.getFitness()); }
0
public boolean equals(Object o) { if (!(o instanceof Map.Entry)) return false; Map.Entry e = (Map.Entry)o; Object k1 = getKey(); Object k2 = e.getKey(); if (k1 == k2 || (k1 != null && k1.equals(k2))) { Object v1 = getValue(); Object v2 = e.getV...
7
public Set<Map.Entry<Double,Integer>> entrySet() { return new AbstractSet<Map.Entry<Double,Integer>>() { public int size() { return _map.size(); } public boolean isEmpty() { return TDoubleIntMapDecorator.this.isEmpty(); } ...
8
public void addServiceListener(IServiceListener listener) { this._listeners.add(listener); }
0
public Response signup(Response resp, JSONObject data) { try { if(data.has("name") && !v.isNullOrEmpty(data.getString("name")) && data.has("email") && v.isValidEmail(data.getString("email")) && data.has("website") && v.isValidURL(data.getString("website"))) { User user = UserDAO.instance().get(d.hashe...
8