text
stringlengths
14
410k
label
int32
0
9
private static void checkArgs() { for (int i = 0; i < arguments.length; i++) { if (arguments[i].contains("noLauncher")) doLauncher = false; if (arguments[i].contains("noIntro")) doIntro = false; if (arguments[i].contains("debug")) DEBUG = true; if (arguments[i].contains("mute")) MUTE = true; //if (argu...
5
private boolean jj_3R_19() { if (jj_scan_token(RETURN)) return true; if (jj_3R_76()) return true; if (jj_scan_token(SEMICOLON)) return true; return false; }
3
private void txtcedulaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtcedulaKeyTyped char caracter = evt.getKeyChar();//Validacion del campo cedula if (caracter >= '0' && caracter <= '9' || caracter == 8 || caracter == KeyEvent.VK_BACK_SPACE || caracter == KeyEvent.VK_CAPS_LOCK || caracter =...
7
public static int insertMstxInfo(String info_title, String info_dis, String info_lon, String info_lat, String uid, String info_sort, int info_price, int where, String mshotelName) { int mid = MstxDao.getMaxNumber("mstx_info"); MstxDao.updateMaxNumber(3);// 将该字段值加1 Connection con = DBUtil.getConnection(); Pre...
6
public static Object[] run(String query) throws ClassNotFoundException, SQLException { System.out.println(query); if (true) return null; Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/Forum?user=root&password=1234"); Statement statement = co...
1
public double repeatNFoldCrossValidation(Matrix features, Matrix labels, int n, int repetitions){ double mseTotal = 0.0; long seed = System.currentTimeMillis(); for (int i = 0; i < repetitions; i++) { Matrix shuffledFeatures = features.shuffle(new Random(seed)); Matrix s...
1
public List<R> getResults() { Iterator<TaskItem<R,C>> items = iterator(); List<R> results = new ArrayList<R>(); while(items.hasNext()) { TaskItem<R,C> item = items.next(); if(item.future.isDone()) { try { results.add(item.future.get()); } catch(Exception e) { ...
3
public static void main(String[] args) { // TODO code application logic here //10. Дан двумерный массив целых чисел. Сформировать одномерный //массив, каждый элемент которого равен наибольшему по модулю //элементу соответствующего столбца двумерного массива. System.out.println...
4
public void addMessage(IMessage message) { history.add(message); setChanged(); notifyObservers(ModelNotification.MESSAGE_RECEIVED); }
0
public PlaySound(GbAudio audio) { int[] samples = audio.samples; int[] soValues = audio.soValues; if (samples.length != soValues.length * 2) throw new IllegalArgumentException("samples length " + samples.length + " does not match twice so length " + soValues.length); if (soValues.length < 1) ...
6
private void autonomousScoreFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_autonomousScoreFocusLost // TODO add your handling code here: try{ Integer.parseInt(autonomousScore.getText()); } catch(Exception e){ autonomousScore.setText("0"); } ...
4
public void stop() { // Pass on to upstream beans if (m_trainingProvider != null && m_trainingProvider instanceof BeanCommon) { ((BeanCommon)m_trainingProvider).stop(); } if (m_testProvider != null && m_testProvider instanceof BeanCommon) { ((BeanCommon)m_testProvider).stop(); } ...
8
public Wave07(){ super(); MobBuilder m = super.mobBuilder; for(int i = 0; i < 75; i++){ if(i < 5){ if(i % 2 == 0) add(m.buildMob(MobID.RATTATA)); else add(m.buildMob(MobID.PIDGEY)); } else if (i > 5 && i < 45){ if(i % 2 == 0) add(m.buildMob(MobID.PIDGEY)); else add(m.b...
9
public void euthanize() { ArrayList<Fish> magikarps = new ArrayList<Fish>(); for (Fish a : fishies) { if (a.getAge() == a.getMaxAge()) { a.setHealth(0); if (a instanceof Magikarp) { magikarps.add(a); } } ...
5
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Jogador other = (Jogador) obj; if (posicao == null) { if (other.posicao != null) return false; } else if (!posicao.equals(other.posicao)...
6
@Override public double get(int i, int j) { outOfBound(i - 1, j - 1); for (Element e : elems) { accessCount += 1; // access auf das Element if (e.getI() == i && e.getJ() == j) { return e.getValue(); } } return 0.0; }
3
@Override public boolean equals(Object that) { if (that == null) { return false; } if (that.getClass() != this.getClass()) { return false; } SpriteElement thatSprite = (SpriteElement) that; return this.mAlignX == thatSprite.mAlignX && this.mAl...
8
public static IautosStatusCode getByDesc(String desc) { if (null == desc) { throw new IllegalArgumentException( "IautosStatusCode desc is null"); } for (IautosStatusCode iautosStatusCode : IautosStatusCode.values()) { if (iautosStatusCode.getDesc().equals(desc)) { return iautosStatusCode; ...
3
protected int computeScore () throws IncompatibleScoringSchemeException { int[] array; int rows = seq1.length()+1, cols = seq2.length()+1; int r, c, tmp, ins, del, sub, max_score; // keep track of the maximum score max_score = 0; if (rows <= cols) { // goes columnwise array = new int [rows]; ...
9
private String getNameTypeObj(String objName) { return objName.substring(nameGameWorld.length()); }
0
@Override public void render(Drawer drawer) { for (int x = 0; x < tileColumns; x++) { for (int y = 0; y < tileRows; y++) { if (tiles[x][y] != null) { drawer.draw(tiles[x][y], (x * tileWidth) + getRenderableX(), (y * tileHeight) + getRenderableY()); ...
3
public void countTail(){ //for(int i = 0; i < m.length;i++){ //if(m[i].equals("Tail")){ countT++; //} //} }
0
private String startSetToString() { StringBuffer FString = new StringBuffer(); boolean didPrint; if (m_starting == null) { return getStartSet(); } for (int i = 0; i < m_starting.length; i++) { didPrint = false; if ((m_hasClass == false) || (m_hasClass == tru...
7
public ViewHandler() { mainPage = new MainPage("Computer Test Programe"); mainPage.setJMenuBar(new CbtMenuBar()); }
0
private static String codeAnswerAux(String answer,String question){ question=question.replace("[???]", answer); MainInfo.submittedQuestion = question; log.finer("\n"+question); try { try {checkForbiddenKeyWords(answer);} catch (Error e) { return "Wrong! Try again.\n You are trying to do ...
6
public Map<String, Groop> getGroopMap() { if (groops.size() == 0) try { execute(); } catch (SQLException e) { e.printStackTrace(); } return groops; }
2
public String nextCDATA() throws JSONException { char c; int i; StringBuffer sb = new StringBuffer(); for (;;) { c = next(); if (c == 0) { throw syntaxError("Unclosed CDATA"); } sb.append(c); i =...
6
public String encrypt(String plainTextStr) { final byte[] cipherTextBytes; final Cipher cipher; final SecretKeySpec SKSAESKey; final int blockSize; final byte[] ivBytes; final SecureRandom random; final IvParameterSpec iv; final byte[] ivWithCipherTextByte...
2
private Case getNextCase() { Case tete = this.listeCasesSerpent.getFirst(); switch(this.directionActuelle) { case VERS_LE_HAUT : return new Case(tete.getPosX(), tete.getPosY()-1); case VERS_LA_DROITE : return new ...
4
public void update() { super.update(); if (level.player != null) { int xd = level.player.x - x; int yd = level.player.y - y; Rectangle r3 = level.player.getBounds(); Rectangle r2 = getBounds(); //if (xd * xd + yd * yd ...
8
public static TileFlags swigToEnum(int swigValue) { if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) { return swigValues[swigValue]; } for (int i = 0; i < swigValues.length; i++) { if (swigValues[i].swigValue == swigValu...
5
protected void addLine(String line) { if (line == null) { IllegalArgumentException iae = new IllegalArgumentException("The line must not be null!"); Main.handleUnhandableProblem(iae); } this.uiFileLines.add(line); }
1
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; User other = (User) obj; if (username == null) { if (other.username != null) return false; } else if (!username.equals(other.username)) ...
6
private boolean r_postlude() { int among_var; int v_1; // repeat, line 56 replab0: while(true) { v_1 = cursor; lab1: do { // (, line 56 ...
8
public String toStringPositionPossible() { // affiche le tableau des positions possible les & represente les cases possibles int cpt = 0; StringBuffer res = new StringBuffer(""); for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) { if (cpt == 8) cpt = 0; cpt++; res.append(Posi...
3
public boolean isActive() { return isActive; }
0
private static void generateSearchMethod(ClassFile cf, Class beanType, BeanProperty[] properties) { MethodInfo mi; { TypeDesc[] params = {TypeDesc.OBJECT, TypeDesc.OBJECT}; mi = cf.addMe...
8
public static boolean canCarry(Actor carries, Actor actor) { if (carries == null || actor == null) return false ; for (Mobile m : actor.aboard().inside()) { if (m instanceof Suspensor) { final Suspensor s = (Suspensor) m ; if (s.passenger == actor) { if (s.followed == carries) re...
6
public static void transferSynonyms(Stella_Object oldobject, Stella_Object newobject) { { List originatedprops = Logic.originatedPropositions(oldobject); { LogicObject synonym = null; Cons iter000 = Logic.getSynonyms(oldobject); for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) { ...
6
@Override public void addUmlDiagramListener( UmlDiagramListener listener ) { if( listener == null ) { throw new IllegalArgumentException( "listener must not be null" ); } umlDiagramListeners.add( listener ); }
1
private ByteBuffer decodeStream(Set<String> filterLimits) throws IOException { ByteBuffer outStream = null; // first try the cache if (decodedStream != null && filterLimits.equals(decodedStreamFilterLimits)) { outStream = (ByteBuffer) decodedStream.get(); } // no lu...
3
public LocalInfo findSlot(int slot) { for (int i = 0; i < count; i++) if (locals[i].getSlot() == slot) return locals[i]; return null; }
2
public void executeSetMethod(Object instance, Method method, Object value) { if(method == null) return; try { method.invoke(instance, value); } catch (IllegalArgumentException e) { System.err.println("<ClassInspect> Failed to execute SET Method <" + method.getName() + ">. Arguments passed to method is wr...
4
public void searchEngineMenu1(DataSource ds) { System.out.println("\n" + "Enter Name or health care number of patient: "); Scanner s1 = new Scanner(System.in); String patient_info = s1.nextLine(); try { ResultSet rs = ds.searchEngineInfo(patient_info); int counter = 0; while (rs.next()) { if (c...
4
@EventHandler(priority = EventPriority.HIGHEST) public void PlayerDamage(EntityDamageEvent e) { if (e.getCause() == DamageCause.FALL) { if (Settings.world || WorldSettings.worlds.contains(e.getEntity().getWorld() .getName())) { if (e.getEntity() instanceof Player) { final Player p = (Player) ...
5
public static HashMap<String, HashMap<String, Integer>> getMap(String filePath) throws Exception { HashMap<String, HashMap<String, Integer>> map = new HashMap<String, HashMap<String,Integer>>(); BufferedReader reader = filePath.toLowerCase().endsWith("gz") ? new BufferedReader(new InputStreamReader( ...
6
private List<ISocketServerConnection> getConnections() { return connections; }
0
public Milk(String brand, Integer price, Integer volume) { this.brand = brand; this.volume = volume; this.price = price; init(); }
0
void remove() { final int oldn = n; n -= k; if (k > n) { k = n; indices = new int[k]; for (int i = 0; i < k; ++i) { indices[i] = i; } } else if (n == k) { if (indices[0] == 0) { for (int i = 0; ...
9
static void orderHand(Hand testHand) { while (true){ for (int x = 1; x < testHand.size();x++){ if (testHand.get(x).getValue() < testHand.get(x-1).getValue()) { Card card1 = testHand.get(x); Card card2 = testHand.get(x-1); testHand.setElementAt(ca...
6
@Override public int span(int row, int column) { switch (column) { case 0: SpanInfo si1 = columnMap.get(0).get(row); return si1.num; case 1: case 2: case 3: case 6: SpanInfo si2 = columnMap.get(2).get(row); return si2.num; default: return 1; } }
5
public int romanToInt(String s) { int value =0; for(int i =0; i< s.length();i++){ System.out.println(s.charAt(i)); value += getValue(s,i); } return value; }
1
public static void enemyMeleeAttackPlayer(Enemy me, Polygon p) { boolean[] hits = {false, false, false, false}; boolean contact = false; if(p == null) { //System.out.println("fuck"); } if(intersectionOf2Shapes(p, CoreClass.mainCharacter.getUpBox())) { hits[0] = true; contact = t...
6
public void getNeighbors(int x, int y){ int reps = culture[x][y].getParameter("HoodSize"); if(reps == 0){return;} int[] info = new int[reps]; for(int d = 0; d <= reps-1; d++){ int tempx = checkAddress("X", culture[x][y].getParameter("NextX")); tempx = mothership.checkLoc("X", tempx); int ...
4
@Override protected void processpacketforward(SimEvent ev) { // search for the host and packets..send to them if (uplinkswitchpktlist != null) { for (Entry<Integer, List<NetworkPacket>> es : uplinkswitchpktlist.entrySet()) { int tosend = es.getKey(); List<NetworkPacket> hspktlist = es.getValue(); i...
8
public static void main(String[] args) { for (int z = 997; z >= 335; z--) { for (int y = (1000 - z - 1); y + z <= 999 && ((1000 - (y + z)) < y); y--) { int x = 1000 - (y + z); if (x*x + y*y == z*z) { System.out.println(x * y * z); } } } }
4
public ArrayList<Account> getAccounts(){ return accountsCatalog; }
0
@Override public List<Environmental> removeSellableProduct(String named, MOB mob) { final Vector<Environmental> V=new Vector<Environmental>(); final Environmental product=removeStock(named,mob); if(product==null) return V; V.addElement(product); if(product instanceof Container) { DoorKey foundKey=nu...
9
@Override public void close() { hide(); }
0
public int compareTo(Object arg0) { DataRow row = (DataRow) arg0; DataHeader header = getTable().getHeader(); DataColumn column; int result = 0; if (header.isDefaultSort()) { for (int i = 0; i < header.getColumnCount(); i++) { column = header.getColumn(i); if (column.isSorted()) { result = he...
7
@Test public void testIterator() { ThriftyList<Integer> list = new ThriftyList<Integer>(); ListIterator<Integer> i = list.listIterator(); try { i.next(); Assert.fail(); } catch (NoSuchElementException e) { } try { i.remove(); Assert.fail(); } catch (IllegalStateEx...
8
protected void generateRowData(RowDetails rowDetails) { List<Column> columns = rowDetails.getTable().getColumns(); List<Object> cellValues = new ArrayList<Object>(); //If column is configured as 'generates own data', then there would //be less number of cell values in the row. W...
8
public boolean contains(int x, int y) { return (x > this.x && x < this.width + this.x && y > this.y && y < this.height + this.y); }
3
public void startIteration() { // has timestep been changed? if (sim.getTimeStep() != savedTimeStep) { setParams(); } v = Math.sin(freqTime) * maxV; freqTime += frequency * 2 * pi * sim.getTimeStep(); frequency = frequency * fmul + fadd; if (frequency ...
6
private boolean shouldBeSwapped(int index1, int index2){ if (index1>=size() || index1<0 || index2>=size() || index2<0) return false; E object1 = theHeap.get(index1); E object2 = theHeap.get(index2); //Causes issues if one of them is null if (object1 == null || object2 == null) return false; //This...
7
public int getSequence_Id() { return sequence_Id; }
0
@Override public void draw(Graphics g) { if (_card.isVisible(_playerID)) { Rectangle bounds = new Rectangle(_bounds); if (bumpUp) { bounds.y += 5; } g.setColor(Color.white); g.fillRect(bounds.x, bounds.y, bounds.width, ...
7
private long readLong_slow (boolean optimizePositive) { // The buffer is guaranteed to have at least 1 byte. position++; int b = niobuffer.get(); long result = b & 0x7F; if ((b & 0x80) != 0) { require(1); position++; b = niobuffer.get(); result |= (b & 0x7F) << 7; if ((b & 0x80) != 0) { req...
9
private void colchete() { // <colchete> ::= “[“ <inteiro> “]” <colchete> | λ if (!acabouListaTokens()) { nextToken(); if (tipoDoToken[1].equals(" [")) { contadorColchete++; if (!acabouListaTokens()) { nextToken(); ...
9
public ArrayList<Object> subarray_as_ArrayList(int start, int end){ if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1)); ArrayList<Object> arrayl = new ArrayList<Object>(end-start+1); for(int i=start; i<=end; i++)array...
2
private boolean isDragOk( final java.io.PrintStream out, final java.awt.dnd.DropTargetDragEvent evt ) { boolean ok = false; // Get data flavors being dragged java.awt.datatransfer.DataFlavor[] flavors = evt.getCurrentDataFlavors(); // See if any of the flavors are a file list int...
7
void checkType(int index, Class<?> value) { if ((value != null) && (value != types.get(index))) { throw new ColumnFormatException(); } }
3
public BitOutputStream(OutputStream out) { if (out == null) throw new NullPointerException("Argument is null"); output = out; currentByte = (byte) 0; numBitsInCurrentByte = 0; }
1
public static void main(String[] args) { Result result; result = JUnitCore.runClasses(BetTest.class); System.out.println("Classe Bet: " + result.getRunCount() + " tests réussis."); for (Failure failure : result.getFailures()) { System.out.println("Classe Bet: " + failure.toString()); } result = J...
8
public com.quickserverlab.quickcached.client.CASValue gets(String key, long timeoutMiliSec) throws TimeoutException, com.quickserverlab.quickcached.client.MemcachedException{ com.quickserverlab.quickcached.client.CASValue value = null; try{ OperationFuture <CASValue<Object>> f = getCache().asyncGets(key); ...
5
@Override public void bfs(String label, Function<Vertex, Vertex> action) { Vertex v = getVertex(label); if (v.wasVisited() == false) { v.setVisited(true); action.apply(v); pQueue.add(v); } JList<Vertex> listOfAdjacent = getEdges(mapOfVerticeIndex.get(v.getLabel())); for (Vertex neighbor : listOfA...
5
protected int loadShader(String filename, int type) { StringBuilder shaderSource = new StringBuilder(); int shaderID = 0; try { BufferedReader reader = new BufferedReader(new FileReader(filename)); String line; while ((line = reader.readLine()) != null) { shaderSource.append(line).append("\n"); ...
2
public void doWork() { Thread thread1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 10; i++) { try { increment(Thread.currentThread().getName()); } catch (InterruptedException ex) { ...
5
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } IntegerSequenceSweep other = (IntegerSequenceSweep) obj;...
9
public Item removeBefore(DNode<Item> nd) { if (nd.prev == head) return null; return remove(nd.prev); }
1
private void check(boolean val) { if (!val) { throw new IllegalArgumentException(); } }
1
void setCodeValues(HTreeNode root){ /* Does nothing if root node is null. */ if (root == null) return; /* Checks if the root is null. */ if (root != null) { /* Checks if the left subtree is null. */ if (root.getLeft() != null) /* Set code of left subtre...
5
public Modules() { this.list = new ArrayList<String> (); String packageName = "jmxattacks"; File file = new File(Modules.class.getProtectionDomain().getCodeSource().getLocation().getPath()); // Test if program is launched from jar file String path = file.getPath(); boolean test = path.matches(".*\\.jar...
9
public static void main(String[] args) throws Exception { HashSet<Integer> set = new HashSet<Integer>(); BufferedReader reader = new BufferedReader(new FileReader(new File( ConfigReader.getChinaDir() + File.separator + "Kathryn_update_NCBI_MostWanted" + File.separator + "otuModel_pValues_otu.txt" )...
6
@Override public Object getValueAt(int rowIndex, int columnIndex) { DeliveryPacket packet = deliveryPackets.get(rowIndex); if (columnIndex == DELIVERY_PACKET_ID) { return packet.getId(); } else if (columnIndex == MEMBER_NAME) { return packet.getMember().getFullName();...
5
@Override public String toString() { return (Platform.isWindows() ? '/' : '-') + mNames[0]; }
1
public Integer isResult(boolean win, boolean lose, boolean cut) { // 0 - win // 1 - lose // 2 - cut Integer num = 2; if ( win == true && lose == false && cut == false ){ num = 0; } else if ( lose == true && win == false && cut == false ){ num = 1; } else { num = 2; } r...
6
public void paint(GC gc, int width, int height) { if (!example.checkAdvancedGraphics()) return; Device device = gc.getDevice(); if (bc[0] == null) { bc[0] = new BallCollection(0, 0, 5, 5, 20, 20, new Color[] { device .getSystemColor(SWT.COLOR_GREEN) }); bc[1] = new BallCollection(50, 300, 10, -5, 50, ...
4
public Object[] getValues() { for (int i = 0; i < editors.length; i++) if (editors[i] != null) values[i] = editors[i].getValue(); return values; }
2
@Override public boolean setObject(String name, JOSObject<?, ?> value) { boolean n = this.getObject(name) == null; srcJOSCompound comp = this; String[] path = name.split("\\\\"); if(path != null && path.length >= 1){ srcJOSCompound ccomp = comp; srcJOSCompound parrent = comp; for(int i = 0 ; i < path....
7
public void supprimerLignes() { int i, j, k; boolean full; for (i = 0; i < hauteur; i++) { full = true; for (j = 0; j < largeur; j++) { if (tab[j][i] == 0) { full = false; } } if (full == true)...
7
private BufferedReader readFile(){ FileReader fr = null; BufferedReader br = null; try { fr = new FileReader(fileName); br = new BufferedReader(fr); }catch(FileNotFoundException ex){ ex.printStackTrace(); } return br; }
1
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); ArrayList<Integer> list = new ArrayList<Integer>(); int size = 0; do { line = in.readLine(); if (line == null...
5
public HandlerList getHandlers() { return handlers; }
0
@Override public void animatedEntityTick(double time) { // tick lifetime, kill if expired lifeTime += time; if(lifeTime >= def.lifeTime){ kill(null); return; } // move to target loc.travelTo(targetLoc, time * def.speed, true); // if target is reached, deal damage and kill self if(loc.hammingDista...
6
public final int getOffsize() { return offsize; }
0
public void setImgPath_PWBtn(Path img, Imagetype type) { switch (type) { case MOUSEFOCUS_KEYFOCUS: // HD simplified this.imgPWBtn_KFocMFoc = handleImage(img, UIResNumbers.PWBTN_KFOCMFOC.getNum()); if (this.imgPWBtn_KFocMFoc == null) { this.imgPWBtn...
6
public void setFieldValue(_Fields field, Object value) { switch (field) { case WHAT: if (value == null) { unsetWhat(); } else { setWhat((Integer)value); } break; case WHY: if (value == null) { unsetWhy(); } else { setWhy((String)value); ...
4
public static String padToMax(String pValue, int padLength) { String text = ""; if (pValue != null) { text = pValue; } while (text.length() < padLength) { text += " "; } return text; }
2
static int f(int cant, int usados, int ant) { if(cant>M) return 0; if(mem[cant][usados][ant]>-1) return mem[cant][usados][ant]; int result=0; if(usados==(1<<N)-1) result++; for(int i=0;i<N;i++) if((cant==0&&i!=0)||(cant>0&&abs(ant-i)==1)) result=(result+f(cant+1,usados|(1<<i),i)%1000000007)%10...
8