text
stringlengths
14
410k
label
int32
0
9
public int compareTo( Casella casella ) { if ( fila < casella.fila ) { return -1; } else if ( fila > casella.fila ) { return 1; } else if ( columna < casella.columna ) { return -1; } else if ( columna > casella.columna ) { return 1; } else { return 0; } }
4
public int compare(Person p1, Person p2){ int result = p2.getName().compareTo(p1.getName()); if(0==result){ return p2.getId() - p1.getId(); //若姓名相同则按id排序 } return result; }
1
public void test_now_nullDateTimeZone() throws Throwable { try { DateTime.now((DateTimeZone) null); fail(); } catch (NullPointerException ex) {} }
1
public MACMethodType getMACMethod() { return macMethod; }
0
private void run(String[] args) throws Exception { if (args == null || args.length < 1 || args.length >2) { System.out.println(); System.out.println(" ##################################################################################"); System.out.println(" # IMDB Tool, Us...
8
public Terrain(Map map) { this.mapRenderer = new OrthogonalTiledMapRenderer((TiledMap) map, 1); camera = new OrthographicCamera(960, 640); camera.translate(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2); camera.update(); this.mapRenderer.setView(camera); rocks = new Array...
7
public static void countUsedHJs(Data data) throws WeFuckedUpException { int usedHJs = 0; for (Subject thisSubject : data.subjects) { for (Semester thisSemester : thisSubject.semesters) { if (thisSemester.usedState != UsedState.none) { usedHJs++; ...
4
protected double getAngleFromVelocity() { double angle = 0.0f; float slope = 0.0f; if(velocityX == 0.0f) { if(velocityX > 0.0f) { angle = Math.PI / 2; } else { angle = -Math.PI / 2; } } else { slope = -veloci...
3
public static Graph randomTree3() { int depth = 10; Graph graph = new Graph(depth * 50, depth * 50); int a = 0; int b = 1; int c = 0; graph.addVertex(new Vertex(c++, 25 + 25 * (depth - 1), 25)); for (int i = 1; i < depth; i++) { for (int j = 0; j <= i; j++) { graph.addVertex(new Vertex(c++, 25 +...
4
public void append(String str) { int newsize = this.size + str.length(); // If there's insufficient capacity, make a new array if (newsize >= this.contents.length) { char[] oldcontents = this.contents; this.contents = new char[computeCapacity(newsize)]; for (int i = 0; i < t...
3
public static String getProfile() { StringBuffer sb = new StringBuffer(); sb.append("OS = " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + "), " + System.getProperty("os.arch") + "\n"); sb.append("Java Version = " + System.getProperty("java.version") ...
1
public void windowDeactivated(WindowEvent e) { System.out.println("Die Anwendung wurde deaktiviert..."); }
0
public void testGetName_berlin() { DateTimeZone berlin = DateTimeZone.forID("Europe/Berlin"); assertEquals("Central European Time", berlin.getName(TEST_TIME_WINTER, Locale.ENGLISH)); assertEquals("Central European Summer Time", berlin.getName(TEST_TIME_SUMMER, Locale.ENGLISH)); if (JDK6) { ...
1
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; } } catch (NumberFormatException e) { ...
5
public void makeMovesFromTree(List<Move> moves) { gameOver = false; int moveCount = 0; for (Move move : moves) { if (move instanceof InitialPosition) { InitialPosition initialPosition = (InitialPosition) move; board = new Board(board.boardSize, initialPosition.handicap); } else if (move instanceof...
6
private TileLayer extractData(Node datanode, TileDataEncoding encoding, TileDataCompression compression, int width, int height, String name, Properties properties, boolean visible, float opacity) throws XPathExpressionException, JTMXParseException { int[] data = new int[width * height]; if (encoding.equals...
4
public void appendLinkedQuestion(LinkedQuestion question) throws Exception { if (question.options.size() == 0) throw new Exception("Question has no options."); for (String target : question.targets) { LinkedList<AbstractQuestion> playersActiveQuestions = activeQuestions.get(target.toLowerCase()); if (pl...
3
static String printGuitarStyles(final Program program) { StringBuilder sb = new StringBuilder(); if (program.isAcoustic()) { sb.append("Acoustic, "); } if (program.isBass()) { sb.append("Bass, "); } if (program.isBlues()) { sb.append("B...
7
private String getNextLine() throws IOException { if (!this.linesSkiped) { for (int i = 0; i < skipLines; i++) { br.readLine(); } this.linesSkiped = true; } String nextLine = br.readLine(); if (nextLine == null) { hasNext = fal...
4
public static void main(String[] args){ Scanner in = new Scanner(System.in); ArrayList<Double> eachTurn = new ArrayList<Double>(); int num_turn = in.nextInt(); double posSum = 0; double negSum = 0; double result = 0.0; double avg = 0.0; double sum = 0.0; System.out.println(Math.round(0.5)); while(nu...
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Cube other = (Cube) obj; if (identifier == null) { if (other.identifier !...
6
public void getEnvironmentData () { ResultSet rs = Main.mysql.getData("SELECT id, name, description FROM `environments`"); try { while (true) { environmentData.put(rs.getInt(1) + ":name", rs.getString(2)); environmentData.put(rs.getInt(1) + ":desc", rs.getStri...
3
public void treeStructureChanged(TreeModelEvent e) { invalidate(); }
0
public void IndexReader(String filename) { // create new file reader FileReader fR; try { // Initialise new file reader and give passed in filename fR = new FileReader(filename); //create and initialise buffered reader BufferedReader bR = new BufferedReader(fR); String indexWord; int coun...
3
public ManifestReaderImpl() { try { URLClassLoader cl = (URLClassLoader) getClass().getClassLoader(); URL url = cl.findResource("META-INF/MANIFEST.MF"); Manifest manifest = new Manifest(url.openStream()); Attributes attrs = manifest.getMainAttributes(); ...
1
public String getPassword() { return password; }
0
RLOGIndividuals() { this.uri = "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/rlog#" + name(); }
0
public static void chooseBiome(Scanner scan, Character player, Random generator) { System.out.println("Select your biome (enter the number): \n"); Biome[] startBiomes = new Biome[5]; for(int i = 0; i < startBiomes.length; i++) { int selection = generator.nextInt(Arrays.biomes.length); startBiomes[i] =...
3
public static int validInput(int choice, int max, int min) throws IOException { int newChoice = choice; BufferedReader r = new BufferedReader (new InputStreamReader(System.in)); boolean valid = false; while (!valid) { if (newChoice >= min && newChoice <= max) { valid = true; } ...
3
public void generateData(int n, TimeComplexity complexity){ super.generateData(n, complexity); if(isHeap) heap.clear(); else bst.clear(); if(complexity.equals(TimeComplexity.AVERAGE) || (!isHeap &&complexity.equals(TimeComplexity.BEST))) data = Helper.permutedInts(n); else if(complexity.equals(Ti...
7
public static ListNode removeNthFromEnd(ListNode head, int n) { ListNode slow = head; ListNode fast = head; int x = n; while (x >= 0 && fast != null) { fast = fast.next; x--; } if (fast == null && x > 0) { return head; } ...
7
private static Method getMethod(int requireMod, int bannedMod, Class<?> clazz, String methodName, Class<?>... params) { for (Method method : clazz.getDeclaredMethods()) { // Limitation: Doesn't handle overloads if ((method.getModifiers() & requireMod) == requireMod && (me...
9
@Override @SuppressWarnings("unchecked") public T next() { if (hasNext()) { if (mIterator == null) { Row row = mList.get(mIndex++); if (row.hasChildren()) { mIterator = new RowIterator<>(row.getChildren()); } return (T) row; } return mIterator.next(); } throw new NoSuchElementExce...
3
public ItemQuery<Item> getItemsInTab(BankTab tab) { final int[] count = getTabCount(); switch (tab) { case ONE: int total = 0; for (Integer i : count) { total += i; } return skip(select(), total); default: int skip = 0; int take = 0; int x = 0; while (x < count.length) {...
4
public List<Files> Search_file(String projectName, String fileName, String format) { String query1 = "SELECT distinct e.projID from project e WHERE e.projName='"+projectName+"'"; EntityManagerFactory emf = Persistence.createEntityManagerFactory("PersistenceUnit"); EntityManager manager = emf.createEntit...
8
public boolean isFPSStatus() { if(frame == null) buildGUI(); return fpsStatus.isSelected(); }
1
public GameSettings GetSettings() { if (this.GetMode() == null) return null; BufferedImage[] Images = new BufferedImage[2]; try { SneekReader Reader = SneekReader.GetReader(new File(FileHelper.GetDataFolder(), this.GetMode() + this.ModeFileSuffix)); String RawData = null; while ((RawData = Reader.read...
7
protected static void copyOrMove(File sourceLocation, File targetLocation, boolean move) throws IOException { String[] children; int i; InputStream in; OutputStream out; byte[] buf; int len; if (sourceLocation.isDirectory()) { if (!targetLocation.exists()) targetLocatio...
7
private void generateHouse(){ int width=(int)Math.round(Math.random()*30)+20; int height=(int)Math.round(Math.random()*30)+20; this.gMap=new Vertex[height][width]; char[][] generatedHouse = new char[height][width]; for(int y=0; y<height; y++){ for(int x=0; x<width; x+...
8
public int openSpot(int x, int y) { if (usrGrid[x][y]) return ansGrid[x][y]; usrGrid[x][y] = true; --numSpacesLeft; theGUI.openSpot(x, y, false); if (ansGrid[x][y] == 9) { openBombs(); if (gameState == 0) gameState = 2; else if (gameState == 1) return 9; else { //System.out.println(...
7
@Override public int getYearsExperience() { return super.getYearsExperience(); }
0
public void setPlayerBust(boolean x){ playerBust=x; }
0
@Override public int compareTo(Point that) { if (this.x == that.x && this.z == that.z) { return 0; } if (this.x == that.x) { if (this.z < that.z) { return -1; } return +1; } if (this.x < that.x) { return -1; } return 1; }
5
public int readRawVarInt() throws IOException { byte tmp = readRawByte(); if (tmp >= 0) { return tmp; } int result = tmp & 0x7f; if ((tmp = readRawByte()) >= 0) { result |= tmp << 7; } else { result |= (tmp & 0x7f) << 7; if ((tmp = readRawByte()) >= 0) { result |= tmp << 14; } else { ...
7
@Override public boolean delete(Hotelier x) {Statement stm = null; try { stm = cnx.createStatement(); int n= stm.executeUpdate("DELETE FROM hotelier WHERE id='"+x.getHotelierId()+"'"); if (n>0) { stm.close(); return true; } } catch (SQLException exp) { } finally { if (stm!=null) try { ...
4
public void insertGenesOnPos(List<Bin> genes, int y) { if(y >= this.bins.size()){ y = this.bins.size(); } this.bins.addAll(y, genes); }
1
public PacienteFacade() { super(Paciente.class); }
0
@Override public String toString() { String result = "Concepto: " + this.getConcepto() + ", Importe: " + this.getImporte() + ", Fecha: " + this.getFecha(); return result; }
0
public SQLConnection(){ try { BufferedReader br = new BufferedReader(new FileReader("C:/windows/journal.txt")); String buffer, result3 = null , result2 = null, result1 = null , result4 = null; int i=0; while ((buffer = br.readLine()) != null) { ...
6
public static void buyTicketsConnect(User usr) { clearConsole(); if (usr == null) { HomePage(); } else { System.out.println ("*******************************"); System.out.println ("**** Tickets Shop ****"); System.out.println ("*******************************"); System.out.println ("Hi "+usr.getUs...
8
@Override public void startTransfer() throws TransferException { Runnable r = new Runnable() { public void run() { try { ByteWriter writer = new ByteArrayWriter(); // 最开始执行了一个i请求 writer.write("SIPP".getBytes()); if (!tryExecuteRequest("i", requestId++, writer, 1)) raiseException(new ...
6
public State[] getNondeterministicStates(Automaton automaton) { LambdaTransitionChecker lc = LambdaCheckerFactory .getLambdaChecker(automaton); ArrayList list = new ArrayList(); /* Get all states in automaton. */ State[] states = automaton.getStates(); /* Check each state for nondeterminism. */ for (int...
7
@Override public boolean equals(Object edge) { if (edge == null) return false; if (edge == this) return true; if (!(edge instanceof Edge))return false; Edge compared = (Edge)edge; if ((compared.getFrom() == this.getFrom() && compared.getTo() == this.getTo()) ||(compared.getTo()...
7
public void test(){ }
0
public static String extract(String line, String key) { if (line == null) { return null; } String code = extractCode(line); int i = code.indexOf(key + assign); if (i == -1) //key not found { return null; } int end = code.indexOf(sep...
5
public TableSwitchInsnNode( final int min, final int max, final LabelNode dflt, final LabelNode[] labels) { super(Opcodes.TABLESWITCH); this.min = min; this.max = max; this.dflt = dflt; this.labels = new ArrayList(); if (labels != null)...
1
public JSONObject toJSONObject(JSONArray names) throws JSONException { if (names == null || names.length() == 0 || this.length() == 0) { return null; } JSONObject jo = new JSONObject(); for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this....
4
public long skip(long size) throws IOException { long skipped = super.skip(size); if (skipped > 0L) { this.monitor.addProgress(skipped); } return skipped; }
1
@Override public void actionPerformed(ActionEvent evt) { if (MainWindow.tripDB.getCheckErrors() + MainWindow.tripDB.getCheckWarnings() > 0) if ( JOptionPane.showConfirmDialog(null, "Die Planung enth\u00E4lt\n " + MainWindow.tripDB.getCheckErrors() + " Fehler und\n " + MainWindow.tri...
5
private void spawnRandom(){ Random random = new Random(); boolean notValid = true; while(notValid){ int location = random.nextInt(ROWS * COLS); int row = location / ROWS; int col = location % COLS; Tile current = board[row][col]; if(current == null){ int value = random.nextInt(10) < 9 ? 16 :...
3
@Override public String execute(SessionRequestContent request) throws ServletLogicException { String page = ConfigurationManager.getProperty("path.page.orders"); String prevPage = (String) request.getSessionAttribute(JSP_PAGE); resaveParamsShowOrder(request); formOrderList(request); ...
2
public static int solution(int[] A) { int len = A.length; if (len <= 0) { return -1; } int leader = A[0]; int counter = 0; /* Find the Leader */ for (int i = 0; i < len; i++) { if (A[i] == leader) { counter++; } else { if (counter == 0) { leader = A[i]; counter++; } else { ...
7
public int getAge() { return Age; }
0
public void run() { try { String line; while (!isInterrupted()) { line = in.readLine(); if (line != null) get(line); else close(); } } catch (IOException exc) { close(); } }
3
private HBox getCustomButtons(String[] buttonLabels, T[] buttonValues, boolean addCancelButton) { if (buttonLabels == null || buttonValues == null) throw new NullPointerException("null argument"); if (buttonLabels.length != buttonValues.length) throw new IllegalArgumentException("different lengt...
5
public void recusarTema(List<Tema> listaTemas, int temaEscolhido) { Tema escolhido = null; if (listaTemas != null) { for (int i = 0; i < listaTemas.size(); i++) { if (i == temaEscolhido - 1) { escolhido = listaTemas.get(i); break; ...
3
public void setOptions(String[] options) throws Exception { String tmpStr; setRawOutput(Utils.getFlag('D', options)); setRandomizeData(!Utils.getFlag('R', options)); tmpStr = Utils.getOption('O', options); if (tmpStr.length() != 0) setOutputFile(new File(tmpStr)); tmpStr = Utils.get...
9
protected static Nodo buscarPrivate(Nodo raiz, int dato) { if(raiz == null) return null; else if(raiz.getDato() == dato) return raiz; else if(raiz.getOpt1() != null) return Arbol.buscarPrivate(raiz.getOpt1(), dato); else if(raiz.getOpt2(...
6
public boolean equals(Object ob) { if ( !(ob instanceof PointerBuffer) ) return false; PointerBuffer that = (PointerBuffer)ob; if ( this.remaining() != that.remaining() ) return false; int p = this.position(); for ( int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j-- ) { long v1 = this.g...
4
public synchronized void receive(File file, boolean resume) { if (!_received) { _received = true; _file = file; if (_type.equals("SEND") && resume) { _progress = file.length(); if (_progress == 0) { doReceive(fi...
4
public static void packMessage(String message, Stream buffer) { // method526 if (message.length() > 80) { message = message.substring(0, 80); } message = message.toLowerCase(); int tmp = -1; for (int i = 0; i < message.length(); i++) { char c = message.charAt(i); int k = 0; for (int j = 0; j < Pla...
9
public void determineBounds() { double value,min,max; // find maximums minimums over all plots m_minX = ((PlotData2D)m_plots.elementAt(0)).m_minX; m_maxX = ((PlotData2D)m_plots.elementAt(0)).m_maxX; m_minY = ((PlotData2D)m_plots.elementAt(0)).m_minY; m_maxY = ((PlotData2D)m_plots.elementAt(...
7
public String getName(){ return name; }
0
static void addTest() { int numBlocks = 100; int[] x = new int[numBlocks]; int[] y = new int[numBlocks]; int[] z = new int[numBlocks]; Set<String> s = new TreeSet<String>(); BlockWorld world = new BlockWorldImpl(); Random r = new Random(1); log.info("Adding blocks"); for (int i = 0; i < numBlocks; ...
7
public int eliminarUsuario(String code){ int condicion = 0; tablaDeUsuarios(); for(int i = 0; i < data.size();i++){ String valorEliminar = data.get(i).getCode(); if(valorEliminar.equals(code)){ ...
3
public static void main(String[] args) throws IOException { //read in data for different kinds of classes BufferedReader citizenReader = new BufferedReader(new FileReader("citizen.txt")); //BufferedReader resourceReader = new BufferedReader(new FileReader("resourcepool.txt")); B...
4
public void toggleVisibility() { if (isShowing()) { pop(); } else { push(defaultMenu); } }
1
@Test /** * Test if the Queue remains consistent after a deletion */ public void testQueueConsistencyOnDeletion() { //Add elements Memory.put("car1", "ferrari"); Memory.put("car2", "toyota"); Memory.put("car3", "honda"); //Get the first version of the queue LinkedList<Node> list1 = (LinkedList<...
5
private static void stringSim(String str) { int totalCount = str.length(); for (int i = 1; i < str.length(); i++) { if (kmpSearch(str, str.substring(i))) { System.out.println(str.substring(i)); totalCount += str.substring(i).length(); } } System.out.println(totalCount); }
2
List<IntKeyValuePair> getKeyValuePairs() { List<IntKeyValuePair> kvpList = new ArrayList<IntKeyValuePair>(); iter = bucket.iterator(); while(iter.hasNext()) { kvpList.add(iter.next()); } return kvpList; }
1
public void create(InfoPaciente infoPaciente) { if (infoPaciente.getPypAdmAgendList() == null) { infoPaciente.setPypAdmAgendList(new ArrayList<PypAdmAgend>()); } EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); ...
7
private synchronized void sendOutboundData() { mOutboundData.flip(); int limit = mOutboundData.limit(); if (limit > 0) { ByteBuffer buffer = ByteBuffer.allocate(limit); buffer.put(mOutboundData); buffer.flip(); mSession.getServer().send(mSession.getChannel(), buffer); } mOutboundData.clear(); }
1
private void asignarEtiquetas() { _columnas.actualizarPregunta("<html>"+_preguntas.get(_posicion).getPregunta()+"</html>"); for (int i = 0; i < _columnaBRevuelta.size(); i++) { _columnas.asignarColumnaLetrasB("<html>"+_columnaBRevuelta.get(i).getRespuesta()+"</html>", i); _column...
4
@SuppressWarnings("deprecation") public void crear(){ if (tFnombre_usuario.getText().isEmpty() || passwordField.getText().isEmpty() || tFemail.getText().isEmpty()){ JOptionPane.showMessageDialog(contentPane,"Algunos campos estan vacios.","Advertencia",JOptionPane.INFORMATION_MESSAGE); }else{ if (chequearCont...
5
public Image getImageFor(FieldType fieldType) { switch (Core.TILESIZE) { case 8 : return images8.get(fieldType.name()); case 16 : return images16.get(fieldType.name()); case 24 : return images24.get(fieldType.name()); ...
4
private void field_cta_nroFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_cta_nroFocusLost if (lab_modo.getText().equals("Baja") || (lab_modo.getText().equals("Modificación"))){ if (!field_cta_nro.getText().equals("")){ if(existeCta(Integer.parseInt(field_cta_nro.ge...
5
public void testDivisionAndAddition() throws NumberFormatException, MalformedParenthesisException, MalformedDecimalException, InvalidOperandException, MalformedTokenException { List<String> basicStrings = new ArrayList<String>(); basicStrings.add("6.0/3.0 + 1"); basicStrings.add("6.0/3 + 1"); basicStrings.ad...
1
@Override public void run() { this.setVisible(true); if (this.GamePanel.getBackground() != this.BackgroundColor) { this.GamePanel.setBackground(this.BackgroundColor); try { Thread.sleep(500L); } catch (InterruptedException e) { new SPopup(new SPopupData(e)); } } while (this.GetG...
8
public static void supprimerReponse(Reponse reponse, Utilisateur utilisateur) { if (!reponse.peutSupprimer(utilisateur)) throw new InterditException("Vous n'avez pas les droits requis pour modifier cette réponse"); if (reponse.getSujet().getReponsePrincipale().equals(reponse)) { ...
4
public String toString() { return "piece" + (this.valid ? "" : "!") + "#" + this.index; }
1
private void stopThreads() { updateEntities.stop(); hitBoxManager.disableCollisions(); for(int i=0; i<invader1.getEntityCount(); i++) {invader1.stopAnimation();} for(int i=0; i<invader2.getEntityCount(); i++) {invader2.stopAnimation();} for(int i=0; i<invader3.getEntityCount(); i++) {invader3.stopAnimat...
3
@Override public Class<?> getColumnClass(int columnIndex) { Class<?> clazz; switch (columnIndex) { case 0: case 3: case 4: clazz = Integer.class; break; case 1: case 2: clazz = String.class; ...
7
public static void tagger(String devDataFile, String countFile, String trainDataFile) throws IOException { HashMap<String, Integer> wordToCount = HMMHelpers.rareWordMarker( "ner_0.counts", trainDataFile); HashMap<String, TreeMap<Double, String>> emissionParams = HMMHelpers .eParamsCalculator(countFile);...
4
public static Cons yieldStructSlotTrees(Stella_Class renamed_Class) { { Cons structslotdefs = Stella.NIL; { StorageSlot slot = null; Cons iter000 = Stella_Class.clStructSlots(renamed_Class).theConsList; Cons collect000 = null; loop000 : for (;!(iter000 == Stella.NIL); iter000 = iter0...
6
public UUID getId() { return this._id; }
0
public static void main(String[] args){ long result = 0; for(int i=1;i<=1000;i++){ result = (result+selfP(i))%(10000000000L); } System.out.println(result); }
1
private WebDriver getLocalDefaultWebDriver() { return registerLocalWebDrivers.getDefaultWebDriver(); }
0
private void collectUniversityChanges(CourseModel courseModel, ArrayList<Change> changes) { // TODO: is there some API to get university descriptions? They do have // numeric codes in facets. for (String u : universities) { String code = makeIdSafe(u); if (courseModel.getUniversity(Source.EDX, code) == n...
5
public static void main(String[] args) throws IOException { Settings settings = new Settings(); try { JCommander JC = new JCommander(settings, args); } catch (Exception E) { System.err.println("\n" + E.getMessage()); Usage.printUsage(); Syste...
4
private static ObjectType parseObjectType(String sig, Cursor c, boolean dontThrow) throws BadBytecode { int i; int begin = c.position; switch (sig.charAt(begin)) { case 'L' : return parseClassType2(sig, c, null); case 'T' : i = c.indexOf(sig, '...
4