method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
db10b532-5993-43d6-87e1-56ceb6052497
2
private void CompileShader() { glLinkProgram(m_resource.GetProgram()); if(glGetProgrami(m_resource.GetProgram(), GL_LINK_STATUS) == 0) { System.err.println(glGetProgramInfoLog(m_resource.GetProgram(), 1024)); System.exit(1); } glValidateProgram(m_resource.GetProgram()); if(glGetProgrami(m_re...
d5c8ab9f-e1e1-4006-8b59-d0b9a720f5c7
5
@SuppressWarnings("unchecked") @Override public boolean equals(Object obj) { if (obj instanceof Tuple<?,?>) { if(x.equals(((Tuple<X,Y>)obj).x) && y.equals(((Tuple<X,Y>)obj).y)) { return true; } } return false; }
9c1fb223-924b-4380-bf3b-526923946791
4
public void action(Player player, boolean doublePay) { if(getOwner() != null && !player.equals(getOwner()) && doublePay && !isInMortgage()) { player.pay(getBill(player) * 2); getOwner().addMoney(getBill(player) * 2); } else { action(player); } }
fc3840f1-c256-4c7e-b100-a3646c08f1cf
1
public MaxAmountIterableClass() { IterableWithAnnot = new ArrayList<String>(); IterableWithoutAnnot = new ArrayList<String>(); int i = 0; while (i < 6) { IterableWithAnnot.add("e" + i); IterableWithoutAnnot.add(i, "e" + i); i++; } }
f77e97cf-8a53-4f17-ad1b-9453804e6859
0
public OMLFileFormat() { super(); }
6f75f330-f3ae-495e-90d0-725cd352d530
9
public static String formatDurationWords( long durationMillis, boolean suppressLeadingZeroElements, boolean suppressTrailingZeroElements) { // This method is generally replacable by the format method, but // there are a series of tweaks and special cases that require /...
e92ed454-44eb-4369-9bde-d25421e61948
5
private void addCatchers(BasicBlock[] blocks, ExceptionTable et) throws BadBytecode { if (et == null) return; int i = et.size(); while (--i >= 0) { BasicBlock handler = find(blocks, et.handlerPc(i)); int start = et....
d6d05d23-c89e-4d59-8cc2-71ca416b2ac8
5
public void loadGame(JFrame frame) { JFileChooser fileChooser = new JFileChooser("."); int result = fileChooser.showOpenDialog(frame); if (result == JFileChooser.APPROVE_OPTION) { try { FileInputStream fis = new FileInputStream( fileChooser.get...
212d9b53-ac78-4fa7-9d5a-53434bcae62f
3
public void applyNews(){ News item = news.pop(); appliedNews.add(item); String[] tags = item.getTags(); for (int i = 0; i < tags.length; i++){ String searching = tags[i]; for (int j = 0; j < stocks.size(); j++){ Stock checking = stocks.get(j); String tick = checking.getTicker(); if (searching.equa...
c87fa55e-25ae-4858-aa63-a3347d180672
5
public void sortBySuit() { ArrayList newHand = new ArrayList(); while (hand.size() > 0) { int pos = 0; // Position of minimal card. Card c = (Card)hand.get(0); // Minimal card. for (int i = 1; i < hand.size(); i++) { Card c1 = (Card)hand.get(i); if ( c1.g...
c2580dbd-8842-4238-9152-c80bae3b5c15
1
public static String complete(String main, int start) { String[] args = main.split(" "); StringBuilder string = new StringBuilder(); for (int i = start; i < args.length; i++) { string.append(args[i] + " "); } return string.toString().substring(0, string.length() - 1); }
0b65a08e-f3ab-405c-83f6-345e2f1d50f9
3
public int get (K key, int defaultValue) { int hashCode = key.hashCode(); int index = hashCode & mask; if (!key.equals(keyTable[index])) { index = hash2(hashCode); if (!key.equals(keyTable[index])) { index = hash3(hashCode); if (!key.equals(keyTable[index])) return getStash(key, defaultValue); } ...
ae067620-4390-427f-9d6c-02eb87ec57ac
5
public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextLine()) { String b = in.nextLine().trim(); if (b.equals("0") ) break; int sum = 0; for(int i = 0;i < b.length();i++) { sum += (b.charAt(i) - '0'); } while ( sum >= 10 ) { int a = sum % 10; wh...
06226f6e-cc27-4ecd-8906-2dde833a531d
7
protected void handleView(final View view) { List<Address> new_mbrs=null; if(local_view != null) new_mbrs=Util.newMembers(local_view.getMembers(), view.getMembers()); local_view=view; coord=view.getMembers().iterator().next(); boolean create_bridge=false; boo...
395b7b54-19e1-4585-9054-8123109ff0c1
4
Deserializer_3(@SuppressWarnings("hiding") final SongData sdc) { super(sdc); final String entry = this.idx.getFilename().replace(".idx", "") .replace(".zip", ""); this.inFile = this.idx.resolve("..", entry); this.tmp = this.idx.getParent().resolve(entry + ".tmp"); final Set<String> zip = this.io.openZipIn...
06ef3fcb-dca0-4a4f-b8db-2ec7b34b3e7d
1
public void learn(DataPoint dp) { /* Properly set all neurons. */ /* Calculate the constant part of the derivative. */ double precomputed = 2*(dp.getExpected() - outputNeuron.evaluate()); /* Modify weights. */ outputNeuron.setBias(outputNeuron.getBias()+ alpha*preco...
729f21b7-5acd-4a77-9d2b-81a211915edc
3
public JSONWriter array() throws JSONException { if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { this.push(null); this.append("["); this.comma = false; return this; } throw new JSONException("Misplaced array."); }
168b7660-3410-47c2-8605-74f437f42b48
4
public void update(int delta, boolean onBeat, int bpm) { if (onBeat) { lastFire++; if (lastFire % beatsPerEmission == 0) { if (projectileCount == 1) { projectiles.add(emitProjectile(bpm, directionMin)); } else { int dirDiff = (directionMax - directionMin) / projectileCount; for (i...
8445fcb2-4d0d-4d6d-89b4-909e708c9bf3
8
public static String getVariableType(String s) { s = s.toLowerCase(); if (s.equals("i")) { return "int"; } else if (s.equals("l")) { return "long"; } else if (s.equals("s")) { return "short"; } else if (s.equals("b")) { return "byte"; } else if (s.equals("c")) { return "char"; } else if (s....
6c100415-9396-4d55-b31a-aba54e4c7cbf
2
public void delete() { if(isReadOnly()) return; try { fdbf.seek( recordpos() ); } catch (IOException e) {} writeChars(0,1,"*"); deleted = true; }
c81cce62-63ad-4ae1-afee-6ead4a9b2e75
3
private boolean generate(Painter painter, int resolutionX, int resolutionY, String filename, String imgformat) { // create a buffered image object using RGB+A pixel format BufferedImage image = new BufferedImage(resolutionX, resolutionY, BufferedImage.TYPE_INT_ARGB); // Set a color for each pixel. Y pi...
62eb4b14-8317-4d5e-b572-0cadaf5daaeb
2
public void save() { try { sql.Query.save(this); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } }
c5d0b39c-b73e-47d8-b49c-de039b30a4f6
2
public static Supply createRandomSupply(Position pos){ Supply s; int random=(int) (Math.random()*100); if (random<33){ s=createRandomAmmo(pos); } else if (random < 66){ s=createRandomFood(pos); } else { s=createRandomHealth(pos); } return s; }
3269625e-1e70-4d58-b982-108497e00b48
6
@EventHandler private void onInventoryClickEvent(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); //Make sure that the player is being watched before continuing if (!InventoryMenuManager.isPlayerWatched(player)) return; //Cancel the event to prevent players from adding/removin...
2d39dd26-ce52-412b-bfce-e8dd62db1f3d
8
private boolean check(int row, int col, int[][] columnForRow) { for (int i = 0; i < row; i++) if (columnForRow[i][col] == 1) return false; // 右对角线(只需要判断对角线上半部分,因为后面的行还没有开始放置) for (int i = row - 1, j = col - 1; i >= 0 && j >= 0; i--, j--) if (columnForRow[i][j] == 1) return false; // 左对角线(只需要判断对角线上...
dddad419-b3f1-4a6f-b690-a112226b146e
7
@EventHandler public void onDeath(PlayerDeathEvent e) { Player p = e.getEntity(); if (p.getKiller() instanceof Player) { Player killer = p.getKiller(); if (CTF.gm.isPlaying(p)) { p.setFireTicks(0); p.setHealth(20.0); CTF.lh.tele...
4652b829-2859-49ad-bc44-1976326d4572
6
private boolean aDown(int x){ boolean ret = false; for (int i =3; i > 0 ; i--){ if (grid.get(i).get(x) != null && grid.get(i-1).get(x)!= null){ if (grid.get(i).get(x).getValue() == grid.get(i-1).get(x).getValue()){ //ADDING grid.get(i).get(x).addValue(grid.get(i-1).get(x).getValue()); //NULLI...
2d8aacf8-13f7-404b-ba33-25a039ee0f0d
8
private TableColumn<Object, ?> getNextColumn(boolean forward) { List<TableColumn<Object, ?>> columns = new ArrayList<>(); for (TableColumn<Object, ?> column : getTableView().getColumns()) { columns.addAll(getLeaves(column)); } //There is no other column that supports editing....
51127e76-dd12-4b32-a421-721b97ee86db
5
private long getPosition(int length){ long bestPos = 0; int bestLeng = 0; for (Long pos : freePointers.keySet()){ int leng = freePointers.get(pos); if (length <= leng){ if (bestLeng == 0 || bestLeng > leng){ bestLeng = leng; ...
2c68160d-e09a-464d-b4c7-3cbc60bd31de
0
public void setCharacter(int character) { this.character = character; }
37db06cb-51e3-4a40-9e6f-7dece81bde43
3
public void putAll(Map other) { if (!(other instanceof CoordinateMap)) return; CoordinateMap coords = (CoordinateMap) other; if (!this.ofSameType(coords)) return; for (CoordinateEntry entry : coords.data) this.put(entry); }
55d2a7b0-482e-4949-bbb0-24c579918093
6
public static void main(String[] args) { try { ////////////////////////////////////////// // Step 1: Initialize the GridSim package. It should be called // before creating any entities. We can't run this example without // initializing GridSim first. W...
54a930c6-8163-49ad-b025-0e6f53ffda8b
1
public TreeNode findSubTree(int start,int end,int[] array){ if(end - start < 0 ){ return null; } else{ TreeNode root = null; int mid = (start +end) /2; root = new TreeNode(array[mid]); root.left = findSubTree(start,mid-1,array); ...
626d737b-d864-44a6-b751-8fd4584b3cfb
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DataWrapper other = (DataWrapper) obj; if (value == null) { if (other.value != null) return false; } else if (!value.equals(other.value)...
179b58f0-20a2-4862-aa1d-5fcf40aa12e4
6
public boolean isValidMove(int startCol, int startRow, int endCol, int endRow) { final int MAXBOUNDS = 8; return ((startRow == endRow && Math.abs(startCol - endCol) <= MAXBOUNDS) || (startCol == endCol && Math.abs(startRow - endRow) <= MAXBOUNDS) || (endCol != startCol && startRow != endRow && (Math.abs(end...
0d82a7d8-c82a-4222-8996-36a3cd27e17b
2
private void inputFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_inputFieldFocusGained if ("Type your message here...".equals(inputField.getText()) && inputField.getFont() == fontI) { inputField.setFont(fontD); inputField.setText(""); } inputField.setF...
55c85f11-bba1-44e0-adc5-668b19cfd2ea
4
@Override public void lockFile(FileHandle handle, long byteOffset, long length) throws PathNotFoundException, AccessDeniedException, NotAFileException, UnsupportedFeatureException, AlreadyLockedException { if (hardlinks) { if (RedirectedFileHandle.class.isInstance(handle)) { handle = ((RedirectedF...
c36f0947-6b03-42ce-9865-518446e55e29
1
public static DaoFactory getFactory() throws DaoException { if (factory == null) { factory = new XmlDaoFactory(); // factory = Class.forName("org.training.d4.dao.xml.XmlDaoFactory"); } return factory; }
f2a0914c-3cb0-4c64-8448-0fd450b4d357
9
private static String before(String s){ //System.out.println("befoe input"+s); int closed=0; int countdownIndex=0; int i=s.length()-1; //gets an xtra char but thts alright i hope for (;i>=0&&countdownIndex==0;i--){ if(s.charAt(i)==']'){ closed++; countdownIndex=i; } } int x=countdownIndex-...
3153d5a3-c685-4950-b637-3db4d273e313
5
private void getCertificate() throws IOException { try { SavingTrustManager tm = openSocketWithCert(); // Try to handshake the socket boolean success = false; try { sslsocket.startHandshake(); success = true; } catch (SSLException e) { sslsocket.close(); } // If we...
4b231adc-bc99-493a-a30d-4428c5e4a71c
4
public GameObject getObject(int x, int y) { if (x >= Realm.WORLD_WIDTH || y >= Realm.WORLD_HEIGHT || x < 0 || y < 0){ return null; } return scenobjects[x][y]; }
51aa7369-0469-464b-8ffd-324cafd2369c
6
private void setSpots(int r, int c, int spots, String color) { if (!_board.exists(r, c)) { throw error("board does not exist at %d %d", r , c); } if (spots < 0) { throw error("can only set a nonnegative number of spots"); } if (spots <= _board.neighbors(r...
187fb376-0b6e-412c-8006-3cb6065c1644
9
@Override public void draw(Graphics g){ if (state ==1){ //<editor-fold defaultstate="collapsed" desc="SAT Polygon vs. Circle Test"> cam.applyCamera(g); g.setColor(Color.WHITE.getRGB()); Vector2D point = cam.projectPoint(new Vector2D(Mouse...
ec09851a-9fa0-431e-9637-346ff22268b6
6
public boolean isEdgeInArea(Point p1, Point p2) { double x1 = p1.getX(); double y1 = p1.getY(); double x2 = p2.getX(); double y2 = p2.getY(); if (x1 > x2) { double temp = x1; x1 = x2; x2 = temp; } if (y1 > y2) { double temp = y1; y1 = y2; y2 = temp; } if (getCenterX() >= x1 && getC...
accdfc7e-239f-482c-a014-ff2bc1bcdc5e
4
public Bank() { setTitle("Bank Application"); //remove all listener that we have first for (ActionListener al : JButton_PerAC.getActionListeners()) { JButton_PerAC.removeActionListener(al); } for (ActionListener al : JButton_CompAC.getActionListeners()) { ...
8f5ee718-0e57-4677-b6b9-d5b855252431
4
private int remap(final int var, final Type type) { if (var + type.getSize() <= firstLocal) { return var; } int key = 2 * var + type.getSize() - 1; int size = mapping.length; if (key >= size) { int[] newMapping = new int[Math.max(2 * size, key + 1)]; System.arraycopy(mapping, 0, newMapping, 0, size);...
c97121ad-6a3e-456f-803d-9f60ce7ef6bc
1
@Override public void removeItem(String item) { try { fTPConnector.deleteFile(item); items.remove(item); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
bf72af97-8bc9-4c18-a7c7-7480b9e99d80
9
@Override public void refreshView(Graphics2D g2d) { List<Shape> shapes = shapeManager.getShapes(); for (Shape s : shapes) { if (s instanceof Rectangle) drawRectangle(g2d, (Rectangle)s); if (s instanceof Square) drawSquare(g2d, (Square)s); if (s instanceof Line) drawLine(g2d, (Line)s); if ...
0531d631-828f-4edb-8333-32e7ee085e68
6
private static void testVarkaDemote(L2PcInstance player) { if (player.isAlliedWithVarka()) { // Drop the alliance (old friends become aggro). player.setAllianceWithVarkaKetra(0); final PcInventory inventory = player.getInventory(); // Drop by 1 the level of that alliance (symbolized by a quest ...
b3613ecf-2970-49c0-a97a-237ba31dab41
0
public void setTelefon(String telefon) { this.telefon = telefon; }
80ceccee-dec6-4fe3-8b3d-0aa0aa6f88cc
3
@Override protected void solidifyComponent() { slots = new Slot[this.getNumSubComponents()]; for (int i = 0; i < slots.length; i++) { slots[i] = new Slot(); slots[i].setSize(componentSize, componentSize); if (this.getSubComponent(i) != null) { slot...
6f8f1569-fc36-4a72-ad21-1bf065e00f38
6
static final void method3230(int[] is, int[] is_1_, int i) { try { anInt9606++; if (is == null || is_1_ == null) { Class348_Sub40_Sub6.aByteArrayArrayArray9134 = null; Class190.anIntArray2552 = null; Class59_Sub2_Sub2.anIntArray8684 = null; } else { Class59_Sub2_Sub2.anIntArray8684 = is; Class...
469eb8df-b5f7-4340-99bd-bb531e71f0b3
7
public void testGetArg2() { System.out.println("\n**** testGetArg2 ****"); CycAccess cycAccess = null; try { try { if (connectionMode == LOCAL_CYC_CONNECTION) { cycAccess = new CycAccess(testHostName, testBasePort); } else if (connectionMode == SOAP_CYC_CONNECTION) { ...
cafc806c-7107-4f43-a3d0-c42f0925e68e
3
public static Priority valueOf(int v) { switch (v) { case 1: return HIGH; case 2: return MEDIUM; case 3: return LOW; default: throw new IllegalArgumentException("priority out of range"); } }
d5864794-115a-4708-b33d-f0ff03ab08b9
9
public void populationInfer() { // TODO Auto-generated method stub debugPrint.print("Starting Population Inference Engine step", 5); /*Setup data strucutre to pass to Yifang's code*/ HashMap<String, HashMap<String, HashSet<String>>> data = new HashMap<String, HashMap<String, HashSet<String>>>(); //<User ID...
df7aac8b-5569-4063-8344-4e2461a55819
4
public static int cmpSrcMaj(final int[] buffer, final int first, final int second) { // if (buffer[first + IDX_SRC] < buffer[second + IDX_SRC]) return SMALLER; if (buffer[first + IDX_SRC] > buffer[second + IDX_SRC]) return BIGGER; if (buffer[first + IDX_DST] < buffer[second + IDX_DST]) r...
eafa7c3a-5a11-49ca-8e33-5955bee2eec6
0
public void setTableFieldString(String tableFieldString) { this.tableFieldString = tableFieldString; }
96efac9a-ac48-44c5-b458-f94a5c6a59f4
4
public void move(StringBuffer output) throws EndGameException { Direction directionToMove = getDirectionToMove(); //directionToMove should be crossable if(myPosition.isCrossable(directionToMove)){ if (myPosition.hasCharacter(directionToMove))//attack { Character defender= myPosition.getCharacter(direc...
7fa7da10-a3ab-4816-95a8-14977481fc32
0
public void setObtained(boolean value) { this.obtained = value; }
e272a8dd-ea63-4938-8e36-dd24bbadc3f7
9
private void appendFriendlyClassName(StringBuilder sb, Class<?> cl) { if (cl == null) { sb.append(cl); return; } if (cl.isPrimitive()) { sb.append(cl.getName()); } else if (cl.isArray()) { appendFriendlyClassName(sb, cl.getComponentType());...
ea015697-a1b1-40e4-96b0-cd5793d55510
8
public static void mouseExited(MouseEvent mouseEvent) { Iterator<PComponent> it = components.iterator(); while(it.hasNext()) { PComponent comp = it.next(); if(comp == null) continue; if (shouldHandleMouse) { if (comp.shouldHandleMouse()...
6deedc25-59b6-4639-8b1d-a61ec14da358
7
public Product inputProduct() { Product product = null; String reply = keyboard("Select product (y - Yes, n - No)"); if (reply.equals("y")) { product = selectProduct(); } if (product != null) { return product; } String typeOfTheProduct = ...
ea4111c9-bc07-424b-8c2a-b18da501b152
2
public static void main(String args[]) { Thread t = new Thread(() -> { while (true) { // updateBalance(); //use synchronized updateBalance2(); // don't use synchronized } }); t.start(); t = new Thread(() -> { while (true) { monitorBalance(); } }); t.start(); }
14d99216-8e4c-4809-9533-32f0388a814f
0
public static void GenerateReport() { System.out.println("The term is finally done! Lets see how Damon did this term."); DamonMarksReport(); DamonGamingReport(); DamonSportsReport(); }
cff3809e-8934-49e7-8b71-d360cd9f5c57
6
public static List<ITileObject> loadMap(String file) { try { InputStream stream = MapLoader.class.getClassLoader().getResourceAsStream("res/maps/" + file); BufferedImage bufferedImage = ImageIO.read(stream); final byte[] pixels = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData(); ...
54a38f37-6563-4bac-8f5e-a62b5dcaeaff
5
@Override public boolean equals(Object obj2) { if (obj2 instanceof Token) { Token tok2 = (Token) obj2; if (this.value.getClass() != tok2.value.getClass()) { return false; } if (this.count != tok2.count) { ...
194e73f8-9ba1-4154-b8d7-91cd9e9f71c7
7
public ListNode reverseKGroup(ListNode head, int k) { ListNode header = new ListNode(0); header.next = head; ListNode[] nodes = new ListNode[k]; int count = 0; ListNode pre = header; ListNode p = head; while (p!=null){ while(p!=...
7d6f2f21-7195-4f49-b87d-d1113ebd4317
0
public void setCell(int x, int y, Cell cell) { this.cells[x][y] = cell; }
74ce0f88-e1fd-4676-b78c-81e4ea795893
5
public static boolean wasKeyReleased(char c) { if (!keyrCheckInitiated) { keyrCheckInitiated = true; keyrLastUpdate = System.currentTimeMillis(); } if (keyrLastUpdate + TIMEOUT < System.currentTimeMillis()) { app.keysReleased.clear(); } Character n = new Character(c); try { ...
8649b0ee-b20b-4b95-acfd-177948ffaee5
2
public void setIn(Node node, Object o) { if(this.in == null) { this.in = new Hashtable<Node,Object>(1); } if(o != null) { this.in.put(node, o); } else { this.in.remove(node); } }
074eece7-3a55-4634-979a-967ba0fc29ba
6
public void createPartControl(Composite frame) { final ToolTipHandler tooltip = new ToolTipHandler(frame.getShell()); GridLayout layout = new GridLayout(); layout.numColumns = 3; frame.setLayout(layout); String platform = SWT.getPlatform(); String helpKey = "F1"; if (platform.equals("gtk")) helpKey =...
e5b5850a-857c-4f41-bffc-3d7c54fdb3c9
9
@Override public boolean InitBase(int ptra_v2m) { int d = 0; m_base.timediv = v2mBuffer.getInt(d); //System.out.println(m_base.timediv); m_base.timediv2 = 10000 * m_base.timediv; //System.out.println(m_base.timediv2); m_base.maxtime = v2mBuffer.getInt(d + 4); //System.out.println(m_base.maxtime); m_base.gdnu...
0fdb80cc-98ef-4277-92b4-3cdf1e87ed13
2
public boolean isPalindrome(int x) { if(x < 0) return false; int y=0; int val = x; while(val > 0){ y = y*10+ (val % 10 ); val = val /10; } return y == x; }
56f74c30-4927-4c79-b1b9-290c061fe250
1
public static List<?> arrayToList(Object source) { return Arrays.asList(SpringObjectUtils.toObjectArray(source)); }
91b45250-a9f6-4d32-8e9e-50b62298e0df
7
private boolean doAction(final String action, final SceneObject obj) { if(Players.getLocal().getAnimation() == -1 && !Players.getLocal().isMoving()) { if(obj.getLocation().distanceTo() > 5) { Walking.walk(obj.getLocation()); } else { if(!obj.isOnScreen()) { Camera.turnTo(obj); } else { if(...
e1c9533e-af09-4005-b79f-9f7cc888c50a
0
public Provider() { this.products = new HashMap<>(); }
6e64bd73-d299-4eb6-ac12-0af1c3f65694
0
public void lopetaTaso() { this.osuikoJohonkin = EsteenTyyppi.QUIT; }
e95ca645-3fab-40f1-89de-b06671f47b7a
3
private boolean vecInList(ArrayList<Node> list, Vector2 vector){ for(Node n : list) { if(n.tile.x == vector.x && n.tile.y == vector.y) return true; } return false; }
1e0c9ab4-1959-4563-aa4b-bfd1729b9eff
9
public String render(){ String s = ""; //keep track of whether the previous part of the term was wrapped with parentheses //this is so we can distinguish between 62 and 6(2), etc. boolean prevHadPar = true; String prevClass = "";//the name of the class of the previous part of the term for(int i = 0; i < thi...
feb48542-ba19-4983-86c9-5ec132ff2626
3
private void fullStrize(){ for(int i = 0; i<n;i++) stroki[i]=new Stroka(A[i]); stolbiki = new Stolbec[m]; for(int i=0; i<m;i++) { stolbiki[i] = new Stolbec(n); for(int j=0; j<n; j++){ stolbiki[i].setone(j, stroki[j].get(i) ); ...
bf0d0702-01ad-4635-8543-9c7b57529b2a
8
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) { final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset()); final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColo...
98370d2f-6b8e-44fe-85cc-f102d1c8aa92
8
public static void main(String[] args) { EvolvingGlobalProblemSetInitialisation starter = new EvolvingGlobalProblemSetInitialisation(); starter.initLanguage(new char[] { '0', '1' }, 10, "(1(01*0)*1|0)*"); int solutionFoundCounter = 0; int noSolutionFound = 0; List<Long> cycleCount = new LinkedList<Long>(); ...
c9f82fcf-2117-414c-b667-9884616adabd
9
@Override public AssertionResult getResult(SampleResult samplerResult) { AssertionResult result = new AssertionResult(getName()); byte[] responseData = samplerResult.getResponseData(); if (responseData.length == 0) { return result.setResultForNull(); } if (isJsonValidation()) { try { if (...
036b50b9-65b5-4e83-903a-a4ad39891b90
7
public static int[] Verprofit(int[] prices) { int len = prices.length; int max = prices[len-1]; int maxPosition = len; int min = prices[len-1]; int minPosition = len; int lastPoint = prices[len-1]; int newMax = -1; int newMaxPosition = -1; int[] result = new int[len+1]; result[len] = 0; result[len...
a458140d-7d26-48d8-b0ab-b9d77b794352
2
@Test public void heapTest(){ long start = System.currentTimeMillis(); for (int i = 0; i < 1000000; i++){ binaryheap.insert(i); } for (int i = 0; i < 1000000; i++){ binaryheap.delete(); } long end = System.currentTimeMillis(); ...
9a7f3df1-1a7a-42ef-8721-6670f3f608a2
8
public void acceptCmd(UUID idClient, byte[] data) { int index = getIndex(data); byte cmd = getCmd(data); if (index < 0 || index >= locks.keySet().size()) { if (!send(idClient, false)) error("acceptCmd", "failed to send fail to client: " + idClient); } else if (cmd == 0 && (locks.get(index).peek() == null ...
d2052881-4a08-4fef-b36a-28b5bab63d6d
3
public static Color getCurrentSecondary(ColorType c) { if (c == ColorType.WALL || c == ColorType.SLOW_WALL) if (beatCount % 2 == 0) return getAltSecondary(); return SECONDARY_COLOR_MAP.get(getColor(c)); }
cb01ba40-ca50-489a-970d-83da8331ef92
7
public static void printlocOutDegVsWheightedMeanPersonSocScore(){ HashMap<Integer,Integer> outDegree = new HashMap<Integer,Integer>(numLocations); HashMap<Integer,Double> meanSoc = new HashMap<Integer,Double>(numLocations); try { Connection con = dbConnect(); Statement getOutDeg = con.createStatement(); ...
363c341a-dc7a-4dd7-a859-c973dbe73351
1
public int sum(String inputNumbers) { if (inputNumbers.isEmpty()) return 0; else { return sumNumbers(parseInput(inputNumbers)); } }
7dd4a8d6-f6ec-4a3a-8932-f82b8fbeed37
7
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
dc47aa09-dbe4-4f4a-bf24-de7bc6b84261
3
private float[] popFloatArray() throws PDFParseException { Object obj = stack.pop(); if (!(obj instanceof Object[])) { throw new PDFParseException("Expected an [array] here."); } Object[] source = (Object[]) obj; float[] ary = new float[source.length]; for (in...
92087439-c03d-4eea-bbb0-fcdd1af03315
7
private boolean isLinked(File file, List<File> list) { String s = file.getName(); BufferedReader br = null; String line; for (File f : list) { if (!f.equals(file)) { try { br = new BufferedReader(new FileReader(f)); line = br.readLine(); while (line != null) { if (line.indexOf(s) != ...
9f467ef2-694b-401b-a149-7eec49f0c84d
1
public int getNumberOfMarkerOwners(String matchName){ try { cs = con.prepareCall("{ call GET_MARKEROWNERCOUNT(?,?) }"); cs.setString(1, matchName); cs.registerOutParameter(2, Types.INTEGER); cs.executeQuery(); //System.out.println("number of players in team: " + cs.getInt(3)); return cs.getInt(2); ...
37eb1ccf-fab7-43c2-8367-6f9c83308784
5
public TransactionSet findKItemSubsets(ItemSet itemSet, int k) { TransactionSet allSubsets = new TransactionSet();/*New subset of transactions to return in a TransactionSet*/ int subsetCount = (int) Math.pow(2, itemSet.getItemSet().size());/*index control for loop*/ int itemSetSize = itemSet.getItemSet().size();/...
e4498dd8-46f2-4774-bf87-696f3897be9c
8
public void actionPerformed(ActionEvent e) { result = new StringBuilder(); try { String patternText = patternMatcher.patternText(); MatcherPreferences.storePatternText(patternText); final List<String> testStringTexts = patternMatcher .testStringTexts(); for (int i = 0, n = testStringTexts.si...
16abe45d-5140-404a-89b7-8041067887bc
5
private static void playAgainstOpponentOnServer(int gameId, int color, int teamNumber, String secret) { PlayChess ourTeam = new PlayChess(color, gameId, teamNumber, secret); while (true) { System.out.println("POLLING AND MOVING FOR " + color); Response r = ourTeam.poll(); System.out.println(r); if (ourT...
ec592bbe-e07b-42cf-8cd3-2d7f4f40ea30
3
public boolean hasHepatitis(String player) { String query = "SELECT * FROM nosecandy WHERE hepatitis='1';"; ResultSet result = null; result = this.sqlite.query(query); boolean hepatitis = false; try { if (result != null && result.next()) { hepatitis = result.getBoolean(Column.HEPATITIS.getName()); }...
1f0378a0-f1f9-40ff-9f8f-dd17940a592a
4
public static int calculatePreferredHeight(FontMetrics fm, int maxWidth, String text) { if("".equals(text)) { return 0; } // utility that helps us to break the lines final BreakIterator bi = BreakIterator.getLineInstance(); bi.setText(text); int lineCount = 0; final int lineHeig...
afe2786c-10e1-4f84-81fd-847e6cad1b5d
6
public static void startupHtmlUtilities() { { Object old$Module$000 = Stella.$MODULE$.get(); Object old$Context$000 = Stella.$CONTEXT$.get(); try { Native.setSpecial(Stella.$MODULE$, Stella.getStellaModule("/ONTOSAURUS", Stella.$STARTUP_TIME_PHASE$ > 1)); Native.setSpecial(Stella.$CONTE...
a3be145f-6088-4903-a926-9728dd015063
9
public void shouldBeEqual(PrintWriter oo, Heaper original, Heaper imported, Heaper importedAgain) { boolean oi; boolean oa; boolean ia; oi = original.isEqual(imported); oa = original.isEqual(importedAgain); ia = imported.isEqual(importedAgain); if (oi && ( ! oa && ( ! ia))) { oo.print("2nd import "); oo.prin...