method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
4e33d9e1-a001-417c-bd47-6450692984df
6
public void onMouseUp(MouseUpEvent event) { switch (m_state) { case SELECTING: case DRAGGING: case RESIZE_HEIGHT: case RESIZE_WIDTH: m_state = State.SELECTED; m_mouseOverArea = null; fireChangeEvent(true); ...
27f827fd-1aeb-486f-8482-c702bf4002a8
8
public void testReplace() throws MemcachedException, TimeoutException { String readObject = null; String key = null; String value = null; //1 value = "ABCD"; key = "testrep1"; c.set(key, 3600, "World"); boolean flag = c.replace(key, 3600, value); assertTrue(flag); readObject = (String) c....
d4d02904-3d15-4858-8f1c-0e1942fd1b2c
9
private void finishDocument(DocumentsWriterThreadState perThread, DocWriter docWriter) throws IOException { if (doBalanceRAM()) // Must call this w/o holding synchronized(this) else // we'll hit deadlock: balanceRAM(); synchronized(this) { assert docWriter == null || docWriter.docID =...
c6268e1a-9879-4f41-a7bc-67d21630bbc5
1
public void closePopUp() { Parent parentRoot = ((Stage) stage.getOwner()).getScene().getRoot(); if (parentRoot instanceof StackPane) { ((StackPane) parentRoot).getChildren().remove(mask); } stage.close(); }
403b87d8-36d0-4338-aaa7-37b57833596f
7
public void paint(Graphics g) { super.paint(g); // Set background colour. g.setColor(new Color(250, 240, 170)); g.fillRect(0, 0, this.getWidth(), this.getHeight()); // Add all the objects to an array to loop over. ArrayList<Sprite> world = new ArrayList<Sprite>(); world.addAll(trees); world.addAll(ship...
d07531a6-007e-41fc-99c2-f1280f6b3796
2
public static ItemStack getRecipe(ItemStack input){ if(input.getItem().getUIN().equals(Items.iron.getUIN())){ return new ItemStack(Items.ingot,1); } else if(input.getItem().getUIN().equals(Items.meat_pig_raw.getUIN())) { return new ItemStack(Items.meat_pig, 1); } return null; }
9ab81500-76c1-459a-aaa4-9ae338d1c52f
1
public static void main( String[] args ) { int loopLimit = 10; int sum = 0; for ( int i = 0; i <= loopLimit; i++ ) { sum = sum + i; } // after the loop print the value System.out.println( "The sum is : " + sum ); }
d5a6cbe2-c354-4b1b-88bc-1338e125a7e6
5
protected void scanString(StringBuffer string) throws IOException { char delimiter = this.readChar(); if ((delimiter != '\'') && (delimiter != '"')) { throw this.expectedInput("' or \""); } for (;;) { char ch = this.readChar(); if (ch == de...
1ac81eb9-be54-4ec4-b0d3-dcb54114079b
2
public void Draw(Graphics2D g2d) { //******************************************* //text coordinates // g2d.setColor(Color.white); g2d.drawString("Enemy car speed: " + this.getSpeedY(), 950, 30); // If the car is raceWin. //image for winnging if (raceWin) { ...
53487fe3-fcf8-4608-b9ac-f4f2f9845ee3
4
public boolean checkBounds(int x, int y){ if(x < 0 || y < 0 || x >= width || y >= height) return false; return true; }
01764475-cf24-4100-9c09-671e91fe7882
2
public static DataProvider create(ProviderType type) { if (type == ProviderType.XML) return new XmlProvider(); if (type == ProviderType.DB) return new DbProvider(); return null; }
9787a0a7-9704-4c02-93c2-254920fa570a
5
private void updateTabla(){ //** pido los datos a la tabla Object[][] vcta = this.getDatos(); //** se colocan los datos en la tabla DefaultTableModel datos = new DefaultTableModel(); tabla.setModel(datos); ...
3206733a-b83e-419e-a20a-ebee600679ea
3
public void createWeightedGraph(){ Scanner console = new Scanner(System.in); int index; int vertex; int adjacentVertex; int edge; String fileName; if (gSize != 0) clearGraph(); Scanner infile = null; try{ ...
ae12be73-53d8-4489-a304-ae26597eca34
9
protected void processMousePressed(MouseEvent e) { requestFocusInWindow(); int x = e.getX(); int y = e.getY(); pressPoint.x = x; pressPoint.y = y; switch (mode) { case DEFAULT_MODE: if (editable) { select(x, y); } break; case LINE_MODE: if (editable) { setSelectedElement(null); c...
bd09123f-7f5f-46d3-a9a7-cefe38912211
5
@Override public double getImportance(List<Example> exampleCollection) { // assume winner 1 as positive, winner 2 as negative double startEntropy = getEntropy(exampleCollection); double entropyReminder = 0; List<AttributeValue> aValueList = getAttributeValues(); List<Double> entropyList = new ArrayList<Dou...
6c8af795-c709-44e5-b55e-dc7239ffa368
1
public void paintComponent(Graphics g) { // recover Graphics2D Graphics2D g2 = (Graphics2D) g; // add string to top left hand corner of component g2.drawString("(Number of match allocations above each bar)", 10, 20); // initialise top left hand corner coordinates, // and width of the bar chart bars ...
11f03231-59cc-44c1-a96c-84bf44f0aad7
3
protected int paeth(int left, int up, int upLeft) { int p = left + up - upLeft; int pa = Math.abs(p - left); int pb = Math.abs(p - up); int pc = Math.abs(p - upLeft); if ((pa <= pb) && (pa <= pc)) { return left; } else if (pb <= pc) { retu...
29961b23-10c3-4a55-82a6-156dc7b1821c
5
public static void ChooserOTs(Circuit c, Formatter f, OT ot, ObjectOutputStream oos, ObjectInputStream ois) { Vector<OTTASK> OTs = new Vector<OTTASK>(10, 10); IO io = null; // Construct vector of all OTs to be executed for (int i = 0; i < f.FMT.size(); i++) { io ...
0bf41deb-c35f-4b59-91c0-93b7e1d017e7
7
public JGImage getImage(String imgname) { if (!existsImage(imgname)) throw new JGameError( "Image '"+imgname+"' not defined.",true ); JGImage img = (JGImage)images.get(imgname); if (img==null) { img = (JGImage)images_orig.get(imgname); if (img==null) return null; // convert indexed to display-compati...
58f72051-ea79-4867-ad82-dec7b111441f
2
public void drawCells(Graphics g) { for (int row = 0; row < width; row++) { for (int col = 0; col < height; col++) { grid[row][col].draw(25, 35, cellWidth, cellHeight, g); } } }
f3b632fb-ec59-43e8-b9b3-4437a1b3590c
7
public static void main(String[] args) throws IOException { if (args.length != 1) { System.out.println("\nUsage: java org.apache.lucene.store.LockVerifyServer port\n"); System.exit(1); } final int port = Integer.parseInt(args[0]); ServerSocket s = new ServerSocket(port); s.setReuseAdd...
cfa46d0d-8068-4b9c-a38d-153df18fd15e
7
public static Stella_Object nativeValueOf(Stella_Object self) { { Surrogate testValue000 = Stella_Object.safePrimaryType(self); if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PATTERN_VARIABLE)) { { PatternVariable self000 = ((PatternVariable)(self)); { Stella_Object value = Logic.g...
84807207-2f56-486e-a735-c0be93035ccd
9
public int validateUser(String name, String unhashedPassword){ String query = String.format("SELECT * FROM %s WHERE username='%s' AND password=(MD5('%s'));", this.getTable(), name, unhashedPassword); int rows = -1; try { rows = super.getRowCount(query.replace("*", "COUNT(*)")); } catch (SQLException e...
882ba6d7-b8dc-48fd-b798-7246822dfc2e
6
public static void main(String args[]) { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); ...
4ac0bccc-772b-4a2c-a8e3-d461aefaa167
8
public SceneObject getDeposit(final String deposit) { Filter<SceneObject> i = new Filter<SceneObject>() { public boolean accept(SceneObject entity) { if(deposit.equals("West")) { return entity.getId() == Variables.GOLD_DEPOSIT_ID && Variables.WEST_TILE.equals(entity.getLocation()); } if(deposit.equals...
76def815-5279-4b75-a12d-631b4604e54a
1
@Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawMain(g2d, rectangles.get(0).getX(), rectangles.get(0).getY(), rectangles.get(0).getWidth(), rectangles.get(0).getHeigth()); g2d.setCo...
c5d8399d-3e6f-4ceb-ac05-fb349da85183
9
private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; blackrevertedGroup = new javax.swing.ButtonGroup(); BColumnGroup = new javax.swing.ButtonGroup(); blackdeletedGroup = new javax.swing.ButtonGroup(); watchdeletedGroup = new javax.swing.ButtonGroup(); watchwarnedGrou...
9e112833-f520-418d-9ee1-34d2cc16afd2
5
public void initialise(boolean[][] world) throws PatternFormatException { String[] cellParts = cells.split(" "); for (int i=0;i<cellParts.length;i++) { char[] currCells = cellParts[i].toCharArray(); for (int j=0;j<currCells.length;j++) { if (currCells[j] != '1' && currCells[j] !=...
646b2214-bef9-4845-9ce4-13ca825457c6
0
private int squaresOfSum(int start, int end) { int sum=(start+end)*(end-start+1)/2; return sum*sum; }
b82693e8-fbab-418d-94b2-e5491027fe8d
3
public ArrayList<Boolean> intToBooList(int num) { ArrayList<Boolean> result = new ArrayList(varCount); String binary = Integer.toBinaryString(num); while(binary.length()<varCount) { binary = "0".concat(binary); //add 0's to make size of list the amount of variables. ...
799c8ebe-6b90-4630-a47b-2577a66b07b4
7
private void calculatePrices() { // // Typically speaking, exports have their value halved and imports have // their price doubled if it's coming from offworld. Anything coming from // another sector of your own planet has much milder cost differences, and // your homeworld will also cut you so...
d6cc0e0a-6de7-4375-b99b-13aaf597db2e
6
private boolean doCollision(Snake snake, CollisionSegment segment) { for (Snake testCollision: activeSnakeList) { if (snake != testCollision && testCollision.isCollidingWithSegment(segment)) { return true; } } boolean wallCollision = (snake.isCollidingW...
72e363e3-a38b-4c12-93ce-7b9e877afbb9
7
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked jList1 = (JList) evt.getSource(); if (evt.getClickCount() == 2) { int index = jList1.locationToIndex(evt.getPoint()); if (index >= 0) { String s = (String) jList1.getModel().g...
77e851f7-7f70-41e3-8332-5f42ee314162
5
public List<String> getStringList(String path) { List<?> list = getList(path); if (list == null) { return new ArrayList<String>(0); } List<String> result = new ArrayList<String>(); for (Object object : list) { if ((object instanceof String) || (isPrimit...
f4773643-58f9-4243-ae00-48003c702dc9
1
private void processPackets() throws IOException { while (true) { lastTS = thisTS; socket.receive(packet); thisTS = (int) System.currentTimeMillis(); totalRX++; response.updatePacket(packet); isreceiving = response.isReceiving(); } }
31e933e0-41c2-43e3-bd4d-08f2da5b33d2
8
@Override //for simplicity, the getNeighbor method is the same for 4 and 8 pixels, works //for both values (and even larger ones, for experiments) public PixelInfo getNeighbor(PixelInfo pixel, int i, int width, int height) { PixelInfo neighbor = new PixelInfo(0,0,0); //in case that i>8: //1 cycle = 8 pixels ...
4a650494-35e9-44c2-bfc7-af7ff0909bc6
9
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { long start = System.currentTimeMillis(); ResponseResult final_result = new ResponseResult(); try{ String query = request.getParameter("query"); List<String> query_terms = query_processor.par...
0cc1cb4b-b2c0-4dc1-a13e-adcda92ba605
9
@Override public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) { final java.util.Map<String,String> parms=parseParms(parm); if(parms.containsKey("ALL")) return ""+CMLib.sessions().getCountLocalOnline(); if(parms.containsKey("TOTALCACHED")) return ""+CMLib.players().numPlayers();...
47055b72-e4b4-4d6c-9a49-99ebfb8c257b
9
final int[][] method3047(int i, int i_8_) { anInt9393++; int[][] is = ((Class348_Sub40) this).aClass322_7033.method2557(-105, i); if (((Class322) ((Class348_Sub40) this).aClass322_7033).aBoolean4035) { int[][] is_9_ = this.method3039((byte) 50, i, 0); int[] is_10_ = is_9_[0]; int[] is_11_ = is_9_...
2c4c18d3-bcc1-48fd-aa16-06db2f70ad78
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Person other = (Person) obj; if (currentCar == null) { if (other.currentCar != null) return false; } else if (!currentCar.equals(other.c...
b4be43f6-e0e1-4259-b557-23cd2630b89b
5
public double increaseAdjustableKomi(int minX, int minY, int ex, int ey) { if (ex > 490 && ex < 490 + minX) { if (ey > 210 && ey < 210 + minY) { if (Komi >= 0) { adjustableKomi += (.5); return adjustableKomi; } } ...
4575e42c-68c4-454d-a454-8f6d04356ae2
2
public ArrayList<InstituicaoCooperadora> listar(String condicao) throws Exception { String sql = "SELECT * FROM instituicaocooperadora " + condicao; ArrayList<InstituicaoCooperadora> listaInstituicaoCooperadora = new ArrayList<InstituicaoCooperadora>(); try { PreparedStatement stmt = ConnectionFactory.ge...
9cc3d5a0-8446-4d1b-a11c-ce32f04e5f01
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://down...
6ae6acc4-1a8f-4bd7-a9b0-5b580e81e6d1
1
public void doDrawing(Graphics g) { for(int i=0;i<markers;i++) { marker[i].doDrawing(g); } }
24ed0208-2474-4caf-b49c-83dd4e4d4d0d
6
public boolean isNeighbourTo(TileType tileType, Side ... sides) { if (sides == null || sides.length == 0) return false; for (Side s : sides) { if (neighbourMaterials.get(s) == null || tileType.neighbourMaterials.get(s.getOppositeSide()) == null || !neighbourMaterials.get(s).equal...
7cc06964-3e03-4914-b632-b69dacc99869
8
public String longestCommonPrefix(String[] strs) { if(strs == null || strs.length == 0) { return ""; } int minLen = strs[0].length(); for(int i = 0; i < strs.length; i++) { if(strs[i].length() < minLen) { minLen = strs[i].length(); } ...
141c20d6-4e4e-4914-bef1-1e94ef66da79
9
public static FillInBlankQuestion getFillInBlankQuestionByXMLElem(XMLElement root, Quiz quiz, int pos) { int quizID = quiz.quizID; int position = pos; Object question = null; Object answer = null; double score = 10; ArrayList<String> questionList = new ArrayList<String>(); ArrayList<String> answerList = n...
04b4a601-ce02-40e8-a3a2-c426c6a83d36
4
private double getEntropy(List<Example> exampleCollection) { double positiveExampleCount = 0; double negativeExampleCount = 0; for (Example e : exampleCollection) { if (e.getWinner() == 1) { positiveExampleCount++; } else { negativeExampleCount++; } } double q = positiveExampleCount / (...
0622c8c8-6f52-4be5-a5e4-a4383f86398e
9
public static boolean isZone1To8OrLocal(String value) { if(value.equals("01") || value.equals("02") || value.equals("03") || value.equals("04") || value.equals("05") || value.equals("06") || value.equals("07") || value.equal...
fe0fe939-4472-44f9-8eb9-a3cb0055fe92
3
public int inserir(Venda v){ Connection conn = null; PreparedStatement pstm = null; int retorno = -1; try{ conn = ConnectionFactory.getConnection(); pstm = conn.prepareStatement(INSERT, Statement.RETURN_GENERATED_KEYS); pstm.setInt(1, v.getQuantidade()...
c0b0f6b4-d07d-4cf7-8e05-9445ada852cd
9
public void run(String arg) { // Check the ImageJ version if (IJ.versionLessThan("1.21a")) return; // Check the presence of the image ImagePlus imp = WindowManager.getCurrentImage(); if (imp == null) { IJ.error("No stack of images open"); return; } // Check the size of the image if (imp.getW...
28e24b85-7dd9-4071-a1ac-074a711871dc
2
public synchronized void synchronizeNode(String name, int port) { if (port != this.port) { try { log.info("Synchronize Child node - " + port); ObjectOutputStream out = createOutputStream(port); EventProtocols.writeEvent(out, new SynchronizationEvent( register)); out.flush(); out.clo...
efdacca9-5162-47e9-9340-1bf2a59e0570
8
private static void loadUnpackedShops() { Logger.log("ShopsHandler", "Packing shops..."); try { BufferedReader in = new BufferedReader( new FileReader(UNPACKED_PATH)); DataOutputStream out = new DataOutputStream(new FileOutputStream( PACKED_PATH)); while (true) { String line = in.readLine(); ...
163939f7-d350-4830-8411-34b0d4621c60
7
@Override public void run() { this.mapWritable = new MapList<String, Writable>(); MapList<String, ParseNode> msp = this.innerNode.getNext(); SocketSender socketSender; for ( String ss : msp.keySet() ) { Vector<ParseNode> vpn = msp.get(ss); for ( ParseNode pn : vpn ) { socketSender = new SocketSender(...
ac2926a4-fbf5-4416-a9ec-6ac3160db7da
1
public String getNoteName(int noteId) throws SQLException { NoteDatabaseManager dm = new NoteDatabaseManager(); String s_noteId = Integer.toString(noteId); String sql = "select note_name from note where note_id = " + s_noteId + ";"; ResultSet rs = dm.sqlQuery(sql); String noteName = null; while (rs.next...
471e8baf-1148-4f3c-8d4c-032355a218de
3
public EmpresaBean get(EmpresaBean oEmpresaBean) throws Exception { if (oEmpresaBean.getId() > 0) { try { oMysql.conexion(enumTipoConexion); if (!oMysql.existsOne("empresa", oEmpresaBean.getId())) { oEmpresaBean.setId(0); } else { ...
c4e90d7e-f972-47c3-a301-6b001cc6cc66
9
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int length = to.length(); char[] circle = new char[length]; /* * First fill the circle buffer with as many characters as are in the...
dd383d65-5825-4a96-b9d6-2cd21adc1a2b
8
@Override public int read() throws IOException { if (!byteBuffer.hasRemaining()) { if (!charBuffer.hasRemaining()) { charBuffer.clear(); reader.read(charBuffer); charBuffer.flip(); } byteBuffer.clear(); if (charBuffer.hasRemaining()) { if (encoder.encode(charBuffer, byteBuffer, ...
7021c05a-8ac0-46da-bfe9-721a64d5ee3d
8
@Override public double convertTo(int type) { switch (type) { case UnitConstants.FEET_SECOND: return getValue() * 1.68781; case UnitConstants.FEET_MINUTE: return getValue() * 101.2686; case UnitConstants.MILES_MINUTE: retur...
ecbf2f7e-7136-4801-80f0-4ecfa6a63eba
6
public static void main(String[] args) { Scanner inputScanner = null; try { inputScanner = new Scanner(new File(args[0])); } catch (FileNotFoundException e) { System.err.println("Invalid input file."); } while (inputScanner.hasNextLine()) { HashSet<Integer> list = new HashSet<Integer>(); String[] ...
4a621302-6e10-4893-9598-1fea8686d665
8
public int firstMissingPositive(int[] A) { if (A == null || A.length == 0) return 1; int len = A.length; for (int i = 0; i < len; i++) { int num = A[i]; if (num > 0 && num <= len) { A[i] = A[num-1]; A[num-1] = num; // if (num-1 != i && A[i] != num) ...
4067491f-f686-45cc-9e45-0f08ec8f62e0
0
public int add(int _a, int _b) { return _a + _b; }
25308491-5415-4ec6-8b0b-18e92d1b43c8
5
public boolean hasNext() { return (alignment != null || stopsIterator.hasNext()) && ((alignment != null && duration <= maxDuration && alignment.startPoint + duration <= intervalsUpperBound) || stopsIterator.hasNext()); }
51fe0812-18dc-4f38-ac4f-4d5425113228
4
public static void authorsImport() throws ClassNotFoundException, SQLException { Class.forName("org.postgresql.Driver"); c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "qqkfq0513"); stmt = c.createStatement(); sql = "select * from authors"; ...
7f92a1bc-2d6d-4b49-b07a-71fa447a5c4b
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://down...
be2e2d3f-fb5d-4000-b10c-c5df7a78b4ee
5
public int candy(int[] ratings) { int[] candy = new int[ratings.length]; //considering the minimal rating on the left, give 1 candy candy[0] = 1; //loop from second child for (int i = 1; i < ratings.length; i++) { //if value bigger than before, add 1, otherwise, set 1...
f4c23e11-6107-4a30-8cca-f176e97f5d30
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://down...
274165da-2263-4256-bedc-7ec1f8616eb1
0
public Land changeLandFraktion(int landID, Fraktion newOwner, int anzahlEinheiten) { int tmpX = laenderMap.get(landID).getXLocation(); int tmpY = laenderMap.get(landID).getYLocation(); this.removeID(landID); Land c = new Land(landID, tmpX, tmpY, newOwner, anzahlEinheiten); this.addVertex(c); return c; }
ed48670f-b311-42ba-b788-8576e1e40a1d
0
public User(String name, String ip) { this.name = name; this.ip = ip; }
13e429db-2d02-42aa-b9f5-f2ab31b88c1f
2
public ArrayList<Gebruiker> getAlleKlantenAfwezig(){ Calendar test = Calendar.getInstance(); test.add(Calendar.DATE, -60); for (Gebruiker k : alleKlanten) { if(!afwezig.contains(k)){ afwezig.add(k); } } return afwezig; }
1be9201b-936d-4351-9875-84e8dbeec138
1
public String getFieldrefClassName(int index) { FieldrefInfo f = (FieldrefInfo)getItem(index); if (f == null) return null; else return getClassInfo(f.classIndex); }
7856a4a6-1771-487f-bbd4-a40f0f085442
1
void foo(String s) { if(s == null) throw new NullPointerException("s is null"); }
955a073b-1543-4349-a3e5-e354b9384cd3
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; AudioMDMetadata other = (AudioMDMetadata) obj; if (audioMD == null) { if ...
26f79e95-cb80-4dbb-87ef-6dce1c49da87
5
@Override public boolean equals(Object that) { if (!(that instanceof Transition)) { return false; } Transition t = (Transition) that; if (!t.destinations.equals(destinations)) return false; if (this.origin.equals(t.origin) && this.origin != t.origin) { Logger.log("WARN: synonymous but different ...
84438491-2c25-404d-9f15-84b3e0307da1
3
public static void changePocket(Item.Pocket newPocket) { currentPocket = newPocket; while (currentDisplay.size()!= 0) currentDisplay.remove(0); for (Item aFullInventory : fullInventory) { if (aFullInventory.pocket == newPocket) currentDisplay.add(aFullInventory); } ...
07e5bb6d-2121-422d-98f6-44804c9bf026
6
public static void init() { menu = new IconMenu("Spell Menu", 9, new IconMenu.OptionClickEventHandler() { @Override public void onOptionClick(IconMenu.OptionClickEvent evt) { Player p = evt.getPlayer(); ItemMeta met = p.getItemInHand().getItemMeta(); Spell s = null; switch (evt.getPosition()) ...
679a1526-c642-4682-9c48-a3de0e74bafe
5
@Test public void buildsGraph() { Point p1 = vc.addPoint(0,0); Point p2 = vc.addPoint(1,-1); Point p3 = vc.addPoint(1,1); Point p4 = vc.addPoint(1.5, 0.0); Point p5 = vc.addPoint(4,-1); Point p6 = vc.addPoint(4,1); p1.setRight(p2); p2.setLeft(p1); ...
a777d125-bf3e-484a-b42b-22129e2ac93c
5
public static Entity getEntityWithinRange(Point location, double maxRange, Team entityTeam) throws EntityNotFound { if (entityTeam == Team.EVIL) { for (Enemy enemy : enemies) { if (enemy.isLocationWithinDistance(location, maxRange)) { return enemy; } } } else { if (HeroInfo.INSTANCE.isHeroAliv...
8e066676-fa53-460b-a0dd-ec58540f91b1
1
public static String getMD5(String phrase) { try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); return (messageDigest.digest(phrase.getBytes())).toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } }
d29a27a8-d55a-4b47-bbdd-765306b9527f
1
public Image colorHealth(Image image, int percent) { if(image == null) { return null; } //create a buffered image, of type argb BufferedImage biTemp = new BufferedImage(image.getWidth(null),image.getHeight(null),BufferedImage.TYPE_INT_ARGB); //make a gra...
2fead1cd-e012-4385-8ab1-6b9185e49d8f
4
private void checkProbabilties(double carProb, double smallCarProb, double mcProb) throws SimulationException { String msg = ""; boolean throwExcept = false; if (invalidProbability(carProb)) { msg += " carProb "; throwExcept = true; } if (invalidProbability(smallCarProb)) { msg += " smallCarProb "...
ec586f9c-5a35-4884-8739-8c6c252d69fb
8
public static void startupTranslateFile() { if (Stella.currentStartupTimePhaseP(0)) { Stella.$LOGICAL_HOST_TABLE$ = StringHashTable.newStringHashTable(); Stella.defineLogicalHostProperty("PL", null, null); } { Object old$Module$000 = Stella.$MODULE$.get(); Object old$Context$000 = Stella.$...
8ec639d4-57c7-4305-993f-515e0a841a9d
0
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); txt2 = new javax.swing.JTextField(); txt3 = new javax....
77528162-7137-4984-9de5-94f2ef4ec0eb
7
public boolean update() { if(life > 0) { life--; if(xDir == "left") { loc.x -= xSpeed; if(yDir == "up") { loc.y -= xSpeed; } if(yDir == "down") { loc.y += ySpeed; } } if(xDir == "right") { loc.x += xSpeed; if(yDir == "up") { loc.y -= xSpeed; ...
c9d50836-5cb3-47a7-ba53-84041cb24c7d
7
public static String optimizeText(String text) { char buf[] = text.toCharArray(); boolean endMarker = true; // marks the end of a sentence to make the next char capital for(int i = 0; i < buf.length; i++) { char c = buf[i]; if(endMarker && c >= 'a' && c <= 'z') { buf[i] -= 0x20; // tr...
b401602e-27bd-40fc-9070-b887bea263b4
5
public void LineUnSwap() { if (caret.row == sel.row) { if (caret.row >= code.size() - 1) { return; } UndoPatch up = new UndoPatch(caret.row, caret.row + 1); StringBuilder swb = code.getsb(caret.row + 1); code.get(caret.row + 1).sbuild = code.get(caret.row).sbuild; code.ge...
52512b17-1898-41da-a355-a4f46881d0da
2
public Map<String,U> getAllEntryArray(){ synchronized(this.cache){ Hashtable<String, U> ret = new Hashtable<String, U>(); this.backing.getAllInGroup(this.group, ret); SoftReference<U> obj; for(Map.Entry<String,U> ent : ret.entrySet()){ if((obj = this.cache.get(ent.getKey())) != null)...
20382642-c5e9-4bb3-89b3-2428b74111ba
8
public static int[] getNextPixel(int orientation_index) { // RSLV: find a mathematical expression for the switch statement? int[] dp = new int[2]; // [0]=dx, [1]=dy switch(orientation_index) { /*case 0: dp[0] = 1; dp[1] = 0; break; case 1: dp[0] = 1; dp[1] = 1; break; case 2: ...
63f7a26e-5dd0-41fb-ade8-a80ffdccdb6d
4
public static void main(String[] args) throws Exception { int p[] = {30, 35, 15, 5, 10, 20, 25}; BUMatrixChainMultiplication bu = new BUMatrixChainMultiplication(p); System.out.println("Number of scalar multiplications"); for ( int i = 1; i < p.length; i++) { for ( int j = i; j < p.length; j++) Syste...
ed50205a-206c-482f-bcd3-7374a345e17c
0
@Override public void onEnable() { init(); this.saveDefaultConfig(); getLogger().info("CreeperWarning is enabled!"); }
e1de59ba-cf81-4a2f-9f79-3cae946b4590
2
public boolean removeUser(User user) { for(int i=0;i<users.length;i++){ if(users[i]==user){ users[i] = null; return true; } } return false; }
3309d3bd-2529-40d3-9da1-07a9dbbc9ff1
1
private void score(Player player) { if (player != null) player.incrementWins(); }
58fdd775-e479-49d4-a97e-1f860d25b7ba
1
@Override public boolean createMember(String lastname, String firstname) { Member member = new Member(lastname, firstname); listOfMembers.add(member); try { serializeObjectToXML("Member.xml", listOfMembers); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrac...
bed4c113-072e-4861-9263-e3d3e09ff68d
3
@Override public void update(Article obj) { PreparedStatement pst = null; try { pst = this.connect().prepareStatement("update Article set titre=?, resume=?, date=? where id=? ;"); pst.setString(1, obj.getTitlre()); pst.setString(2, obj.getResume()); pst.setDat...
fb9b9053-1e9d-4933-83ae-711f49e14fca
4
protected void renderEquippedItems(EntityLiving var1, float var2) { ItemStack var3 = var1.getHeldItem(); if(var3 != null) { GL11.glPushMatrix(); this.modelBipedMain.bipedRightArm.postRender(0.0625F); GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F); float var4; if(v...
de0d7a97-83fa-4ba0-80fb-d4cc9fba7323
6
@Override public int hashCode() { int hash = 0; hash += (a == null ? 0 : a.hashCode()); hash += (b == null ? 0 : b.hashCode()); hash += (c == null ? 0 : c.hashCode()); hash += (d == null ? 0 : d.hashCode()); hash += (e == null ? 0 : e.hashCode()); hash += (f == null ? 0 : f.hashCode()); return hash; }
4f6c6a40-a305-497c-8e84-fc2e55571766
0
public void setPerson(Person person) { Person = person; }
0b4ee328-4d04-4f9d-a9ed-6ef4b77da0da
0
public void setUsername(String username) { this.username = username; }
b7330c6b-c29b-421d-95f7-1ea224153bb2
4
public void execute() { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = null; int lineNumber = 0; try { while (true) { System.out.print("> "); line = br.readLine(); if (line == null) break; lineNumber++; try { Date date = parser.parseDa...
e81b3ac6-e22d-4d92-83d7-61a9f52f7255
5
public set Union(set DataSetA, set DataSetB) { //Make a new Data set and call it C set DataSetC = new set(); //Cycle Through A and put everything in C for (int i = 0; i < DataSetA.stuff.size(); i++) { int item = DataSetA.stuff.get(i); if (DataSetC.stuff.contains...