method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
4c1057e8-f604-44d1-ad16-4032e36a2850
8
void finishDocument() throws IOException { if (doVectors == false) { return; } doVectors = false; final int numPostings = bytesHash.size(); final BytesRef flushTerm = termsWriter.flushTerm; assert numPostings >= 0; // This is called once, after inverting all occurrences // of a given field in the doc. At this point we flush // our hash into the DocWriter. TermVectorsPostingsArray postings = termVectorsPostingsArray; final TermVectorsWriter tv = termsWriter.writer; final int[] termIDs = sortPostings(); tv.startField(fieldInfo, numPostings, doVectorPositions, doVectorOffsets, hasPayloads); final ByteSliceReader posReader = doVectorPositions ? termsWriter.vectorSliceReaderPos : null; final ByteSliceReader offReader = doVectorOffsets ? termsWriter.vectorSliceReaderOff : null; for(int j=0;j<numPostings;j++) { final int termID = termIDs[j]; final int freq = postings.freqs[termID]; // Get BytesRef termBytePool.setBytesRef(flushTerm, postings.textStarts[termID]); tv.startTerm(flushTerm, freq); if (doVectorPositions || doVectorOffsets) { if (posReader != null) { initReader(posReader, termID, 0); } if (offReader != null) { initReader(offReader, termID, 1); } tv.addProx(freq, posReader, offReader); } tv.finishTerm(); } tv.finishField(); reset(); fieldInfo.setStoreTermVectors(); }
c550ad84-54ba-4053-818b-cc153b2d106c
3
public void run(){ while (!m_isAborted){ boolean currentAction = m_isRising; checkSwitches(); if(currentAction != m_isRising){ double speed = 0; if(m_isRising){ speed = 1; }else{ speed = -0.8; } Robot.ratchetClimber.driveMotor(speed); } this.yield(); } }
05c5fd1e-0422-4f27-bccc-210903e161a4
4
public SQLite(Logger log, String prefix, String name, String location) { super(log, prefix, "[SQLite] "); this.name = name; this.location = location; File folder = new File(this.location); if (this.name.contains("/") || this.name.contains("\\") || this.name.endsWith(".db")) { this.writeError("The database name can not contain: /, \\, or .db", true); } if (!folder.exists()) { folder.mkdir(); } sqlFile = new File(folder.getAbsolutePath() + File.separator + name + ".db"); }
2f9ab185-bc3b-4262-a204-a70abb633ff7
6
public final void makeroom(int nbefore, int nafter) { if (value != null) { LuaString s = value.strvalue(); value = null; length = s.m_length; offset = nbefore; bytes = new byte[nbefore + length + nafter]; System.arraycopy(s.m_bytes, s.m_offset, bytes, offset, length); } else if (offset + length + nafter > bytes.length || offset < nbefore) { int n = nbefore + length + nafter; int m = n < 32 ? 32 : n < length * 2 ? length * 2 : n; realloc(m, nbefore == 0 ? 0 : m - length - nafter); } }
81b2d9a0-c720-4e04-9b62-8e875a5ee977
6
public static XmlGlobalAttribute makeXmlGlobalAttributeInternal(String name, String namespaceName, String namespaceUri, String surfaceForm) { if ((namespaceUri == null) || ((namespaceName == null) || (Stella.stringEqlP(namespaceUri, "") || Stella.stringEqlP(namespaceName, "")))) { throw ((BadArgumentException)(BadArgumentException.newBadArgumentException("namespace-name and namespace must be specified").fillInStackTrace())); } { StringHashTable nsHashTable = ((StringHashTable)(Stella.$XML_GLOBAL_ATTRIBUTE_HASH_TABLE$.lookup(namespaceUri))); XmlAttribute attribute = null; if (nsHashTable == null) { nsHashTable = StringHashTable.newStringHashTable(); Stella.$XML_GLOBAL_ATTRIBUTE_HASH_TABLE$.insertAt(namespaceUri, nsHashTable); } attribute = ((XmlAttribute)(nsHashTable.lookup(name))); if (attribute == null) { { XmlGlobalAttribute self002 = XmlGlobalAttribute.newXmlGlobalAttribute(); self002.name = name; self002.namespaceName = namespaceName; self002.namespaceUri = namespaceUri; self002.surfaceForm = surfaceForm; attribute = self002; } nsHashTable.insertAt(name, attribute); } return (((XmlGlobalAttribute)(attribute))); } }
cba16c02-4889-43fa-b386-5c2f7a1367e4
7
private int findNearestPair(double key, double secondaryKey) { int low = 0; int high = m_CondValues.size(); int middle = 0; while (low < high) { middle = (low + high) / 2; double current = ((Double)m_CondValues.elementAt(middle)).doubleValue(); if (current == key) { double secondary = ((Double)m_Values.elementAt(middle)).doubleValue(); if (secondary == secondaryKey) { return middle; } if (secondary > secondaryKey) { high = middle; } else if (secondary < secondaryKey) { low = middle + 1; } } if (current > key) { high = middle; } else if (current < key) { low = middle + 1; } } return low; }
856b4de3-7a38-44fb-961a-6cf82d7af2e0
6
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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MatriculaMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MatriculaMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MatriculaMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MatriculaMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new MatriculaMain().setVisible(true); } }); }
7b692314-077d-4079-891e-5f09ca0243a3
7
private void calculeRoof(){ boolean matrixAuxiliar[][] = new boolean[matrix_height][matrix_width]; int auxLen; for(int row = 0; row < matrix_height; row++){ for(int col = 0; col < matrix_width; col++){ if(!matrixAuxiliar[row][col] && matrix[row][col]==1){ auxLen = chaseRoof(row, col); for(int i=0;i<auxLen;i++){ matrixAuxiliar[row][col+i]=true; } if(auxLen>0){ tracert.add(new LineTrace(col,row,col+auxLen,row, RunGame.TILE_LEN)); //tracert.add(new LineTrace(this,"drawHorizontalLine",new Object[] {(Object) g,(Object)row,(Object) col,(Object) auxLen})); } }else if(matrix[row][col]==2){ ballsToEat++; } } } }
d7856b76-20d2-4e45-ab41-2486372060bd
1
public int haeVuodentilaukset (int vuosi) throws DAOPoikkeus { TilastointiDAO tilasto = new TilastointiDAO(); HashMap<Integer, Tilastointi> tilaustenlkm = tilasto.haeTilaukset(vuosi); int vuodentilaukset = 0; for (int i = 1; i < 13; i++) { Tilastointi tilauksia = tilaustenlkm.get(i); vuodentilaukset = vuodentilaukset + tilauksia.getTilaustenlkm(); System.out.println(vuodentilaukset); } return vuodentilaukset; }
0d596eed-afa6-4a57-8436-2ac220f79896
1
public static int strdtoi(String decimal) { /* * The basic set up for the next three methods is to basically check the value at a given index * convert that character to its ASCII representation and subtract the appropriate value so that * it matches correctly. When going through again, the sum is multiplied by the base to represent * a larger number. */ final int ASCII_CUTOFF = 48; final int BASE = 10; int sum = 0; for(int i = 0 ; i < decimal.length() ; i++){ sum *= BASE; sum += ((int) decimal.charAt(i)) - ASCII_CUTOFF;//get the ascii value, then subtract the cutoff. } return sum; }
b1dfa637-8a92-474b-9a57-32d1366d358e
3
private void added (DeviceImpl dev) { // call synch'd on devices for (int i = 0; i < listeners.size (); i++) { USBListener listener; listener = (USBListener) listeners.elementAt (i); try { listener.deviceAdded (dev); } catch (Exception e) { if (MacOSX.debug) e.printStackTrace (); } } }
68cae35b-b0cb-4da3-bb09-26ad437dab7e
9
void drawVLine(int argb, boolean tScreened, int x, int y, int z, int h) { // hover, labels only int width = g3d.width; int height = g3d.height; if (h < 0) { y += h; h = -h; } int[] pbuf = g3d.pbuf; int[] zbuf = g3d.zbuf; if (y < 0) { h += y; y = 0; } if (y + h >= height) { h = height - 1 - y; } int offset = x + width * y; if (!tScreened) { for (int i = 0; i <= h; i++) { if (z < zbuf[offset]) { zbuf[offset] = z; pbuf[offset] = argb; } offset += width; } return; } boolean flipflop = ((x ^ y) & 1) != 0; for (int i = 0; i <= h; i++) { if ((flipflop = !flipflop) && z < zbuf[offset]) { zbuf[offset] = z; pbuf[offset] = argb; } offset += width; } }
21c860da-c258-4061-a3c3-fabd78800602
8
public static void main(String[] args) { TargetDataLine line = null; Mixer mixer = null; final AudioBuffer buffer = new AudioBuffer(); PeakListener peakListener = new PeakListener(buffer, 300,500); //buffer.activateLowPassFilter(100); //peakListener.addPeakHandler(new LetterDetector("letterData.txt", 1)); //peakListener.addPeakHandler(new LetterTrainer("letterData.txt")); byte[] rawChunk = new byte[128]; int[] chunk = new int[256]; int frame = 0; int length = 0; String mixerName = ".*Primary Sound Capture.*"; //mixerName = ".*What U Hear.*"; for (Mixer.Info info : AudioSystem.getMixerInfo()) { System.out.println(info.getName()); if (info.getName().matches(mixerName)) { System.out.println("GETTING MIXER"); mixer = AudioSystem.getMixer(info); break; } } for (Line.Info info : mixer.getTargetLineInfo()) { System.out.println(info.toString()); try { line = (TargetDataLine) mixer.getLine(info); System.out.println(line.getFormat().getChannels()); System.out.println(line.getFormat().getSampleSizeInBits()); } catch (LineUnavailableException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { line.open(); } catch (LineUnavailableException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } line.start(); final VisualiserWindow w = new VisualiserWindow(); Visualiser vis = new RadialFFTFrequencyVisualiser(buffer); //Visualiser vis = new StreamVisualiser(buffer,5000); vis.setBackground(Color.BLACK); vis.setForeground(Color.GREEN); w.add(vis); //peakListener.addPeakHandler((SegmentVisualiser)vis); SwingUtilities.invokeLater(new Runnable() { public void run() { // w.setUndecorated(true); // w.setOpacity(0.5f); w.begin(); w.setBounds(0,0,600,200); w.setAlwaysOnTop(true); } }); int ii = 0; while (true){ length = line.read(rawChunk,0,rawChunk.length); frame = 0; for (int i=0; i<length; i+=2) { ByteBuffer bB = ByteBuffer.wrap(new byte[]{rawChunk[i],rawChunk[i+1]}); bB.order(ByteOrder.LITTLE_ENDIAN); // if you want little-endian chunk[frame] = bB.getShort(); frame += 1; } buffer.addSamples(chunk, length/2); //peakListener.analyseBuffer(); //Do all drawing on the Event thread if (ii % 10 == 0) { SwingUtilities.invokeLater(new Runnable() { public void run() { w.repaint(); } }); } ii++; } }
a98252bc-f81e-4af6-a96e-8cd728dd08bf
5
public void addListener() { itemtf[4].addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent arg0) { if (!itemtf[4].getText().equals("")) { String name = logic.showTeacherName(itemtf[4].getText()); itemtf[5].setText(name); } } @Override public void focusGained(FocusEvent arg0) { } }); confirmBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (int i = 0; i < itemtf.length; i++) { String item = itemtf[i].getText(); if (item.equals("") || item.equals("null")) { showFeedBack(Feedback.ITEM_EMPTY); itemInfo = null; break; } itemInfo += item + ";"; } if (itemInfo != null) { Feedback fb = logic.addCommonCourse(itemInfo); JOptionPane.showMessageDialog(frame, fb.getContent()); frame.setVisible(false); frame.dispose(); } } }); cancelBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.setVisible(false); frame.dispose(); } }); }
5cbe29b8-7f19-4f11-8e69-23d6b034ee86
9
private static String convertToneNumber2ToneMark(final String pinyinStr) { String lowerCasePinyinStr = pinyinStr.toLowerCase(); if (lowerCasePinyinStr.matches("[a-z]*[1-5]?")) { final char defautlCharValue = '$'; final int defautlIndexValue = -1; char unmarkedVowel = defautlCharValue; int indexOfUnmarkedVowel = defautlIndexValue; final char charA = 'a'; final char charE = 'e'; final String ouStr = "ou"; final String allUnmarkedVowelStr = "aeiouv"; final String allMarkedVowelStr = "āáăàaēéĕèeīíĭìiōóŏòoūúŭùuǖǘǚǜü"; if (lowerCasePinyinStr.matches("[a-z]*[1-5]")) { int tuneNumber = Character.getNumericValue(lowerCasePinyinStr.charAt(lowerCasePinyinStr.length() - 1)); int indexOfA = lowerCasePinyinStr.indexOf(charA); int indexOfE = lowerCasePinyinStr.indexOf(charE); int ouIndex = lowerCasePinyinStr.indexOf(ouStr); if (-1 != indexOfA) { indexOfUnmarkedVowel = indexOfA; unmarkedVowel = charA; } else if (-1 != indexOfE) { indexOfUnmarkedVowel = indexOfE; unmarkedVowel = charE; } else if (-1 != ouIndex) { indexOfUnmarkedVowel = ouIndex; unmarkedVowel = ouStr.charAt(0); } else { for (int i = lowerCasePinyinStr.length() - 1; i >= 0; i--) { if (String.valueOf(lowerCasePinyinStr.charAt(i)).matches( "[" + allUnmarkedVowelStr + "]")) { indexOfUnmarkedVowel = i; unmarkedVowel = lowerCasePinyinStr.charAt(i); break; } } } if ((defautlCharValue != unmarkedVowel) && (defautlIndexValue != indexOfUnmarkedVowel)) { int rowIndex = allUnmarkedVowelStr.indexOf(unmarkedVowel); int columnIndex = tuneNumber - 1; int vowelLocation = rowIndex * 5 + columnIndex; char markedVowel = allMarkedVowelStr.charAt(vowelLocation); return lowerCasePinyinStr.substring(0, indexOfUnmarkedVowel).replaceAll("v", "ü") + markedVowel + lowerCasePinyinStr.substring(indexOfUnmarkedVowel + 1, lowerCasePinyinStr.length() - 1).replaceAll("v", "ü"); } else // error happens in the procedure of locating vowel { return lowerCasePinyinStr; } } else // input string has no any tune number { // only replace v with ü (umlat) character return lowerCasePinyinStr.replaceAll("v", "ü"); } } else // bad format { return lowerCasePinyinStr; } }
d7564ecc-5847-4452-8049-501cbd2e0b00
1
public boolean release(long id) { if(weaponID == id) { weaponID = NO_WEAPON; return true; } return false; }
f9d0aa2d-2296-443b-9e86-2bf5cc59c2ff
7
private static int getServerCertificateFailures(X509Certificate cert, String realHostName) { int mask = 8; Date time = new Date(System.currentTimeMillis()); if (time.before(cert.getNotBefore())) { mask |= 1; } if (time.after(cert.getNotAfter())) { mask |= 2; } String hostName = cert.getSubjectDN().getName(); int index = hostName.indexOf("CN=") + 3; if (index >= 0) { hostName = hostName.substring(index); if (hostName.indexOf(' ') >= 0) { hostName = hostName.substring(0, hostName.indexOf(' ')); } if (hostName.indexOf(',') >= 0) { hostName = hostName.substring(0, hostName.indexOf(',')); } } if (realHostName != null && !realHostName.equals(hostName)) { mask |= 4; } return mask; }
67a07404-d8d5-4e2a-b57f-d5118db97bc0
0
public String getSeatType() { return this._seatType; }
6e77e7ad-a305-47d3-9d5f-a990bdef3189
7
public void addOutgoingEdge(Edge out) throws MaltChainedException { super.addOutgoingEdge(out); if (out.getTarget() != null) { if (out.getType() == Edge.DEPENDENCY_EDGE && out.getTarget() instanceof DependencyNode) { Node dependent = out.getTarget(); if (compareTo(dependent) > 0) { leftDependents.add((DependencyNode)dependent); } else if (compareTo(dependent) < 0) { rightDependents.add((DependencyNode)dependent); } } else if (out.getType() == Edge.PHRASE_STRUCTURE_EDGE && out.getTarget() instanceof PhraseStructureNode) { children.add((PhraseStructureNode)out.getTarget()); } } }
eba1bdb2-1e2a-4e84-ad79-19ea0a4d2bd2
2
private void locationClicked() { World<T> world = parentFrame.getWorld(); Location loc = display.getCurrentLocation(); if (loc != null && !world.locationClicked(loc)) editLocation(); parentFrame.repaint(); }
7106cb83-5bc3-4ebe-8580-624580431284
6
public static void manageProfessors() { System.out.print("Do you want to add (0) or delete (1) a professor ? "); int res = -1; while (res < 0 || res > 1) { Scanner sc = new Scanner(System.in); res = sc.nextInt(); } switch (res) { case 0: createProfessor(); break; case 1: if (FileRead.profListFiles.isEmpty()) { System.out.println("There is no Professor !"); } else { System.out.println("Which professor do you want delete ?"); displayProfessorList(); Scanner scIndexProf = new Scanner(System.in); Professor prof = null; while (prof == null) { int iProf = scIndexProf.nextInt(); prof = chooseProfessorList(iProf); } FileRead.profListFiles.remove(prof); System.out.println("The professor " + prof + " has been deleted."); } break; default: createProfessor(); break; } }
2750f850-f0aa-4201-bd6b-8ab69d60e18e
9
protected void process(int att, int pos, BitSet C, double[][] D, double[][] minGen) { if (C.cardinality() < minSup) return; if (!addCandidate(minGen, C)) return; if (Main.printResult) { System.out.print(" Closed " + toStringPattern(D) +" ; "); System.out.println("Generator " +toStringPattern(minGen) + " --- " + toStringBitSet(C)); } // for Trie version : if D is canonical, we could free main memory // of its attached generators // (i.e. removing from the trie the associated word) gensCount++; for (int i = attCount-1; i >= att; i--) { if (D[i][0] == D[i][1]) continue; minGenL = clonePattern(minGen); minGenL[i][0] = domains[i].higher(D[i][0]); if (minGenL[i][0] <= minGenL[i][1]) { prime = prime(minGenL,C); process(i, 1, prime, prime(prime), minGenL); } if (!(i == att && pos == 1)) { minGenR = clonePattern(minGen); minGenR[i][1] = domains[i].lower(D[i][1]); if (minGenR[i][0] <= minGenR[i][1]) { prime = prime(minGenR,C); process(i, 0, prime, prime(prime), minGenR); } } } }
02d24513-c922-40c8-841a-2b20c3471c2e
3
public void changeSelection() { drawer.clearSelected(); Configuration[] configs; configs = configurations.getConfigurations(); boolean foundFocused = false; for (int i = 0; i < configs.length; i++) { Configuration current = configs[i]; foundFocused = setFocusIfNeeded(current, foundFocused); if (current instanceof TMConfiguration){ //then blocks become relevant TMState cur = (TMState) current.getCurrentState(); while (((TuringMachine) cur.getAutomaton()).getParent() != null) cur = ((TuringMachine) cur.getAutomaton()).getParent(); drawer.addSelected(cur); } // Stack blocks = (Stack) configs[i].getBlockStack().clone(); // if (!blocks.empty()) { // State parent = (State) configs[i].getBlockStack().peek(); // int start = blocks.lastIndexOf(parent); // while (start >= 0) { // parent = (State) blocks.get(start); // drawer.addSelected(parent); // start--; // } // } drawer.addSelected(configs[i].getCurrentState()); } component.repaint(); }
89a7a253-cdef-4cdc-858e-ff3f7f712e53
4
@Test public final void testRemoveSeveral() { for (int j = 1; j <= 10; j++) { for (int i = 1; i <= 1000; i++) { s.add(i); } } // remove 10 elements 10 times for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { s.remove(j * 10); } } assertEquals("Wrong size():", 990, s.size()); }
766648bd-93ce-432e-ab93-c78c8cc8ef80
5
public static void main(final String[] args) { // int n = 200; // double pi = f(n, 6) + f(n, 75) + f(n, 89) + f(n, 226); // System.out.println(f(n, 6) + f(n, 75) + f(n, 89) + f(n, 226)); // pi int max = 1; int n = 10000; for(int a = 0; a < max; a++) { for(int b = 0; b < max; b++) { for(int c = 0; c < max; c++) { for(int d = 0; d < max; c++) { if ((f(n, a) + f(n, b) + f(n, c) + f(n, d) - 3.141) == 0) { System.out.println(f(n, a) + f(n, b) + f(n, c) + f(n, d)); System.out.println(a); System.out.println(b); System.out.println(c); System.out.println(d); } } } } } // int a = 1000; // int b = 1000; // int c = 1000; // int d = 15000; // System.out.println(f(n, a) + f(n, b) + f(n, c) + f(n, d)); uptime(); }
7233b0f4-ab8b-4f0b-b474-2b88ff2d0d9e
1
public byte evaluate_byte(Object[] dl) throws Throwable { if (Debug.enabled) Debug.println("Wrong evaluateXXXX() method called,"+ " check value of getType()."); return 0; };
c276e7ec-6a0f-4331-8873-e4c19651e873
8
public String processArgs(String[] args) throws Exception { int i = 0, j; String arg; char flag; boolean vflag = false; String outputfile = ""; String readFromFile = null; try { while (i < args.length && args[i].startsWith("-")) { arg = args[i++]; if (arg.equals("-verbose")) { System.out.println("verbose mode on"); vflag = true; } if (args[0].equals("-f")) { logger.info("reading VIVO URI's from file " + args[1]); readFromFile = args[1]; } else if (arg.equals("-output")) { if (i < args.length) outputfile = args[i++]; else System.err.println("-output requires a filename"); if (vflag) System.out.println("output file = " + outputfile); } //if (args[2].equals("-u")) { // logger.info("reading HRIS person URI's from file " + args[3]); // readFromFile = args[3]; //} } } catch (Exception e) { logger.error("exception reading args! Error" + e); throw e; } finally { //logger.debug("created new model..."); } return readFromFile; }
f22f32ca-7015-446f-86d8-113714edcac3
7
public List<Argument> getArguments(boolean ordered) { List<Argument> results = new ArrayList<Argument>(); Set<Resource> classes = JenaUtil.getAllSuperClasses(this); classes.add(this); for(Resource cls : classes) { StmtIterator it = cls.listProperties(SPIN.constraint); while(it.hasNext()) { Statement s = it.nextStatement(); if(s.getObject().isResource() && JenaUtil.hasIndirectType(s.getResource(), (Resource)SPL.Argument.inModel(s.getModel()))) { results.add((Argument)s.getResource().as(Argument.class)); } } } if(ordered) { Collections.sort(results, new Comparator<Argument>() { public int compare(Argument o1, Argument o2) { Property p1 = o1.getPredicate(); Property p2 = o2.getPredicate(); if(p1 != null && p2 != null) { return p1.getLocalName().compareTo(p2.getLocalName()); } else { return 0; } } }); } return results; }
69060a6c-a74b-4252-87ef-73e1a0b4d0e0
9
public String getColumnName( int column) { String nom=""; switch (column) { case 0: nom="ID"; break; case 1: nom="Descripcion"; break; case 2: nom="Color"; break; case 3: nom="Peso"; break; case 4: nom="Consumo"; break; case 5: nom="Costo"; break; case 6: nom="Carga"; break; case 7: nom="Resolucion"; break; case 8: nom="Sintonizador TDT"; default: break; } return nom; }
be9ec134-df0a-4b24-ab7a-40326a5ed7f7
4
public int getYSquares() { boolean test = false; if (test || m_test) { System.out.println("GameBoardGraphics :: getYSquares() BEGIN"); } if (test || m_test) { System.out.println("GameBoardGraphics :: getYSquares() END"); } return Y_SQUARES; }
eafb41ad-1d8d-4a62-9b1c-4ac8a55a6e15
6
public void remove(Object removed, int type){ Drop drop = null; if(type == 1){ for(int n = 0; n < managers.size(); n++){ if(managers.get(n).getDrop().getPath().equals((String) removed)){ drop = managers.get(n).getDrop(); ports.remove((Integer) Integer.parseInt(managers.get(n).getDrop().getID())); managers.remove(n); threads.get(n).interrupt(); threads.remove(n); } } } else if(type == 2){ for(int n = 0; n < managers.size(); n++){ if(managers.get(n).getDrop().getDLTO().equals((String) removed)){ drop = managers.get(n).getDrop(); managers.remove(n); threads.get(n).interrupt(); threads.remove(n); } } } Main.status.getPool().removeFile(drop); }
722e36c6-1e48-4336-bffa-0c2f41a21d24
1
public void paint(Graphics g) { g.setColor(color); for(int i = 0; i < currentSquares; i++) { g.fillRect(i * (squareWidth + padding), 0, squareWidth, height); } }
3b098bb5-9ca0-4dbf-a493-571114184853
5
@Test public void testClearEdges() { final DCRGraph graph = new DCRGraph(); final OrdinaryCluster parent = new OrdinaryCluster(graph, 1.0); parent.setGroundTruthIndex(0); final ClusterAdjacencyList list = new ClusterAdjacencyList(parent); final Node[] nodes = { new Node(), new Node(), new Node(), new Node(), new Node() }; for (final Node node : nodes) { list.addNode(node); } final int[] edges = { 0, 1,// 1, 2,// 1, 3,// 1, 4,// 2, 3,// 3, 4,// }; for (int e = 0; e < edges.length - 1; e += 2) { Assert.assertTrue(edges[e] < nodes.length && edges[e + 1] < nodes.length); list.addEdge(Edge.createEdge(new Pair<Node>(nodes[edges[e]], nodes[edges[e + 1]]))); Assert.assertEquals((e + 2) / 2, list.getEdgeCount()); } list.clearEdges(); Assert.assertEquals(0, list.getEdgeCount()); for (int e = 0; e < edges.length - 1; e += 2) { Assert.assertTrue(edges[e] < nodes.length && edges[e + 1] < nodes.length); list.addEdge(Edge.createEdge(new Pair<Node>(nodes[edges[e]], nodes[edges[e + 1]]))); Assert.assertEquals((e + 2) / 2, list.getEdgeCount()); } }
6af833a1-6bdc-46d1-b3eb-7970172a688d
7
private Map<String, Set<JarFile>> buildMapOfExportsToJars() { String classPath = System.getProperty("java.class.path"); String pathSeparator = System.getProperty("path.separator"); Map<String, Set<JarFile>> exportsToJars = new HashMap<String, Set<JarFile>>(); String[] classPaths = classPath.split(pathSeparator); for (String path: classPaths) { if (path.endsWith(".jar")) { try { JarFile jarFile = new JarFile(path); Manifest manifest = jarFile.getManifest(); if (manifest != null) { OSGiManifestUtil manifestUtil = new OSGiManifestUtil(manifest); if (manifestUtil.isBundle()) { Set<String> exports = manifestUtil.getExports(); for (String export: exports) { Set<JarFile> jars = exportsToJars.get(export); if (jars == null) { jars = new LinkedHashSet<JarFile>(); // keep the order the same as on the classpath exportsToJars.put(export, jars); } jars.add(jarFile); } } } } catch (IOException e) { logger.warn(String.format("could not read jar file: %s", path), e); } } } return exportsToJars; }
3ca8bbf9-cad2-4439-ac04-64e12ededf0e
9
public void testResizeWithPurgeAndGetOfNonExistingElement() { Table<Integer> table=new Table<>(3, 10, 0); for(int i=1; i <= 50; i++) addAndGet(table, i); System.out.println("table: " + table); assertIndices(table, 0, 0, 50); assert table.size() == 50 && table.getNumMissing() == 0; // now remove 15 messages for(long i=1; i <= 15; i++) { Integer num=table.remove(false); assert num != null && num == i; } System.out.println("table after removal of seqno 15: " + table); assertIndices(table, 0, 15, 50); assert table.size() == 35 && table.getNumMissing() == 0; table.purge(15); System.out.println("now triggering a resize() by addition of seqno=55"); addAndGet(table, 55); assertIndices(table, 15, 15, 55); assert table.size() == 36 && table.getNumMissing() == 4; // now we have elements 40-49 in row 1 and 55 in row 2: List<Integer> list=new ArrayList<>(20); for(int i=16; i < 50; i++) list.add(i); list.add(55); for(long i=table.getOffset(); i < table.capacity() + table.getOffset(); i++) { Integer num=table._get(i); if(num != null) { System.out.println("num=" + num); list.remove(num); } } System.out.println("table:\n" + table.dump()); assert list.isEmpty() : " list: " + Util.print(list); }
9f4ff40d-1b6a-49b9-8873-c6d18686c8e1
2
public static long getVideoDurationInSeconds(File video) { IContainer container = null; try { container = IContainer.make(); if (container.open(video.getAbsolutePath(), IContainer.Type.READ, null) < 0) { throw new IllegalArgumentException("Could not open file: " + video.toString()); } return container.getDuration() / 1000000; // Seconds } finally { if (container != null) { container.close(); } } }
ae429410-8762-4749-8567-86b972ad0f6d
8
public static long toAmount(String price) { if(price.charAt(0) == '$') price = price.substring(1); index = price.indexOf("."); if(index == -1) price = price + "00"; else if(index == price.length()-1) price = price.substring(0,price.length()-1) + "00"; else if(index == 0 && price.length() == 2) price = price.substring(1) + "0"; else if(index == 0 && price.length() == 3) price = price.substring(1); else if(price.substring(index).length() == 2) price = price.substring(0,price.indexOf(".")) + price.substring(price.indexOf(".")+1) + "0"; else price = price.substring(0,price.indexOf(".")) + price.substring(price.indexOf(".")+1); return Long.parseLong(price); }
85af879a-d3cd-4c27-8626-aae5d12e6800
7
@EventHandler public void WitherResistance(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getZombieConfig().getDouble("Wither.Resistance.DodgeChance") / 100; final double ChanceOfHappening = random.nextDouble(); if (ChanceOfHappening >= randomChance) { dodged = true; } if (damager instanceof WitherSkull) { WitherSkull a = (WitherSkull) event.getDamager(); LivingEntity shooter = a.getShooter(); if (plugin.getWitherConfig().getBoolean("Wither.Resistance.Enabled", true) && shooter instanceof Wither && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) { Player player = (Player) e; player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, plugin.getWitherConfig().getInt("Wither.Resistance.Time"), plugin.getWitherConfig().getInt("Wither.Resitance.Power"))); } } }
6cfcddf9-c903-4eeb-af9c-99f0df6c8b93
6
public void addTab(final String name) { int i; int matchCount = 0;// how many tabs have that name String title; for (i = 0; i < this.tabbedPane.getTabCount(); i++) { title = this.tabbedPane.getTitleAt(i); if (title.equals(name)) { matchCount++;// exactly the same name } else if (title.matches(name + "\\(\\d\\)")) { matchCount++;// 1 digit numbers } else if (title.matches(name + "\\(\\d\\d\\)")) { matchCount++;// two digit numbers } else if (title.matches(name + "\\(\\d\\d\\d\\)")) { matchCount++;// three digit numbers } } if (matchCount <= 0) { this.tabbedPane.addTab(name, ScrollPane.getInstance()); } else { this.tabbedPane.addTab(name + "(" + matchCount + ")", ScrollPane.getInstance()); } }
8cb2fd8e-d68b-4c5e-8c98-7701a7b0879c
0
public Double[][] getFVal() { return fVal; }
dae8a9f2-dd78-4115-bb6c-6931b39b347c
3
public int maxArea2(int[] height, int start, int end, int max) { while (end > start) { int thisArea = Math.min(height[start], height[end]) * (end - start); if (thisArea > max) max = thisArea; if (height[start] > height[end]) end--; else start++; } return max; }
a1e123d1-f3d2-40fd-b1c0-0071c05b0f74
3
public int[] vote(int length) {//Randomly select how many answers we're going to pick, since multiplechoice can have multiple answers //then randomly select which indexes we think are the right answers and return this array //part of the code is similar to the generateQuestions method in SimulationDriver for multiplechoice Random rand = new Random(); //makes sure we can pick only one answer for singlechoice, and correctly ranges for multiplechoice int tmp = rand.nextInt(length - 1) + 1; int[] answersIndex = new int[tmp]; ArrayList<Integer> alreadyAdded = new ArrayList<Integer>(tmp); int ansInd = -1; for(int i = 0; i < tmp; i++) answersIndex[i] = -1; for(int i = 0; i < tmp; i++) { do { ansInd = rand.nextInt(length); } while(alreadyAdded.contains(ansInd)); alreadyAdded.add(ansInd); answersIndex[i] = ansInd; } return answersIndex; }//this entire method would be different if it were to be implemented in a webserver/app
c70ef5a3-3539-4de9-bcf6-a63173eeda73
4
public static boolean implementsSerializable(final ClassEditor ce) { if (ce.type().equals(Type.OBJECT)) { // Stop the recursion! return (false); } final Type serializable = Type.getType("Ljava/io/Serializable;"); final Type[] interfaces = ce.interfaces(); for (int i = 0; i < interfaces.length; i++) { if (interfaces[i].equals(serializable)) { return (true); } } // Does its superclass implement Serializable? final Type superclass = ce.superclass(); final ClassInfoLoader loader = ce.classInfo().loader(); try { final ClassInfo ci = loader.loadClass(superclass.className()); final ClassEditor sce = new ClassEditor(ce.context(), ci); return (SerialVersionUID.implementsSerializable(sce)); } catch (final ClassNotFoundException ex) { System.err.println("Could not load class: " + superclass + ", superclass of " + ce.name()); System.exit(1); } return (false); }
f7225ce3-a107-4a69-97f4-3759e89d75d5
9
public Debate getSpecificDebate(String id) { Element root = document.getRootElement(); Element debateElement; Debate debate = null; Element debateE = (Element) document .selectSingleNode("//debate[@id='" + id + "']"); if (debateE != null) { String topic = debateE.element("topic").getText() , description = debateE.element("description").getText() , maxTurns = debateE.element("maxTurns").getText() , turnDuration = debateE.element("turnDuration").getText() , maxTime = debateE.element("maxTime").getText() , timeLeft = debateE.element("timeLeft").getText() , materials = debateE.element("materials").getText() , status = debateE.element("status").getText() , isDelete = debateE.element("isDelete").getText() , memberA = debateE.element("memberA").getText() , memberB = debateE.element("memberB").getText() , winner = debateE.element("winner").getText() , teamALeader = debateE.element("teamALeader").getText() , teamBLeader = debateE.element("teamBLeader").getText() , teamARep = debateE.element("teamARep").getText() , teamBRep = debateE.element("teamBRep").getText() , currentTurnTeam = debateE.element("currentTurnTeam").getText() , acceptPositionTeam = debateE.element("acceptPositionTeam").getText(); String[] teamA = memberA.split(","); String[] teamB = memberB.split(","); String[][] team; if (teamA.length > teamB.length) { team = new String[2][teamA.length]; } else { team = new String[2][teamB.length]; } for (int j = 0; j < teamA.length; j++) { team[0][j] = teamA[j]; } for (int j = 0; j < teamB.length; j++) { team[1][j] = teamB[j]; } int winnerValue = 0, maxTurnsValue = 0; if (winner != null) { winnerValue = Integer.parseInt(winner); } if (maxTurns != null) { maxTurnsValue = Integer.parseInt(maxTurns); } boolean isDeleteValue = false; if (isDelete != null) { if (isDelete.equals("true")) { isDeleteValue = true; } } int turnLeft = 0; if (turnDuration != null) { turnLeft = Integer.parseInt(turnDuration); } String[] teamLeader = {teamALeader, teamBLeader} , teamRep = {teamARep, teamBRep}; debate = new Debate(id, maxTurnsValue, topic, description, team, winnerValue , maxTime, materials, teamLeader, teamRep, isDeleteValue, currentTurnTeam , status, acceptPositionTeam, turnLeft, timeLeft); } return debate; }
015fdb28-bd62-41bf-ac3f-4a55ce95b05c
3
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().write("hi"); HashMap<String,Integer> accessList=new HashMap<String,Integer>(); System.out.println("test called"); try { URL textURL = getServletContext().getResource("/AccessList.xml"); InputStream is = textURL.openStream() ; DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(is); //optional, but recommended //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work doc.getDocumentElement().normalize(); System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nList = doc.getElementsByTagName("page"); System.out.println("----------------------------"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); System.out.println("\nCurrent Element :" + nNode.getNodeName()); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; accessList.put(eElement.getElementsByTagName("url").item(0).getTextContent(),Integer.parseInt(eElement.getElementsByTagName("level").item(0).getTextContent())); //System.out.println("URL : " + eElement.getElementsByTagName("url").item(0).getTextContent()); //System.out.println("Level : " + eElement.getElementsByTagName("level").item(0).getTextContent()); } System.out.println(accessList.get(request.getParameter("url"))); } } catch (Exception e) { e.printStackTrace(); } }
355d0e02-4b36-45fa-af7b-a2cd49d84f4c
5
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if(qName.equals("levelWidth")) { inLevelWidth = true; } if(qName.equals("levelHeight")) { inLevelHeight = true; } if(qName.equals("x")) { inX = true; } if(qName.equals("y")) { inY = true; } if(qName.equals("color")) { inColor = true; } }
c4424d58-3347-43c8-86ed-7ac855c9ddda
3
public ArrayList<Car> findCarsById(int id) { ArrayList<Car> carList = new ArrayList<Car>(); for (int i = 0; i < 4; i++) { for (int j = 0; j < Cars.get(i).size(); j++) { if (Cars.get(i).get(j).getId() == id) carList.add(Cars.get(i).get(j)); } } return carList; }
2b35af5a-29e3-45fc-bdba-54a32742a81f
2
public void update() { //if a global state exists, call its execute method, else do nothing if(pGlobalState != null) pGlobalState.execute(pOwner); //same for the current state if (pCurrentState != null) pCurrentState.execute(pOwner); }
21074ec7-4c15-40fb-8971-e8977186dac7
1
@Test public void filtersByAuthorLastnameWorks() { citations.add(c1); filter.addFieldFilter("author", "Kekkonen"); List<Citation> filtered = filter.getFilteredList(); assertTrue(filtered.contains(c1) && filtered.size() == 1); }
83168f81-d41b-40c2-b8b8-cdd72acada8b
2
private void writeLong( long l ) { if ( l <= Integer.MAX_VALUE && l >= Integer.MIN_VALUE ){ writeInt((int)l); }else{ writeBytes(Long.toString( l ).getBytes()); } }
8b5a0dcd-2600-4d96-890d-a8250593d3df
8
static void setComboBox(JComboBox cb, int k) { ActionListener[] al = cb.getActionListeners(); if (al != null) { for (ActionListener i : al) cb.removeActionListener(i); } ItemListener[] il = cb.getItemListeners(); if (il != null) { for (ItemListener i : il) cb.removeItemListener(i); } cb.setSelectedIndex(k); if (al != null) { for (ActionListener i : al) cb.addActionListener(i); } if (il != null) { for (ItemListener i : il) cb.addItemListener(i); } }
d6e98351-67e6-40f9-830f-8fcd78c4409f
0
private void setUpInfoPanel() { infoPanel = new JPanel(); cEquals = new JLabel("C = "); cText = new JTextField(27); cText.setEditable(false); infoPanel.add(cEquals); infoPanel.add(cText); add(infoPanel, BorderLayout.SOUTH); }
9ee205b1-8ec7-40ab-8f94-1f9a2089ad91
5
private static void printHelper(RBNode n, int indent) { if (n == null) { System.out.print("<empty tree>"); return; } if (n.right != null) { printHelper(n.right, indent + INDENT_STEP); } for (int i = 0; i < indent; i++) System.out.print(" "); if (n.color == NodeColor.BLACK) System.out.println(n.toString()); else System.out.println("<" + n.toString() + ">"); if (n.left != null) { printHelper(n.left, indent + INDENT_STEP); } }
b076b348-4b2e-42a3-bf5d-79fdd1e45b38
2
public GoGame() { super("Go"); // name of the top of the board groups = new ArrayList<Group>(); board = new ImageIcon("go.png");// puts the board as an image icon whitePass = false;// boolean which checks to see if white has passed blackPass = false;// Checks to see if black has passed JPanel panel = new JPanel();// new jpanel and setting the size and putting it to the jframe panel.setPreferredSize(new Dimension(720, 720)); add(panel, BorderLayout.NORTH); image = new BufferedImage(720, 720, BufferedImage.TYPE_INT_RGB); addMouseListener(this);// sets a mouselistener to the jframe addWindowListener(this); setSize(720, 720); // sets the size of jframe setVisible(true);// shows frame setResizable(false);// makes it not resizable setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// exits the program when the x is clicked setIgnoreRepaint(true); // doesnt repaint the board addMouseMotionListener(this); // adds mouse motion listener to the screen territories = new ArrayList<Territory>(); ko = new ArrayList<int[][]>(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); // gets screen size and put // the frame in the middle setLocation((screen.width - 720) / 2, (screen.height - 720) / 2); squares = new Square[9][9]; // double array of a 9 by 9 squares blackScore = 0;// Score of black whiteScore = 6.5;// Score of white, white gets s 6.5 handicap because black goes first // goes through and actually places the squares on the board and sets them to null for (int i = 0; i < squares.length; i++) { for (int j = 0; j < squares[i].length; j++) { squares[i][j] = new Square(i, j, null); } } }
9d3c24ee-a65a-4351-8220-50c741812dae
1
public byte GetByte(int distance) { int pos = _pos - distance - 1; if (pos < 0) pos += _windowSize; return _buffer[pos]; }
a6f419cd-a067-4bd3-bc10-764fa15fc70f
8
public static void printQueryIteratorSolutionOrnately(QueryIterator self, QuerySolution solution, int solutionnumber, PrintableStringWriter stream) { if (solutionnumber == Stella.NULL_INTEGER) { solutionnumber = 0; { QuerySolution solution000 = null; DictionaryIterator iter000 = ((DictionaryIterator)(self.solutions.allocateIterator())); while (iter000.nextP()) { solution000 = ((QuerySolution)(iter000.value)); if (!Stella_Object.equalP(solution000.bindings, solution000)) { solutionnumber = solutionnumber + 1; } } } } { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get(); try { Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true); stream.print(" #" + solutionnumber + ": "); { Stella_Object value = null; Vector vector000 = solution.bindings; int index000 = 0; int length000 = vector000.length(); PatternVariable variable = null; Vector vector001 = self.externalVariables; int index001 = 0; int length001 = vector001.length(); int vi = Stella.NULL_INTEGER; int iter001 = 0; for (;(index000 < length000) && (index001 < length001); index000 = index000 + 1, index001 = index001 + 1, iter001 = iter001 + 1) { value = (vector000.theArray)[index000]; variable = ((PatternVariable)((vector001.theArray)[index001])); vi = iter001; stream.print((((vi == 0) ? "" : ", ")) + variable.skolemName + "=" + value); } } if ((self.partialMatchStrategy != null) && (solution.matchScore != Stella.NULL_FLOAT)) { stream.print(" " + solution.matchScore); } } finally { Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000); } } }
5a0d5692-a05e-4a37-87cf-ee5b67520380
7
private static final void method2623(AbstractToolkit var_ha, int[] is, int i, int i_19_, int i_20_, int[] is_21_, int[] is_22_) { int[] is_23_ = new int[4]; var_ha.getDimensions(is_23_); if (is_21_ != null && is_23_[3] - is_23_[1] != is_21_.length) throw new IllegalStateException(); method2624(); method2622(is, i, i_19_); method2618(is_23_[1]); while (method2627(is_23_[3])) { int i_24_ = anInt4106; int i_25_ = anInt4108; int i_26_ = anInt4103; if (is_21_ != null) { int i_27_ = i_26_ - is_23_[1]; if (i_24_ < is_21_[i_27_] + is_23_[0]) i_24_ = is_21_[i_27_] + is_23_[0]; if (i_25_ > is_21_[i_27_] + is_22_[i_27_] + is_23_[0]) i_25_ = is_21_[i_27_] + is_22_[i_27_] + is_23_[0]; if (i_25_ - i_24_ <= 0) continue; } var_ha.drawHorizontalLine(i_24_, i_26_, i_25_ - i_24_, i_20_, 1); } }
341d5a09-0d59-4d5a-9433-8213f9e48628
7
public void addCity(City cit) { int id; Connection con = null; PreparedStatement pstmt = null; Statement idstmt = null; try { DBconnection dbCon = new DBconnection(); Class.forName(dbCon.getJDBC_DRIVER()); con = DriverManager.getConnection(dbCon.getDATABASE_URL(), dbCon.getDB_USERNAME(), dbCon.getDB_PASSWORD()); con.setAutoCommit(false); idstmt = con.createStatement(); ResultSet rs = idstmt.executeQuery("Select ifnull(max(cty_id),0)+1 From city"); rs.next(); id = rs.getInt(1); pstmt = con.prepareStatement("Insert Into city Values(?,?,?,?)"); pstmt.setInt(1, id); pstmt.setString(2, cit.getShortName()); pstmt.setString(3, cit.getName()); pstmt.setInt(4, cit.getprovince()); pstmt.execute(); con.commit(); } catch (SQLException | ClassNotFoundException ex) { System.err.println("Caught Exception: " + ex.getMessage()); if (con != null) { try { con.rollback(); } catch (SQLException ex2) { System.err.println("Caught Exception: " + ex2.getMessage()); } } } finally { try { if (idstmt != null) { idstmt.close(); } if (pstmt != null) { pstmt.close(); } if (con != null) { con.close(); } } catch (SQLException ex) { System.err.println("Caught Exception: " + ex.getMessage()); } } }
eb4742b9-c09f-4e52-a689-7cb14089f1bf
9
public boolean renderBlockFenceGate(BlockFenceGate par1BlockFenceGate, int par2, int par3, int par4) { boolean var5 = true; int var6 = this.blockAccess.getBlockMetadata(par2, par3, par4); boolean var7 = BlockFenceGate.isFenceGateOpen(var6); int var8 = BlockDirectional.getDirection(var6); float var9; float var10; float var11; float var12; if (var8 != 3 && var8 != 1) { var9 = 0.0F; var11 = 0.125F; var10 = 0.4375F; var12 = 0.5625F; par1BlockFenceGate.setBlockBounds(var9, 0.3125F, var10, var11, 1.0F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); var9 = 0.875F; var11 = 1.0F; par1BlockFenceGate.setBlockBounds(var9, 0.3125F, var10, var11, 1.0F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); } else { var9 = 0.4375F; var11 = 0.5625F; var10 = 0.0F; var12 = 0.125F; par1BlockFenceGate.setBlockBounds(var9, 0.3125F, var10, var11, 1.0F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); var10 = 0.875F; var12 = 1.0F; par1BlockFenceGate.setBlockBounds(var9, 0.3125F, var10, var11, 1.0F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); } if (!var7) { if (var8 != 3 && var8 != 1) { var9 = 0.375F; var11 = 0.5F; var10 = 0.4375F; var12 = 0.5625F; par1BlockFenceGate.setBlockBounds(var9, 0.375F, var10, var11, 0.9375F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); var9 = 0.5F; var11 = 0.625F; par1BlockFenceGate.setBlockBounds(var9, 0.375F, var10, var11, 0.9375F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); var9 = 0.625F; var11 = 0.875F; par1BlockFenceGate.setBlockBounds(var9, 0.375F, var10, var11, 0.5625F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(var9, 0.75F, var10, var11, 0.9375F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); var9 = 0.125F; var11 = 0.375F; par1BlockFenceGate.setBlockBounds(var9, 0.375F, var10, var11, 0.5625F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(var9, 0.75F, var10, var11, 0.9375F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); } else { var9 = 0.4375F; var11 = 0.5625F; var10 = 0.375F; var12 = 0.5F; par1BlockFenceGate.setBlockBounds(var9, 0.375F, var10, var11, 0.9375F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); var10 = 0.5F; var12 = 0.625F; par1BlockFenceGate.setBlockBounds(var9, 0.375F, var10, var11, 0.9375F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); var10 = 0.625F; var12 = 0.875F; par1BlockFenceGate.setBlockBounds(var9, 0.375F, var10, var11, 0.5625F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(var9, 0.75F, var10, var11, 0.9375F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); var10 = 0.125F; var12 = 0.375F; par1BlockFenceGate.setBlockBounds(var9, 0.375F, var10, var11, 0.5625F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(var9, 0.75F, var10, var11, 0.9375F, var12); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); } } else if (var8 == 3) { par1BlockFenceGate.setBlockBounds(0.8125F, 0.375F, 0.0F, 0.9375F, 0.9375F, 0.125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.8125F, 0.375F, 0.875F, 0.9375F, 0.9375F, 1.0F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.5625F, 0.375F, 0.0F, 0.8125F, 0.5625F, 0.125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.5625F, 0.375F, 0.875F, 0.8125F, 0.5625F, 1.0F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.5625F, 0.75F, 0.0F, 0.8125F, 0.9375F, 0.125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.5625F, 0.75F, 0.875F, 0.8125F, 0.9375F, 1.0F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); } else if (var8 == 1) { par1BlockFenceGate.setBlockBounds(0.0625F, 0.375F, 0.0F, 0.1875F, 0.9375F, 0.125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.0625F, 0.375F, 0.875F, 0.1875F, 0.9375F, 1.0F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.1875F, 0.375F, 0.0F, 0.4375F, 0.5625F, 0.125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.1875F, 0.375F, 0.875F, 0.4375F, 0.5625F, 1.0F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.1875F, 0.75F, 0.0F, 0.4375F, 0.9375F, 0.125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.1875F, 0.75F, 0.875F, 0.4375F, 0.9375F, 1.0F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); } else if (var8 == 0) { par1BlockFenceGate.setBlockBounds(0.0F, 0.375F, 0.8125F, 0.125F, 0.9375F, 0.9375F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.875F, 0.375F, 0.8125F, 1.0F, 0.9375F, 0.9375F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.0F, 0.375F, 0.5625F, 0.125F, 0.5625F, 0.8125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.875F, 0.375F, 0.5625F, 1.0F, 0.5625F, 0.8125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.0F, 0.75F, 0.5625F, 0.125F, 0.9375F, 0.8125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.875F, 0.75F, 0.5625F, 1.0F, 0.9375F, 0.8125F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); } else if (var8 == 2) { par1BlockFenceGate.setBlockBounds(0.0F, 0.375F, 0.0625F, 0.125F, 0.9375F, 0.1875F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.875F, 0.375F, 0.0625F, 1.0F, 0.9375F, 0.1875F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.0F, 0.375F, 0.1875F, 0.125F, 0.5625F, 0.4375F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.875F, 0.375F, 0.1875F, 1.0F, 0.5625F, 0.4375F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.0F, 0.75F, 0.1875F, 0.125F, 0.9375F, 0.4375F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); par1BlockFenceGate.setBlockBounds(0.875F, 0.75F, 0.1875F, 1.0F, 0.9375F, 0.4375F); this.renderStandardBlock(par1BlockFenceGate, par2, par3, par4); } par1BlockFenceGate.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); return var5; }
660c3da5-2012-4815-a338-913b2c097613
6
public void dequeueSound(String filename) { if (!toStream) { errorMessage("Method 'dequeueSound' may only be used for " + "streaming and MIDI sources."); return; } if (filename == null || filename.equals("")) { errorMessage("Filename not specified in method 'dequeueSound'"); return; } synchronized (soundSequenceLock) { if (soundSequenceQueue != null) { ListIterator<FilenameURL> i = soundSequenceQueue.listIterator(); while (i.hasNext()) { if (i.next().getFilename().equals(filename)) { i.remove(); break; } } } } }
21bf31c3-051e-4b4d-b53b-86617eabdacc
1
private boolean jj_2_31(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_31(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(30, xla); } }
b7cc88fd-9cda-4842-9ef5-ca59f8567dc7
4
protected Boolean IsPronome(String pTexto) { ConexaoMySql cn = new ConexaoMySql(); Boolean retorno=false; String strSQL = "select cleasing_pronome from cleasing_pronome"; try{ ResultSet rs = cn.retornarResultSet(strSQL); while(rs.next()){ if(pTexto.equals(rs.getString("cleasing_pronome"))){ retorno=true; } if(retorno){ break; } } return retorno; } catch(Exception ex){ return retorno; } }
c71b09da-e715-480b-8b3d-0b4b9537737c
7
public void mouseReleased(MouseEvent e) { try { if (mapViewer.getGotoPath() != null) { // A mouse drag has ended (see CanvasMouseMotionListener). PathNode temp = mapViewer.getGotoPath(); mapViewer.stopGoto(); // Move the unit: Unit unit = mapViewer.getActiveUnit(); InGameController ctlr = freeColClient .getInGameController(); ctlr.setDestination(unit, temp.getLastNode().getTile()); if (freeColClient.currentPlayerIsMyPlayer()) { ctlr.moveToDestination(unit); boolean canStayActive = unit.getState() == UnitState.ACTIVE && unit.getDestination() == null && unit.getMovesLeft() > 0; if(canStayActive){ return; } ctlr.nextActiveUnit(); } } else if (mapViewer.isGotoStarted()) { mapViewer.stopGoto(); } } catch (Exception ex) { logger.log(Level.WARNING, "Error in mouseReleased!", ex); } }
1eedad55-ce33-4d9c-866c-8410d18c0a10
5
private void processWrite(SelectionKey key) throws IOException { WritableByteChannel ch = (WritableByteChannel) key.channel(); synchronized (writeBuf) { writeBuf.flip(); int bytesOp = 0, bytesTotal = 0; while (writeBuf.hasRemaining() && (bytesOp = ch.write(writeBuf)) > 0) bytesTotal += bytesOp; bytesOut.addAndGet(bytesTotal); // int internalbyteSent= socketChannel.write(buffer); bytesSent.addAndGet(bytesTotal); if (writeBuf.remaining() == 0) { key.interestOps(key.interestOps() ^ SelectionKey.OP_WRITE); } if (bytesTotal > 0) writeBuf.notify(); else if (bytesOp == -1) { log.info("peer closed write channel"); ch.close(); } writeBuf.compact(); } }
b7ae0753-7360-4475-9603-08d3f5ff5e1a
3
private static boolean isLetter(char arg0) { return arg0 >= 'a' && arg0 <= 'z' || arg0 >= 'A' && arg0 <= 'Z'; }
3661bf3e-64e2-4e5f-ade5-ad2ba9f45b0c
1
private Owner PlayerToOwner(Player p){ if(p == Player.Cathargo){ return Owner.Cathargo; } return Owner.Rom; }
a736e88b-41c2-4815-9794-fc76facad978
0
protected final void setLogin(String login) { _login = login; }
3d145ffe-aa29-49e4-b4d2-f475ef6b57b9
2
public <T extends ICreature> Collection<T> createCreatures(IEnvironment env, int count, IColorStrategy colorStrategy, Constructor<T> constructor) { Collection<T> creatures = new ArrayList<T>(); Dimension s = env.getSize(); for (int i=0; i<count; i++) { // X coordinate double x = (rand.nextDouble() * s.getWidth()) - s.getWidth() / 2; // Y coordinate double y = (rand.nextDouble() * s.getHeight()) - s.getHeight() / 2; // direction double direction = (rand.nextDouble() * 2 * Math.PI); // speed int speed = (int) (rand.nextDouble() * maxSpeed); T creature = null; try { creature = constructor.newInstance(env, new Point2D.Double(x,y), speed, direction, colorStrategy.getColor()); } catch (Exception e) { logger.info("calling constructor " + constructor + " failed with exception " + e.getLocalizedMessage()); e.printStackTrace(); } creatures.add(creature); } return creatures; }
be798a30-71cc-4a9f-a747-80f70209ecb3
1
@Override public ArrayList<Map<String, String>> getAllWonBidsOfUser(String user) { System.out.println("getAllWonAuctionsOfUser"); ArrayList<Map<String, String>> bidsList = new ArrayList<Map<String,String>>(); TypedQuery<Bid> allWonBidsQuery = emgr.createNamedQuery("Bid.findAllWonAuctionsByUser", Bid.class); allWonBidsQuery.setParameter("userName", user); List<Bid> obtainedBids = allWonBidsQuery.getResultList(); System.out.println("OBTAINED BIDS SIZe = " + obtainedBids.size()); for (int i = 0; i < obtainedBids.size(); i++) { /*String highestBid = Double.toString(obtainedBids.get(i).getCurrentHighest()); String dateBid = obtainedBids.get(i).getBidDate().toString(); bids.add(highestBid + ":" + dateBid);*/ Map<String,String> bidsMap = new HashMap<String,String>(); bidsMap.put("price", Double.toString(obtainedBids.get(i).getCurrentHighest())); Date date = obtainedBids.get(i).getBidDate(); Calendar cal = Calendar.getInstance(); Time time = obtainedBids.get(i).getBidTime(); String[] splitTime = time.toString().split(":"); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(splitTime[0])); cal.set(Calendar.MINUTE, Integer.valueOf(splitTime[1])); cal.set(Calendar.SECOND, Integer.valueOf(splitTime[2])); bidsMap.put("date", cal.getTime().toString()); int auctionId = obtainedBids.get(i).getAuctionId(); bidsMap.put("auctionId", Integer.toString(auctionId)); // Obtain the auction details from the database Auction auction = emgr.find(Auction.class, auctionId); bidsMap.put("auctionName", auction.getAuctionName()); bidsMap.put("auctionDescription", auction.getAuctionDescription()); bidsList.add(bidsMap); } System.out.println("Returning bidsList = " + bidsList); return bidsList; }
966c1d14-9df1-49eb-9ab2-81983ccc83a6
0
@Override public void connectionSuccessful() { messagelog.append("Connected!\n"); messageToSend.setText(""); messageToSend.setEditable(true); }
e9ace3da-c1db-4bd3-abe2-fdbb274d69e0
4
public int getMachineIndexByName(String machineFileName){ ArrayList machines = getEnvironment().myObjects; if(machines == null) return -1; for(int k = 0; k < machines.size(); k++){ Object current = machines.get(k); if(current instanceof Automaton){ Automaton cur = (Automaton)current; if(cur.getFileName().equals(machineFileName)){ return k; } } } return -1; }
f4c3bf79-91d7-413d-acd3-b1a5588dc849
2
private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed if (Utils.promptQuestion("Weet je zeker dat je " + selectedEmployee.getFirstName() + " " + selectedEmployee.getFamilyName() + " wilt verwijderen?", true, "Ja", "Nee")) { if (selectedEmployee.isAdmin()) { Utils.showMessage("U kunt geen administrator verwijderen.", "Fout!", null, false); return; } selectedEmployee.delete(); searchTable(); } }//GEN-LAST:event_btnDeleteActionPerformed
1073db49-a8ba-45ca-b363-1f68d807df99
3
@Test public void testBoardingPassengersOfLP() throws TrainException{ d = new DepartingTrain(); loco = new Locomotive(grossWeight, locoClassification); d.addCarriage(loco); passenger1 = new PassengerCar(grossWeight, passenger1Seats); d.addCarriage(passenger1); assertEquals(0, (int)d.numberOnBoard()); int newPassengers = 20; d.board(newPassengers); assertEquals(newPassengers > d.numberOfSeats() ? d.numberOfSeats() : newPassengers, (int)d.numberOnBoard()); d.board(newPassengers); assertEquals(newPassengers*2 > d.numberOfSeats() ? d.numberOfSeats() : newPassengers*2, (int)d.numberOnBoard()); d.board(newPassengers); assertEquals(newPassengers*3 > d.numberOfSeats() ? d.numberOfSeats() : newPassengers*3, (int)d.numberOnBoard()); }
a552a1cf-10ea-4811-9405-2c4009faf650
3
public int getFirstFreeSeat() { for(int i = 0; i < seatStatus.length; i++) for(int j = 0; j < seatStatus[i].length; j++) if(seatStatus[i][j] == 'L') return i*40+j; return -1; }
d489f571-4650-42b2-985b-0a8dc2c45db7
7
public void receiveResponse(byte[] data, int length) throws IOException { DNSInputStream dnsIn = new DNSInputStream(data, 0, length); int id = dnsIn.readShort(); if (id != queryID) { throw new IOException("ID does not match request"); } int flags = dnsIn.readShort(); decodeFlags(flags); int numQueries = dnsIn.readShort(); int numAnswers = dnsIn.readShort(); int numAuthorities = dnsIn.readShort(); int numAdditional = dnsIn.readShort(); while (numQueries-- > 0) { // discard questions dnsIn.readDomainName(); dnsIn.readShort(); dnsIn.readShort(); } try { while (numAnswers-- > 0) { answers.addElement(dnsIn.readRR()); } while (numAuthorities-- > 0) { authorities.addElement(dnsIn.readRR()); } while (numAdditional-- > 0) { additional.addElement(dnsIn.readRR()); } } catch (EOFException ex) { if (!truncated) { throw ex; } } }
76085bd9-f10f-4b9b-a2c1-3a6469b8437b
6
private int valueXexpand(char[] charArray, int i) { if ('X' == charArray[i]) { if (charArray.length > i & ('L' == charArray[i + 1] | 'C' == charArray[i + 1] | 'D' == charArray[i + 1] | 'M' == charArray[i + 1])) { return -10; } else if (charArray.length + 1 > i + 1 & ('L' == charArray[i + 2] | 'C' == charArray[i + 2] | 'D' == charArray[i + 2] | 'M' == charArray[i + 2])) { return -10; } else if (charArray.length + 2 > i + 1 & ('L' == charArray[i + 3] | 'C' == charArray[i + 3] | 'D' == charArray[i + 3] | 'M' == charArray[i + 3])) { return -10; } else if (charArray.length + 3 > i + 1 & ('L' == charArray[i + 4] | 'C' == charArray[i + 4] | 'D' == charArray[i + 4] | 'M' == charArray[i + 4])) { return -10; } else if (charArray.length + 4 > i + 1 & ('L' == charArray[i + 5] | 'C' == charArray[i + 5] | 'D' == charArray[i + 5] | 'M' == charArray[i + 5])) { throw new RuntimeException(); } return 10; } return 0; }
49ee57fb-2d79-4752-8818-a7ed72458380
7
public static Map mapEnchantmentData(int par0, ItemStack par1ItemStack) { Item var2 = par1ItemStack.getItem(); HashMap var3 = null; Enchantment[] var4 = Enchantment.enchantmentsList; int var5 = var4.length; for (int var6 = 0; var6 < var5; ++var6) { Enchantment var7 = var4[var6]; if (var7 != null && var7.canEnchantItem(par1ItemStack)) { for (int var8 = var7.getMinLevel(); var8 <= var7.getMaxLevel(); ++var8) { if (par0 >= var7.getMinEnchantability(var8) && par0 <= var7.getMaxEnchantability(var8)) { if (var3 == null) { var3 = new HashMap(); } var3.put(Integer.valueOf(var7.effectId), new EnchantmentData(var7, var8)); } } } } return var3; }
941fb44b-53f1-4e27-9bf7-12f39285a3f2
5
public Object getValueAt(int row, int col) { try { BasicRecipe r = data.get(row); switch (col) { case 0 : return r.title; case 1 : return r.style; case 2 : return r.brewer; case 3 : return r.iteration; default : return ""; } } catch (Exception e) { }; return ""; }
fac8e3e1-56d4-4c41-bbcb-941781bd0776
7
public void indication(final FrameEvent e) { final CEMILData f = (CEMILData) e.getFrame(); final byte[] apdu = f.getPayload(); // can't be a process communication indication if too short if (apdu.length < 2) return; final int svc = DataUnitBuilder.getAPDUService(apdu); // Note: even if this is a read response we have waited for, // we nevertheless notify the listeners about it (we do *not* discard it) if (svc == GROUP_RESPONSE && wait) { synchronized (indications) { indications.add(e); indications.notify(); } } try { // notify listeners if (svc == GROUP_READ) fireGroupReadWrite(f, new byte[0], svc, false); else if (svc == GROUP_RESPONSE || svc == GROUP_WRITE) fireGroupReadWrite(f, DataUnitBuilder.extractASDU(apdu), svc, apdu.length <= 2); } catch (final RuntimeException rte) { logger.error("on group indication", rte); } }
084b27e7-b0d0-4e1d-9ff7-4370dbe25f34
5
@Override public boolean show() { if (!getTab().open()) { return false; } final WidgetChild list = Widgets.get(EMOTE_WIDGET, EMOTE_LIST); if (list == null || !list.visible()) { return false; } final WidgetChild emote = list.getChild(childId); return Widgets.scroll(emote, Widgets.get(EMOTE_WIDGET, EMOTE_SCROLLBAR)) && emote.visible() && list .getBoundingRectangle().contains(emote.getBoundingRectangle()); }
d4dd316a-9d26-46b5-8bbd-4b0859869afc
0
@Override public void mouseEntered(MouseEvent e) { }
16421a42-877f-45da-bafd-9effeb481cf0
3
public void run() { while (true) { if (animationEnabled()) { repaint(); } try { Thread.sleep(FRAME_DELAY); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
f1dc787d-9392-4127-8b80-7f9a4b4e50aa
3
public void applyNoise() { currCycle++; currCycle %= NUMBER_OF_CYCLES_PER_CHANGE; // every NUMBER_OF_CYCLES_PER_CHANGE we do the change if (currCycle == 0) { this.speed += ((random() * 2) - 1); // maintain the speed within some boundaries if (this.speed < MIN_SPEED) { this.speed = MIN_SPEED; } else if (this.speed > MAX_SPEED) { this.speed = MAX_SPEED; } setDirection(this.direction + ((random() * PI / 2) - (PI / 4))); } }
9576bf47-2bfe-4e45-9920-9f211acc8d32
9
public static List<Graph.Edge> findShortestPath(Graph g, int sourceVertex, int destinationVertex){ int n = g.getVerticesCount(); //keeping space for 1 extra cycle to detect a negative cycle int [][]cost = new int[n+1][n]; Graph.Edge[][] retrackt = new Graph.Edge[n+1][n]; for( Integer i: g.getAllVertex()) { cost[0][i] = i!=sourceVertex ? Integer.MAX_VALUE: 0; } for( int i =1; i <=n; i++) { for( int v = 0; v<n; v++ ) { Set<Graph.Edge> inboundEdges = g.getInboundEdges(v); if(inboundEdges.size() == 0){ cost[i][v] = cost[i-1][v]; } else{ cost[i][v] = Math.min(cost[i-1][v], getMinCostFromNeighbours(cost,v,g,sourceVertex, i, retrackt)); } } } //Detect negative cycle // if cost[n-1][v] != cost[n][v] that means a negative cycle is present for( int i= 0; i <n; i ++){ if(cost[n-1][i] != cost[n][i] ){ throw new RuntimeException("Negative Cycle detected"); } } System.out.println("Shortest Cost : "+ cost[n-1][destinationVertex]); List<Graph.Edge> shortestPath = new ArrayList<>(); while(true) { if(destinationVertex == sourceVertex){ break; } Graph.Edge e = retrackt[n-1][destinationVertex]; shortestPath.add(e); destinationVertex = e.from; } return shortestPath; }
5fb75848-dcef-467f-85a1-f785135511c7
4
public static int characterSize(int character) throws JSONException { if (character < 0 || character > 0x10FFFF) { throw new JSONException("Bad character " + character); } return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3; }
fd710c6a-3180-4107-98eb-431b02959bb0
3
@Override public int compareTo(DataChunk chunk) { DataChunk arg0 = (DataChunk)chunk; for (int i = arg0.getStart().length - 1; i >= 0; --i) { if (this.getStart()[i] == arg0.getStart()[i]) continue; return this.getStart()[i] < arg0.getStart()[i] ? -1 : 1; } return 0; }
fad72b0f-eae5-451f-adce-94558e9d2fb5
7
private int alphabeta(int m, int dt, int a, int b, Board B, boolean max) { if (dt == 0 || findPossibleMoves(max, B).length == 0) { return getRating(max, B, m); } else if (max == true) { for (int i : findPossibleMoves(max, B)) { Board nB = B; nB.move(max, m); a = Math.max(a, alphabeta(i, dt - 1, a, b, nB, false)); if (b <= a) { break; } } return a; } else { for (int i : findPossibleMoves(max, B)) { Board nB = B; nB.move(max, m); b = Math.min(b, alphabeta(i, dt - 1, a, b, nB, true)); if (b <= a) { break; } } return b; } }
23e2ab06-46c7-4bd3-b157-d71c71fff984
4
@Override public String display() { //Display memory on command line interface String displayString = ""; for (int i = 0; i < MEMORY.length; i++) { if (MEMORY[i] == null) { if (i < 10) { //For formatting of single digits String iString = " 0" + i; displayString += "\n" + iString + "| ------------"; } else { displayString += "\n " + i + "| ------------"; } } else { if (i < 10) { String iString = " 0" + i; displayString += "\n" + iString + "| " + MEMORY[i].toString(); } else { displayString+= "\n " + i + "| " + MEMORY[i].toString(); } } } return displayString; }
71e5f56e-0a7f-40ac-8e83-7264f1bba0f9
5
protected static Map<String, String> resolveDataProviderArguments(Method testMethod) throws Exception { if (testMethod == null) throw new IllegalArgumentException("Test Method context cannot be null."); DataProviderArguments args = testMethod.getAnnotation(DataProviderArguments.class); if (args == null) throw new IllegalArgumentException("Test Method context has no DataProviderArguments annotation."); if (args.value() == null || args.value().length == 0) throw new IllegalArgumentException("Test Method context has a malformed DataProviderArguments annotation."); Map<String, String> arguments = new HashMap<String, String>(); for (int i = 0; i < args.value().length; i++) { String[] parts = args.value()[i].split("="); arguments.put(parts[0], parts[1]); } return arguments; }
2b3187bd-aeaa-41a0-b291-5b807d31fd39
0
protected void useCameraValue(double value) { setSetpoint(returnPIDInput()+value); }
7bfe4cd3-b136-4a22-86a6-a04f8093b633
9
private byte[] hashPassword(String password, byte[] nonce) throws IOException { byte[] passw = password.toUpperCase().getBytes(); byte[] lmPw1 = new byte[7]; byte[] lmPw2 = new byte[7]; int len = passw.length; if (len > 7) { len = 7; } int idx; for (idx = 0; idx < len; idx++) { lmPw1[idx] = passw[idx]; } for (; idx < 7; idx++) { lmPw1[idx] = (byte) 0; } len = passw.length; if (len > 14) { len = 14; } for (idx = 7; idx < len; idx++) { lmPw2[idx - 7] = passw[idx]; } for (; idx < 14; idx++) { lmPw2[idx - 7] = (byte) 0; } // Create LanManager hashed Password byte[] magic = { (byte) 0x4B, (byte) 0x47, (byte) 0x53, (byte) 0x21, (byte) 0x40, (byte) 0x23, (byte) 0x24, (byte) 0x25 }; byte[] lmHpw1; lmHpw1 = encrypt(lmPw1, magic); byte[] lmHpw2 = encrypt(lmPw2, magic); byte[] lmHpw = new byte[21]; for (int i = 0; i < lmHpw1.length; i++) { lmHpw[i] = lmHpw1[i]; } for (int i = 0; i < lmHpw2.length; i++) { lmHpw[i + 8] = lmHpw2[i]; } for (int i = 0; i < 5; i++) { lmHpw[i + 16] = (byte) 0; } // Create the responses. byte[] lmResp = new byte[24]; calcResp(lmHpw, nonce, lmResp); return lmResp; }
9746ee76-f7a7-4ae2-80eb-9cac7630513d
6
private void sortiere(int[] zahlen, int l, int r) { int positionRechts = r; /* * Sortierung von der Mitte aus starten */ // int pivot = zahlen.length / 2 ; int pivot = Math.round((r + 1 - l) / 2 + l); System.out.println(); System.out.println("Mittelwert: " + zahlen[pivot]); if (l < r) { for (int i = l; i < zahlen.length; i++) { if (zahlen[i] >= zahlen[pivot]) { for (int j = positionRechts; j >= 0; j--) { if (zahlen[j] <= zahlen[pivot]) { positionRechts = j; int tmpJ = zahlen[j]; zahlen[j] = zahlen[i]; zahlen[i] = tmpJ; System.out.println("Zahlen " + "(Index " + l + "-" + r + "): " + zahlenArraysToString(zahlen)); break; } else if (i == j) { int tmpJ = zahlen[j]; zahlen[j] = zahlen[pivot]; zahlen[pivot] = tmpJ; sortiere(zahlen, l, pivot - 1); sortiere(zahlen, pivot + 1, r); System.out.println("fertig 1: " + zahlenArraysToString(zahlen)); continue; } } } } } }
108f1618-1b0a-4e58-aa08-542cd6545821
6
public void newGame() { String s; String name = ""; s = "Welcome to Ye Olde RPG!\n"; s += "\nChoose your class: \n"; s += "\t1: Warrior\n"; s += "\t2: Mage\n"; s += "\t3: Archer\n"; s += "\t4: Assassin\n"; s += "Selection: "; System.out.print( s ); try { role = Integer.parseInt( in.readLine() ); } catch ( IOException e ) { } s = "Intrepid warrior, what doth thy call thyself? (State your name): "; System.out.print( s ); try { name = in.readLine(); } catch ( IOException e ) { } //instantiate the player's character if (role == 1) pat = new Warrior( name ); else if (role == 2) pat = new Mage( name ); else if (role == 3) pat = new Archer( name ); else if (role == 4) pat = new Assassin( name ); }//end newGame()
557cbbb3-fe01-48a2-b806-a8e6ccf0f815
0
public void updateList(ArrayList<ClientContact> contacts){ clientContactCurrent = contacts; list.setModel(new AbstracListModelForClient(clientContactCurrent)); }
80e4b583-7335-44bd-93d1-171e8a909b35
0
public void setList(JTextArea list) { this.list = list; }
6d7a25d9-73b4-41f4-875e-65ffa2f66231
0
@Override public Object clone() throws CloneNotSupportedException { //PropertyContainerImpl cloned = new PropertyContainerImpl(); PropertyContainerImpl cloned = (PropertyContainerImpl) super.clone(); cloned.current_values = (HashMap) this.current_values.clone(); cloned.default_values = (HashMap) this.default_values.clone(); cloned.filter_chains = (HashMap) this.filter_chains.clone(); return cloned; }
0b4df8fb-9136-40c5-9a3c-f313a94dd3ae
1
private void notifyOfLockedStateWillChange() { for (OutlineModelListener listener : getCurrentListeners()) { listener.lockedStateWillChange(this); } }
e0f84b77-a48b-4405-ad0f-3b7a4e863221
4
public ScriptFile(String fileName) { this.fileName = fileName; try { BufferedReader reader = new BufferedReader(new FileReader(fileName)); while (reader.ready()) { String line = reader.readLine().trim(); if (line.length() == 0) continue; if (line.charAt(0) == ';') continue; lines.add(line); } } catch (Exception e) { throw new FileReadError("Ошибка при чтении файла: " + e.toString()); } }
216664a9-df2c-4848-a219-86d0cb4d27c4
6
public double getProbability(String[] ratings) { int n = ratings.length; ArrayList<Integer> list = new ArrayList<Integer>(); int Enumber; int x; int R; double ans = 0.0; String str = ""; for(int i = 0;i < n;i++){ str = str + ratings[i]; } String s[] = str.split(" "); for(int i = 0;i < s.length;i++){ list.add(Integer.parseInt(s[i])); } n = list.size(); Enumber = list.get(0); Collections.sort(list); Collections.reverse(list); x = list.indexOf(Enumber); if((n % 20) == 0){ R = n / 20; }else{ R = (n / 20) + 1; } if((n <= 20)||(x == 0)){ return 1; } if(x + 1 <= R){ return 0; } ans = 1 / (double)R; return ans; }
43dd41e1-5613-4498-9edc-cc0939c45795
3
private static int[] getCrewsIndices() { Set s = (Set<Crew>) map.get(flightList.getSelectedValue().toString()); int[] selectedIndices = new int[s.size()]; for(int i = 0; i<s.size(); i++){ for(int j=0; j<data.fetchCrewsList().length; j++){ if(data.fetchCrewsList()[j].toString().equals((s.toArray()[i]).toString())){ selectedIndices[i] = j; } } } return selectedIndices; }