method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
15c4c14c-690d-430a-904e-f94db9b71d37
2
public void swim(int k) { /** * Checking for isGreater makes sure that the <= property of MinHeap is * satisfied. */ while (k > 1 && isGreater(k / 2, k)) { swapArrayValues(k / 2, k); k = k / 2; this.arrayAccess += 2; this.compari...
88007bea-c56c-4216-a511-3b249fd8bc19
9
public static void startupStreams() { if (Stella.currentStartupTimePhaseP(0)) { { OutputStream self001 = OutputStream.newOutputStream(); self001.nativeStream = new PrintableStringWriter(java.lang.System.out); Stella.STANDARD_OUTPUT = self001; } if (!(Stella.STANDARD_WARNING != nul...
70102a37-c21b-45db-bb04-fd78d1eaf300
6
* @param decimalPlaces * @param a_RoundingMode * @return e^y where e is the Euler constant. The result is returned correct * to decimalPlaces decimal place precision. */ public static BigDecimal exp( BigDecimal y, Generic_BigDecimal a_Generic_BigDecimal, int d...
0257a5aa-2a56-4cd9-bbfc-d6e13a246ac5
4
public synchronized void sendGamestate(int turnNumber, int dimension, String mapData[][], AIConnection playerlist[]){ JSONObject root = new JSONObject(); try { root.put("message", "gamestate"); root.put("turn", turnNumber); JSONArray players = new JSONArray(); for(AIConnection ai: playerl...
f1460515-ea36-4455-b59b-cc8bd0fbdb65
2
public static byte[] serializeToBytes(Object object) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { ObjectOutputStream out = new ObjectOutputStream(stream); try { out.writeObject(object); out.flush(); } finally { if (out != ...
1373d609-f48a-4f1b-be90-108077b10ec0
8
public String searchAll(String name, String criteria) { String result = ""; //loop over entire table from start for(int i = 0 ; i < hashTableSize -1 ; i ++) { //if current data is not null, and equals to search add to result if(hashtable[i]!= null) { if(criteria.equals("First Name")) if(hasht...
efe9a58e-5121-45c6-857f-460f164fdf42
1
public static ResultSet query(String sql,Statement stmt) { ResultSet rs = null; try { rs = stmt.executeQuery(sql); } catch (SQLException e) { e.printStackTrace(); } return rs; }
340a6be6-89a7-4762-992b-5435ba756c12
8
public void mouseDown(MouseEvent e, int x, int y) { switch (count) { case 0: { editor.showStatus("State change: Moving archer to (1,1)"); game.moveUnit(new Position(2, 0), new Position(1, 1)); break; } case 1: { ...
079badfc-7553-41a9-8fc7-fc7c1624ce35
8
@EventHandler public void onBlockPlace(BlockPlaceEvent e){ Block block = e.getBlock(); Player player = e.getPlayer(); boolean grow = false; if(GiantTreesRevived.getSettings().allowBlockNearGrow() && GiantTreesRevived.checkPermission(player, "grow")){ if(block.getTypeId()...
dafcc63a-bc37-41b7-9075-c86828f77a5c
3
private void loadTileSheet(String src) { try { tileSheet = ImageIO.read(getClass().getResource(src)); tileRows = tileSheet.getHeight() / (tileSize + offset * 2); tileCols = tileSheet.getWidth() / (tileSize + offset * 2); BufferedImage tile; tileSet = new Tile[tileCols][tileRows]; for(int ...
8683892c-d537-432c-9e9c-a6971898f500
7
protected void addForumJournalsVar(final HTTPRequest httpReq, final String index, final StringBuilder str) { final String name=httpReq.getUrlParameter("FORUMJOURNAL_"+index+"_NAME"); if((name!=null)&&(name.trim().length()>0) &&(!name.trim().equalsIgnoreCase("auction"))) { if(str.length()>0) str.append("...
b739d9a7-0aa9-47e7-aabb-f87aee3cedad
0
public void render(Graphics2D graphics) { graphics.setColor(Color.BLACK); graphics.drawRect(screenX, screenY, 15, 15); graphics.setColor(state.getColor()); graphics.fillRect(screenX + 1, screenY + 1, 14, 14); }
518b18a9-9491-408f-9178-37988ddaae59
8
private MarkupItem createMarkupItem( URI id, String gi, URI ns, Collection.Type type, EARMARKNode.Type markupType) { MarkupItem markup = null; if (markupType == EARMARKNode.Type.Attribute) { markup = new Attribute(this, gi, ns, type, id); } else if (markupType == EARMARKNode.Type.Comment) { markup = n...
4ae59ef4-2a22-4ed7-a04b-3769308de0c8
8
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { String commandType=""; if(commands.size()>1) { commandType=commands.get(1).toUpperCase(); } if(commandType.equals("ITEM")) { mob.location().show(mob,null,CMMsg.MSG_OK_VISUAL,L("^S<S-NAME> ...
18f89ec4-f2f8-4166-af71-b5e2e8f124cd
9
private int performPeroxyFunctionalReplacement(Element groupToBeModified, Element locantEl, int numberOfAtomsToReplace) throws StructureBuildingException { List<Atom> oxygenAtoms = findFunctionalOxygenAtomsInApplicableSuffixes(groupToBeModified); if (oxygenAtoms.size()==0){ oxygenAtoms = findEthericOxygenAtomsIn...
6b43ee62-fbb4-4777-b335-02d7668afce5
0
public void setDateOfJoining(Date dateOfJoining) { this.dateOfJoining = dateOfJoining; }
97d17917-287d-46b9-90d5-60a41ce52a4c
3
public void moveToScene(String viewName) { Resource res = this.applicationContext.getResource(MessageFormat.format("views/layouts/{0}.fxml", viewName)); try { FXMLLoader loader = new FXMLLoader(res.getURL()); loader.setControllerFactory((Class<?> clazz) -> this.appli...
80baf8c2-199d-4cf0-ad89-ffbc256ba6c9
5
@Override public final void leftRotation() { int rowLength = WIDTH_FIELDS; int colLength = HEIGHT_FIELDS; IField[][] tmpFieldMatrix = new IField[rowLength][colLength]; for (int row = 0; row <= rowLength - 1; row++) { for (int column = 0; column <= colLength - 1; column++) { tmpFieldMatrix[row][column] ...
318b615c-ceec-4091-8de6-5ef4812275a0
2
public static <T, U> String writeJson(Map<T, U> map, Object[]... typeAdaptors) { GsonBuilder gb = new GsonBuilder().setPrettyPrinting(); for(Object[] o : typeAdaptors) { if(o.length >= 2) { gb.registerTypeAdapter((Type)o[0], o[1]); } } Gson gson = gb.create(); return gson.toJson(map); }
6d9cfcfd-dc1e-4e64-90f2-330920642d1c
2
public void addDload(int n) { if (n < 4) addOpcode(38 + n); // dload_<n> else if (n < 0x100) { addOpcode(DLOAD); // dload add(n); } else { addOpcode(WIDE); addOpcode(DLOAD); addIndex(n); } ...
555969f3-2d55-4df9-b6f3-8c8ce97fb125
0
private void goNext() { FalseStartLabel.getInstance().clear(); StateManager.getInstance().setState(new EndRound()); }
8387bdb0-6b1c-40d6-90eb-e2bf567c1a04
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; MavenDependency other = (MavenDependency) obj; if (artifactId == null) { if (other.artifactId != null) return false; } else if (!artifac...
46785603-9e54-4e6b-a6fc-52f1da619582
9
private static void setData(Object obj, Method objMethod, Object param) { try { Class []ptt = objMethod.getParameterTypes(); if (ptt == null) { throw new ASNException(null, "Cannot find parameters in method: " + objMethod.toGenericString()); } Clas...
9c454c9f-75d8-4919-9192-e55334ac2902
9
public void launchNext(final int wexp, final int ah) { Thread subExpThread; subExpThread = new Thread() { public void run() { m_remoteHostsStatus[ah] = IN_USE; m_subExpComplete[wexp] = TaskStatusInfo.PROCESSING; RemoteExperimentSubTask expSubTsk = new RemoteExperimentSubTask(); expSubTs...
7c224207-672b-4025-9f13-906024b25cb4
3
private void waitForThread() { if ((this.thread != null) && this.thread.isAlive()) { try { this.thread.join(); } catch (final InterruptedException e) { plugin.getLogger().log(Level.SEVERE, null, e); } } }
0f92a1f4-a991-4de3-a3af-87ba3bf6357c
5
public static Direction convertActToDir(MovementAction action){ switch(action){ case MOVE_DOWN: return SOUTH; case MOVE_LEFT: return WEST; case MOVE_RIGHT: return EAST; case MOVE_UP: return NORTH; case STAND: return null; default: return null; } }
efc580a1-da24-42c6-b24f-31d3a9d51550
6
@Override public void run() { if(!running) return; try { String msg = ""; String line; while((line = inRead.readLine()) != null) { msg += line; if(line.endsWith("{OP}")) { msg = msg.substring(0, line.length() - 4); List<String> parts = new ArrayList<String>(); parts = A...
587859df-ea47-4f98-b224-d6263866aa77
8
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost,msg); if((msg.othersMajor(CMMsg.MASK_CHANNEL))) { final int channelInt=msg.othersMinor()-CMMsg.TYP_CHANNEL; final ChannelsLibrary.CMChannel chan=CMLib.channels().getChannel(channelInt); final boolean...
79a1d9c7-3867-4891-a2c1-300e714b9878
6
@Override public void removeProgram(Program program) { Double programFitness = 0.0; if(program.getFitness() == null) fitnessFunction.computeFitness(program); programFitness = program.getFitness(); int index = 0; while (index < this.programs.size() && programFitness > this.fitness.get(index)) { index++; ...
e3b8bee1-a52a-465c-9864-32bfb484b56b
2
public static byte[] toMQttString(String s) { if (s == null) { return new byte[0]; } ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(byteOut); try { dos.writeUTF(s); dos.flush(); } catch (IOException e) { // SHould never happen; return ...
92a6b3ce-457e-4d22-8db6-9d3d84c3ceac
9
public static Thing lookup(String gType) { Thing stored, dupe, black; String bareGType; /* * Lookup the type. This will work most of the time... */ stored = things.get(gType); if (stored != null) { return stored; } /* * ....
14c6fefb-6eee-4159-bb56-56faad35f1cb
7
private void getCPUUsage() { new Thread() { @Override public void run() { setName("CPU Info Thread"); setPriority(Thread.MIN_PRIORITY); while (getDeviceInfo) { // if (debug) // logger.log(Level.DEBU...
19c75a58-30bf-472b-a718-a7915c71cabf
3
public static Vector selectRackID_from_rackCategory(String catname){ Vector v=new Vector(); try { ResultSet rs1=DB.myConnection().createStatement().executeQuery("select * from category where CategoryName='"+catname+"'"); while(rs1.next()){ String catID=r...
199805d4-d6cc-4c2b-a082-abfaf87d9d4c
7
@Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); int hit = 0; int attackStyle = Utils.random(2); if (attackStyle == 0 && (di...
d3a9932a-3e6a-49e1-a8a2-206dff92c5cc
8
private ArrayList<Course> removeClassesWOPre(ArrayList<Course> needed, ArrayList<Course> taken) { ArrayList<Course> ret = new ArrayList<>(); for (Course course : needed) { boolean allContained = true; if (course.getPrereqs() != null && course.getPrereqs().get(0) != null) { ...
0fa7db6a-259e-4c2c-8900-3de919cf0426
0
public MasterGameThread(NetworkGameScreen screen) throws IOException { super("MasterGameThread"); this.screen = screen; String remoteHost = ((PongWindow)screen.parent).RemotePlayer; // formato HRS-GUA-02/169.254.80.80 slaveSocket = new Socket(remoteHost.substring(remoteHost.lastIndexOf('...
b9450e3c-ec91-472d-9b6e-2909cea396da
6
public static int getHighestLevel(Pokemon party[], Pokemon pc[]) { int highest=0; for (Pokemon aParty : party) { if (aParty != null) { if (aParty.level > highest) highest = aParty.level; } else break; } for (Pokemon...
e888dd13-0522-4833-8b89-6a3955fb01c8
7
private void addRule(Document document, Rule rule) throws OutputterException { Element ele = document.createElement(Tag.RULE.getXmlTag()); if (!rule.getLabel().startsWith(DEFAULT_RULE_LABEL_PREFIX)) ele.setAttribute(Attribute.RULE_LABEL.getAttributeName(), rule.getLabel()); switch (rule.getRuleType()) { case ST...
00312d31-d93a-4973-b5e3-bb3762218ab0
4
public Element generateElement(Document document) { Element edge = document.createElement(mxGraphMlConstants.EDGE); if (!edgeId.equals("")) { edge.setAttribute(mxGraphMlConstants.ID, edgeId); } edge.setAttribute(mxGraphMlConstants.EDGE_SOURCE, edgeSource); edge.setAttribute(mxGraphMlConstants.EDGE_TA...
9760fcaa-fb58-46d2-9771-8102c3ef4016
2
@Override public int compare(Integer o1, Integer o2) { return (o1>o2 ? -1 : (o1==o2 ? 0 : 1)); }
2f6b864c-a0c3-41fb-bb51-45fbd2cb583e
9
private void drawPodatek(Graphics g, final ArrayList al) { g.setFont(newRomanNormal); HashMap VatMap = new HashMap(7); double sumNetto = 0; double sumBrutto = 0; double sumVat = 0; for (int i = 0; i < al.size() ; i++) { DataEntry dat = (DataEntry)al.get(i); String Stawka = dat.getVatStawka...
425c7f46-b991-42b4-9812-66763200935a
9
public int longestValidParentheses(String s) { if(s == null || s.length() < 2 || s.indexOf(")") == -1) { return 0; } int ret = 0; int[] len = new int[s.length() + 1]; len[0] = 0; len[1] = 0; for(int i = 2; i <= s.length(); i++) { if(s.ch...
d93ec099-5500-4993-86f6-00cae5ca71db
0
public Configuration[] getInitialConfigurations(String input) { /** The stack should contain the bottom of stack marker. */ Configuration[] configs = new Configuration[1]; CharacterStack stack = new CharacterStack(); stack.push("Z"); configs[0] = new PDAConfiguration(myAutomaton.getInitialState(), null, i...
c3a5f63c-c83f-40b3-a68c-7bf38d5f8fa7
6
public boolean checkSize(int min,int max, int size) { if(size>=min&&size<=max){ return true; } if(min==max&&min==UNLIMITED){ return true; } if(size<min){ System.out.println(Language.tooFewArguments); } if(size>max){ System.out.println(Language.tooManyArguments); } return false; }
30b979aa-7150-4ae5-b86c-8a7f14da26a0
4
Response doSend() throws IOException { connection.setRequestMethod(this.verb.name()); if (connectTimeout != null) { connection.setConnectTimeout(connectTimeout.intValue()); } if (readTimeout != null) { connection.setReadTimeout(readTimeout.intValue()); } addHeaders(connect...
b25348f0-d232-4d65-a0e9-ca2779e79d50
0
public Counter(String name) { this.name = name; count = 0; }
b7bdee0a-398a-48c5-ad2e-163d91864f78
9
private static void reachingDefDataFlow(OptFunctionNode fn, Node[] statementNodes, Block theBlocks[], int[] varTypes) { /* initialize the liveOnEntry and liveOnExit sets, then discover the variables that are def'd by each function, and those that are used before being def'd (hence liveOnEntry) */ ...
0c58cf05-c1b9-42d3-8d48-5035ac80781a
4
private ResGridlet cancel(int gridletId, int userId) { ResGridlet rgl = null; // Find in EXEC List first int found = gridletInExecList_.indexOf(gridletId, userId); if (found >= 0) { // update the gridlets in execution list up to this point in time ...
0fbc19d1-301e-48f6-82b9-9087ff7d0672
0
public confirmRemoval() { this.requireLogin = true; this.addRtnCode(405, "not removing"); }
51c9a5e6-3d96-408c-9d2f-d5c2e8843408
5
public static void main(String[] args) { System.out.println("Building Huffman Tree:"); Byte[] byteArray = new Byte[] { 45, 56, 67, 78, 89, 12, 23, 34, 45, 23, 45, 67, 45 }; HuffmanTree<Byte> hTree = new HuffmanTree<Byte>(byteArray); System.out.println(); System.out.println("Printing Tree:"); hTree.pri...
d253b154-4f13-422f-9cef-d056ac7d15f6
4
public List<GPSData> getAccIter(List<GPSData> gpss, List<AccMagn> magns) { // TODO: add boundary conditions (if arrays.size() < 2...) long accMagnPreTimestamp = magns.get(0).getTimestamp(); int k = 0; for (int i = 0; i < gpss.size(); i++) { GPSData gpsData = gpss.get(i); long gpsTimestamp = gpsData.get...
cf22f2db-83f8-4672-93f3-43f13f6cd95a
2
public String getDate(){ String day, month, year; day = Integer.toString(time.get(5)); if (day.length()==1) day = "0" + day; month = Integer.toString(time.get(2)+1); if (month.length()==1) month = "0" + month; year = Integer.toString(time.get(1)); return day + "/" + month + "/" + year; }
a3873df1-a731-46aa-b5eb-2b964a254dfe
4
public static int charge(String ion){ ion = ion.trim(); boolean test0 = true; boolean test1 = false; int i = 0; int charge = 0; // check entered ion against ion list while(test0){ if(IonicRadii.compareBare(ion, i)){ test0 = false; ...
41de0fbd-1879-4959-8a99-3727dd5d19a4
0
public void setAvb(Double avb) { this.avb = avb; }
f7ccce42-4e75-4683-9a67-28df8cedd408
6
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player) { final WarPlayer damager = this.war.getHelper().getPlayerExact(((Player) event.getDamager()).getName()); if (!damage...
92e1efef-461e-4a31-9bc8-7fd2708bc6a9
8
public static void reCalculateTFandIDFwithApproxValues(String docContents, String docName, int collectionSize, double docLength) { System.out.println("reCalculateTFandIDFwithApproxValues running"); ArrayList<String[]> currentPostingsList; String[] posting; for (int k = 0; k ...
e982ab1d-e24d-4cd1-a79f-174df4df69e9
0
TotalPanel() { this.setLayout(new GridLayout(3, 2)); this.setBorder(new TitledBorder("总流量")); getContent(); this.add(totaltitle); this.add(totalnum); this.add(tcptitle); this.add(tcpnum); this.add(udptitle); this...
e95a18db-6fce-4116-8304-7088cd464094
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...
6f93121b-1c3f-45e7-b785-6e444f3362b3
0
public int getMarker() { return this.marker; }
a03f540d-023e-4987-8933-b6efd83dddae
7
public HashMap getInfo(String link){ String sourceName = "挑食网"; String html = GetHTML.getHtml(link, "utf-8"); Document doc = Jsoup.parse(html); Elements ele = doc.select("script[type]"); Element eleJson = ele.get(7); String jsonData = eleJson.html().replaceAll("\t",""); ...
bf02761f-a3ef-441e-8f0a-52725253083c
9
public String predict(){ String s; if(getNext()== 1 || getNext()== 3 || getNext()== 4 || getNext()== 5 || getNext()== 9 || getNext()== 10 || getNext()== 11 || getNext()== 12 || getNext()== 15){ return s = "Head"; } else { return s = "Tail"; } }
4a14616e-049a-4a7f-acce-b991bbed5733
1
public static void main(String[] args) { String[] names = { "Aman", "Amar", "Himanshu", "Piyush", "Gunjan", "Ankit", "Shruthi" }; Container nameContainer = new NameContainer(names); Iterator iterator = nameContainer.getIterator(); for (; iterator.hasNext();) { System.out.println("Name :" + iterator.ne...
0c986ce6-f1d1-4af1-8c6d-576f6bcdd9bb
9
@Override boolean canPerform(Creature cc, World w) { if(cc.canwork && cc.isAlive() && cc.stuntime==0) { if(w.getItemcollection().isRecqExist(worldObjectRecquire)==false) return false; if(this.getTasktype()==TaskEnum.walking) { ...
fcb28adf-e037-40a6-9385-1835725c4f4f
3
public List<String> getNouns (int idx) { List<String> nouns = new ArrayList<String>(); List<TermPos> phrase = phrases.get(idx); int i = 0; for (; i < phrase.size() && !phrase.get(i).pos.startsWith("NN"); i++); for (; i < phrase.size(); i++) { nouns.add(phrase.get(i).term); } return nouns; }
9d28e499-207e-4914-873d-5abb38a63081
4
public static void main(String[] args){ Scanner in = new Scanner(System.in); int n=in.nextInt(); int m=in.nextInt(); isBlack = new boolean[n][m]; for(int i=0;i<n;i++){ String line = in.next(); for(int j=0;j<m;j++){ isBlack[i][j]=line.charAt(j)=='1'; // System.out.println(isBlack[i][j]); ...
b302215d-0ec5-4fbb-89d3-752a59dddde5
7
public void calculatePerCapitas() { popCap = houseNumber * MAXHOUSECAPACITY + 5; foodPerCapita = ((double) (foodings))/population; energyPerCapita = energies/population; popDeriv = (foodPerCapita * energyPerCapita); if(foodPerCapita <= 0 && energyPerCapita <= 0) { popDeriv = 0.5; } ...
017f93cd-bfa2-4d27-82f9-e5428d554b66
8
private void extractCircles (Mat mask, List<Circle> balls, List<BallCluster> ballClusters, List<MatOfPoint> contours) { // clear input balls.clear(); ballClusters.clear(); contours.clear(); // find the contours Imgproc.findContours(mask.clone(), contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPRO...
a98ea0cb-f1eb-4dab-b931-0866bd354d99
0
protected boolean test2 () { return true; }
85edecb2-8344-42d5-8294-c0f827fe0918
7
private void parseNodeString(String nodeLine) { StringTokenizer tokenizer = new StringTokenizer(nodeLine); // number of node parameters to parse (counts at linestart) int parameters = 3; // first test to step to the next parsing-state (edges) if (nodeLine.contains("Edges:")) { // Log.printLine("found st...
b57e020a-f124-4508-a0cd-f73855992eb4
4
public void SendMessageByGet(){ CloseableHttpClient client=HttpClients.createDefault(); HttpGet get=new HttpGet(url+"?"+"&user="+user+"&key="+key+"&number="+number+"&text="+text); try { System.out.println(url+"?"+"&user="+user+"&key="+key+"&number="+number+"&text="+text); HttpResponse response=client.execut...
51c401e8-4833-460a-93e0-f953ff5c271d
4
private void update(String image) { switch (TODOManager.backend.getSorting()) { case TIME: time.setImage(image); break; case PRIO: prio.setImage(image); break; case TITLE: title.setImage(image); ...
e79c6fca-5cf2-4651-a6c4-a372b5bcef05
5
boolean resolve(final MethodWriter owner, final int position, final byte[] data) { boolean needUpdate = false; this.status |= RESOLVED; this.position = position; int i = 0; while (i < referenceCount) { int source = srcAndRefPositions[i++]; int ...
c68cd1aa-b22f-4cde-8968-cb22fd406e87
3
public static int[] sortLogList(int[] logList) { int i, j, first, temp; for (i = logList.length - 1; i > 0; i--) { first = 0; //initialize to subscript of first element for (j = 1; j <= i; j++) //locate smallest element between positions 1 and i. { ...
604d1a5c-2668-46bf-a4c2-4779546f3cb2
8
private ScoreObject addop(ScoreObject a, ScoreObject b) { if (a.isNumeric() && b.isNumeric()) { if (a.isFloat() || b.isFloat()) return new ScoreObject(a.getAsFloat() + b.getAsFloat()); // one is an int? else if (a.isInt() || b.isInt()) return new ScoreObject(a.getAsInt() + b.getAsInt()); // must b...
33fa670c-ed57-4a13-b87b-98a0e734b383
8
public void keyReleased(KeyEvent w) { int code = w.getKeyCode(); if (code == KeyEvent.VK_A) { left = false; if (right) { } else { dx = 0; } } else if (code == KeyEvent.VK_D) { right = false; if (left) { ...
722ea8b0-1fbe-4876-a122-dd891bed7375
3
private static String loadSiteUID(){ String uid = DEFAULT_SITE_USER_ID; try{ FileInputStream fis = new FileInputStream(workingDir + SITE_UID_FILE_NAME); try{ BufferedReader reader = new BufferedReader(new InputStreamReader(fis)); try { uid = reader.readLine(); } catch (IOException e) {} r...
9a045670-fc73-443a-8190-26c737d3aa99
8
public static void main(String[] args) { TreeSet<Integer> products = new TreeSet<Integer>(); int[][] grid = readFile(System.getProperty("user.dir") + "/external/problem11.txt"); for (int i = 0; i < 20; i++) { for (int j = 0; j <= 16; j++) { products.a...
1412423d-45ad-4b96-979f-59cfc1cf8dc1
3
public void changePrice(GraphNode<T> a, GraphNode<T> b, int weight){//T siendo graphNode con elemento de tipo Base, client o hub. for(int i=0;i<aristas.getLength();i++){//checks coincidence to find link between nodes. if(((GraphNode) aristas.get(i).getInitial()).equals(a) && ((GraphNode) aristas.get...
fa8e478c-e8cf-442f-8376-372f3f5b825e
0
public boolean isRelativeMouseMode() { return (robot != null); }
d4cdf86a-b2d2-4743-a588-3e4da93284a1
7
public void addClassificationAttempt(int trueClass, double[] classVotes, double weight) { if (weight > 0.0) { if (TotalweightObserved == 0) { reset(classVotes.length > 1 ? classVotes.length : 2); } this.TotalweightObser...
a116e2fe-53d7-4271-a072-8a0d23a9df94
3
@Override public Source getSource(String sId) throws BadResponseException { Source s = null; JsonRepresentation representation = null; Representation repr = serv.getResource("intervention/" + interId + "/source", sId); try { representation = new JsonRepresentation(repr); } catch (IOException e) { ...
6c7455b1-e1c2-4801-8a21-9ffca5699488
6
private static HashMap<String, Holder> getMap(String level) throws Exception { HashMap<String, Holder> map = new LinkedHashMap<String, Holder>(); BufferedReader reader = new BufferedReader(new FileReader(new File( ConfigReader.getRachSachReanalysisDir() + File.separator + "rdpAnalysis" + File.separ...
bcc4521b-54ef-40b9-b6e8-a32d99ac9578
9
private Node nextIntersectionNode( Node node, K key ) { if( node == null ) { return null; } while( true ) { // Check right tree. Node ret = firstIntersectionNode( node.mRight, key ); if( ret != null ) { return ret; } ...
b7c94ce2-cc6f-4083-b45e-05a8d5c3d990
6
public void body() { // wait for a little while for about 3 seconds. // This to give a time for GridResource entities to register their // services to GIS (GridInformationService) entity. super.gridSimHold(3.0); LinkedList resList = super.getGridResourceList(); // in...
53d73447-0b08-486e-b547-84282b7b8a35
8
@Override public void run() throws IOException, ClassNotFoundException, SQLException { // let's create output dir DateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); String ts = df.format(new Date()); Path pathTs = Files.createDirectory(Paths.get(Config.getPathOut() + ts));...
77e9fc63-2142-4b72-b27d-dcac0b812d67
5
private boolean won() { if (mSweeper.isDied()) return false; final int width = mField.getWidth(), height = mField.getHeight(); final byte open = mField.getMasks().getOpen().getId(), openBomb = mField.getMasks().getOpenBomb().getId(), bomb = mField.getTiles().getBomb().getId(); for (int tile = 0; tile < width *...
4151c544-0a27-4bed-8d04-4894d180f034
6
private void sendFiles(Transferable tran) throws UnsupportedFlavorException, IOException { if (fileList == null) { // If files are drag&dropped filelist will be filled at DragAndDropListener prtscr = true; if (tran.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { ...
63f5eb47-cf4f-4957-a128-8be4ad18fee0
8
@Override public int[] getInts(int par1, int par2, int par3, int par4) { int i1 = par1 - 1; int j1 = par2 - 1; int k1 = par3 + 2; int l1 = par4 + 2; int[] aint = this.parent.getInts(i1, j1, k1, l1); int[] aint1 = IntCache.getIntCache(par3 * par4); for (in...
cc298505-b69d-4f34-b4b4-727cba691f82
9
public boolean isStillMaintained(Environmental thang, ShopKeeper SK, Item I) { if((I==null)||(I.amDestroyed())) return false; if(SK!=null) return SK.getShop().doIHaveThisInStock(I.Name(),null); if(thang instanceof Area) { final Room R=CMLib.map().roomLocation(I); if(R==null) return false; re...
4d9aac48-b0b2-40a5-a11c-0c62c1d45488
5
private void launch() { //The method that kick starts execution of a program and manages it in standard mode pc.setPC(0); //Initialise PC to 0 for GUI display if (!pipeliningMode) { while (active) { fetchDecodeStage.run(); int opcode = fetchDecodeStage.getOpcodeValue(); if (opcode == -1) { //fe...
f926480a-1717-41c0-aed5-a5a4fba91f88
4
public void connectToService() { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { Remote service = Naming.lookup("//127.0.0.1:1699/quiz"); quizService = (QuizService) service; } catch (MalformedUR...
acbdc150-3c6c-469f-9c87-8c030e396c6f
4
protected static String toHtml(String wiki) { wiki = wiki.replaceAll("<BR>|<br>", " "); wiki = wiki.replaceAll("\n", " "); wiki = wiki.replaceAll(" ", " "); int countBold = 0; int indexOfApostrophe = wiki.indexOf("'''"); while (indexOfApostrophe != -1) { if ...
22df914f-0812-47a6-9935-4a4b1b1eb5f1
2
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((frequency == null) ? 0 : frequency.hashCode()); result = prime * result + ((symbol == null) ? 0 : symbol.hashCode()); return result; }
3faee16d-3b03-46a7-bdd1-aa1bfed75afd
3
public OneTangent(Craft craft, double rFinal, double transPoint) { //Faster but less efficient than a Hohmann transfer //Decrease transPoint for a shorter transfer time double grav = craft.parent.mass * Astrophysics.G; double rInitial = craft.position.clone().subtract(craft.parent.position).magnitude(); doubl...
1279cb73-62e5-4d55-b4d9-05838b7a526a
6
public void zapImageParts(BufferedImage im, double likelihood) // change some of the image's pixels to red or yellow { if (im == null) { System.out.println("zapImageParts: input image is null"); return; } if ((likelihood < 0) || (likelihood > 1)) { ...
087e6f9d-dd23-4959-98c6-c0f5f6f3e573
9
public void setDimensions(){ for(int i=0; i<books.size();i++){ BookNode book = books.get(i); int x= (int)book.getX(); int y= (int)book.getY(); int radius = (int)book.getPaddedRadius(); if(i==0 || x-radius<minX) minX=x-radius; if(i==0 || x+radius>maxX) maxX=x+radius; if(i==0 || y-ra...
61c7f827-4a0b-4f6e-9945-ff9529c34df8
6
public static void removeConnection(String username, Integer type) { Client client = getClient(username); // Check if client target client exists. if (client != null) { // Remove from GUI List. clientListModel.removeElement(username + " (" + client.g...
60890824-cf87-482d-9734-ef2737f4b8a8
9
public Matrix decomposeLU(boolean LUP) { if(rows != cols) { throw new IllegalArgumentException("Matrica nije kvadratna!"); } Matrix P = new Matrix(rows); for(int i = 0; i < rows - 1; i++) { if(LUP) { // ako je LUP postupak odabran napravi pivotiranje po stupcima int pivotIndex = i; ...
f1f0b697-a53c-4067-b859-dd9b9cf9d858
0
public void removeRange(int fromIndex, int toIndex) { int numMoved = size - toIndex; System.arraycopy(data, toIndex, data, fromIndex, numMoved); size = size - (toIndex - fromIndex); }
97ec6a7b-c03a-4f54-974f-39641f7a8ac8
4
public void aplicarMascarilla() throws InterruptedException { if (!mascarillaAplicada) { for (Barrillo barrillo : barrillos) { barrillo.mascarillaAplicada = true; } mascarillaAplicada = true; repaint(); semaforo.acquire(); ...