text
stringlengths
14
410k
label
int32
0
9
private void predict(Particle a) { if (a == null) return; for (int i = 0; i < particles.length; i++) { double dt = a.timeToHit(particles[i]); if (t + dt < limit) pq.insert(new Event(t + dt, a, particles[i])); } double dtx = a.timeToHitVerticalWall(); double dty = a.timeToHitHorizontalWall(); if...
5
private float setFontScale(int line) { String[] hold = script[line].split(":"); float scale = 1; switch (hold[0]) { case "POS": scale = 1f; break; case "EMPLOYE": scale = .5f; break; case "DEPT": scale = 1.5f; break; case "STAGE": scale = 1f; break; case "COLLAB": ...
6
@Id @Column(name = "sale_id") public int getSaleId() { return saleId; }
0
public boolean checkFields(){ if(this.nameTextField.getText().compareTo("") == 0){ ErrorMessage.giveErrorMessage("Please enter a sequence name."); return false; } if(this.sequencePanel.getOriginalText().compareTo("") == 0){ ErrorMessage.giveErrorMessage("Please enter a genetic sequence."); return f...
6
@Override public void init() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { ex.printStackTrace(); } //Create and display the applet try { java.awt.EventQueue.invokeAndWait(new Runnable(...
3
public void paint(Graphics g){ g.drawImage(this.bodypart.getIcon(), 0, 0, null); if(bodypart.isUsed()){ g.setColor(Color.red); }else{ g.setColor(Color.black); } g.drawString(this.bodypart.getName(), 8, 18); }
1
public int getId() { return id; }
0
public void close () { try { if (socketChannel != null) { socketChannel.close(); socketChannel = null; if (selectionKey != null) selectionKey.selector().wakeup(); } } catch (IOException ex) { if (DEBUG) debug("kryonet", "Unable to close TCP connection.", ex); } }
4
public static double incompleteGammaSer(double a, double x) { if (a < 0.0D || x < 0.0D) throw new IllegalArgumentException("\nFunction defined only for a >= 0 and x>=0"); if (x >= a + 1) throw new IllegalArgumentException("\nx >= a+1 use Continued Fraction Representation"); double igf = 0.0D; if (x != 0.0D)...
8
public void addIncrement(int nmult){ try { if(allowedValue == null){ int n = this.getValue(); if(n + nmult*increment > vmax) { n = vmax; }else if(n + nmult*increment < vmin) { n = vmin; }else{ n += nmult*increment; n = increment * (int)( n / (double)increment + 0.5); } setN...
5
public List<BookLanguage> getBookLanguages() { List<BookLanguage> list = new ArrayList<>(); Connection con = null; Statement stmt = null; try { DBconnection dbCon = new DBconnection(); Class.forName(dbCon.getJDBC_DRIVER()); con = DriverManager.getConn...
5
private void processCookies(String setCookie) throws Exception{ //================================= //init Reader input = new StringReader(setCookie); int n = 0; //================================= //parse Set-Cookie pairLoop: while(n != -1){ //init pair StringBuilder key = new StringBuilder()...
9
public String otherPlayer(String s) { if (s.equals("red")) return "blue"; else if (s.equals("blue")) return "red"; else return null; }
2
public static void setMinDestToRad(float minDestToRad) { MinDestToRad = minDestToRad; }
0
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed if(Domino.listaTablero.size()!=0&&MiSistema.turno==1){ d.robarFicha(true); this.tablero.add(Domino.listaFichaHumano.get(Domino.listaFichaHumano.size()-1)); ...
5
public static Entity create(int id, int lvl){ Entity mob = null; switch(id){ case 1: mob = new Slime(lvl); break; case 2: mob = new AniBear(lvl); break; } return mob; }
2
private static void ReadWordFileFilldictionary(String string) { BufferedReader br1 = null; BufferedReader br2 = null; Writer writer = null; try { String FirstCurrentLine; String SecondCurrentLine; br1 = new BufferedReader(new InputStreamReader(ParseTamilMeanings.class.getClassLoader().getResource...
7
public boolean replaceSubBlock(StructuredBlock oldBlock, StructuredBlock newBlock) { for (int i = 0; i < subBlocks.length; i++) { if (subBlocks[i] == oldBlock) { subBlocks[i] = newBlock; return true; } } return false; }
2
private void faceCam(Vector3f direction) { float cameraROT = (float)Math.toDegrees(Math.atan(direction.getZ() / direction.getX())); if(direction.getX() < 0) { cameraROT += 180; } transform.getRotation().setY(cameraROT + 90); }
1
private static void updateKeyboardList() { mousePressed = false; mouseReleased = false; while(Mouse.next()) { boolean button = Mouse.getEventButtonState(); int eventButton = Mouse.getEventButton(); if(button && eventButton == 0) { mousePressed = true; } else if(!button && eventButton == 0) ...
9
public Map(String res) { tileList = new ArrayList<Tile>(); try { map = new TiledMap(res); for (int i = 0; i < map.getHeight() - 1; i++) { for (int j = 0; j < map.getWidth() - 1; j++) { TileType type = null; if (map.getTileId(j, i, 0) == 1) { type = TileType.WALL; } if (map.getT...
6
@Override public void parse() throws IllegalArgumentException { try { setEncoding(Encoding.getEncoding(buffer[0])); } catch (IllegalArgumentException ex) { // ignore the bad value and set it to ISO-8859-1 so we can continue parsing the tag setEncoding(Encoding.ISO_...
3
private static void setColor(int hue, float sat, float val, int max) { int h = 6*hue/max; float f = 6*(float) hue/max - h; float p = val*(1-sat); float q = val*(1-sat*f); float t = val*(1-sat*(1-f)); if (h == 0 || h == 6) GL11.glColor4f(val,t,p,1); if (h == 1) GL11.glColor4f(q,val,p,1); if (h == ...
7
public DataType typeFromString(String strType){ if(strType.equals("FLOAT")){ return DataType.FLOAT; }else if(strType.equals("STRING")){ return DataType.STRING; }else if(strType.equals("INFILENAME")){ return DataType.INFILENAME; }else if(strType.equals("OUTFILENAME")){ return DataType.OUTFILENAME; ...
8
public Point getInitialPoint() { return initialPoint; }
0
@Override public void deserialize(Buffer buf) { nbSubOwned = buf.readInt(); if (nbSubOwned < 0) throw new RuntimeException("Forbidden value on nbSubOwned = " + nbSubOwned + ", it doesn't respect the following condition : nbSubOwned < 0"); subTotal = buf.readInt(); if (sub...
7
public void setFund(String fund) { this.fund = fund; }
0
public String stringApiValue() { if (isKeyword() || (!shouldQuote())) { return toString(); } return "(QUOTE " + toString() + ")"; }
2
@Override public Buildable create(Object name, Object value) { if (name.equals("model")) { if (model != null) { throw new ComponentException("Only one 'model' element allowed."); } model = new Model(); model.setRes(res); return mode...
7
public MainFrame() { super("Conway's Game of Life"); try { doAesthetics(); setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
1
public static SampleRoundingContext narrow(final RoundingContext context) { if (SampleRoundingContext.class.isInstance(context)) { return (SampleRoundingContext) context; } else { throw new ClassCastException("Not sample context " + context); } }
1
public void execute(InetAddress addr, int port, JSONObject arguments){ try { Iterator<PodLocation> it = pod.getPendingFriends().iterator(); //on vérifie qu'il s'agit bien d'une réponse à un ADD en parcourant la liste des pendingsFriends. while(it.hasNext()) { PodLocation friendLocation = it.next(); ...
5
public void changeVIP(){ if (VIP == false){ VIP = true; }else{ VIP = false; } }
1
public Object getFoo() { return foo; }
0
private void unicast (Message m, int delay) { int src = m.getSource(); int dst = m.getDestination(); Record source = r.find (src); Record destination = r.find (dst); if ((source == null) || (destination == null)) { /* In this unlikely event. */ String msg = String.format("Error: link <P%d, ...
7
private void setKeyToFirstElement() { Column column; for ( int i = 0; i < columns.size(); i++ ) { column = columns.get( i ); if ( column.isKey() ) { if ( i == 0 ) return; columns.remove( i ); columns.add( 0, c...
4
public boolean existsInListMultipleTimes(String stringToCount, List<String> allKMers) { int count = 0; for (String s : allKMers) { if (s.equals(stringToCount)) { count++; } } if (count > 1) { return true; } return fal...
3
private boolean zzRefill() throws java.io.IOException { /* first: make room (if you can) */ if (zzStartRead > 0) { System.arraycopy(zzBuffer, zzStartRead, zzBuffer, 0, zzEndRead-zzStartRead); /* translate stored positions */ zzEndRead-= zzStartRe...
5
public void start() { // Initialization initLogger(); initDisplay(); initGL(); initTime(); initTexture(); initSprite(); while (!Display.isCloseRequested()) { int delta = getDelta(); update(delta); renderGL(); Display.update(); Display.sync(60); } log.dbg("Closing."); Display.destro...
1
public static InputHandler getInstance() { if (instance == null) { instance = new InputHandler(); } return instance; }
1
public static int solve(String group) { if (counted.containsKey(group)) return counted.get(group); if (!groups.containsKey(group)) { counted.put(group, 0); return 1; } String[] members = groups.get(group); int count = 0; for (int i = 0; i < members.length; i++) if (!counted.containsKey(members[i...
4
public TextConversionStream(int inputStyle, int outputStyle, OutputStream out) { super(out); switch (inputStyle) { case TEXT_CRLF: { stripCR = false; stripLF = false; stripCRLF = true; ...
9
public void setHalted(boolean b){ isHalted = b; }
0
public void clear(Location one, Location two) { World w = one.getWorld(); int sx = one.getBlockX() + 1; int sy = one.getBlockY(); int sz = one.getBlockZ() + 1; int ex = two.getBlockX(); int ey = two.getBlockY(); int ez = two.getBlockZ(); // clear the area...
7
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof AccessRequestResponseType)) { return false; } AccessRequestResponseType other = (AccessRequestResponseType) object; ...
5
private void mergeStacks(Collection sources, ASTNodeStack target) { logger.debug("Merging ..."); Iterator iter = sources.iterator(); while (iter.hasNext()) { Node pred = (Node) iter.next(); dump(pred.stack, "Stack for " + pred); } ...
8
public void GraphToXml(Graph g, String _path) throws IOException { // inicio padrão do schema xml do prefuse StringBuffer xml = new StringBuffer( "<?xml version=\"1.0\" encoding=\"ISO8859-1\"?>\n<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\">\n" + "\t<graph edgedefault=\""+ ((g.isOrientado()) ? "d...
8
public T get(PK id) { T entity = (T) hibernateTemplate.get(this.persistentClass, id); if (entity == null) { log.warn("Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found..."); throw new ObjectRetrievalFailureException(this.persistentClass, id); } ...
1
public static String implode(String delimiter, List<?> arlist) { if (arlist == null) return ""; if (delimiter == null) delimiter = ""; StringBuilder arlstTostr = new StringBuilder(); if (arlist.size() > 0) { arlstTostr.append(Functions.nn(arlist.get(0))); for (int i=1; i<arlist.size(); i++) { arlstTos...
5
public void inactiveCustormer(VPosFuncionarios funcionario){ // OBTENGO EL CUSTOMER PosFuncEstado posFuncEstado = facOracleDAO.getPosFuncEstado( getIdPos(), funcionario.getFunCedula()); if (posFuncEstado.getFesIdFuncionario()!=null) { // DE PRONTO VAYA SIN ID EN MYSQL ...
2
public void f() { System.out.println("public f()"); }
0
private void startGame() { if (!gameActive) { gameActive = true; // Start the timer gameTimer.schedule(new TimerTask() { /** Update the game by moving all objects as needed. The timer * fires every interval defined in TIMERINTERVAL. ...
4
private void openHttpsPostConnection(final String urlStr, final byte[] data, final int sampleRate) { new Thread () { public void run() { HttpsURLConnection httpConn = null; ByteBuffer buff = ByteBuffer.wrap(data); byte[] destdata = new byte[2048]; int resCode = -1; OutputStream out = null; ...
9
private int readFrameType(final Object[] frame, final int index, int v, final char[] buf, final Label[] labels) { int type = b[v++] & 0xFF; switch (type) { case 0: frame[index] = Opcodes.TOP; break; case 1: frame[index] = Opcodes.INTEGER; ...
8
private static void monitorChannel(final ServerSocket server) { new Thread(new Runnable() { @Override public void run() { try { while (isRunning) { Socket socket = server.accept(); Communication comm = new Communication(socket); Message msg = comm.readMessage(); Communication cl...
8
public boolean isAdditiveNumber(String num) { //if(Double.valueOf(num)>Integer.MAX_VALUE) return false; boolean[]arr=new boolean[num.length()]; for(int i=num.length()-1;i>=0;--i){ calculate(num,arr,i); } return arr[0]; }
1
public void moveLeft(){ if(canMoveLeft()){ int[][] temp = BlockInControl.getBlock(); int tempPosX = BlockPosX; int tempPosY = BlockPosY; ArrayList <Point> CoordinatesToLeft = new ArrayList <Point>(); for(int r=0; r<4; r++){ for(int c=0;c<4;c++){ if(temp[r][c] == 1 && getRowCol(tem...
6
protected Document createDefaultModel() { return new UpperCaseDocument(); }
0
private Expr term() { Expr res, nextFactor; res = factor(); while (theTokenizer.ttype == '*' || theTokenizer.ttype == '/') { char op = (char) theTokenizer.ttype; theTokenizer.next(); nextFactor = factor(); if (op == '*') { res = new Mult(res, nextFactor); } else { res = new Div(res, nextFac...
3
@SuppressWarnings("deprecation") public static void parseFile() throws IOException,Exception { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("./log/events.log.2013-12-29"))); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("./log/...
3
public void run() { ServerSocket serversocket = null; Socket s; InputStreamReader input; BufferedReader b; String message = null; boolean done = false; try { serversocket = new ServerSocket(process.getPort(), 1); serversocket.setSoTimeout(0); } catch (IOException e) { String msg = Str...
5
public boolean clearDir(File dir) { File[] contents = dir.listFiles(); if (contents != null) { for (File file : contents) { if (file.isDirectory()) { clearDir(file); } file.delete(); } } return dir.delete(); }
3
public static <T extends DC> Set<Pair<PT<Integer>,T>> codom(Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>> phiMax) { if(phiMax!=null) { if(phiMax.getNext()!=null) { return new Set(phiMax.getFst().snd(),codom(phiMax.getNext())); } else { return new Set(phiMax.getFst().snd(),null); ...
2
public String getAcademicLevel() { return AcademicLevel; }
0
void coalesce(final IGNode node) { Assert.isTrue(wide == node.wide); weight += node.weight; final Iterator iter = node.defs.iterator(); while (iter.hasNext()) { final LocalExpr def = (LocalExpr) iter.next(); defs.add(def); } }
1
private void extractModeConversionRule() throws XMLStreamException, TheoryException { String mode = ""; List<String> conversionList = new ArrayList<String>(); while (reader.hasNext()) { int event = reader.next(); switch (event) { case XMLStreamConstants.START_ELEMENT: currTag = getXmlTag(reader.getLo...
9
@Override public NetworkConfiguration offerResource(String mac) { ResourceStatus rs = null; String ip = null; checkTimeOutLease(); synchronized(this) { for(Entry<String, ResourceStatus> e : getResources().entrySet()) { if(e.getValue().getMac().equals(mac) && e.getValue().isInLeasing()) { rs ...
7
public BufferedImage modificatorType(int t) { try { switch(t) { case 0: return ImageIO.read(new File("data/img/wave.jpg")); case 1: return ImageIO.read(new File("data/img/chrono.jpg")); case 2: return ImageIO.read(new File("data/img/reversal.jpg")); case 3: return ImageIO.read(...
9
public SchemeObject Invoke(SchemeObject args, SchemeEnvironment env) { SchemeObject argList = args; SchemeObject temp = SchemeObject.NIL; String result = ""; boolean symbol = true; while(argList != SchemeObject.NIL) { temp = interpreter.Eval(argList.Car(), env); if(temp.isError()) { return tem...
8
public String getMD5(String yourString){ // yourString = "123456789"; if (yourString != null) { byte[] bytesOfMessage = yourString.getBytes(); try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] thedigest = md.digest(bytesOfMessage); StringBuffer hexString = new StringBuffer()...
4
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; QuizCatalogus other = (QuizCatalogus) obj; if (id != other.id) return false; if (quizzen == null) { if (other.quizzen != null) return...
7
public void createFile(File file){ try{ f = new Formatter(file.getPath()); }catch(Exception e){ System.out.println( "File creation failed! " + e ); } }
1
public int getAttack() { int result = attack + cityAttack; for (Artifact a: active.values()) { result += a.attack; } return result; }
1
public void driver() { System.out.println("audo car drive"); }
0
void previous() { if (image != null && imageDataArray.length > 1) { if (imageDataIndex == 0) { imageDataIndex = imageDataArray.length; } imageDataIndex = imageDataIndex - 1; displayImage(imageDataArray[imageDataIndex]); } }
3
public void actionPerformed(ActionEvent e) { String a = e.getActionCommand(); if (a.startsWith(Commands.MOVE) && running) { try { out.println(a + " " + player); String reply = in.readLine(); if (reply.equals(Erro...
5
@Override public Vector3D getNormalVectorAt(Point3D point) { if(Math.abs(point.x - xBoundHigh) < .0001) { return new Vector3D(1, 0, 0); } if(Math.abs(point.x - xBoundLow) < .0001) { return new Vector3D(-1, 0, 0); } if(Math.abs(point.y - yBoundHigh) < .0001) { return new Vector3D(0, 1, 0); ...
6
public void showTop(CommandSender viewing, int amount) { LinkedHashMap<String, Double> Ranking = iConomy.Accounts.ranking(amount); int count = 1; Messaging.send(viewing, this.Template.parse("top.opening", new Object[] { "+amount,+a" }, new Object[] { Integer.valueOf(amount) })); if ((Ranking ...
3
public void testInit() { SmartDashboard.putBoolean("Enabled", false); }
0
public Iterator getOpenDocumentIterator(int index) { ArrayList temp = new ArrayList(); temp.addAll(openDocuments.subList(index, openDocuments.size())); temp.addAll(openDocuments.subList(0, index)); return temp.iterator(); }
0
public void fade(float dt){ // System.out.println(title+": "+volume); float volume = getVolume(); volume += dt * fadeType * speed; if (volume >= goalVolume && fadeType==FADE_IN){ volume = goalVolume; fading = false; fadeType=0; } if (volume <= goalVolume && fadeType==FADE_OUT){ volume = goalVolume;...
6
public void setOption(String option, Collection values) { if (option.equals("all")) { onlySUID = false; } else throw new IllegalArgumentException("Invalid option `" + option + "'."); }
1
public void endElement(String name) { switch (etape) { case DICTIONNAIRE: if ("INFORMATION".equalsIgnoreCase(name)) { dictionnaireTable.addData((String) hashtable.get("code"), (String) hashtable.get("nom"), (String) hashtable ...
7
@Override public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (code>0 && code<keys.length) { keys[code] = true; } }
2
public int addStore(int n, CtClass type) { if (type.isPrimitive()) { if (type == CtClass.booleanType || type == CtClass.charType || type == CtClass.byteType || type == CtClass.shortType || type == CtClass.intType) addIstore(n); else if (typ...
9
public void init(final Map attributes) throws SaslException { if (state != -1) { throw new IllegalMechanismStateException("init()"); } if (properties == null) { properties = new HashMap(); } else { properties.clear(); } if (attributes != null) { a...
7
public String parentRow(){ return "<tr class=\"parent nosort\" data-level=\"1\">"+ "<td/><td colspan=\"6\">"+this.label+"</td>"+ "<td>"+this.timediff+"</td>"+ "</tr>"; }
0
private String nand(Register dest, Register source1, Register source2) { int source1Value = binaryToDecimal(source1.getValue()); int source2Value = binaryToDecimal(source2.getValue()); int newValue = (source1Value & source2Value); String theNewValue = decimalToBinary(newValue); String returnString=""; for...
2
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ConwaysCommunity other = (ConwaysCommunity) obj; if (cells == null) { if (other.cells != null) return false; } else if (!cells.equals(ot...
7
public int evaluatePieceDevelopment() { int score = 0; int[] minorPiecePositions = new int[]{ 1, 2, 5, 6 }; int turn = isWhiteTurn() ? 0 : 112; for ( int pos : minorPiecePositions ) { if ( !squareEmpty( pos + turn ) && !hasPieceMoved( pieceAt( pos + turn ) ) ) { if ( isWhiteTurn() ) { ...
6
public Artist getArtistFromShowName(String name) throws SQLException { if (exist(name)) return artists.get(name); else if (tempStore.containsKey(name)) return tempStore.get(name); else { collectQueryShowName.setString(1, name); ResultSet rs = collectQuerySh...
3
@Override public CollectionObject putItem(String path, InputStream content) throws ContentRepositoryException, IOException { try (BufferedInputStream in = new BufferedInputStream(content)) { in.mark(1); int c = in.read(); in.reset(); if (c >= 0) { File file = new File(rootDir, path); try (File...
3
public void testingPartialSeqScenario3(){ System.out.println("execute epi_test"); System.out.println("======================="); System.out.println("ONE SEQUENCE LEARNT"); System.out.println("======================="); int numTrials = seqStartIndexes.size()-1; int sumSuccess = 0; int l...
8
public boolean hasUnaryInput() { if (left instanceof LvalExpression && ((LvalExpression) left).hasUnaryInput()) { return true; } if (right instanceof LvalExpression && ((LvalExpression) right).hasUnaryInput()) { return true; } return false; }
4
public boolean isValid() { return !(Float.isInfinite(x) || Float.isNaN(x) || Float.isInfinite(y) || Float.isNaN(y) || Float.isInfinite(z) || Float.isNaN(z)); }
5
protected void checkLongArgResults(GetOpt getopt, Map<String,String> parsedArgsMap) { assertFalse(parsedArgsMap.size() == 0); int errs = 0; Iterator<Map.Entry<String,String>> it = parsedArgsMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry e = it.next(); String key = (String)e.getKey(); ...
6
public int findClosest(){ int index=-1; for(int q=0;q<objects.size();q++) { if (objects.get(q) == this||objects.get(q).kind==kind||(objects.get(q).kind==0)) continue; int searchRadius = 400; //radius of whether the object will be findable boolean searc...
8
public static void writeStreamContent(XMLInputFactory inputFactory, XMLStreamWriter writer, InputStream content, Map<String, String> replacementMap, LocalizationUtil localizationUtil) throws XMLStreamException { XMLEventReader parser = inputFactory.createXMLEventReader(content); StartElement startEleme...
8
public Date getDataEvasione() { return dataEvasione; }
0
private void setupPropertyView() { this.propKey = new Label(this.prop.getKey()); //set the font, if it is an object type (has sub properties) then make it bold like a header. if(this.prop.getPropertyType() == TiProperty.PROPERTY_TYPE_OBJECT) { this.propKey.setFont(Font.font("Arial", FontWeight.BOLD, 14)); } ...
9