method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
af45b41b-aeef-4dbc-8d32-4c87ff25ee04
3
public static void main(String[] args) { long start = System.nanoTime(); boolean found = false; int x = 190; while (!found) { found = false; for (int i = 20; i > 2; i--) { if (x % i != 0) { found = false; break; } found = true; } x += 2; } System.out.println(x - 2); Syste...
8e121ae1-4b63-4e9b-9a33-36d1981a53db
1
public String toString() { String s = ""; for(int i = 0; i < elementen.length; i++) s = s + elementen[i] + " "; return s; }
c9a1b0de-491e-49c2-a7c0-0c9a8beaf907
1
public AbstractInsnNode[] toArray() { int i = 0; AbstractInsnNode elem = first; AbstractInsnNode[] insns = new AbstractInsnNode[size]; while (elem != null) { insns[i] = elem; elem.index = i++; elem = elem.next; } return insns; }
03c848d7-cca9-437d-b058-9d2604498c4a
3
//@Test public void nonDeterministeMC() { final double[][] transtionMatrixNonDeterministe = { /*0 1 2 */ /*0*/{0.0, 0.3, 0.7}, /*1*/ {0.2, 0.0, 0.8}, /*2*/ {1.0, 0.0, 0.0},}; final Integer[] states = {0, 1, 2}; ...
134098fe-752e-4125-9dfe-ed36a346be6d
8
public static void main(String[] args) { String[] faces = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"}; char[] suits = {'♣', '♦', '♥', '♠' }; int count = 0; for (int i = 0; i < faces.length; i++) { for (int j = 0; j < faces.length; j++) { for (int k = 0; k < suits.length; k++) { ...
286eb115-3834-4406-b551-fe3cc3a0fa4d
5
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String nivel = request.getParameter("nivel"); if(nivel != null){ j.inicializarJuego(nivel); } PrintWriter out = response.getWriter(); response.setContentType("text/html"); ...
e17cbc4a-423d-4b33-941f-512d10126f0c
3
private void newChunk() throws IOException { if(!delegateEof) { int cLength = readVInt(); if (cLength == 0) { delegateEof = true; return; } byte[] cbuffer = new byte[cLength]; int o = 0; while(o < cLength) { o += in.read(cbuffer, o, cbuffer.length - o); } DecompTask task = new Deco...
4b6ec6ba-95fb-4832-a01f-273cd6e6831b
1
public static double getRatio() { int losses = getLosses(); int wins = getWins(); return losses == 0 ? 0 : ((double) wins) / ((double) losses + wins); }
c74e4833-ffd6-486b-846c-b3af6d86e374
4
public Document parseURL(String xmlURL, String refType, String bibcode) { DocumentBuilder docBuilder; Document doc = null; DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setIgnoringElementContentWhitespace(true); ...
19840a5b-505b-490a-8f6c-6e21087e40d8
9
public static String getTransactionAsString(int t){ switch(t){ case TRANSACTION_TRANSITION_ID: return TRANSACTION_TRANSITION_STRING; case TRANSACTION_ACTION_ID: return TRANSACTION_ACTION_STRING; case TRANSACTION_QUESTION_ID: return TRANSACTION_QUESTION_STRIN...
341fe0eb-90c5-4c65-81f4-718b429e7fea
1
private void btnAdicionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdicionarActionPerformed if(JOptionPane.showConfirmDialog(rootPane, "Você tem certeza que deseja" + "adicionar o item ?","",JOptionPane.OK_CANCEL_OPTION) == 0){ FormasPagamento nov...
7ce4ffb1-8f8c-47cc-bb3c-b18e8817e130
3
public void loadSpelprojekt() { PanelHelper.cleanPanel(spelprojektHolder); Dimension d = spelprojektHolder.getPreferredSize(); d.setSize(360, 10); spelprojektHolder.setPreferredSize(d); ArrayList<String> a1 = null; try { a1 = DB.fetchColumn("select SPELPROJEKT...
9033a2d6-e1c7-414c-90d7-1882c77370d4
1
private static void displayPrescriptions(ResultSet rs)throws SQLException{ StringBuffer bf = new StringBuffer(); while (rs.next()){ bf.append(rs.getInt("presc_id")+": "); bf.append(rs.getDate("start_date")+", "); bf.append(rs.getDate("this_day")); System.out.println(bf.toString()); bf.delete(0, bf...
c3f64330-6c86-49ea-8627-11bb365716af
0
static public double getXToMap() { return xToMap[zoomIndex]; }
ae184a4b-77ff-4093-8465-8149eee18852
0
public short getShortType() { return (short) type; }
f9609e37-7f54-44da-a40f-1a64e98389ea
9
private void addAllWells(WellDispatcher disp, String orderingType){ int wellIndex = 1; if (orderingType == "ALPHANUMERIC") { for (int i = 0; i < plateSpecs.getNumRows(); i++){ for (int j = 0; j < plateSpecs.getNumCols(); j++){ char rowLetter = (char) (i + ...
38aafc40-c91f-424e-8afe-e7de9f390b80
6
public static void loadSQLTextForStatements(List<SQLStatement> sqlStatements, ProgressListener progressListener) { if (progressListener != null) { progressListener.setStartValue(0); progressListener.setEndValue(sqlStatements.size()); progressListener.setCurrentValue(0); ...
6d385fd7-88d6-4308-95fd-b5e9f1a0c8bf
3
@Override public void paintComponent(final Graphics g) { // Check if we have a running game super.paintComponent(g); g.setColor(this.getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); if (this.model != null) { // Draw all tiles by going over them x-wise and y-wise. for (int i = 0; i < this....
58b7bb78-8d63-4f87-9b64-1c3830650b42
7
protected boolean findVictim(MOB mob, Room room, Vector<Room> rooms, int depth) { if(depth>5) return false; if(victimHere(room,mob)!=null) { rooms.addElement(room); return true; } for(int d=Directions.NUM_DIRECTIONS()-1;d>=0;d--) { final Room R=room.getRoomInDir(d); final Exit E=room.getExit...
c39710b6-53ce-462c-bf43-9a98366f1e25
0
public void setjLabel8(JLabel jLabel8) { this.jLabel8 = jLabel8; }
5d06b8ad-6bc3-4857-b79e-9eb511964b45
4
public void visitIincInsn(final int var, final int increment) { if (var > 255 || increment > 127 || increment < -128) { minSize += 6; maxSize += 6; } else { minSize += 3; maxSize += 3; } if (mv != null) { mv.visitIincInsn(var, increment); } }
023c3e9b-f60e-4bb0-bc34-54f4a6c42cbb
8
public static void main(String[] args) { System.out.println("Starting."); System.out.flush(); try { FreshLRUCache cache1 = new FreshLRUCache(0, 3, 6); cache1.put(1, 2); try { Thread.sleep(10); } catch (InterruptedException ie) {} cache1.clearStaleEntries(); if (ca...
1204b363-a86a-44fa-bc81-addee3b9a218
5
void parse(String table) { table = table.toUpperCase(); String entries[] = table.split(","); for (String entry : entries) { entry = entry.trim(); if (entry.length() > 0) { String t[] = entry.split("/"); if (t.length == 2) { String codon = t[0]; String aa = t[1]; // If it contains a ...
b7c60e3a-3c32-4090-8b2e-9d90cb3fb0de
4
private final String getFileOverview() { StringBuffer overview = new StringBuffer(); // only add the header if javadocs are present if ( javadocLinkDir != null ) { overview.append( "<div id=\"overview\">" ); //get the URI to get Javadoc info. Stri...
2de6444c-838e-46d5-aa8d-c36fbf1ca6a4
1
private List<RepositoryContents> getRepositoryContents(final Repository repository, final Release release) throws IOException { logger.log(Level.INFO, "Getting contents for {0}.", repository.getName()); ContentsService contentsService = new ContentsService(connectToGitHub()); if (release == nul...
f19b7ba9-c741-4532-be1a-750fc00b022d
4
protected void calculateFitness() { for(int i = 0; i < numberOfParticles; i++){ double currentfitness = objectiveFunction.CalculateFitness(position[i]); if(maximum){ if(currentfitness > fitness.get(i)){ fitness.put(i, currentfitness); updatePersonalBest(i); } }else{ if(currentfitness < ...
83a3c72b-b979-42fd-9831-bef84b7f9d68
7
int getSetType() throws Exception { int sum = 0; int type = -1; if (nominal) { sum ++; type = Attribute.NOMINAL; } if (numeric) { sum ++; type = Attribute.NUMERIC; } if (string) { sum ++; type = Attribute.STRING; } if (date) { sum ++; type = Attribute.DATE; } if (relational)...
d9e6c03c-6167-42af-8af5-f26889a2baae
4
private void do_cross_validation() { double total_error = 0; double sumv = 0, sumy = 0, sumvv = 0, sumyy = 0, sumvy = 0; double[] target = new double[prob.l]; long start, stop; start = System.currentTimeMillis(); Linear.crossValidation(prob, param, nr_fold, target); ...
dde9c52f-9046-465a-8ff7-36f6d36441db
4
public void add(ApiController<?, ?> apiController) { ApiController<?, ?> wasBefore = put(apiController.getPath(), apiController); Assert.assertNull(wasBefore, "Such count already exists"); }
1ec5e400-0d49-44d0-b7ed-f7f511a7f4f3
3
@Override public void delete(IEmailKontakt emailKontakt) { JAXBContext context = null; try { context = JAXBContext.newInstance(EmailKontaktList.class); EmailKontaktList emailContacts = readContacts(); for (int i = 0; i < emailContacts.getContactList().size(); i++) { if (emailContacts.getContactList()....
7871245b-0ba3-4f00-9398-da9eea660f2d
7
@EventHandler public void onMove(PlayerMoveEvent event) { if (Hub.alreadySending.contains(event.getPlayer().getName())) { if (event.getTo().getY() == event.getFrom().getY() || event.getTo().getX() == event.getFrom().getX() || event.getTo().getZ() == event.getFrom().getZ()) return...
36a1587d-f8ef-4aaf-be61-874444a20876
4
@Override public List<String> getSuggestions(CommandInvocation invocation) { int tokensLeft = invocation.tokens().size() - invocation.consumed(); if (tokensLeft == 1) { ArrayList<String> result = new ArrayList<>(); String token = invocation.currentToken().toLowerC...
f3de500e-6cf7-4b7c-be84-2377eeecb567
8
public void takeControl() { this.setLocationRelativeTo(null); this.setVisible(true); if(this.splash != null) { splash.setVisible(false); splash.dispose(); } this.loadPerksAndFlaws(); this.loadGear(); this.listCharacterEdgesFlaws.se...
b9482f41-c41e-4efe-9f33-322fe917f572
2
public Duration calcRest() { Duration gap = intervals.findGap(period, rest); if (gap == null) { gap = intervals.lastGap(); } if (gap.isShorterThan(rest)) { return rest.minus(gap); } else { return new Duration(0); } }
d7a0aa56-80f1-4307-a0d5-0c0ab25d9e50
9
public static void lowFrequencyTagger(String countFile, String dataFile) throws IOException { HashMap<String, Integer> wordToCount = new HashMap<String, Integer>(); FileReader in = new FileReader(countFile); BufferedReader br = new BufferedReader(in); StringTokenizer stk; String input; String wordTag;...
13e01e1b-69f9-4982-9129-3795b200ec11
3
public void error(Throwable e, String message) { if (verbose && (e != null)) e.printStackTrace(); if (!quiet) System.err.println(message); }
5a3d1de3-65ca-44a5-a09a-3dc3bb2be7a3
7
public static Image openImage(String filename) { String extension = null; try { int index_of_extension = filename.lastIndexOf("."); extension = filename.substring(index_of_extension); if(extension.equalsIgnoreCase(".gif") ) { ...
667b21f1-a92d-4af6-bef7-8532a54324d1
0
public void addTVC(TVC tvc) { connectionsSortedUp.add(tvc); connectionsSortedDown.add(tvc); }
f7434787-b270-427c-8ea1-c54990a8b7a6
2
public ArrayList<Models.DatabaseModel.Patient> listAllPatients() { String query = "SELECT `patients`.`ID`" +",`patients`.`name`" + "FROM `patients`" + "LEFT JOIN `deletedPatient` ON `patients`.`ID` = `deletedPatient`.`patientId` " ...
4129ed5d-dd1b-429b-9ee3-b4fdce1669e5
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...
cbc80b45-89eb-4c62-88f4-3ea9f02063de
1
private Point getWorldCoordinates(Point screenCoordinates) { if (!isPlaying()) return null; Dimension boardSize = client.getSession().getBoardDimension(); return new Point((int) (screenCoordinates.getX() * (boardSize.getWidth() / getSize().getWidth())), (int) (screenCoordinates.getY() * (boardS...
3f00f14c-d05d-4613-b3a4-f329a473b975
6
public boolean setBlockMetadata(int par1, int par2, int par3, int par4) { if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000) { if (par2 < 0) { return false; } else if (par2 >= 256) { ...
b73670f7-36bf-49a8-8e03-ee2fe30f775c
5
public String getPath() { String path = this.getText(); if (path.contains("/") || path.contains("\\")) { path = "'" + path + "'"; } TreeItem parent = this; while ((parent = parent.getParentItem()) != null) { String parentPath = parent.getText(); if (parentPath.contains("/") || parentPath.contains("\\...
8f97fa45-0803-4531-863b-f11a39a2706a
2
public void runTurns() { for (int c = 0; c < actors.size(); c++) { Actor actor = actors.get(c); Point oldpos = actor.getPos().copy(); actor.runTurn(senses.shadowCasting(oldpos.getX(), oldpos.getY(), 20)); if (actor.hasMoved()) { actorHashMap.remov...
8e7b86d7-3257-4165-804c-00e246578ca3
3
public void mouseExited(MouseEvent e) { // if mouse stops hovering over top right options... if (e.getSource()==InScreens.getBookHubButton()) { // animate BookHub option system.getContentPane().remove(InScreens.getBookHubSelected()); system.getContentPane().add(InScreens.getOptionsUnselected(),0); system.get...
180a6822-6272-44f6-ade8-ff0bf800d72e
0
public String getCookieForResponse() { return COOKIE_KEY + "=" + sessionId + "; Path=/; HttpOnly "; }
84375353-b6b8-4bc5-b4ff-abb0f1647d4e
7
public void prTable(int num_estado, int num_simbolo) { this.cbxeorigen.setModel(new DefaultComboBoxModel()); this.cbxedestino.setModel(new DefaultComboBoxModel()); this.cbxsimbolo.setModel(new DefaultComboBoxModel()); num_simbolo = num_simbolo + 2; Object[][] ob = new Object[num_...
723a02f8-03d1-4428-9144-95fb6a9ae964
8
public boolean hasCollided(int xa, int ya) { int xMin = 0; int xMax = 7; int yMin = 3; int yMax = 7; for (int x = xMin; x < xMax; x++) { if (isSolidTile(xa, ya, x, yMin)) { return true; } } for (int x = xMin; x < xMax; x++) ...
b9d65fc7-70a5-4ec5-acdc-90ab3a2987db
4
public static byte[] compressRow(byte[] b) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte active = b[0]; byte same = (byte) -127; for (int i = 1; i < b.length; i++) { if (b[i] == active && same < 127) same += 1; else { baos.write(new byte[] { same, active }); same...
e6548eeb-5b8f-4c74-aa11-981b511da7c3
0
@Override public void run() { cleanUpAllExpiredSession(); }
30c5e436-1215-46d7-94a2-2f43c3993531
7
private void setFilenames(String filename, char app){ BufferedReader input0; try{ input0 = new BufferedReader(new FileReader(filename)); }catch(FileNotFoundException e){ this.fileExists = false; } if...
315c500b-2e1c-41d2-a0f6-6ba3d26267db
6
public List<Challenge> getChallengeList(String oppositeFileName, String teamType) { List<Challenge> challengeList = new ArrayList<Challenge>(); Element challengeE; Challenge challenge; BipolarQuestionDao biploarQuestionDao = new BipolarQuestionDao(oppositeFileName); List<BipolarQuestion> challengeParentList =...
24953a59-ae6f-4875-9418-1676fda7d289
7
boolean valid(Graph G) { return G.getEdgeWeight(1, 0) == 1&& G.getEdgeWeight(1, 2) == 3 && G.getEdgeWeight(2,4) == 1 && G.getEdgeWeight(3, 4)== 2 && G.getEdgeWeight(3, 6) == 3 && G.getEdgeWeight(7, 6) == 2 && G.getEdgeWeight(7, 8) == 4 && G.getEdgeWeight(4, 5) == 3; }
ff5b45ce-2558-407a-95e1-93af308ec6dd
7
protected void setupInventory() throws FileNotFoundException, AcsException, URISyntaxException, SAXException { ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(acsFile)); try { ZipEntry zipEntry; while ((zipEntry = zipInputStream.getNextEntry()) != null) { ...
4ed5eeed-f9ee-4dfc-882c-431cadfec451
9
public Matrix<T> getVer () throws Exception { if (this.cols != this.rows) { throw new MatrixIsNotInversebleException(); } Matrix<T> ex = this.getEx(); // set the diagonal line elements of the Matrix as "1" for (int r = 0; r < rows; r++) { T c = ex.get(r, r); if (!c.isOne()) { ex.set(r, r, thi...
4f4ba48d-044f-434c-9805-e0c6fad15482
0
public static void runDataWindow(){ frames.runDataWindow(); frames.getDataWindow().setVisible(true); }
d0b49b08-0759-4275-8ce5-cda0626dcaa7
1
public boolean containIndex(int index) { if (data.containsKey(index)) { return true; } return false; }
3677fe3e-7dfa-4484-8a43-9098bba35ec0
1
private boolean jj_3_26() { if (jj_3R_43()) return true; return false; }
bf36897e-927b-444d-9940-e907ec9216aa
7
protected void prepare_sample_reading(Header header, int allocation, //float[][] groupingtable, int channel, float[] factor, int[] codelength, float[] c, float[] d) { int channel_bitrate = header.bitra...
7ce93c98-b51d-42be-a4fc-a0f88c5c884c
7
private void makeSwarmMotion() { iteration++; double w; if (iteration > linWeightTreshold) { w = linWeightEnd; } else { w = linWeightStart + (linWeightEnd-linWeightStart)* (iteration-1.0)/linWeightTreshold; } neighborhood.scan(particles); for (int i = 0; i < particles.length; i++) { ...
4759d100-f041-49b9-9b63-d83fb551d161
3
@Command(command = "readmail", arguments = {"mail ID"}, description = "reads the mail message with the given ID", permissions = {"read"}, playerOnly = true) public static boolean readMail(CommandSender sender, int mailID) throws EssentialsCommandException { // get our mail ArrayList<HashMap<String, Obj...
551f0717-5dd8-41ee-90e5-ca3639485592
6
public void TwentyOneDisplay() // displays twenty one cards in three collumns // maintains original order and selection { int index = 1; System.out.println("Right Stack: "); while(!rightStack.isEmpty()) { currentCard = (String) rightStack.top(); ...
d76ccd68-0586-453c-94a4-181cdb71fc27
5
private Node parseMultiplicative() throws ScriptException { Node left = parsePower(); if (left == null) return null; Token token; while ((token = analyzer.getNextToken()) != null) { if (token.getType() != Operators.MUL && token.getType() != Ope...
6d4e0db5-c627-4bde-b624-6ad9c5ff3376
4
public void calcCosts(Player[] players) { for (Player player : players) { PlayerData quartalData = player.getData().lastElement(); quartalData.setFixCosts(quartalData.getCapacity()*100); int tmp = quartalData.getQualityOfMaterial(); if(tmp == 0) { quartalData.setVarCosts(100); } else if (tmp == ...
6df734a9-5d57-4dba-a192-82e0f625a7c9
4
public void itemStateChanged(ItemEvent e) { try { Object o = e.getSource(); if (o instanceof JComboBox) { JComboBox btn = (JComboBox) o; if (list.getSelectedIndex() != -1) { // some func is selected Function f = (Function) list.getSelectedValue(); if (f != null) { f.retu...
01039137-e0e1-45dd-84f5-fededc24a1ad
9
public static String patttobin(String code, String zero, String one) { if(!zero.equals("") || !one.equals("")) { char[] zeros = zero.toCharArray(); char[] ones = one.toCharArray(); char[] codeline = code.toCharArray(); String result = ""; for(int i = 0...
0819b44b-d2f7-45e5-989b-d22379d9b7b2
7
public void mapKeyToGroup(Comparable key, Comparable group) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable currentGroup = getGroup(key); if (!currentGroup.equals(this.defaultGroup)) { if (!currentGroup.equals(group...
dc784fc2-e552-40ce-8a62-cc49ea1ac63e
8
private void loadUser(String accountName) { //Get the 'friendly' username string (removes '@' and '.') String friendlyAccountName = getFriendlyName(accountName); //Clear instance ComboBox InstanceComboBox.removeAllItems(); InstanceComboBox.addItem("<None>"); ...
f0a3c403-4c91-4326-9592-87069ed7b429
8
protected void setup() throws SlickException { if (targetDisplayMode == null) { setDisplayMode(640,480,false); } Display.setTitle(game.getTitle()); Log.info("LWJGL Version: "+Sys.getVersion()); Log.info("OriginalDisplayMode: "+originalDisplayMode); Log.info("TargetDisplayMode: "+targetDisplayMode); ...
bb7084e9-8327-425f-9e60-f160e88e8be3
1
public int hashCode() { int result = 17; if(name != null) result = 37 * result + name.hashCode(); result = 37 * result + (int)id; return result; }
94947f9b-1854-44a1-80d3-0e3c0c866368
4
public void initTreeRightClickPopup() { treeRightClickPopup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Get Card Info"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (Card c: cardTreePanel.getCardBuffer()) { ...
94dde211-da7f-469e-b287-b43d07662801
6
public void checkForFlag() { try { File dir = new File("characters"); if(dir.exists()) { String read; File files[] = dir.listFiles(); for (int j = 0; j < files.length; j++) { File loaded = files[j]; if (loaded.getName().endsWith(".txt")) { Scanner s = new Scanner (loaded); whi...
9a7e8d3d-fcb7-4693-a4d5-67b55b6611c2
5
@Override public List<Student> getStudentsWithMarks(int courseId) throws SQLException { List<Student> studentList = new ArrayList<>(); Connection connect = null; PreparedStatement statement = null; try { Class.forName(Params.bundle.getString("urlDriver")); con...
a25b2c69-fbc9-4964-be68-f0db52bdb93a
8
@Override protected boolean isTestable(int u, int j) { switch (view) { case "cold-start": return trainMatrix.rowSize(u) < 5 ? true : false; case "trust-degree": int min_deg = cf.getInt("min.trust.degree"); int max_deg = cf.getInt("max.trust.degree"); if (min_deg == -1) min_deg = 0; if (max_deg...
7b95b6fd-c704-48a8-82ff-b9279e4f9889
7
public void func_31070_a(TileEntityPiston var1, double var2, double var4, double var6, float var8) { Block var9 = Block.blocksList[var1.getStoredBlockID()]; if(var9 != null && var1.func_31008_a(var8) < 1.0F) { Tessellator var10 = Tessellator.instance; this.bindTextureByName(Minecraft.TERRA...
81a45d5e-041b-4cbc-be36-4c47c69c78a9
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...
26da6b4f-2fd4-484c-bec3-e3e6febe44a9
5
public static ArrayList<Entity> getEntitiesAdjacentTo(Point location, Team entityTeam) { ArrayList<Entity> adjacentEntities = new ArrayList<Entity>(); if (entityTeam == Team.EVIL) { for (Entity enemy : enemies) { if (enemy.isLocationWithinDistance(location, Physics.getAdjacencyDistance())) { adjacentEnt...
8a4ea781-59f1-4ed0-8ad7-a0f8ac71a41c
2
public static void writeAllLines(File file, List<String> lines) throws IOException { PrintWriter writer = null; try { writer = new PrintWriter( new OutputStreamWriter( new FileOutputStream(file), "windows-1251")); String compared = ""; for (String s:lines) ...
3d8da423-897d-4d9b-af4c-79bc990a4370
8
public static int getSum(int n, long x0, long a, long b) { int totalRadii = 0; long prevElement = x0; for (int index = 1; index < n - 1; index++) { long currElement = getSeriesElement(index, a, b, prevElement); long prev = x0; long curr; int maxRadii = (index <= n/2) ? index : (n-1)-index; for(int ...
5ad78b48-32e7-45db-99bb-1ae575e680ce
6
public boolean getDecision(ArrayList<Boolean> enemyDecision) { int loyalty = 0; int betrayed = 0; boolean lastDecision = false; for (boolean e : enemyDecision) { if (e == true) { betrayed++; } else { loyalty++; } ...
6b8facad-b026-437f-afea-e6a55d681fcc
7
static void createPlayersTable() throws IOException { getLink(); if (!stop) { URL url = new URL(link.substring(trashLength, link.length())); URLConnection con; con = url.openConnection(); java.io.InputStream is = con.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is));...
42f28bec-7397-49b0-a1b0-f875b798c6d1
8
public void setCam(int xCam, int yCam) { int xCamD = this.xCam - xCam; int yCamD = this.yCam - yCam; this.xCam = xCam; this.yCam = yCam; g.setComposite(AlphaComposite.Src); g.copyArea(0, 0, width, height, xCamD, yCamD); if (xCamD < 0) { i...
2f0f3de1-686c-4ba2-b8ef-f438033e4834
8
private void parseSequenceHeader() throws MpegVideoDecodeException, IOException { Statistics.startLog(PARSE_SEQ_HEADER_STRING); if( m_ioTool.isEOF() ) return; if( m_ioTool.getBits(32) != SEQ_START_CODE ) { throw new MpegVideoDecodeException("SEQ_START_CODE expect...
fc4e4afe-c205-4482-b4d3-a3a5da9abe11
2
@Override public boolean activate() { return (isAnswering() || isTalking() || isListening()); }
19568e43-2dda-4015-bca3-a69dce889082
5
public Object getValueAt(int row, int col) { Booking booking = transaction.getBusinessObjects().get(row); if (booking.isDebit()) { if (col == 0) { return booking.getAccount(); } if (col == 2) { return booking.getAmount(); } return null; }// else credit if (col == 1) { return booking.ge...
eec87737-5ad1-4a6b-a8a2-e3bcc96c1415
5
@Test public void testReceiveMultipleManyExpiredTwoValid() { int noOfMessages = 13; try { consumer = new AbstractMessageConsumer(mockTopic) { }; assertNotNull(mockTopic.getTopicSubscriber()); HashSet<Message> messages = new HashSet<Message>(); for (int i = 0; i < noOfMessages; i++) { Message ms...
0c615d4d-6a77-4cc9-9e10-487bc29b9f74
6
static public Object deserializeArray(InputStream in, Class elemType, int length) throws IOException { if (elemType==null) throw new NullPointerException("elemType"); if (length<-1) throw new IllegalArgumentException("length"); Object obj = deserialize(in); Class cls = obj.getClass(); ...
68d7ab40-a545-4347-8e9b-cba08f008084
0
public int getDepartureEnd() { return this._departureEnd; }
723ee431-683e-4541-b640-4f8822628269
6
private void updateShields() { ArrayList<Shield> deadShields = new ArrayList<Shield>(); for(int i = 0; i < shields.size(); i++) { Shield s = shields.get(i); s.move(); if(CollisionDetector.isColliding(s, sc)) { sc.activateShield(); deadShields.add(s); } if(!s.isOnScreen()) deadSh...
dcfc0934-0c57-4b23-87ec-35a6a8fa51a3
0
private int GetStopBusStop() { return stopBusStop; }
dfb85cb4-ab54-4c7a-bc6b-c586eb017fcb
6
private CardPower isFullHouse(int[] valueCounts) { int highCard = -1; int kickerCard = -1; for (int i = valueCounts.length - 1; i >= 0; i--) { if (valueCounts[i] == 3) { highCard = i; break; } } for (int i = valueCounts.length - 1; i >= 0; i--) { if (valueCounts[i] == 2) { kickerCard = i;...
970dfbd2-71d0-43e3-876a-4d9ce7e2afe4
8
public boolean userCanRead(String uid, String uunit, Patient person, JournalEntry entry) { int type = findType(uid); if (type == TYPE_GOV) { return true; } else if (type == TYPE_DOCTOR) { if (entry.getDoctorId().equals(uid) || entry.getUnit().equals(uunit)) { return true; } } else if (type == TYPE_...
c503fdbf-2024-49a7-b8dc-a559d447b341
7
void fil(int x, int y, int color1) { if (color1 == color.getRGB()) return; class StackElem { int x, y; } ArrayList<StackElem> stack = new ArrayList<StackElem>(); StackElem NowIs = new StackElem(); NowIs.x = x; NowIs.y = y; stack.add(NowIs); while (stack.size() > 0) { int a = 0; StackElem N...
16f7bc61-6723-4885-8c12-94035166e3d4
6
public boolean isBlockHere(int x, int y, int z) { int cx = x / Chunk.chunkW; int cy = y / Chunk.chunkH; int cz = z / Chunk.chunkD; if((x >= 0 && y >= 0 && z >=0) && (cx < ncx && cy < ncy && cz < ncz)) { return chunks[cx + (cy * ncx) + (cz * ncx * ncy)].isBlockHere(x - (cx * Chunk.chunkW),y - (cy * Chunk.chun...
4479f7d4-2a01-4a38-a0ce-d7b89984102f
6
public void solve() { Scanner in = new Scanner(System.in); int n = in.nextInt(); String s = in.next(); int len = 1; while (true) { int cnt = (int) Math.pow(2, len); // System.out.println(cnt + "---" + len); Set<Integer> set = new TreeSet<Integer>(); for (int i = 0; i + len <= ...
9981e6a3-b4ee-4c77-b944-d0fae04d87eb
0
public void onAccount(IAccount account) throws JFException { this.account = account; }
795cc459-7fe6-4483-82b5-89bd0263ec57
2
protected float findRadius() { float radius2 = 0.0f; for (Polygon p: polygons) { for (Vertex v: p.verticies) { radius2 = Math.max(radius2, v.coord.magnitude2()); } } return (float)Math.sqrt(radius2); }
2bc439cd-17e8-4eaf-8256-89067fdd9a7e
0
public void setK(float k) { this.k = k; }
cc1c075f-2b3d-4518-945b-f5ab62b07df0
5
public static double[] doLinearRegression(double[][] args) //input double[0]=array of day number { //input double[1]=array of prices double[] answer = new double[3]; int n = 0; double[] x = new dou...
8c21fc2f-760f-4d93-accc-44ce78e167ac
8
public static Keyword hasPartitionMembershipSpecialist(ControlFrame frame, Keyword lastmove) { { Proposition proposition = frame.proposition; Stella_Object argumentvalue = Logic.argumentBoundTo((proposition.arguments.theArray)[0]); lastmove = lastmove; if ((argumentvalue == null) || (!S...