method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
7f35a564-5e06-4913-9208-ba6b4f5abb8a
7
private String pickOnSwingThread(String[] aliases) { Preferences prefs = Preferences.userNodeForPackage(getClass()); String choosenAlias = prefs.get("choosenAlias", ""); final JOptionPane pane = new JOptionPane(); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JButto...
f5ca84e3-6510-4db8-8d24-2f167a7dc2ad
2
private synchronized void recenterMouse() { if (robot != null && comp.isShowing()) { centerLocation.x = comp.getWidth() / 2; centerLocation.y = comp.getHeight() / 2; SwingUtilities.convertPointToScreen(centerLocation, comp); isRecentering = true; ...
44d5f65e-d7e0-4333-b712-db50f1c2e5ae
5
public Omni<T> setAll(Object sourceObj){ // if this object is null or the sourceObj is null, then, do nothing and return this. if (classInfo == null || sourceObj == null){ return this; } Omni jSource = (sourceObj instanceof Omni)?(Omni)sourceObj:mapper.omni(sourceObj); Class targetClass = classInfo.getObj...
c774ac33-053e-427d-b205-d1e6449eb47c
7
public void writeEnemy(int a_y, byte a_data) { //Check boundaries if(m_currentXWritting == -1 || a_y < 0 || a_y >= LEVEL_HEIGHT) return; if(a_data == Sprite.KIND_MUSHROOM || a_data == Sprite.KIND_FIRE_FLOWER) { if(!m_itemCollection.containsKey(m_currentXWritt...
c86bae9e-9c3a-4249-81c6-cd1462b22654
6
public boolean equals(Object other) { if (other instanceof FileHash) { FileHash fh = (FileHash) other; if (hash != fh.hash || fileLength != fh.fileLength) return false; if (digestBytes.length != fh.digestBytes.length) re...
2c0a1e8e-4873-46ce-9d89-765a0e0f4e76
9
private Shape createShapeWithTwoParameters(BufferedReader reader, String shape, ShapeColor color, Map<String, String[]> shapeMap) { // Ask for 2 parameters System.out.println(shapeMap.get(shape)[0] + ":"); double param1 = readParameter(reader); System.out.println(shapeMap.get(shape)[1] + ":"); double para...
8072143d-1c22-4bc8-9d9c-28f1143017eb
3
public boolean hasMoreShips() { for (int x = 0; x < SIZE; x++) { for (int y = 0; y < SIZE; y++) { if (fField[x][y] == VALUE_SHIP) { return true; } } } return false; }
a94cca2e-755d-47db-bd8c-7619750ccb82
4
private void interpret(final String l) { final String line = uncommentAndTrim(l).replace("##", "#"); if (line.startsWith("[")) { final int end = line.indexOf(']'); if (end < 0) throw new IllegalArgumentException("no area definition: " + line); area = line.substring(1, end).trim(); ...
0fc5355f-eecf-49c2-8fe4-a1f1e3fc3813
6
final void method522(byte i) { anInt5266++; if (anIntArray5269 != null && i < -27) { for (int i_0_ = 0; i_0_ < 10 && anIntArray5269.length > anInt5270 + i_0_; i_0_++) { if (aByteArrayArray5275[i_0_] == null && aClass45_5267.isLoaded((anIntArray5269 [i_0_ + anInt5270]), 0)) a...
0e97aa3d-fa02-4abc-8ed7-1e9e60df54b4
7
public List<PackedItem> getAllPackedItems(Session S) { final List<PackedItem> items=new LinkedList<PackedItem>(); if(super.miscText.trim().length()>0) { final int locStart=super.miscText.lastIndexOf(locationsDelim); final int contStart=super.miscText.lastIndexOf(containerDelim); if((locStart>0)&&(contSt...
88e1d2a0-80f7-4900-9509-20a166eb1f50
4
public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = in.readLine(); String[] num = line.split("\\s+"); int n = Integer.parseInt(num[0]); int m = Integer.parseInt(num[1]); int[] low = new int[n+1]; int...
e7cc6177-46d1-4db1-aae0-ab6aaae7b38d
5
@Override public String getFinishedResult(String id) { File finish = new File(getFilePath(id)); String content = ""; if (finish.exists()) { Scanner scan = null; try { scan = new Scanner(finish).useDelimiter("\\Z"); //delimiter na konec souboru if (scan.hasNext()) { content = scan.next(); ...
2bf49a52-0356-489a-a79e-2f6f878c9ac6
8
public void setDirection(faceWay way) { Vector2D dif = new Vector2D(bodyPartPos.get(0).x() - lastHeadPos.x(), bodyPartPos.get(0).y() - lastHeadPos.y()); if(way == faceWay.up && dif.y() <= 0 ) { direction.setCoords(0, -STEP_SIZE); } else if(way == faceWay.down && dif.y() >= 0) { direction.setCoord...
caafd7ed-ddce-43ec-82e7-527f94d2be48
8
private boolean r_postlude() { int among_var; int v_1; // repeat, line 62 replab0: while (true) { v_1 = cursor; lab1: do { // (, line 62 // [, line 63 bra = cursor; // substring, line 63 among_var = find_among(a_1, 3); if (among_var == 0) { break lab1; } // ], line 63 ...
3844f456-3559-4e77-ab76-9a6e1548afab
8
public void mod(TACCommand c) { if ((c.getP1() instanceof VarLocation) && (c.getP2() instanceof Literal)) { VarLocation loc = (VarLocation) c.getP1(); assembly.add(" movl $0, %edx"); assembly.add(" movl " + offset(loc) + ", %eax"); //muevo el dividendo operando al r...
bd254624-30d2-4923-a647-e3f2239cc820
5
private String searchLegals(String str) { String tmp = null; int start = str.indexOf("<div id=\"game_area_legal\">"); if (start >= 0) { tmp = str.substring(start); int end = tmp.indexOf("</div>"); if (end >= 0) { tmp = tmp.substring(0, end + 6); } start = tmp.indexOf("<p>") + 3; end = tmp.l...
66a1baf3-ea7c-4eb3-84cf-110daf410fe0
9
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(target,null,null,L("<S-NAME> alread...
a52ecde1-dd12-4b8f-b38c-89eb32554d27
9
public String showEquipment(){ boolean noEquipment=true; String retVal="Equipped items:"+"\n"+"\n"; for(int i=0;i<INVENTORYSLOTS;i++){ if(equippedItems[i]!=null){ //if an item is equipped in the slot noEquipment=false; String slotName=""; switch(i){ //maybe this switch statement should have...
0c6f4d05-938c-408c-a081-6b35ba4bcccf
3
public void visitFlowGraph(final FlowGraph cfg) { if (FlowGraph.DEBUG) { System.out.println("Verifying CFG for " + cfg.method()); } this.cfg = cfg; uses = new HashSet(); nodes = new HashSet(); cfg.visitChildren(this); final Iterator e = uses.iterator(); while (e.hasNext()) { final Expr use = ...
d382ecfd-1cce-4a17-986f-4b6c9137a9eb
6
private void eventLogin(String command) { UILogin UI = ((UILogin) display.getUI()); UI.warningClear(); switch (command.charAt(0)) { case 'N':// Num0-Num9 UI.codeAddNum(Integer.parseInt(command.substring(3, 4))); break; case 'C':// Clear UI.codeClear(); break; case 'B':// Back UI.codeBack()...
8205c43d-cdc4-4dc1-87cb-01ec13499738
4
private boolean yIntersects(Vec3D var1) { return var1 == null?false:var1.x >= this.x1 && var1.x <= this.x2 && var1.z >= this.z1 && var1.z <= this.z2; }
85c5cb57-d55e-4796-84ad-65a11b96b5d1
7
public int getRenderHeight(int width, int size) { if(cachedRenderHeight == -1 || cachedWidth == -1 || cachedSize == -1 || width != cachedWidth || size != cachedSize) { cachedWidth = width; cachedSize = size; if(width > 0) { ArrayList<String> set = new ArrayList<String>(); int h = 0; set = Fo...
7cad1a61-6ddb-43ae-b209-88cf547b2487
1
public SkidMarkManager(World world) { for (int i=0; i<SKID_MARKS; i++) { skidmarks[i]=new SkidMark(); world.addObject(skidmarks[i]); } }
ea3a45ef-c30e-423e-b99a-7c984b8dc469
4
public boolean use() { synchronized (this) { return canUse() && start() && send() && new TimedCondition(700) { @Override public boolean isDone() { return !canUse() || BarNode.this.isDone(); } }.waitStop(); } }
76317fb7-346f-4890-ad7a-a54bff1fb854
8
private void updateGate(String A, String B, String C, String D, String E, String F, String G, String H, String Y) throws InvalidPinException { if (this.isHigh(A) && this.isHigh(B) && this.isHigh(C) && this.isHigh(D) && this.isHigh(E) && this.isHigh(F) && this.isHigh(G) && this.isHigh(H)) { this.setPin(Y, Pin.PinSt...
3f78d1dd-c163-4e5c-a626-564c54eab1a6
5
@Override public void caseAWhileStmt(AWhileStmt node) { inAWhileStmt(node); if(node.getStmt() != null) { node.getStmt().apply(this); } if(node.getRPar() != null) { node.getRPar().apply(this); } if(node.getExp() != null) ...
1b17850c-5db1-4255-abfb-c422735f3c78
5
public int sum(int a, int b) { while(true) { if(! this._is_local()) { org.omg.CORBA.portable.InputStream _is = null; try { org.omg.CORBA.portable.OutputStream _os = _request( "sum", true); _os.write_long(a); _os.write_long(b); _is = _invoke(_os); int _result = _is.read_long(); ...
ebe09048-6509-4428-a3cd-72b89474b085
4
@Override public void update() { checkTileCollision(); setPos(xTemp, yTemp); if(dx == 0 && !hit) setHit(); animation.update(); if(hit && animation.hasPlayedOnce()) remove = true; }
0af9dd06-1996-49b1-a110-f8cc3027f1a3
2
private void copyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyButtonActionPerformed TreePath path = this.studiesList.getSelectionPath(); if(path == null || path.getLastPathComponent().equals("Root")) return; // No study selected. Study study =...
0d172124-4022-47aa-bfde-982521a87181
6
public final void skipLine() { int ch; while (pos < length) { ch = src[pos]; if ((ch == 10) || (ch == 13)) { break; } pos++; } while (pos < length) { ch = src[pos]; if ((ch == 10) || (ch == 13)) { ...
db72a900-c8b6-4e98-85f9-d5b923ccb9d8
4
public static MetaData getPZMetaDataFromFile(final String line, final char delimiter, final char qualifier, final Parser p, boolean addSuffixToDuplicateColumnNames) { final List<ColumnMetaData> results = new ArrayList<ColumnMetaData>(); final Set<String> dupCheck = new HashSet<String>(); ...
0beff20c-8db4-42f3-8a31-fb0762b18d23
8
public void shift(String dir, int row, int col) { switch (dir) { case "up": for (int r = row; r < 3; r ++) BOARD[r][col] = BOARD[r+1][col]; BOARD[3][col] = 0; //set last one to 0 because all others have been shifted break; case "down": for (int r = row; r > 0; r --) BOARD[r][col] = BOARD[r-1...
6effd832-16fb-423b-b097-7d4ad04bc3e4
0
@Override public void setFileName(String fileName) { this.fileName = fileName; }
4c2177ab-0bdb-4a3c-a3c7-e5f448dd1dbb
4
private static void doFindVariants() throws MVDToolException { try { MVD mvd = loadMVD(); if ( version == 0 ) version = 1; Variant[] variants = mvd.getApparatus( version, fromOffset, variantLen ); if ( mvd.getEncoding().toUpperCase().equals("UTF-8") ) out.write( UTF8_B...
b1e003eb-d6ae-4e79-aa0c-db68a4e79bf7
9
protected Node representSequence(Tag tag, Iterable<? extends Object> sequence, Boolean flowStyle) { int size = 10;// default for ArrayList if (sequence instanceof List<?>) { size = ((List<?>) sequence).size(); } List<Node> value = new ArrayList<Node>(size); SequenceNo...
fcd007f3-b594-4c54-a4e1-f3e4af1e7cec
5
public boolean mousewheel(Coord c, int amount) { for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) { if (!wdg.visible) continue; Coord cc = xlate(wdg.c, true); if (c.isect(cc, (wdg.hsz == null) ? wdg.sz : wdg.hsz)) { if (wdg.mousewheel(c.add(cc.inv()), amount)) { return (true); } } ...
d5570f67-d979-4fda-8e4e-1883427f0f8d
4
public static void main(String[] args) { System.out.println(RandomUtil.GUID()); int count = 0; int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; for (int i = 0; i < 100000; i++) { // int temp = RandomUtil.randomIntIn(100); int temp = RandomUtil.ran...
9a88cb8a-7373-4602-b024-c58f5052315b
5
public int VerifyValidity() { boolean ret = header.ckID == FourCC("fmt ") && (data.nChannels == 1 || data.nChannels == 2) && data.nAvgBytesPerSec == ( data.nChannels * data.nSamplesPerSec * data.nBit...
de1ba9c2-2a99-418a-b4a6-bf3a65f595d2
4
public static int characterSize(int character) throws JSONException { if (character < 0 || character > 0x10FFFF) { throw new JSONException("Bad character " + character); } return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3; }
a56de0bf-4d03-4dc3-998c-9654270d3cf2
1
public BasicIOHandler(final InputStream IS, OutputStream OS, IConnectionManager imh, boolean client) { IMH = imh; log.fine("Creating Streams"); dis = new DataInputStream(IS); dos = new DataOutputStream(OS); if(imh.getSide() == Side.CLIENT) { startHandshake(client); } else { sendPacket(imh.getPacketReg...
0416dee2-8e0c-4f7c-ae2c-ab4249e7d5a3
9
public synchronized boolean fill() throws IOException { try { if (pos > fc.size()) return false; } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } byte[] bytes = new byte[CHUNK]; bb = ByteBuffer.wrap(bytes); try { // System.out.println(pos + " - " + (pos ...
52f2e12b-70cf-4f94-ac10-cc876d0ed2ac
7
private void maxHeapify(int a[], int i, int heapSize) { int left = left(i, a, heapSize); int right = right(i, a, heapSize); int largest = i; if (left == -1 && right == -1) { return; } if (left != -1 && a[left] > a[largest]) { largest = left; ...
8621832f-56d5-44ce-9a4b-ced9ba9182fc
4
public Thread acquirePackets(final List<Packet> buffer, final int count) { //Method to hold the received packets in an arrayList of packets //ArrayList of packets called List final PacketReceiver receiver = new PacketReceiver() { //Declaration of a new packetReciever called receiver @Override public v...
4120fc3a-3b6f-4096-b933-891c219ae481
1
public Soundplayer(String path) { AudioInputStream ais; try { ais = AudioSystem.getAudioInputStream(getClass().getClassLoader().getResource(path)); clip = AudioSystem.getClip(); clip.open(ais); volume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); } catch(Exception e) { e.pri...
ade1443a-3e51-4ece-a0e5-3c691adb981f
6
protected void notifySubscribers(String topicKey, String userKey, List<SubscriberData> subscribers, boolean selfNotify, String jsonMessage) throws SubscriberNotificationExc...
cfc912fb-4735-4ed8-863b-688a49c8711a
8
public boolean isAssignableTo(Type type) { if (resolved != null) return type.isAssignableFrom(resolved); if (Type.OBJECT.equals(type)) return true; if (potentialClass != null && !type.isAssignableFrom(potentialClass)) potentialClass = null; Map map ...
eb3e7c89-bdd6-413b-a935-61d3fb3e083b
2
private void processPsCommand() { if (processes.isEmpty()) { System.out.println("No running process"); } else { Iterator<MigratableProcess> it = processes.iterator(); while (it.hasNext()) { MigratableProcess process = it.next(); System....
d239c56d-d85f-49b1-995c-9a8fb3731742
8
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ComplexObject that = (ComplexObject) o; if (longValue != that.longValue) return false; if (!firstAggregate.equals(that.firstAggregate)) return ...
0c087d49-43db-444c-ab78-4fe63d6533cc
2
public List<User> displayAll() { List<User> userList = new ArrayList<User>(); try { // Erforderlicher SQL-Befehl String sqlStatement = "SELECT * FROM bookworm_database.users;"; // SQL-Befehl wird ausgeführt myResultSet = mySQLDatabase.executeSQLQuery(sqlStatement); while (myResultSet.next()) { ...
97016560-ca13-41bb-8338-5c1e4cd13626
8
private ArrayList<Task> searchKeyword(String keyword) { toDisplay.clear(); String[] keywords = keyword.split(" "); for (int i = 0; i < current.size(); i++) { Task temp = current.get(i); if (containStrings(temp.getTaskName(), keywords)) { toDisplay.add(temp); temp.setKeyWord(keyword); } } ...
2085b9d5-2966-470b-ad29-9ace0e152ca0
8
public static int[] runThreeCard (int [] c, long dead) { int res[] = new int[Valuation.NUM_RANKINGS]; for (int i=0; i<52; i++) if (((one<<i)&dead) == 0) for (int j=i+1; j<52; j++) if (((one<<j)&dead) == 0) for (int k=j+1; k<52; k++) if (((one<<k)&dead) == 0) for (int l=k+1; l<52; l++) ...
8962556b-0b9a-4431-bcdc-b69a43f7f5f1
8
private static String fixName(final String s) { if(s.length() > 0) { final char ac[] = s.toCharArray(); for(int j = 0; j < ac.length; j++) if(ac[j] == '_') { ac[j] = ' '; if((j + 1 < ac.length) && (ac[j + 1] >= 'a') && (ac[j + 1] <= 'z')) { ac[j + 1] = (char) ((ac[j + 1] + 65) - 97); ...
7e8822bd-ea0b-4f5f-9f69-b79a2c8cdaa8
8
public List<VariableAppearance> getVariableAppearances( FileObfuscationStructure structure, boolean firstScan) { List<VariableAppearance> result = new ArrayList<VariableAppearance>(); for (IStringAnalyser analyzer : stringAnalysers) { if (firstScan || (analyzer.isTwoScansAnalyzer())) { if (analyzer.isOutO...
334693cc-3e68-46a9-9797-1980d6e07522
7
private List<String[]> getValueList(int[] arrayToSort, String problemSize, String status, List<String[]> values) throws NotSortedException { // do all sorts int length = arrayToSort.length; int[] copy = arrayToSort.clone(); Insertionsort myInsertion = new Insertionsort(); myInsertion.sort(arrayToSort); ...
b28e3fc1-48c7-463d-825e-dc148a54275c
4
private boolean insideBounds(Position position) { if (position.getX() >= 0 && position.getX() < field.length && position.getY() >= 0 && position.getY() < field[0].length) { return true; } return false; }
a551bd2b-e971-491b-96ca-6321fe4eb663
5
@Override public boolean equals(Object other) { try { PlayerImpl otherPlayer = (PlayerImpl) other; return (strategy == null && otherPlayer.strategy == null) || (strategy != null && otherPlayer.strategy != null && strategy .equals(otherPlayer.strategy)); } catch (ClassCastException e) { return ...
71c320f7-224e-4379-ab72-f71867244de7
5
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page ...
ecc3e60b-60b0-4648-8bdc-00c1e90fa9ad
9
public static void showHelp(Player player) { player.sendMessage( ChatColor.YELLOW + "**" + ChatColor.GREEN + "-----=={" + ChatColor.YELLOW + " SugCubeCommandPack-Help " + ChatColor.GREEN + "}==-----" + ChatColor.YELLOW + "**"); player.sendMessage( ChatColor.GOLD + "Plugin made by MrSugarCane...
04434599-e476-4c2b-9560-784f459422c4
1
public static boolean checkProcessEnd(Process process) { try { logger.info("Process ends with exit value: " + process.exitValue()); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
e4cb5f3d-238d-42b0-84e1-9b492c3da615
2
public byte[] toByteArray() { byte[] p = new byte[PACKAGE_SIZE]; for(int i = 0; i < HEADER_SIZE; i++) { p[i] = header[i]; } int payloadOffset = HEADER_SIZE; for(int i = 0; i < PAYLOAD_SIZE; i++) { p[i + payloadOffset] = payload[i]; } return p; }
c29b9394-b3a7-4459-a8aa-b2d9dc26f8cb
7
public WorldSavedData loadData(Class par1Class, String par2Str) { WorldSavedData worldsaveddata = (WorldSavedData)loadedDataMap.get(par2Str); if (worldsaveddata != null) { return worldsaveddata; } if (saveHandler != null) { try { ...
294ba9dd-826b-4360-a5a7-c1b7ffe64f22
0
public Tutorial() { super("What would you like to know?"); panel = new JPanel(new GridLayout(5, 1)); rules = new JButton("Rules"); generalPlay = new JButton("General Play"); capturing = new JButton("Capturing"); territories = new JButton("Gaining territories"); endGame = new JButton("End Game"); map =...
7f6a3eaa-e0a6-4d69-8600-ce92d1bf9cf4
2
public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); XMLTokener x = new XMLTokener(string); while (x.more() && x.skipPast("<")) { parse(x, jo, null); } return jo; }
3d042252-853a-4d6c-863d-8ad5aae69970
7
public Long resolve() throws IOException { if (resolved) { throw new IOException("Value already resolved"); } resolved = true; boolean negative = false; long value = 0; int b = 0; while ((b = is.read()) >= 0) { int digit = b - '0'; if (digit < 0 || digit > 9) { if (b == '-') { ...
928a5ed4-a13c-47d3-a7c5-57c1f9a5afb7
3
public int getStance(String playerName, String targetName) { if (playerName.equalsIgnoreCase(targetName)) return 0; int stance = Config.defaultStance;// Not found. String SQL = "SELECT *" + " FROM " + tblStances + " WHERE `player` LIKE ?" + " AND `target` LIKE ?"; // boolean found = false; try { Conn...
9ae8f1c6-ac5e-466e-b7f7-61479f1f78b9
7
private List<Sprite.Part> findobsc() { ArrayList<Sprite.Part> obsc = new ArrayList<Sprite.Part>(); if (obscgob == null) return (obsc); boolean adding = false; for (Sprite.Part p : clickable) { Gob gob = (Gob) p.owner; if (gob == null) c...
524620b8-3d14-45fb-8d6c-0cbaa95f054d
3
public void setExtraHeader(String userAgent, String cookie) { if (EXTRA_HEADER == null && (!CommonUtils.isStringNullOrWhiteSpace(userAgent) || !CommonUtils.isStringNullOrWhiteSpace(cookie))) { EXTRA_HEADER = new HashMap<String, String>(); EXTRA_HEADER.put(EXTRA_HEADER_USER_AGENT, userAgent); EXTRA_HEADER.put...
6f2110c3-229f-46ff-a2cb-c18c2b28e4f9
2
public void move(){ int RandomWalk; if (!_arriere){ moveX(_vitesse / 200 * _REFRESH_POS / 5); } else { moveX(-_vitesse / 200 * _REFRESH_POS / 5); } RandomWalk = (int) (Math.random() * 3000); if (RandomWalk < 3) { switchArriereState(); } updateTexture((int)Math.ceil(1.0 * (_liste_textur...
cab99357-a995-49bc-b2f3-3369b71d545c
7
private Task<?> getParent(Set<Related<Task<?>>> relationships) { Task<?> potentialParent = null; for(Related<Task<?>> related : relationships) { if (related.getRelationship().equals(Relationship.CHILD_OF.name())) { return related.getRelated(); } else if (related.getRelation...
3deeb8a9-cb77-4cb3-97e9-da82aca4bcb6
2
@Test public void multipleInsertsHasCorrectOrder() { for (int i = 0; i < 10; i++) { a.insert(new Vertex(0, i)); } for (int i = 0; i < 10; i++) { assertEquals(i, a.get(i).getDistance()); } }
d20ca0c8-cda2-4544-812f-8dd546cf62e2
5
public int getRight(int yBottom, int range, TBlock movingBlk) { int minX = 11; int yTop = yBottom + range; for (TBlock blk: blks) { if (!blk.equals(movingBlk)) { TSquare[] sqs = blk.getSquares(); for (int i = 0; i < sqs.length; i++) { Point2D pInContainer = blk.getSqCoordinate(i); i...
9b6406d4-5877-416c-a5f6-04dc100e95de
5
public CheckResultMessage checkDayofMonth8() { int r1 = get(13, 5); int c1 = get(14, 5); date(); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); if (!(getValueString(r1 + maxDay, c1 - 1, 3).equals(maxDay + "日"))) { return...
e59ae5a4-73cd-4b9c-b9b6-c887d7f34f8a
2
private void progress(String p) { synchronized (ui) { if (progress != null) progress = null; if (p != null) progress = textf.render(p, java.awt.Color.WHITE); } }
7b14da5f-1ce6-465c-86b7-1f811fab8de2
4
public static void main(String[] args) { int[][] arr = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 16 } }; for (int[] a : arr) { for (int b : a) { System.out.print(b); System.out.print(' '); } System.out.println(); } rotate(arr, 4); for (int[] a : arr) { for (in...
ce51d796-5dea-4601-97dc-2fa63f6020af
3
public String actionat(Coord c) { for (Part part : parts) { if(c.isect(new Coord(part.x, part.y), new Coord(part.width(), part.height()))) { String action = null; if(part instanceof TextPart) { TextPart tp = (TextPart) part; action = tp.getAction(tp.charAt(c.x - part.x)); } return action; ...
043d4c01-c1a7-4a7b-8843-ff2bca66ca6d
5
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; ...
895b65ff-04c8-4d4b-810b-1d67af2f8615
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 fe...
d2928899-69af-4a2c-97ae-a36101aeabe6
5
public Tile getTile(int x, int y) { if (x < 0 || y < 0 || x >= width || y >= height) { return Tile.emptyTile; } int spot = tiles[x + y * width]; Tile t = Tile.getTileFromNumber(spot); if (t != null) { return t; } else { return Tile....
394c1674-e43b-4ca6-bcf2-87facdf4f694
2
private float getLowestInvader(Sprite sprite) { float y = 0; for(int i=0; i<sprite.getEntityCount(); i++) { if(sprite.getEntity(i).getY() > y) {y = sprite.getEntity(i).getY();} } return y; }
9efa94f2-cd58-4d27-b25a-e044a9527555
6
public void setEnabled(boolean enable){ if (enabled && !enable){ if (inputManager!= null && (!dragToRotate || (dragToRotate && canRotate))){ inputManager.setCursorVisible(true); } } enabled = enable; }
88f6e9fe-3637-4942-9ed5-161028df443f
4
public GUI(String frameName) throws IOException { frame = new JFrame(frameName) {{ setMinimumSize(new Dimension(500, 500)); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setLayout(new MigLayout("wrap 7, fill")); KeyboardFocusManager manager = KeyboardFo...
279773a9-f092-462e-ae7d-94564c172913
7
//@Override public boolean equals(Object obj){ if(obj instanceof Plane){ Plane p = (Plane)obj; if(p.getX() == m_coordinates.getX() && p.getY() == m_coordinates.getY() && p.getDirectionVector().X() == this.getDirectionVector().X() && p.getDirectionVector()...
6083da2b-f97f-4db7-ad68-076431c9cd1b
0
public String getMbid() { return mbid; }
d62e626f-e758-4479-8458-0fb7443a15a0
9
public void search(int v) { // ʾ p = root; if (p == null) { Message.AtLeastOneElement(); return; } state = State.search; data = v; while (p != null) { int i; for (i = 1; i <= p.numOfElements; i++) { p.ElementHighlightIdx = i; repaint(); paintAll(getGraphics()); try { Thr...
012a4162-9f42-4204-9949-efdd7a9aea0f
9
public boolean isValid(String s) { // Start typing your Java solution below // DO NOT write main() function Stack<String> parentheses = new Stack<String>(); for (int i = 0; i < s.length(); i++) { if (parentheses.isEmpty()) { parentheses.push(String.va...
18c8a374-4d0f-4e28-a56c-3c8f8958ffb3
2
public void bringToTop(Layer l, PersistentCanvas canvas) { for (DrawableItem pi : l.getDrawable()) { canvas.removeItem(pi); } for (DrawableItem pi : l.getDrawable()) { canvas.addItem(pi); } }
018aaf6c-1adb-41d9-bf4b-eedd3ac0d6ec
8
public boolean moveUp() { // Block invalid moves if (!canMoveUp) return false; boolean result = false; for (int j = 0; j < dim; j++) { for (int i = 1; i < dim; i++) { // Can skip the top most row // Skip empty tiles if (isTileEmpty(i, j)) continue; // Stepping indices ...
93d3ec80-1f43-43ad-8561-07eccd8e4dd3
9
private static void createDecodeTables(int limit[], int base[], int perm[], byte length[], int minLen, int maxLen, int alphaSize) { int pp = 0; for (int i = minLen; i <= maxLen; i++) { for (int j = 0; j < alphaSize; j++) if (length[j] == i) { perm[pp] = j; pp++; } } for (int j1 = 0; j1 < ...
a204f6c0-fd22-4d58-b8c5-0bcec0e8b696
9
public boolean readPartition(String filename) { FileInputStream in = null; BufferedReader reader = null; try { // Open one partition file as input. in = new FileInputStream(filename); reader = new BufferedReader(new InputStreamReader(in)); ...
44ad01f8-d1cc-4b35-af22-a86c5d6a42af
1
private void dispatchBundle(OSCBundle bundle) { Date timestamp = bundle.getTimestamp(); OSCPacket[] packets = bundle.getPackets(); for (OSCPacket packet : packets) { dispatchPacket(packet, timestamp); } }
d1a20ddc-700f-4a75-92ad-480207bd13f6
3
public static void main(String[] args){ Scanner in=new Scanner(System.in); long m = in.nextLong(); k=in.nextInt(); f[0]=1; f[1]=1; while(MAX>MIN){ long mid = (MAX+MIN)/2; long c = count(mid); if(c==m){ System.out.println(mid); return; }else{ if(c < m) MIN = mid+1; else MAX = mid...
6403b0e4-e04f-4e27-a95a-1c31151e1cb9
5
public void startTimer(String gs, Job j) { ExecutorService service = Executors.newSingleThreadExecutor(); final Integer jobId = new Integer((int) j.getId()); try { Runnable r = new Runnable() { @Override public void run() { while (timers.get(jobId)) {} } };...
0408364c-0382-49e4-8474-87f2b8420002
7
public static Direction getOppositeDirection(Direction d) { if ( d == null ) { return null; } switch (d) { case N: return S; case E: return W; case S: return N; case W: return E; case FLOOR: return CEILING; case CEILING: default: return FLOOR; } }
060d6a83-9381-444f-b818-5d65005f5ecd
6
@Override //altera status atraves da indicação do numero public void alteraStatus(String codigoVenda) { int status; System.out.println("\nAlterando status..."); for (int i = 0; i < listaVendas.size(); i++) { if (listaVendas.get(i).getCodigoVenda().equals(codigoVenda)) { ...
14935bbd-f27c-44b2-97e2-55eadba9ffd2
6
private GenericGFPoly[] runEuclideanAlgorithm(GenericGFPoly a, GenericGFPoly b, int R) throws ReedSolomonException { // Assume a's degree is >= b's if (a.getDegree() < b.getDegree()) { GenericGFPoly temp = a; a = b; b = temp; } GenericGFPoly rLast = a; GenericGFPoly r = b; ...
8be8cf1e-8166-4beb-825a-ef15a7815adf
5
public SchemaEditorToolBar(final BasicGraphEditor editor, int orientation) { super(orientation); setBorder(BorderFactory.createCompoundBorder(BorderFactory .createEmptyBorder(3, 3, 3, 3), getBorder())); setFloatable(false); add(editor.bind("New", new NewAction(), "/com/mxgraph/examples/swing/images/ne...
462d91f5-732f-483f-86d8-f35a1404259b
1
public static void restartUserOperators(){ Iterator<UserOperator> it = userOperators.values().iterator(); while(it.hasNext()){ it.next().restart(); } }
98c91146-69e8-4f16-a8e8-3c82de98fc8a
9
public ArrayList<Object> getPrevTestCase() { ArrayList<Object> result = new ArrayList<Object>(); if(currTestCasePos > 0) currTestCasePos --; if(currTestCasePos % 2 == 0) { testcase = this.listCon.get(currTestCasePos/2).getTruetc(); } else { testcase = this.listCon.get(currTestCasePos/2).getFalset...
56259a6f-e19f-4af0-b446-be1b9f496bbf
9
protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = maxNextCharInd = 0; available = tokenBegin; } else if (tokenBegin < 0) bufpos = maxN...
779471c5-0028-4368-b824-f65f824ae54c
9
public static void main(String[] args) { Kattio io = new Kattio(System.in, System.out); int n = io.getInt(); int m = io.getInt(); HashMap<String, List<String>> translations = new HashMap<>(); for (int i = 1; i < n + 1; i++) { String ia = i + "A"; String ib = i + "B"; String ic = i + "C"; String[...