method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
e896b3fe-2c55-4728-a5fc-df139394363f
1
private Map<String, Quantity> loadStock() { if(stock == null) { stock = Maps.newConcurrentMap(); declare(stock, "Coffee", 10); declare(stock, "Chocolate", 10); declare(stock, "OrangeJuice", 10); declare(stock, "Tea", 10); declare(stock, "TomatoPotage", 10); } return stock; }
9fa19b95-deb8-449a-b763-66337e6bd34e
8
public void assignAffectedPerts( Residue res ){ if(res.perts != null){ PriorityQueue<Integer> affected = new PriorityQueue<Integer>(); for(int b=0;b<res.perts.length;b++){ Perturbation pert = perts[res.perts[b]]; for(int c=0;c<pert.successors.length;c++){ if( !affected.contains(pert.successors[c]) ){ boolean inPerts = false; for(int d=b;d<res.perts.length;d++){//Check if it is also in perts (it would come after pert in perts) if( res.perts[d] == pert.successors[c] ) inPerts=true; } if(!inPerts) affected.add(pert.successors[c]); } } } int numAffected = affected.size(); res.affectedPerts = new int[numAffected]; for(int b=0;b<numAffected;b++) res.affectedPerts[b] = affected.poll(); } }
445dace6-6515-4933-b084-d712647c2ee5
5
@SuppressWarnings("unchecked") char getCharValue(Object obj, int k) { if ((obj instanceof ArgHolder<?>) && ((ArgHolder<?>) obj).getType().equals(Character.class)) { return ((ArgHolder<Character>) obj).getValue(); } else if (obj instanceof char[]) { return ((char[]) obj)[k]; } else { verify(false, "object doesn't contain char values"); return 0; } }
cfe51c1f-5e76-4b29-826b-3137cb265fa6
0
private Salir() { // JFormDesigner - Action initialization - DO NOT MODIFY //GEN-BEGIN:initComponents putValue(NAME, "Salir"); putValue(SHORT_DESCRIPTION, "Salir el programa"); putValue(LONG_DESCRIPTION, "Salir el programa"); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_MASK)); putValue(ACTION_COMMAND_KEY, "Salir"); putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/images/exclamation.png"))); // JFormDesigner - End of action initialization //GEN-END:initComponents }
26a0468c-4fce-48f8-9516-b93eceb850ed
7
public void determinSched(int days, int[] sec, int min){ int num_sec = sec.length; int [][] M = new int[days + 1][num_sec + 1]; int T = 0; for(int j=0; j<=10; j++){ T = T + sec[j]; if(j == 0){ M[1][j] = (int)Math.pow(Math.max(min-0, 0), 4) + Math.max(0-min, 0); } else{ M[1][j] = (int)Math.pow(Math.max(min - T, 0), 4) + Math.max(T - min, 0); } } System.out.print("\nMax Table at i = 1 is : "); for(int s : M[1]) System.out.print(s + " "); for(int i=2; i<=7; i++){ for(int j=1; j<=10; j++){ int curr_min = M[i-1][j] + (int)Math.pow(Math.max(min - T, 0), 4) + Math.max(T - min, 0); M[i][0] = M[i-1][0] + (int)Math.pow(Math.max(min - T, 0), 4) + Math.max(T - min, 0); for(int k=1; k <= j; k++){ M[i][j] = Math.min(curr_min, M[i-1][j-k] + (int)Math.pow(Math.max(min - getTx(sec, j-k+1, j), 0), 4) + Math.max(getTx(sec, j-k+1, j) - min,0)); curr_min = M[i][j]; } } System.out.print("\nMax Table at i = "+i+ " is : "); for(int s : M[i]) System.out.print(s + " "); } }
8e59df29-03a1-4ba3-80d8-535b5f71ce7a
5
private void jj_rescan_token() { jj_rescan = true; for (int i = 0; i < 1; i++) { try { JJCalls p = jj_2_rtns[i]; do { if (p.gen > jj_gen) { jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; switch (i) { case 0: jj_3_1(); break; } } p = p.next; } while (p != null); } catch(LookaheadSuccess ls) { } } jj_rescan = false; }
4e4e674a-6121-49a2-bd18-3c146fdf0682
6
private void inicializaPercentuaisDesconto() { switch (diaDaSemana) { case SEGUNDA: descontosPorTipo.put(TiposDeIngresso.CRIANCA, 10); descontosPorTipo.put(TiposDeIngresso.ESTUDANTE, 10); descontosPorTipo.put(TiposDeIngresso.IDOSO, 10); break; case TERCA: descontosPorTipo.put(TiposDeIngresso.CRIANCA, 15); descontosPorTipo.put(TiposDeIngresso.ESTUDANTE, 5); descontosPorTipo.put(TiposDeIngresso.IDOSO, 15); break; case QUARTA: descontosPorTipo.put(TiposDeIngresso.CRIANCA, 30); descontosPorTipo.put(TiposDeIngresso.ESTUDANTE, 50); descontosPorTipo.put(TiposDeIngresso.IDOSO, 40); break; case QUINTA: descontosPorTipo.put(TiposDeIngresso.ESTUDANTE, 30); descontosPorTipo.put(TiposDeIngresso.IDOSO, 30); break; case SEXTA: descontosPorTipo.put(TiposDeIngresso.CRIANCA, 11); break; case SAB_DOM_FER: descontosPorTipo.put(TiposDeIngresso.IDOSO, 5); break; } }
41c86551-0997-4a46-876a-68a37557db10
0
public UploadListener(HttpServletRequest request, long debugDelay) { this.request = request; this.delay = debugDelay; totalToRead = request.getContentLength(); this.startTime = System.currentTimeMillis(); }
f6c7b613-c9a1-44f0-8280-c3149282eddf
9
@Override public void doSomething() throws IOException, ParsingException, LexingException, IncorrectProofException { String[] temp = in.readLine().split(Pattern.quote("|-")); if (temp.length > 2) { throw new IOException("more than one |- in first line"); } String s = temp[0]; int l = 0; int r = 0; while (l < s.length()) { r++; Expression tempExpr; try { String ss = s.substring(l, r); tempExpr = parseExcept(ss); } catch (Exception e) { continue; } if (r == s.length() || s.charAt(r) == ',') { l = r + 1; r = l; hypos.add(tempExpr); } } /*for (String value : s) { hypos.add(parse(value)); } -*/ alpha = hypos.remove(hypos.size() - 1); List<Expression> proof = new ArrayList<>(); String s1 = in.readLine(); while (s1 != null && !s1.replace("\\s+", "").isEmpty()) { Expression e = parse(s1); proof.add(e); s1 = in.readLine(); } List<Expression> newProof = move1HypoToProof(proof); if (success) for (Expression e : newProof) { out.println(e.asString()); } }
acda2cbc-a536-4455-bccf-24bf0309c2c2
9
public PogNode chooseNeighborWeighted_Fast(TreeQualifier qualifier, Random generator) { Node editedNode = null; boolean isAdded = false; if (addableList.isEmpty() && removableList.isEmpty()) { // this is a null node; choose a node to add from the whole dataset isAdded = true; Set<Node> entireNodeList = qualifier.entireNodeList(); int chosenIndex = generator.nextInt(entireNodeList.size()); int i = 0; for (Node n : entireNodeList) { if (i++ == chosenIndex) { editedNode = n; break; } } } else { double[] w = new double[addWeight.length + removeWeight.length]; int j = 0; for (int i = 0; i < addWeight.length; i++){ w[j++] = addWeight[i]; } for (int i = 0; i < removeWeight.length; i++){ w[j++] = removeWeight[i]; } int chosenIndex = randomIndex(generator, w); if (chosenIndex < addWeight.length){ // add a vertex isAdded = true; editedNode = candidateArrayAdd[chosenIndex]; } else { // remove a vertex editedNode = candidateArrayRemove[chosenIndex - addWeight.length]; } } // create a node with the new infomation PogNode q = null; if (isAdded) { q = recalcInfoAdded(editedNode, qualifier); } else { q = recalcInfoRemoved(editedNode, qualifier); } if (q != null) { candidateEditedNode = editedNode; } return q; }
2da2bb1e-3c57-4c5d-a6b8-9f321d6551e4
3
private void validateParticipantsInCSVFile(List<Participant> participants) { List<String[]> results = new ArrayList<String[]>(); try { CSVReader reader = new CSVReader(new FileReader(csvPath)); results = reader.readAll(); reader.close(); } catch (FileNotFoundException ex) { Logger.getLogger(RegistrationTest.class.getName()).log(Level.SEVERE, null, ex); fail(ex.getMessage()); } catch (IOException ex) { Logger.getLogger(RegistrationTest.class.getName()).log(Level.SEVERE, null, ex); fail(ex.getMessage()); } validateHeaderInCSVFile(csvHeaderLine, results.get(0)); for (int i = 1; i < results.size(); ++i) { validateParticipantInCSVFile(participants.get(i-1), results.get(i)); } }
08b0cb3b-4c77-4618-883c-61593c0177d5
4
public boolean canIssue(Instruction instruction) { boolean freeResStat = false; String opcode = instruction.getOpcode(); for (int i = 0; i < reservationStations.size(); i++) { ReservationStation resStation = reservationStations.get(i); if (resStation.getUnit().equals(opcode)) { if (!resStation.isBusy()) { freeResStat = true; break; } } } return (freeResStat && ROB.canInsert()); }
6a827d41-a6b1-4476-985e-f8624ffe3f02
5
private void computeRoutingTablesParser(String input){ boolean splitHorizon = false; int i = 0; Scanner inputscanner = new Scanner(input); inputscanner.next(); //take away command while(inputscanner.hasNext()){ String token = inputscanner.next(); if (token.charAt(0)=='t'|| token.charAt(0)=='T'){ splitHorizon = true; } else if(token.charAt(0)=='f' || token.charAt(0)=='F'){ splitHorizon = false; } else { i = Integer.parseInt(token); } this.computeRoutingTables(i, splitHorizon); } inputscanner.close(); }
d3ba741e-2453-4723-b6dc-e15bf06c4df2
6
private Integer Find(String key, Node node) { if(node instanceof LeafNode){ for(int i = 0; i <= node.getSize() - 1; i++){ if(key.compareTo(node.getKey(i)) == 0){ return node.getValue(i); } } return null; } if(node instanceof InternalNode){ for(int i = 1; i <= node.getSize();i++){ if(key.compareTo(node.getKey(i)) < 0){ return Find(key,node.getChild(i-1)); } } return Find(key,node.getChild(node.getSize())); } return null; }
df885da6-baa3-42fb-a075-aa419a8f916d
5
public static void handleEvent(int eventId) { // return to main menu if(eventId == 1) { System.out.println("Exit new game menu selected"); Main.newGameMenu.setVisible(false); Main.newGameMenu.setEnabled(false); Main.newGameMenu.setFocusable(false); Main.mainFrame.remove(Main.newGameMenu); Main.mainFrame.add(Main.mainMenu); Main.mainMenu.setVisible(true); Main.mainMenu.setEnabled(true); Main.mainMenu.setFocusable(true); Main.mainMenu.requestFocusInWindow(); } // TODO: this currently returns to main menu as placeholder // start a new game else if(eventId == 2) { System.out.println("Exit new game menu selected"); Main.newGameMenu.setVisible(false); Main.newGameMenu.setEnabled(false); Main.newGameMenu.setFocusable(false); Main.mainFrame.remove(Main.newGameMenu); Main.mainFrame.add(Main.HowToPlayScreen); Main.HowToPlayScreen.setVisible(true); Main.HowToPlayScreen.setEnabled(true); Main.HowToPlayScreen.setFocusable(true); Main.HowToPlayScreen.requestFocusInWindow(); } else if(eventId == 3) { } else if(eventId == 4) { } else if(eventId == 5) { } }
d52133df-e97d-47fa-97bc-61001db7490e
5
public void Start(String name) { Land_objects = new ObjectsThread(Land_Matrix); Animal_objects = new ObjectsThread(); Char_objects = new ObjectsThread(); for (int ix = 0; ix < Land_Matrix.length; ix++) for (int iy = 0; iy < Land_Matrix[ix].length; iy++) for (BaseObject elem : Land_Matrix[ix][iy].GetConteiner()) { if(elem instanceof AnimalObject) Animal_objects.Add(elem); if(elem instanceof CharacterObject) Char_objects.Add(elem); } Land_objects.start(); Animal_objects.start(); Char_objects.start(); TextMessage("Started Land. Name: " + name + " Size: " + Land_Matrix.length); this.start(); new WorldServer(); }
2d2f3d18-0804-4df4-aef5-de490c333f1e
0
public double getY2Coordinate() { return y2Coordinate; }
94e9b033-551e-4266-82a0-5d96b28518b4
3
public CharacterBoard() { try { charSheetBig = ImageIO.read(new File("sprites/player.png")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } charSheet = new BufferedImage[charRows * charCols]; for (int i = 0; i < charCols; i++) { for (int j = 0; j < charRows; j++) { charSheet[i * charRows + j] = charSheetBig.getSubimage(i * charWidth, j * charHeight, charWidth, charHeight); } } }
0faacf1b-972e-4d25-88fa-8a860e912d95
4
public void close() { try {if (dataParser != null) dataParser.close();} catch (IOException e) {} try {if (resourceParser != null) resourceParser.close();} catch (IOException e) {} }
7c37f3cb-7da8-4eb6-a7ed-3f91d5d5d848
3
public static void main(String[] args) { Map<Model,Model> map = new HashMap<Model, Model>(); for(int i = 0;i<100;i++){ Model m = new Model(i); map.put(m, m); map.put(m, m); } while(true){ Set<Model> set = map.keySet(); if(!"[57, 33, 20, 71, 4, 49, 42, 23, 39, 35, 15, 18, 74, 14, 94, 77, 58, 25, 81, 31, 19, 52, 91, 54, 3, 21, 67, 2, 44, 61, 92, 99, 10, 17, 65, 27, 64, 79, 86, 96, 88, 40, 62, 93, 90, 0, 26, 7, 43, 53, 51, 16, 55, 56, 78, 34, 30, 11, 13, 47, 32, 9, 66, 70, 76, 97, 24, 89, 41, 37, 87, 45, 83, 80, 22, 95, 85, 69, 63, 60, 29, 1, 84, 82, 8, 98, 59, 48, 75, 72, 6, 68, 5, 12, 28, 38, 36, 73, 50, 46]".equals(set.toString())){ System.out.println(set); } } }
01e75d04-cafe-4b20-a3b1-f8f571289f63
7
public void operationManager(char symbol) throws DivisionByZeroException { if (!"".equals(text.getText())) { switch (symbol) { case '+': memory = memory + Double.parseDouble(text.getText()); break; case '-': memory = memory - Double.parseDouble(text.getText()); break; case '*': memory = memory * Double.parseDouble(text.getText()); break; case '/': if (!"0".equals(text.getText())) { memory = memory / Double.parseDouble(text.getText()); } else { JOptionPane.showMessageDialog(rootPane, "Division by zero!"); throw new DivisionByZeroException("Division by zero!"); } break; case startAction: memory = Double.parseDouble(text.getText()); } } }
e3af6712-c25b-4b2e-ac72-be441436d8a9
6
private void buildHotSpots() { File hotSpotFile = new File(MODEL_PATH + name + ".hspot"); BufferedReader in; String line; try { if (hotSpotFile.exists()){ in = new BufferedReader(new FileReader(hotSpotFile)); File transformFile = new File(MODEL_PATH + name + ".trfm"); math.Matrix4f transform; if(transformFile.exists()) transform = new math.Matrix4f(WavefrontObjLoader.loadTranform(transformFile)); else transform = new math.Matrix4f(); // While we have lines in our file while((line = in.readLine()) != null){ String[] tokens = line.split(" ", 5); // Get our type we are going to add List<Vector3f> spotList = hotSpots.get(tokens[0]); // Make it if it is a new type if(spotList == null){ hotSpots.put(tokens[0], new ArrayList<Vector3f>()); } try{ float x = Float.parseFloat(tokens[1]); float y = Float.parseFloat(tokens[2]); float z = Float.parseFloat(tokens[3]); hotSpots.get(tokens[0]).add(transform.times(new Vector3f(x,y,z))); } catch(NumberFormatException e){ System.err.println("Unable to parse hotspots for " + name + " on tokens " + tokens[0] + " " + tokens[1] + " " +tokens[2] + " " +tokens[3]); } } } } catch (IOException e) { // Oh well } }
f3d56537-9c6c-4df1-a4d5-5d50d476572d
7
public void visitIincInsn(final int var, final int increment){ if(currentBlock != null) { if(compute == FRAMES) { currentBlock.frame.execute(Opcodes.IINC, var, null, null); } } if(compute != NOTHING) { // updates max locals int n = var + 1; if(n > maxLocals) { maxLocals = n; } } // adds the instruction to the bytecode of the method if((var > 255) || (increment > 127) || (increment < -128)) { code.putByte(196 /* WIDE */) .put12(Opcodes.IINC, var) .putShort(increment); } else { code.putByte(Opcodes.IINC).put11(var, increment); } }
23675f60-7aeb-47de-b5ce-d8d6bf753e64
8
public int individualHappy(Room r) { int totalHappy = 0; String good = this.roomList(); String bad = this.noRoomList(); String[] goodName = good.split(","); String[] badName = bad.split(","); for(Person q : r.roomies) // See how they feel about every other person in the room. { for(int i = 0; i < badName.length; i++) if(q.getName().equalsIgnoreCase(badName[i].trim())) return -999; for(int i = 0; i < goodName.length; i++) { if(q.getName().equalsIgnoreCase(goodName[i].trim())) { if(i == 0) totalHappy = totalHappy + 4; else if (i == 1) totalHappy = totalHappy + 3; else if (i == 2) totalHappy = totalHappy + 2; else totalHappy++; } } } return totalHappy; }
ee52caf5-b91c-4d71-becb-8f3a48f364b7
0
protected void end() { }
477701f7-729f-4335-b4ca-31f2cf4677e4
5
public static String reverseSubstring(String string, int startIndex, int endIndex) { if (string == null || startIndex < 0 || startIndex > endIndex || endIndex > string.length()) return null; // build result String result = string.substring(0, startIndex); // prefix int currIndex = endIndex; while (currIndex-- > startIndex) result += string.charAt(currIndex); result += string.substring(endIndex, string.length()); // suffix return result; }
d5eae037-6afc-4910-9d79-95873c7508fb
6
public String getHelpText(HelpType command) throws CheckersException { String helpText = ""; switch (command) { case INSTRUCTIONS: case BOARD: case GAME: case REAL_PLAYER: case LOCATION: case MARKER: helpText = command.getHelpText(); break; default: throw new CheckersException(ErrorType.ERROR105.getMessage()); } return helpText; }
4f41a8ac-acea-4ce4-9a99-5a7cedab23c6
3
public boolean openAndReadTemplate(){ try { String line; reader = new BufferedReader(new FileReader(file)); while ((line = reader.readLine()) != null) { template.add(line); } reader.close(); return true; } catch (FileNotFoundException e) { writeLog(e); return false; } catch (IOException e) { writeLog(e); return false; } }
3c358761-01d0-4fe1-9de1-b54a9f360b95
5
public List<Integer> getSCC(Graph graph, Graph reversedGraph) { List<Integer> result = new ArrayList<Integer>(); System.out.println("Start sorting"); Stack<Vertex<T>> dfsSorting = getDfsSorting(graph); System.out.println("End sorting"); Stack<Vertex<T>> stack = new Stack<Vertex<T>>(); while (!dfsSorting.isEmpty()) { stack.push(reversedGraph.getVertex(dfsSorting.pop())); Set<Vertex<T>> scc = new HashSet<Vertex<T>>(); while (!stack.isEmpty()) { Vertex<T> vertex = stack.pop(); scc.add(vertex); for (Edge<T> edge : vertex.getEdges()) { if (!scc.contains(edge.getVertex2()) && dfsSorting.contains(edge.getVertex2())) { stack.push(edge.getVertex2()); } } } //remove all visited nodes dfsSorting.removeAll(scc); result.add(scc.size()); } return result; }
c46fedd0-21ea-4b52-81f0-4d90867675a8
0
protected Class getTransitionClass() { return MooreTransition.class; }
930429a5-114f-4343-82f6-7a6551635ff1
5
public void displayCardValues() { for (Card card : cards) { if (card.isAce()) { System.out.println(card.getType().toString() + " ACE"); } else if (card.getValue() == 11) { System.out.println(card.getType().toString() + " JACK"); } else if (card.getValue() == 12) { System.out.println(card.getType().toString() + " QUEEN"); } else if (card.getValue() == 13) { System.out.println(card.getType().toString() + " KING"); } else { System.out.println(card.getType().toString() + " " + card.getValue()); } } }
1e0d899f-bc86-49e8-9c07-3db9c42b1d5f
3
public void setEssensration( int rationssatz ) { if ( rationssatz == 1 ) { this.essensration = 1; } else if ( rationssatz == 2 ) { this.essensration = 2; } else if ( rationssatz == 3 ) { this.essensration = 4; } }
051cf00e-6e3f-4fa0-b563-3ed07d5ac679
5
@EventHandler public void onClick(PlayerInteractEvent e){ Player p = e.getPlayer(); if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){ if(p.getInventory().getItemInHand().equals(guns.ChickenGun())){ p.getWorld().spawnEntity(p.getEyeLocation(), EntityType.CHICKEN); for(final Entity ent : p.getNearbyEntities(1,1,1)) { if (ent instanceof Chicken) { ent.setVelocity(p.getLocation().getDirection().multiply(3.0)); p.sendMessage("test"); Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() { @Override public void run() { ent.getWorld().createExplosion(ent.getLocation(), 5F, false); } }, 20*4L); } } } } }
218a65cc-003e-4197-85b1-95156374159d
1
public Cell(int x, int y) { // Passing default values to prevent null pointer exceptions during testing this.pos[0] = x; this.pos[1] = y; this.rock = false; this.adjacentAntsBlack = 0; this.adjacentAntsRed = 0; this.anthill = "none"; this.food = 0; for (int i = 0; i < 6; i++) { markersRed[i] = false; markersBlack[i] = false; } }
750ffd61-f333-43f6-809d-38a379015d5f
8
public int[] getIntArrayArgument(String name, boolean required){ if(M.containsKey(name)) { String a = M.get(name).trim(); if("iI".indexOf(a.charAt(0)) == -1){illFormedArray(a," expected integer array");} if(a.charAt(1) != '[' || a.charAt(a.length()-1) != ']'){illFormedArray(a,"");} String[] parts = a.split(":"); if(parts.length != 3){illFormedArray(a,"");} int start = Integer.parseInt(parts[0].trim().substring(2)); int step = Integer.parseInt(parts[1].trim()); int stop = Integer.parseInt(parts[2].trim().substring(0,parts[2].trim().length()-1)); int l = ((stop-start)/step) +1; int[] res = new int[l]; int i =0; while(i< res.length && start <= stop) { res[i++] = start; start += step; } return res; } else { if(required) { argumentMissing(name); } } return null; }
912cc8b7-9993-4751-86af-41c1b21869c0
0
public AbstractFileProtocol() {}
f8254cf8-ca9e-4b2a-a088-f06f145e4735
8
public boolean contains(Info otherInfo) { if ((otherInfo.color != null && otherInfo.color != color) || (otherInfo.size != null && otherInfo.size != size) || (otherInfo.location != null && otherInfo.location != location) || (otherInfo.image != null) && otherInfo.image != image) { return false; } return true; }
8c7b4f00-c463-42f5-8c62-3e48554a5468
9
public int tally(int[] parValue, String[] scoreSheet) { int total = 0; for(int i = 0; i < parValue.length; i++){ int current = 0; if(scoreSheet[i].equals("double bogey")){ current = parValue[i] + 2; }else if(scoreSheet[i].equals("bogey")){ current = parValue[i] + 1; }else if(scoreSheet[i].equals("par")){ current = parValue[i]; }else if(scoreSheet[i].equals("birdie")){ current = parValue[i] - 1; }else if(scoreSheet[i].equals("eagle")){ current = parValue[i] - 2; }else if(scoreSheet[i].equals("albatross")){ current = parValue[i] - 3; }else if(scoreSheet[i].equals("hole in one")){ current = 1; }else if(scoreSheet[i].equals("triple bogey")){ current = parValue[i] + 3; } total += current; } return total; }
b80bd41c-86ae-4efe-8720-0049f4c94f8c
7
public void renderSprite(int xp, int yp, Sprite sprite, boolean fixed) { if (fixed) { xp -= xOffset; yp -= yOffset; } for (int y = 0; y < sprite.getHeight(); y++) { int ya = y + yp; for (int x = 0; x < sprite.getWidth(); x++) { int xa = x + xp; if (xa < 0 || xa >= width || ya < 0 || ya >= height) continue; pixels[xa + ya * width] = sprite.pixels[x + y * sprite.getWidth()]; } } }
800de0d6-0849-41b3-9494-3e73834cb637
5
public static ArrayList<ArrayList<Integer>> generate(int numRows) { ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>(); if (numRows == 0){ return result; } for (int i = 0;i<numRows;i++){ ArrayList<Integer> temp = new ArrayList<Integer>(); for (int j = 0;j<=i;j++){ if(j==0||j==i){ temp.add(1); } else { temp.add(result.get(i-1).get(j-1)+result.get(i-1).get(j)); } } result.add(temp); } return result; }
df25f56f-c1cd-4240-bf4a-3d63a64ef110
9
public synchronized void unlock() { if (ASSERTS && owner != Thread.currentThread()) { Thread.dumpStack(); throw new IllegalLockStateException("Don't own monitor"); } locked = false; if (waiters > 0) { if (STATISTICS) { unlock_waiting++; unlock_waiters += waiters; } if (!PRIORITY || prio_waiters == waiters) { if (STATISTICS) { unlock_waiting++; } // either no prio -> wake up anybody // or prio and only prio waiters -> wake up a prio waiter notify(); } else { // Sorry, there are prio and nonprio waiters. To be sure a // prio waiter comes alive, we have no choice but to wake all. if (STATISTICS) { unlock_bcast++; } notifyAll(); } } if (ASSERTS) { owner = null; } }
a5b712dc-8a69-4547-a393-d9cd2b79b5c9
2
private static final int reduce(int current, int desired) { if (current > desired) { current -= current / 7; if (current < desired) { current = desired; } } return current; }
661bc12b-c815-4152-a4e1-e3b6260d73d7
9
private boolean SingleLineConditionCheck(String type,String string){ Scanner scanner = new Scanner(string); boolean condition = false; scanner.useDelimiter(type+"\t*"); while(scanner.hasNext()){ String getcontent = scanner.next(); if(type.equals("name")){ if(this.NameFieldCheck(getcontent)){ condition =true; } else{ condition =false; } } else if(type.equals("birthday")){ if(this.BirthdayFieldCheck(getcontent)){ condition =true; } else{ condition =false; } } else if(type.equals("phone")){ if(this.PhoneFieldCheck(getcontent)){ condition =true; } else{ condition =false; } } else if(type.equals("email")){ if(this.MailFieldCheck(getcontent)){ condition =true; } else{ condition =false; } } } scanner.close(); return condition; }
e0c9555c-a9a9-4f31-8585-8ca67b1a9468
6
private int unaryExecute(int i) { switch(sim40.memory[i]) { /* Unary Instructions */ case 4: /* cclear */ switchOffFlag(2); break; case 5: /* cset */ switchOnFlag(2); break; case 6: /* xinc */ sim40.memory[Simulator.XREG_ADDRESS]++; checkResetOverflow(Simulator.XREG_ADDRESS); break; case 7: /* xdec */ sim40.memory[Simulator.XREG_ADDRESS]--; checkResetUnderflow(Simulator.YREG_ADDRESS); break; case 8: /* yinc */ sim40.memory[Simulator.YREG_ADDRESS]++; checkResetOverflow(Simulator.YREG_ADDRESS); break; case 9: /* ydec */ sim40.memory[Simulator.YREG_ADDRESS]--; checkResetUnderflow(Simulator.YREG_ADDRESS); break; } return ++i; }
2f7c5b92-33bf-4735-bd3d-e35372f49300
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Client other = (Client) obj; if (this.ip == null) { if (other.ip != null) return false; } else if (!this.ip.equals(other.ip)) return false; if (this.tcpPort != other.tcpPort) return false; return true; }
8a078aaa-adc0-4fc5-910c-ee457b5cfaed
2
public void put(Node node, long key) { try { if (node.previous != null) { node.unlink(); } Node previous = cache[(int) (key & size - 1)]; node.previous = previous.previous; node.next = previous; node.previous.next = node; node.next.previous = node; node.hash = key; return; } catch (RuntimeException runtimeexception) { Signlink.reporterror("91499, " + node + ", " + key + ", " + (byte) 7 + ", " + runtimeexception.toString()); } throw new RuntimeException(); }
ce8a7e32-7239-4d70-8876-ee1eea09ac06
5
public boolean isPerson(String word) { int i; // Teste referente ao tamanho da palavra, excluindo palavras com menos // de 3 caracteres e mais de 10. // if (word.length() < 3 || word.length() > 10) { return false; } // Teste referente a primeira letra da palavra ser maiúscula, indicando // nome de pessoa em caso geral. // if (word.charAt(0) != 'A') { return false; } // Teste de ocorrência de letra maiúscula no restante da palavra, indicando // não se tratar de um nome próprio e sim de uma sigla de Organização ou falha // ocorrente na palavra // for (i = 1; i < word.length(); i++) { if (Character.isUpperCase(word.charAt(i))) { return false; } } return true; }
cb122e50-08e3-4f7c-9678-138ebe7b0c5b
8
private static boolean canInvokeWithArguments(Method method, Object[] arguments) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != arguments.length) { return false; } for (int index = 0; index < arguments.length; index++) { Class<?> argumentType = (arguments[index] == null) ? null : arguments[index].getClass(); if (argumentType == null || BeansUtils.isPrimitiveWrapper(argumentType, parameterTypes[index])) { continue; } if (!argumentType.isAssignableFrom(parameterTypes[index])) { return false; } } return true; }
e1f5580c-117b-42d9-82da-00d3330514f7
6
public AIUnit yieldUnit(UnitType ut, AIObject o) { float unitWeight = 99f; AIUnit yieldedUnit = null; boolean isOwnUnit = false; Iterator<AIUnit> uit = getOwnedAIUnitsIterator(); while (uit.hasNext()) { AIUnit u = uit.next(); //all units in one goal have the same weight, so no need to compare if (u.getUnit().getType().equals(ut)) { unitWeight = getAbsoluteWeight(); yieldedUnit = u; isOwnUnit = true; } } //check subgoals Iterator<Goal> git = getSubGoalIterator(); while (git!=null && git.hasNext()) { Goal g = git.next(); float newWeight = g.getYieldedUnitWeight(ut, o); if (newWeight < unitWeight) { unitWeight = newWeight; yieldedUnit = g.yieldUnit(ut, o); isOwnUnit = false; } } if (isOwnUnit) { removeUnit(yieldedUnit); needsPlanning = true; } return yieldedUnit; }
dd3f76a8-b172-452c-be7b-0541db3b3d1d
3
public static void backTrace (int[][] s, int[][] c, int f, int e, int base) { if ( e == 0 || f == 0 ) { return; } int p = c[f][e]; System.out.println(String.format("floor: %d, egg: %d, choose %d", f, e, p+base) ); if ( s[p-1][e-1] > s[f-p][e] ) { backTrace(s, c, p-1, e-1, base); } else { backTrace(s, c, f-p, e, base+p); } }
efd15754-630c-48e9-8e9c-1b818e4e1589
3
public IllegalOrphanException(List<String> messages) { super((messages != null && messages.size() > 0 ? messages.get(0) : null)); if (messages == null) { this.messages = new ArrayList<String>(); } else { this.messages = messages; } }
edebdd10-114b-4995-9867-be50d26a40ae
2
protected int findColumnStrict(String col) throws IllegalArgumentException { if (col == null) { throw new IllegalArgumentException("Got null column name."); } int val = columnNames.indexOf(col); if (val < 0) { throw new IllegalArgumentException("Invalid column: " + col); } return val + 1; }
5cdf93b3-ee65-4c4e-b434-196b91810683
0
protected void match(int w, int j) { matchJobByWorker[w] = j; matchWorkerByJob[j] = w; }
6b17a246-f23b-4f9d-a2ab-c4dcfc4687cb
8
private void createOpdrachtLink(Opdracht opdracht) { String type = opdracht.getClass().getSimpleName(); Connection con = maakVerbinding(); PreparedStatement createLink = null; if (type.equals("EenvoudigeOpdracht")) { try { createLink = con.prepareStatement(insertEenvoudigeOpdracht); createLink.setInt(1, eenvoudigeOpdrachtID); createLink.setInt(2, opdrachtID); eenvoudigeOpdrachtID++; createLink.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } else if (type.equals("Opsomming")) { try { createLink = con.prepareStatement(insertOpsomming); // createLink.setInt(1, opsommingID); createLink.setInt(1, opdrachtID); createLink.setBoolean(2, ((Opsomming) opdracht).getInJuisteVolgorde()); opsommingID++; createLink.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } else if (type.equals("Meerkeuze")) { try { createLink = con.prepareStatement(insertMeerkeuze); // createLink.setInt(1, meerkeuzeID); createLink.setInt(1, opdrachtID); createLink.setString(2, ((Meerkeuze) opdracht).getMeerkeuze()); meerkeuzeID++; createLink.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } else if (type.equals("Reproductie")) { try { createLink = con.prepareStatement(insertReproductie); // createLink.setInt(1, reproductieID); createLink.setInt(1, opdrachtID); createLink.setString(2, ((Reproductie) opdracht).getAntwoord()); createLink.setInt(3, ((Reproductie) opdracht) .getMinAantalJuisteTrefwoorden()); reproductieID++; createLink.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } else { System.out.println("fucking hell waarom lukt het niet " + type); } }
7cd989f4-56b4-4ab9-b617-ad5bcf56cbd0
5
@Override public void run() { for(int i = 0; i<active.length; i++){ for(int j = 0; j<active[0].length; j++){ if (strengthMap[i][j] != 0 && active[i][j] == Board.VISUAL_EMPTY_AREA){ active[i][j] = strengthMap[i][j] == Tetromino.STRENGTH_MANA ? Board.VISUAL_MANA_ORB : ViewController.getRandomVisual(); } } } }
0281a1dc-d20d-47f4-8640-ec9aed57661c
9
private AccessToken requestAccessToken(Map<String, String> params) throws AuthorizationException { try { HttpRequest request = HttpRequest.post("https://graph.renren.com/oauth/token"); request.form(params); int statusCode = request.code(); String body = request.body(); JSONObject response = new JSONObject(body); if (statusCode == HttpURLConnection.HTTP_OK && response.has("access_token")) { String accessToken = response.getString("access_token"); String refreshToken = response.has("refresh_token") ? response .getString("refresh_token") : null; String macKey = response.has("mac_key") ? response.getString("mac_key") : null; String macAlgorithm = response.has("mac_algorithm") ? response .getString("mac_algorithm") : null; AccessToken.Type type = response.has("mac_algorithm") && response.has("mac_algorithm") ? AccessToken.Type.MAC : AccessToken.Type.Bearer; return new AccessToken(type, accessToken, refreshToken, macKey, macAlgorithm); } else { throw new AuthorizationException("Authorization failed with Authorization Code. " + response.getString("error") + ": " + response.getString("error_description")); } } catch (HttpRequestException e) { throw new AuthorizationException("Authorization failed. Failed to send http request"); } catch (JSONException e) { throw new AuthorizationException("Parse OAuth response failed. " + e.getMessage()); } }
47b8db37-0fa3-4a2f-a776-3bf02a47a994
6
final public String literalPredicate() throws ParseException { Token argument=null; // LiteralVariable lv=null; String predicate=null; if (jj_2_30(7)) { argument = jj_consume_token(NUMBER); } else if (jj_2_31(7)) { predicate = literalFunction(); } else if (jj_2_32(7)) { argument = jj_consume_token(STRING); } else { jj_consume_token(-1); throw new ParseException(); } // if (null!=lv) { // String preds=lv.getPredicateString(); // return preds.substring(1,preds.length()-1); // } if (null!=predicate) {if (true) return predicate;} {if (true) return argument.image;} throw new Error("Missing return statement in function"); }
8c4c17f7-59ad-4ba2-a171-069fb2f5b62a
0
public String getToolTip() { return "De-expressionify Transition"; }
807a3c48-0a78-4a6c-b914-5b749aae161f
9
public void useTransportableTool(State state, ObjectInstance tool, ObjectInstance container, String agent) { if (ToolFactory.isEmpty(tool)) { Set<String> contentNames = ContainerFactory.getContentNames(container); Set<String> includes = ToolFactory.getIncludes(tool); Set<String> excludes = ToolFactory.getExcludes(tool); if (!includes.isEmpty()) { // only add the ingredients that have the trait we're trying to includes for (String name : contentNames) { ObjectInstance ingredient = state.getObject(name); for (String trait : includes) { if (IngredientFactory.getTraits(ingredient).contains(trait)) { ToolFactory.addIngredientToTool(state, tool, ingredient); break; } } } } else { // Add all ingredients but those with the traits we're trying to exclude for (String name : contentNames) { ObjectInstance ingredient = state.getObject(name); boolean exclude = false; for (String trait : excludes) { if (IngredientFactory.getTraits(ingredient).contains(trait)) { exclude = true; break; } } if (!exclude) { ToolFactory.addIngredientToTool(state, tool, ingredient); } } } } else { ToolFactory.pourIngredients(domain, state, tool, container, agent); } }
8183603d-fb2e-4577-a98d-673a22449a6b
9
public int search(int[] A, int target) { if (A == null || A.length == 0) return -1; int leftIndex = 0; int rightIndex = A.length - 1; int middle; while (leftIndex <= rightIndex) { middle = leftIndex + (rightIndex - leftIndex)/2; if (A[middle] == target) return middle; // the left part of array are sorted if (A[leftIndex] < A[middle]) { if (target >= A[leftIndex] && target < A[middle]) { // the target failed into left side rightIndex = middle - 1; } else { leftIndex = middle + 1; } } // the right part of array are sorted else { if (target > A [middle] && target <= A[rightIndex]) { leftIndex = middle + 1; } else { rightIndex = middle - 1; } } } return -1; }
7fe4626a-d8e1-47a1-96cf-bf9513b788af
9
public int method304(int i, int j, int k, int l) { Ground class30_sub3 = groundArray[i][j][k]; if(class30_sub3 == null) return -1; if(class30_sub3.obj1 != null && class30_sub3.obj1.uid == l) return class30_sub3.obj1.aByte281 & 0xff; if(class30_sub3.obj2 != null && class30_sub3.obj2.uid == l) return class30_sub3.obj2.aByte506 & 0xff; if(class30_sub3.obj3 != null && class30_sub3.obj3.uid == l) return class30_sub3.obj3.aByte816 & 0xff; for(int i1 = 0; i1 < class30_sub3.anInt1317; i1++) if(class30_sub3.obj5Array[i1].uid == l) return class30_sub3.obj5Array[i1].aByte530 & 0xff; return -1; }
a81d3ff4-e6b0-42ef-afcf-360d5bfe7edd
8
public void step(SimState state) {//2 prey in same state with mating motor neuron firing final WallBuilding wb = (WallBuilding)state; if((wb.prey.allObjects.size() < WallBuilding.PREY_CAP) && WallBuilding.DO_PREY_CAP){//this is a bit harsh, but I need it! AND BROKEN for(int x = 0; x < WallBuilding.GRID_WIDTH; x++){ for(int y = 0; y < WallBuilding.GRID_HEIGHT; y++){ if(wb.prey.numObjectsAtLocation(x,y) >1){ Bag preyAtLocation = wb.prey.getObjectsAtLocation(x,y); Bag matePrey = new Bag(); for(int i = 0; i < preyAtLocation.size(); i++){//make a bag of those who WANT to mate if(((Prey)preyAtLocation.get(i)).canMate()){ matePrey.add(preyAtLocation.get(i)); } } for(int i = 0; i+1 < matePrey.size(); i += 2){ Prey parent1 = (Prey)matePrey.get(i); Prey parent2 = (Prey)matePrey.get(i+1); double[] childEncoding = EvolutionEngine.evolve(parent1.getNNDirectEncoding(), parent2.getNNDirectEncoding()); Prey child = new Prey(childEncoding); wb.prey.setObjectLocation(child, x, y); child.setStoppable(wb.schedule.scheduleRepeating(wb.schedule.getSteps()+2, 1, child, 2)); parent1.resetMating(); parent2.resetMating(); } } } } } }
b9b941c4-70d1-4e38-b584-fe5545c4e8c1
7
private static void setPropertyFromString(String line) { line = line.trim(); /* ignore blank lines */ if (line.equals("")) return; /* ignore comments */ if (line.startsWith("//")) return; if (line.startsWith("##")) return; /* ignore lines that do not have a space in them */ if (line.indexOf(" ") == -1) return; /* getting the property name and the propert value */ String propertyName = line.substring(0, line.indexOf(" ")); String propertyValue = line.substring(line.indexOf(" ") + 1, line.length()); //Files if (propertyName.equals("annotationFile")) annotationFile = propertyValue.trim(); if (propertyName.equals("peppyFileDirectory")) peppyFileDirectory = propertyValue.trim(); if (propertyName.equals("outputDir")) outputDir = propertyValue.trim(); }
c43e41eb-f70d-418b-a707-c579c51494d4
9
void processResponseHeaders(Map<String, List<String>> resHeaders) { for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) { String name = entry.getKey(); if (name == null) continue; // http/1.1 line List<String> values = entry.getValue(); if (name.equalsIgnoreCase("Set-Cookie")) { for (String value : values) { if (value == null) continue; TokenQueue cd = new TokenQueue(value); String cookieName = cd.chompTo("=").trim(); String cookieVal = cd.consumeTo(";").trim(); if (cookieVal == null) cookieVal = ""; // ignores path, date, domain, secure et al. req'd? // name not blank, value not null if (cookieName != null && cookieName.length() > 0) cookie(cookieName, cookieVal); } } else { // only take the first instance of each header if (!values.isEmpty()) header(name, values.get(0)); } } }
4b75494a-7117-4ad1-9dbf-18c19d54f21e
7
public static <T extends DC> Set<Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>>> getAllPhis(Set<Pair<PT<Integer>,T>> baseSetA, Set<Pair<PT<Integer>,T>> baseSetB) { Set<Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>>> allPhis=null; if(baseSetA==null || baseSetB==null) { return allPhis; } else//baseSetA!=null && baseSetB!=null { Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>> allPairs=getAllPairs(baseSetA,baseSetB); if(allPairs.size()==1) { return new Set(allPairs,null); } else//allPairs.size()!=1 { for(Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>> p=allPairs;p!=null;p=p.getNext()) { Set<Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>>> onePairSets=despatch(p.getFst(),getAllPhis(baseSetA.del(p.getFst().fst()),baseSetB.del(p.getFst().snd()))); if(allPhis==null) { allPhis=new Set(onePairSets.getFst(),null); for(Set<Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>>> t=onePairSets;t!=null;t=t.getNext()) { allPhis=allPhis.ins(t.getFst());} } else { for(Set<Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>>> t=onePairSets;t!=null;t=t.getNext()) { allPhis=allPhis.ins(t.getFst());} } } return allPhis; } } }
f9b97429-d13e-4466-b995-8038fa291111
9
public static Direction getOppositeDirection(Direction d) { switch(d) { case SOUTHWEST : return NORTHEAST; case SOUTH : return NORTH; case SOUTHEAST : return NORTHWEST; case WEST : return EAST; case NONE : return NONE; case EAST : return WEST; case NORTHWEST : return SOUTHEAST; case NORTH : return SOUTH; case NORTHEAST : return NORTHWEST; } return NONE; }
b8473c03-0436-46ca-9e5d-db15bb6a65a8
6
@DELETE @Path("/{idres}") public void deleteResena(@PathParam("idres") String idres) { String username; Connection conn = null; Statement stmt = null; String sql; ResultSet rs; try { conn = ds.getConnection(); } catch (SQLException e) { throw new ServiceUnavailableException(e.getMessage()); } try { stmt = conn.createStatement(); sql = "SELECT * FROM resenas WHERE idres='" + idres + "'"; rs = stmt.executeQuery(sql); if (!rs.next()) { throw new ResenaNotFoundException(); } // rs.next(); username = rs.getString("username"); } catch (SQLException e) { throw new ResenaNotFoundException(); } if (security.getUserPrincipal().getName().equals(username)) { try { stmt = conn.createStatement(); sql = "DELETE FROM resenas WHERE idres='" + idres + "'and username='" + username + "'"; stmt.executeUpdate(sql); } catch (SQLException e) { throw new InternalServerException(e.getMessage()); } finally { try { stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } else { throw new NotAllowedException(); } }
ff063649-4881-489e-9ac1-9f4ceca9977a
1
public int saveUser(User userToSave) { try { // Erforderlicher SQL-Befehl String sqlStatement = "INSERT INTO bookworm_database.users VALUES (default, '" + userToSave.getUserName() + "', md5('" + userToSave.getUserPassword() + "'), '" + userToSave.getUserRole() + "');"; // SQL-Befehl wird ausgeführt successful = mySQLDatabase.executeSQLUpdate(sqlStatement); return successful; } catch (Exception e) { System.out.println(e.toString()); // Ein Dialogfenster mit entsprechender Meldung soll erzeugt werden String errorText = "Datenbank-Fehler beim Abspeichern eines Datensatzes"; errorMessage.showMessage(errorText); successful = 0; return successful; } finally { // offene Verbindungen werden geschlossen mySQLDatabase.closeConnections(); } }
2324cfbe-20db-420a-a5fd-05e213dce3f0
5
public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj instanceof Position) { Position other = (Position)obj; if (super.equals(obj) && other.z == z) { return true; } } return false; }
c3118ff8-1b85-4b85-b732-fa42a25709f1
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Resource other = (Resource) obj; if (price != other.price) return false; if (resourceType == null) { if (other.resourceType != null) return false; } else if (!resourceType.equals(other.resourceType)) return false; return true; }
d1a6e36b-682d-4028-858b-ae0e56c0d5ce
1
public Type getComponent() { return dims == 1 ? (Type)component : new MultiArrayType(component, dims - 1); }
60cb18b1-2c28-402c-9e9c-fa89034c68ec
5
public byte[] read(long pos,int length){byte[] b=new byte[length]; try{if(VRAM){long[] disk;long end=pos+length;int r=0; System.out.println("Read Ram Address: Position="+pos+",End="+end+""); while(pos<end){disk=VraToPh(pos); System.out.println("Reading Section: Position="+disk[0]+",End="+(disk[0]+disk[1])+""); if(disk[0]>0){Data.seek(disk[0]);if(disk[1]<(length)){Data.read(b,r,(int)disk[1]);}else{Data.read(b,r,length);}} r+=disk[1];pos+=disk[1];}}else{Data.seek(pos);Data.read(b,0,b.length);}}catch(Exception e){System.out.println("READING ERROR");}; return(b);}
112e71ba-b240-4a36-a847-9602daf05566
8
int numroots(int np, poly sseq[], int at[]) { int atposinf, atneginf, s; double f, lf; atposinf = atneginf = 0; /* * changes at positive infinity */ lf = sseq[0].coef[sseq[0].ord]; for ( s = 1; s <= np; s++ ){ f = sseq[s].coef[sseq[s].ord]; if (lf == 0.0 || lf * f < 0) atposinf++; lf = f; } /* * changes at negative infinity */ if ( (sseq[0].ord & 1) != 0 ) lf = -sseq[0].coef[sseq[0].ord]; else lf = sseq[0].coef[sseq[0].ord]; for (s = 1; s <= np; s++ ) { if ( ( sseq[s].ord & 1 ) != 0 ) f = -sseq[s].coef[sseq[s].ord]; else f = sseq[s].coef[sseq[s].ord]; if (lf == 0 || lf * f < 0) atneginf++; lf = f; } at[0] = atneginf; at[1] = atposinf; // printf("atneginf, atposinf = %d %d\n", atneginf, atposinf); return(atneginf - atposinf); }
99590679-7ab1-4541-b5c4-5e33ac26d999
0
@Override public boolean supportsAttributes() {return true;}
59649e21-f3ca-4c7a-aa09-f4fa79f20ffa
9
public void create(TipoFreio tipoFreio) { if (tipoFreio.getConfiguracaoFreioCollection() == null) { tipoFreio.setConfiguracaoFreioCollection(new ArrayList<ConfiguracaoFreio>()); } if (tipoFreio.getConfiguracaoFreioCollection1() == null) { tipoFreio.setConfiguracaoFreioCollection1(new ArrayList<ConfiguracaoFreio>()); } EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); Collection<ConfiguracaoFreio> attachedConfiguracaoFreioCollection = new ArrayList<ConfiguracaoFreio>(); for (ConfiguracaoFreio configuracaoFreioCollectionConfiguracaoFreioToAttach : tipoFreio.getConfiguracaoFreioCollection()) { configuracaoFreioCollectionConfiguracaoFreioToAttach = em.getReference(configuracaoFreioCollectionConfiguracaoFreioToAttach.getClass(), configuracaoFreioCollectionConfiguracaoFreioToAttach.getCodigoConfiguracaoFreio()); attachedConfiguracaoFreioCollection.add(configuracaoFreioCollectionConfiguracaoFreioToAttach); } tipoFreio.setConfiguracaoFreioCollection(attachedConfiguracaoFreioCollection); Collection<ConfiguracaoFreio> attachedConfiguracaoFreioCollection1 = new ArrayList<ConfiguracaoFreio>(); for (ConfiguracaoFreio configuracaoFreioCollection1ConfiguracaoFreioToAttach : tipoFreio.getConfiguracaoFreioCollection1()) { configuracaoFreioCollection1ConfiguracaoFreioToAttach = em.getReference(configuracaoFreioCollection1ConfiguracaoFreioToAttach.getClass(), configuracaoFreioCollection1ConfiguracaoFreioToAttach.getCodigoConfiguracaoFreio()); attachedConfiguracaoFreioCollection1.add(configuracaoFreioCollection1ConfiguracaoFreioToAttach); } tipoFreio.setConfiguracaoFreioCollection1(attachedConfiguracaoFreioCollection1); em.persist(tipoFreio); for (ConfiguracaoFreio configuracaoFreioCollectionConfiguracaoFreio : tipoFreio.getConfiguracaoFreioCollection()) { TipoFreio oldCodigoTipoFreioTraseiroOfConfiguracaoFreioCollectionConfiguracaoFreio = configuracaoFreioCollectionConfiguracaoFreio.getCodigoTipoFreioTraseiro(); configuracaoFreioCollectionConfiguracaoFreio.setCodigoTipoFreioTraseiro(tipoFreio); configuracaoFreioCollectionConfiguracaoFreio = em.merge(configuracaoFreioCollectionConfiguracaoFreio); if (oldCodigoTipoFreioTraseiroOfConfiguracaoFreioCollectionConfiguracaoFreio != null) { oldCodigoTipoFreioTraseiroOfConfiguracaoFreioCollectionConfiguracaoFreio.getConfiguracaoFreioCollection().remove(configuracaoFreioCollectionConfiguracaoFreio); oldCodigoTipoFreioTraseiroOfConfiguracaoFreioCollectionConfiguracaoFreio = em.merge(oldCodigoTipoFreioTraseiroOfConfiguracaoFreioCollectionConfiguracaoFreio); } } for (ConfiguracaoFreio configuracaoFreioCollection1ConfiguracaoFreio : tipoFreio.getConfiguracaoFreioCollection1()) { TipoFreio oldCodigoTipoFreioDianteiroOfConfiguracaoFreioCollection1ConfiguracaoFreio = configuracaoFreioCollection1ConfiguracaoFreio.getCodigoTipoFreioDianteiro(); configuracaoFreioCollection1ConfiguracaoFreio.setCodigoTipoFreioDianteiro(tipoFreio); configuracaoFreioCollection1ConfiguracaoFreio = em.merge(configuracaoFreioCollection1ConfiguracaoFreio); if (oldCodigoTipoFreioDianteiroOfConfiguracaoFreioCollection1ConfiguracaoFreio != null) { oldCodigoTipoFreioDianteiroOfConfiguracaoFreioCollection1ConfiguracaoFreio.getConfiguracaoFreioCollection1().remove(configuracaoFreioCollection1ConfiguracaoFreio); oldCodigoTipoFreioDianteiroOfConfiguracaoFreioCollection1ConfiguracaoFreio = em.merge(oldCodigoTipoFreioDianteiroOfConfiguracaoFreioCollection1ConfiguracaoFreio); } } em.getTransaction().commit(); } finally { if (em != null) { em.close(); } } }
8fa9c7fc-3bbb-43be-8c55-80a60ae7d6d2
5
@Test public void depth0opponent1() { for(int i = 0; i < BIG_INT; i++) { int numPlayers = 2; //assume/require > 1, < 7 Player[] playerList = new Player[numPlayers]; ArrayList<Color> factionList = Faction.allFactions(); playerList[0] = new Player(chooseFaction(factionList), new SimpleAI()); playerList[1] = new Player(chooseFaction(factionList), new DepthAI(0)); Color check = playerList[1].getFaction(); GameState state = new GameState(playerList, new Board(), gameDeck, gameBag, score); Set<Player> winners = Game.run(state, new StandardSettings()); boolean won = false; for(Player p : winners) { if(p.getFaction().equals(check)) { won = true; wins++; if(winners.size() > 1) { tie++; } } } if(!won) { loss++; } } assertEquals(true, wins/(wins+loss) > .9); }
83acb4a4-6405-4b3c-b100-8d6dc7a68ee3
5
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { BeanFilter_train bf_train = null; try { bf_train = new BeanFilter_train(); if("yahoo".equals(request.getParameter("datasource"))){ //使用yahoofinance資料來源 bf_train.setRDataSource(request.getParameter("trainStockSymbol"),request.getParameter("trainStartDate"),request.getParameter("trainEndDate")); request.setAttribute("trainStartDatetime", request.getParameter("trainStartDate")); request.setAttribute("trainEndDatetime", request.getParameter("trainEndDate")); }else if("db".equals(request.getParameter("datasource"))){ ServletContext sc = this.getServletConfig().getServletContext(); bf_train.setRDataSource(sc,request.getParameter("trainStockSymbol"),request.getParameter("trainStartDate"),request.getParameter("trainStartTime"),request.getParameter("trainEndDate"),request.getParameter("trainEndTime")); request.setAttribute("trainStartDatetime", request.getParameter("trainStartDate") + " " + request.getParameter("trainStartTime")); request.setAttribute("trainEndDatetime", request.getParameter("trainEndDate") + " " + request.getParameter("trainEndTime")); } bf_train.excute(); } catch (Exception ex) { throw new ServletException(ex); }finally{ //關閉Rconnection連結 if(bf_train!=null) try { bf_train.closeRconn(); } catch (RserveException ex) { throw new ServletException(ex); } } String bestn = bf_train.getBestN(); String bestk = bf_train.getBestK(); request.setAttribute("Bestn", bestn); request.setAttribute("Bestk", bestk); request.getRequestDispatcher("/WEB-INF/FilterPages/training/displayFilter_train.jsp").forward(request, response); }
d043848b-b225-419c-a383-60c183f5a54c
6
static private boolean jj_3R_10() { if (jj_scan_token(ACTOR)) return true; if (jj_scan_token(TYPEIDENT)) return true; if (jj_scan_token(LBRACE)) return true; Token xsp; if (jj_3_4()) return true; while (true) { xsp = jj_scanpos; if (jj_3_4()) { jj_scanpos = xsp; break; } } return false; }
5a99966b-dc7a-4c72-a362-175008975242
0
public EncoderDrive(double goal, double driveSpeed){ _goal = goal; _driveSpeed = driveSpeed; requires(Robot.driveTrain); }
bab4d79f-b958-46c6-b448-bbda93056830
4
public void book_search(Member loginmem) throws Exception{ int a=0; //ִܿµ & ԷѴܾԵȸ絵Ѵ. String newtitle; do{ System.out.println("*******************************************************************"); System.out.print(":"); newtitle = scan.next(); if(bookcollect.getequal2(newtitle)==1){ a=1; //˻ bookcollect.print(newtitle); System.out.println("*******************************************************************"); } else{ //˻ġϴ a=2; } }while(a ==0); if(a==1){ System.out.println("˻ѴܾѸå̰˻Ǿϴ!"); System.out.println("*******************************************************************"); student_menu(loginmem); } else if(a==2){ System.out.println("˻ġϴ°ϴ!"); System.out.println("*******************************************************************"); student_menu(loginmem); } }
44b1c9a6-139b-430d-8d6b-2f9881e07d4e
7
static private int jjMoveStringLiteralDfa0_0() { switch(curChar) { case 40: return jjStopAtPos(0, 12); case 41: return jjStopAtPos(0, 13); case 42: return jjStopAtPos(0, 7); case 43: return jjStopAtPos(0, 5); case 45: return jjStopAtPos(0, 6); case 47: return jjStopAtPos(0, 8); case 59: return jjStopAtPos(0, 11); default : return jjMoveNfa_0(0, 0); } }
9c4e67b4-6f65-483f-96ca-d71ba8cbe10d
1
public int puntajeTotal(){ int acum =0; for(Pregunta pregunta: preguntas) { acum= acum + pregunta.puntaje; } return acum; }
57f04b8e-f853-4162-b3d9-3f958b20c784
0
public Transition copy(State from, State to) { return new MooreTransition(from, to, getLabel(), getOutput()); }
5f70c0bb-77a8-4b46-84d4-6a9aa48707cb
1
public void winn() { SoundManager.play("win"); hasWinn = true; player.setWinn(true); new Thread(new Runnable() { public void run() { try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } getStageManager().setStatge(StageManager.STAGE_SHOP, null); } }).start(); PlayerData.playerData.setCoins(PlayerData.playerData.getCoins() + 20); PlayerData.save(); }
e9e79b76-5a12-456d-9025-605fe98302e3
9
public void accessCell(int accessType,int x,int y) { if (accessType == 0) { //reveal if (!cells[x][y].getRevealed() && !cells[x][y].getFlagged()) { //note if a cell is flagged in cannot be revealed until unflagged score--; cells[x][y].setRevealed(true); if (cells[x][y].getMined()) { //this is the game over condition, a cell containing a mine is clicked cells[x][y].setExploded(true); gameOver(); //as such it triggers the gameOver method } else { revealAdjacentSquares(x,y); } } } else if (accessType == 1) { //flag if (!cells[x][y].getRevealed() && !cells[x][y].getFlagged() && getFlagsRemaining() > 0) { //flag the cell score--; //note that score is in both the if and else if rather than simply executing before the if statement, this is because if the if or else if are not true, the score should not be decremented, as the user has not taken an action cells[x][y].setFlagged(true); flagsRemaining--; } else if(cells[x][y].getFlagged()) { //unflag the cell score--; cells[x][y].setFlagged(false); flagsRemaining++; } } checkWinCondition(); setChanged(); notifyObservers(); //to update the view of the board }
305eeb43-077b-4d30-a40c-2532c0d104ec
3
public CtMember compile(String src) throws CompileError { Parser p = new Parser(new Lex(src)); ASTList mem = p.parseMember1(stable); try { if (mem instanceof FieldDecl) return compileField((FieldDecl)mem); else { CtBehavior cb = compileMethod(p, (MethodDecl)mem); CtClass decl = cb.getDeclaringClass(); cb.getMethodInfo2() .rebuildStackMapIf6(decl.getClassPool(), decl.getClassFile2()); return cb; } } catch (BadBytecode bb) { throw new CompileError(bb.getMessage()); } catch (CannotCompileException e) { throw new CompileError(e.getMessage()); } }
8d63eb17-af2d-44b8-aa27-368751eb4432
6
final boolean method2500(int i, int i_0_) { if (!((Class318_Sub3) this).aBoolean6401) return false; int i_1_ = (((Class318_Sub3) this).anInt6406 - ((Class318_Sub3) this).anInt6405); int i_2_ = (((Class318_Sub3) this).anInt6404 - ((Class318_Sub3) this).anInt6402); int i_3_ = i_1_ * i_1_ + i_2_ * i_2_; int i_4_ = (i * i_1_ + i_0_ * i_2_ - (((Class318_Sub3) this).anInt6405 * i_1_ + ((Class318_Sub3) this).anInt6402 * i_2_)); if (i_4_ <= 0) { int i_5_ = ((Class318_Sub3) this).anInt6405 - i; int i_6_ = ((Class318_Sub3) this).anInt6402 - i_0_; if (i_5_ * i_5_ + i_6_ * i_6_ >= (((Class318_Sub3) this).anInt6403 * ((Class318_Sub3) this).anInt6403)) return false; return true; } if (i_4_ > i_3_) { int i_7_ = ((Class318_Sub3) this).anInt6406 - i; int i_8_ = ((Class318_Sub3) this).anInt6404 - i_0_; if (i_7_ * i_7_ + i_8_ * i_8_ >= (((Class318_Sub3) this).anInt6403 * ((Class318_Sub3) this).anInt6403)) return false; return true; } i_4_ = (i_4_ << 10) / i_3_; int i_9_ = ((Class318_Sub3) this).anInt6405 + (i_1_ * i_4_ >> 10) - i; int i_10_ = ((Class318_Sub3) this).anInt6402 + (i_2_ * i_4_ >> 10) - i_0_; if (i_9_ * i_9_ + i_10_ * i_10_ >= (((Class318_Sub3) this).anInt6403 * ((Class318_Sub3) this).anInt6403)) return false; return true; }
fe0ce621-a75a-4b6a-bbb3-d656096cd158
2
public CSVObject addLine() { //protect against multiple calls to addLine() if(actLine != null && lastIndex <= 0) return this; return addLineForced(); }
4ad871f7-fcf5-4fcc-9715-6f25ff47f7d6
7
public static boolean eat(final Player player, Item item, int slot) { Food food = Food.forId(item.getId()); if (food == null) return false; if (player.getFoodDelay() > Utils.currentTimeMillis()) return true; if (!player.getControlerManager().canEat(food)) return true; String name = ItemDefinitions.getItemDefinitions(food.getId()) .getName().toLowerCase(); player.getPackets().sendGameMessage("You eat the " + name + "."); player.setNextAnimation(EAT_ANIM); long foodDelay = name.contains("half") ? 600 : 1800; player.getActionManager().setActionDelay((int) foodDelay / 1000); player.addFoodDelay(foodDelay); player.getActionManager().setActionDelay( player.getActionManager().getActionDelay() + 2); player.getInventory() .getItems() .set(slot, food.getNewId() == 0 ? null : new Item(food.getNewId(), 1)); player.getInventory().refresh(slot); int hp = player.getHitpoints(); player.heal(food.getHeal() * 10, food.getExtraHP() * 10); if (player.getHitpoints() > hp) player.getPackets().sendGameMessage("It heals some health."); player.getInventory().refresh(); if (food.effect != null) { food.effect.effect(player); } return true; }
378245d3-b267-47ce-93f2-564f2fd1d531
7
private void parseRxResponse() throws IOException { //TODO untested after 64-bit refactoring if (apiId == ApiId.RX_16_RESPONSE || apiId == ApiId.RX_64_RESPONSE) { if (apiId == ApiId.RX_16_RESPONSE) { response = new RxResponse16(); ((RxBaseResponse)response).setSourceAddress(this.parseAddress16()); } else { response = new RxResponse64(); ((RxBaseResponse)response).setSourceAddress(this.parseAddress64()); } } else { response = new RxResponseIoSample(); if (apiId == ApiId.RX_16_IO_RESPONSE) { ((RxBaseResponse)response).setSourceAddress(this.parseAddress16()); } else { ((RxBaseResponse)response).setSourceAddress(this.parseAddress64()); } } int rssi = this.read("RSSI"); // rssi is a negative dbm value ((RxBaseResponse)response).setRssi(-rssi); int options = this.read("Options"); ((RxBaseResponse)response).setOptions(options); if (apiId == ApiId.RX_16_RESPONSE || apiId == ApiId.RX_64_RESPONSE) { int[] payload = new int[length.getLength() - this.getFrameDataBytesRead()]; int bytesRead = this.getFrameDataBytesRead(); for (int i = 0; i < length.getLength() - bytesRead; i++) { payload[i] = this.read("Payload byte " + i); //log.debug("rx data payload [" + i + "] " + payload[i]); } ((RxResponse)response).setData(payload); } else { // I/O sample log.debug("this is a I/O sample!"); ((RxResponseIoSample)response).parse(this); } }
58dafbe4-6b64-4295-8f84-237394a6bf2f
3
private void getPicturesPath(DefaultListModel<String> list) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Chose JPEG file"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if(ProjectMainView.actualFolder!=null) chooser.setCurrentDirectory(ProjectMainView.actualFolder); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { ProjectMainView.actualFolder=chooser.getSelectedFile().getParentFile(); int dialogResult=JOptionPane.showConfirmDialog (null, "Czy chcesz dodać dźwięk jako ekwipunek?","Ekwipunek",JOptionPane.YES_NO_OPTION); if(dialogResult==JOptionPane.YES_OPTION) { soundInventoryList.add(true); } else{soundInventoryList.add(false);} //String str = chooser.getSelectedFile().getName(); String str = chooser.getSelectedFile().getPath(); list.addElement(str); listNarration.add(Integer.toString(list.size())); comboBoxNarration.removeAllItems(); comboBoxNarration.setModel(new DefaultComboBoxModel(listNarration.toArray())); setOfpath.add(chooser.getCurrentDirectory().toString() + chooser.getSelectedFile()); System.out.println(setOfpath); } else { System.out.println("No Selection "); } }
0cd037f4-b259-4815-95ba-c4f10050381f
3
public void sortColors(int[] A) { int i = 0; int mm = -1; int nn = A.length; while(i < nn){ if(A[i] == 0){ // do need ++i actually because in the next iteration the 3rd condition would work // A[i++] = A[++mm]; A[i] = A[++mm]; A[mm] = 0; }else if(A[i] == 2){ A[i] = A[--nn]; A[nn] = 2; }else ++i; } return ; }
e99e51fe-268d-4440-8f9d-ca6acda9810d
0
@Override protected void setColoredExes() { ParametricCurve besie = new BesieCurve(allex); coloredEx = besie.Calculation(); }
8da507ca-2031-4d34-bc67-3e63f8b88943
7
public String [] getResultNames() { int addm = (m_AdditionalMeasures != null) ? m_AdditionalMeasures.length : 0; int overall_length = RESULT_SIZE+addm; overall_length += NUM_IR_STATISTICS; overall_length += NUM_WEIGHTED_IR_STATISTICS; overall_length += NUM_UNWEIGHTED_IR_STATISTICS; if (getAttributeID() >= 0) overall_length += 1; if (getPredTargetColumn()) overall_length += 2; String [] resultNames = new String[overall_length]; int current = 0; resultNames[current++] = "Number_of_training_instances"; resultNames[current++] = "Number_of_testing_instances"; // Basic performance stats - right vs wrong resultNames[current++] = "Number_correct"; resultNames[current++] = "Number_incorrect"; resultNames[current++] = "Number_unclassified"; resultNames[current++] = "Percent_correct"; resultNames[current++] = "Percent_incorrect"; resultNames[current++] = "Percent_unclassified"; resultNames[current++] = "Kappa_statistic"; // Sensitive stats - certainty of predictions resultNames[current++] = "Mean_absolute_error"; resultNames[current++] = "Root_mean_squared_error"; resultNames[current++] = "Relative_absolute_error"; resultNames[current++] = "Root_relative_squared_error"; // SF stats resultNames[current++] = "SF_prior_entropy"; resultNames[current++] = "SF_scheme_entropy"; resultNames[current++] = "SF_entropy_gain"; resultNames[current++] = "SF_mean_prior_entropy"; resultNames[current++] = "SF_mean_scheme_entropy"; resultNames[current++] = "SF_mean_entropy_gain"; // K&B stats resultNames[current++] = "KB_information"; resultNames[current++] = "KB_mean_information"; resultNames[current++] = "KB_relative_information"; // IR stats resultNames[current++] = "True_positive_rate"; resultNames[current++] = "Num_true_positives"; resultNames[current++] = "False_positive_rate"; resultNames[current++] = "Num_false_positives"; resultNames[current++] = "True_negative_rate"; resultNames[current++] = "Num_true_negatives"; resultNames[current++] = "False_negative_rate"; resultNames[current++] = "Num_false_negatives"; resultNames[current++] = "IR_precision"; resultNames[current++] = "IR_recall"; resultNames[current++] = "F_measure"; resultNames[current++] = "Area_under_ROC"; // Weighted IR stats resultNames[current++] = "Weighted_avg_true_positive_rate"; resultNames[current++] = "Weighted_avg_false_positive_rate"; resultNames[current++] = "Weighted_avg_true_negative_rate"; resultNames[current++] = "Weighted_avg_false_negative_rate"; resultNames[current++] = "Weighted_avg_IR_precision"; resultNames[current++] = "Weighted_avg_IR_recall"; resultNames[current++] = "Weighted_avg_F_measure"; resultNames[current++] = "Weighted_avg_area_under_ROC"; // Unweighted IR stats resultNames[current++] = "Unweighted_macro_avg_F_measure"; resultNames[current++] = "Unweighted_micro_avg_F_measure"; // Timing stats resultNames[current++] = "Elapsed_Time_training"; resultNames[current++] = "Elapsed_Time_testing"; resultNames[current++] = "UserCPU_Time_training"; resultNames[current++] = "UserCPU_Time_testing"; // sizes resultNames[current++] = "Serialized_Model_Size"; resultNames[current++] = "Serialized_Train_Set_Size"; resultNames[current++] = "Serialized_Test_Set_Size"; // Prediction interval statistics resultNames[current++] = "Coverage_of_Test_Cases_By_Regions"; resultNames[current++] = "Size_of_Predicted_Regions"; // ID/Targets/Predictions if (getAttributeID() >= 0) resultNames[current++] = "Instance_ID"; if (getPredTargetColumn()){ resultNames[current++] = "Targets"; resultNames[current++] = "Predictions"; } // Classifier defined extras resultNames[current++] = "Summary"; // add any additional measures for (int i=0;i<addm;i++) { resultNames[current++] = m_AdditionalMeasures[i]; } if (current != overall_length) { throw new Error("ResultNames didn't fit RESULT_SIZE"); } return resultNames; }
47f38a58-d08e-4a7c-94ba-05f6a7e2a94b
0
public GameSettingsDialog(Campaign campaign) { super(); setTitle("Ustawienia widok\u00F3w"); this.setSize(new Dimension(600, 262)); this.campaignRef=campaign; this.setVisible(true); this.setResizable(false); getContentPane().setLayout(new FlowLayout()); background1Label=new JLabel("T\u0142o 1"); background1Label.setPreferredSize(new Dimension(80,30)); getContentPane().add(background1Label); background1Field = new JTextField(); background1Field.setPreferredSize(new Dimension(300,30)); background1Field.setEditable(false); getContentPane().add(background1Field); addBackground1btn = new JButton("Dodaj"); addBackground1btn.setPreferredSize(new Dimension(80,30)); getContentPane().add(addBackground1btn); delBackground1btn = new JButton("Usu\u0144"); delBackground1btn.setPreferredSize(new Dimension(80,30)); getContentPane().add(delBackground1btn); background2Label=new JLabel("T\u0142o 2"); background2Label.setPreferredSize(new Dimension(80,30)); getContentPane().add(background2Label); background2Field = new JTextField(); background2Field.setPreferredSize(new Dimension(300,30)); background2Field.setEditable(false); getContentPane().add(background2Field); addBackground2btn = new JButton("Dodaj"); addBackground2btn.setPreferredSize(new Dimension(80,30)); getContentPane().add(addBackground2btn); delBackground2btn = new JButton("Usu\u0144"); delBackground2btn.setPreferredSize(new Dimension(80,30)); getContentPane().add(delBackground2btn); background3Label=new JLabel("T\u0142o 3"); background3Label.setPreferredSize(new Dimension(80,30)); getContentPane().add(background3Label); background3Field = new JTextField(); background3Field.setPreferredSize(new Dimension(300,30)); background3Field.setEditable(false); getContentPane().add(background3Field); addBackground3btn = new JButton("Dodaj"); addBackground3btn.setPreferredSize(new Dimension(80,30)); getContentPane().add(addBackground3btn); delBackground3btn = new JButton("Usu\u0144"); delBackground3btn.setPreferredSize(new Dimension(80,30)); getContentPane().add(delBackground3btn); logoLabel=new JLabel("Logo"); logoLabel.setPreferredSize(new Dimension(80,30)); getContentPane().add(logoLabel); logoField = new JTextField(); logoField.setPreferredSize(new Dimension(300,30)); logoField.setEditable(false); getContentPane().add(logoField); addLogoBtn = new JButton("Dodaj"); addLogoBtn.setPreferredSize(new Dimension(80,30)); getContentPane().add(addLogoBtn); delLogoBtn = new JButton("Usu\u0144"); delLogoBtn.setPreferredSize(new Dimension(80,30)); getContentPane().add(delLogoBtn); buttonLabel=new JLabel("Przycisk"); buttonLabel.setPreferredSize(new Dimension(80,30)); getContentPane().add(buttonLabel); buttonField = new JTextField(); buttonField.setPreferredSize(new Dimension(300,30)); buttonField.setEditable(false); getContentPane().add(buttonField); addButtonBtn = new JButton("Dodaj"); addButtonBtn.setPreferredSize(new Dimension(80,30)); getContentPane().add(addButtonBtn); delButtonBtn = new JButton("Usu\u0144"); delButtonBtn.setPreferredSize(new Dimension(80,30)); getContentPane().add(delButtonBtn); okBtn = new JButton("Ok"); okBtn.setPreferredSize(new Dimension(70,30)); getContentPane().add(okBtn); btnCancel = new JButton("Anuluj"); btnCancel.setPreferredSize(new Dimension(70,30)); getContentPane().add(btnCancel); addActionListeners(); setData(); }
f83a2c17-0021-4bc2-ac9e-df0dde86a182
5
public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_SPACE) { fire(); } if (key == KeyEvent.VK_LEFT) { dx = -1; } if (key == KeyEvent.VK_RIGHT) { dx = 1; } if (key == KeyEvent.VK_UP) { dy = -1; } if (key == KeyEvent.VK_DOWN) { dy = 1; } }
dca6eff5-0561-468c-88ed-ec79165e9b40
6
public void init() { for (int i = 0; i < TEST_SIZE; i++) { graph[i] = new NonDirectedGraph<Integer>(); } Scanner scanner = new Scanner(getClass().getResourceAsStream("/kargerMinCut.txt")); while (scanner.hasNextLine()) { String line = scanner.nextLine(); String[] split = line.split("\t"); for (int i = 1; i < split.length; i++) { Vertex<Integer> source = new Vertex<Integer>(Integer.valueOf(split[0])); Vertex<Integer> dest = new Vertex<Integer>(Integer.valueOf(split[i])); for (int j = 0; j < TEST_SIZE; j++) { graph[j].addVertex(source); graph[j].addVertex(dest); if (!graph[j].isEdge(source, dest)) { if (i % 2 == 0) { graph[j].addEdge(source, dest); } else { graph[j].addEdge(dest, source); } } } } } scanner.close(); }
d2f38e72-4bf9-49ca-839f-1e3933f2f250
7
public int getTotalCount(int itemID) { int count = 0; for (int j = 0; j < c.playerItems.length; j++) { if (Item.itemIsNote[itemID+1]) { if (itemID+2 == c.playerItems[j]) count += c.playerItemsN[j]; } if (!Item.itemIsNote[itemID+1]) { if (itemID+1 == c.playerItems[j]) count += c.playerItemsN[j]; } } for (int j = 0; j < c.bankItems.length; j++) { if (c.bankItems[j] == itemID + 1) count += c.bankItemsN[j]; } return count; }
ad911f60-b8b1-40b8-9e93-c3cdb90a907c
2
public static long toLong(byte ... b) { /* long l = 0; int len = b.length; if (len > 0) l += b[0]; if (len > 1) l += ((long) l << 8 | b[1]); if (len > 2) l += ((long) l << 16 | b[2]); if (len > 3) l += ((long) l << 24 | b[3]); if (len > 4) l += ((long) l << 32 | b[4]); if (len > 5) l += ((long) l << 40 | b[5]); if (len > 6) l += ((long) l << 48 | b[6]); if (len > 7) l += ((long) l << 56 | b[7]); return l; */ int mask = 0xff; int temp = 0; long res = 0; int byteslen = b.length; if (byteslen > 8) { return Long.valueOf(0L); } for (int i = 0; i < byteslen; i++) { res <<= 8; temp = b[i] & mask; res |= temp; } return res; }
65821126-fc39-42c6-9149-230689f3eaa7
6
/* */ @EventHandler /* */ public void onPlayerQuit(PlayerQuitEvent event) /* */ { /* 61 */ if (Main.getAPI().isSpectating(event.getPlayer())) /* */ { /* 63 */ Main.getAPI().stopSpectating(event.getPlayer(), true); /* 64 */ return; /* */ } /* 66 */ if (Main.getAPI().isBeingSpectated(event.getPlayer())) /* */ { /* 68 */ for (Player p : Main.getAPI().getSpectators(event.getPlayer())) /* */ { /* 70 */ if ((Main.getAPI().getSpectateMode(p) == SpectateMode.SCROLL) || (Main.getAPI().isScanning(p))) /* */ { /* 72 */ SpectateScrollEvent scrollEvent = new SpectateScrollEvent(p, Main.getAPI().getSpectateablePlayers(), ScrollDirection.RIGHT); /* 73 */ Bukkit.getServer().getPluginManager().callEvent(scrollEvent); /* */ /* 75 */ ArrayList<Player> playerList = scrollEvent.getSpectateList(); /* */ /* 77 */ playerList.remove(p); /* 78 */ playerList.remove(event.getPlayer()); /* */ /* 80 */ p.sendMessage(ChatColor.GRAY + "The person you were previously spectating has disconnected."); /* */ /* 82 */ if (!Main.getAPI().scrollRight(p, playerList)) /* */ { /* 84 */ Main.getAPI().stopSpectating(p, true); /* 85 */ p.sendMessage(ChatColor.GRAY + "You were forced to stop spectating because there is nobody left to spectate."); /* */ } /* */ /* */ } /* */ else /* */ { /* 91 */ Main.getAPI().stopSpectating(p, true); /* 92 */ p.sendMessage(ChatColor.GRAY + "You were forced to stop spectating because the person you were spectating disconnected."); /* */ } /* */ /* */ } /* */ /* 98 */ return; /* */ } /* */ }