method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
5ad95189-5da2-4601-90b7-c331c201c210
5
public void reloadSanninCommands() { sannincommands.clear(); try { ClassFinder classFinder = new ClassFinder(); String[] classes = classFinder.listClasses("net.sf.odinms.client.messages.commands.Sannin", true); registerSanninCommand(new HelpSanninCommand()); // regist...
6a457136-fd99-4c05-a5d0-dd69e659b585
5
public static void addEntry(Map<String, String> data,String tag){ /** * addEntry: add tracks info into the json database file * tag - String: This is a searchable string which should be * unique and be used to identify this entry. * data - Map<String,String>: This should contain key/value pairs * of th...
d15e4b95-1905-4c11-9ba9-275c121ed407
0
public static Response showFavicon() { return new Response("no icon to display"); }
902bebf7-0396-41f9-8662-5070a2edc164
6
private void drawLightning(Graphics g) { if (lightnings.isEmpty()) { return; } Graphics2D g2d = (Graphics2D) g; final Stroke bigStroke = new BasicStroke(6F); final Stroke smallStroke = new BasicStroke(3F); final Color mainColor = new Color(255, 243, 60); final Color shadeColor = new Color(255, 25...
62265405-9b11-413e-893c-0f2ae3e7ba48
1
public void insert(String item) { // make case-insensitive item = item.toLowerCase(); Integer count = 0; for (int i = 0; i < item.length(); i++) { Character c = item.charAt(i); // get ASCII value for current char int charIndex = (int) c; count = map.get(charIndex); count = count + 1; map.se...
86ef30fb-1d1f-429c-b365-30912ccd56fd
5
public Object [][] getDatos(){ Object[][] data = new String[getCantidadElementos()][colum_names.length]; //realizamos la consulta sql y llenamos los datos en "Object" try{ if (colum_names.length>=0){ r_con.Connection(); String c...
ca660e53-7a82-4e3f-8b53-3d83c07e1f52
5
public static void TypeOfCallForList(String hangupInitNumber, String hangupNumber, Boolean missCall) { for (int i = 0; i < AllExtensions.size(); i++) { // исходящий звонок if (hangupNumber.equals(AllExtensions.get(i)) && missCall) { NumForList(hangupInitNumber, "MissCall"); } else if (hangupInitNumbe...
95d1f926-f9ce-43b0-89d3-4785fcc3a748
5
private float[] mdct_kernel(float[] x, float[] w, int n, int n2, int n4, int n8) { // step 2 int xA = n4; int xB = 0; int w2 = n4; int A = n2; for (int i = 0; i < n4;) { float x0 = x[xA] - x[xB]; float x1; w[w2 + i] = x[xA...
cecdba19-835a-4d2e-834c-781accf408ab
0
public <T2> T2[] toArray(T2[] a) { return this.toArrayList().toArray(a); }
e3a97adc-ce19-41ba-952e-8d64192b8e10
6
public Tile[][] setAreaUnavailable(Tile[][] grid, Rectangle area) { if (area.x >= 0 && area.y >= 0 && area.width < grid.length && area.height < grid[0].length) { for (int i = area.x; i < area.width; i++) { for (int j = area.y; j < area.height; j++) { grid[i][j].setAvailable(false); } } ...
63be13ba-a70e-4f00-a20c-71a4a2ed7137
4
public static int dp(int s, int e, boolean t) { if (s > e) return 0; if (dp[s][e] != INF) return dp[s][e]; int max = 0; if (!t) { if (v[s] < v[e]) max = dp(s, e - 1, !t); else max = dp(s + 1, e, !t); } else max = Math.max(dp(s, e - 1, !t) + v[e], dp(s + 1, e, !t) + v[s]); return dp[s]...
87fddb21-a064-4eac-9a6e-605d1625f8f3
9
@Override public void actionPerformed(ActionEvent ae){ int accion = Integer.parseInt(ae.getActionCommand()); switch(accion){ case 1: System.out.println("Simple"); this.seleccionarEquipo(); break; case 2: Sys...
9e7a49d4-456b-406e-94b3-826930609a55
1
private int getInt(String s) { try { return Integer.parseInt(s); } catch (NumberFormatException ex) { return 0; } }
be4fc421-abc5-46e0-b134-d8e09d933056
4
public void addPoint() { this.points += 1; this.player.sendMessage(ChatColor.GOLD + "You now have " + this.points + " Points!"); if (this.level.nextLevel == null) { this.team.handleWin(this); for (Team t : this.arena.teams) if (!t.equals(this.team)) t.handleLoose(this); ...
33fb3f6e-e8ca-4f54-95c6-be9880712d68
0
public long getSize() { return _size; }
64ec25e5-c3e8-429b-8ed0-40a2286beeb3
0
public long getInitialTemp() { return initTemps[2]; }
8e5162ef-8cb2-400f-961e-5d2eb8251a15
7
private static int bounty(Board b, int rank, int file, int opponentColor) { if (b.spaceHasOpponent(new Position(rank, file), opponentColor)) { switch (Math.abs(b.board[rank][file])) { case 1: return pawnBounty; case 2: return knightBounty; case 3: return bishopBounty; case 4: re...
adabf852-a9eb-45d2-86f6-387a4cfc209d
4
static private boolean jj_3R_18() { Token xsp; xsp = jj_scanpos; if (jj_3_3()) { jj_scanpos = xsp; if (jj_scan_token(23)) { jj_scanpos = xsp; if (jj_scan_token(31)) { jj_scanpos = xsp; if (jj_scan_token(44)) return true; } } } return false; }
75918cc2-810d-4160-a5a4-557284ccd30d
6
public int longestValidParentheses(String s) { if(s == null || s.length() == 0) return 0; Stack<Integer> stack = new Stack<Integer>(); int last = -1; int max = 0; for(int i=0; i<s.length(); i++){ if(s.charAt(i) == '('){ stack.push(i);...
65825365-87ec-439c-bc87-118fa19bb216
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Usuario other = (Usuario) obj; if (idade != other.idade) return false; if (nome == null) { if (other.nome != null) return false; } ...
a3965294-72dc-4dbf-b5b2-5222b5f7102f
8
@Override public ContainerRequest filter(ContainerRequest containerRequest){ String method = containerRequest.getMethod(); String path = containerRequest.getPath(true); String UUID = containerRequest.getQueryParameters().getFirst("UUID"); System.out.println("Auth-meth...
3f12d577-b502-4a5e-b803-456aba19c071
3
public static IdStore create(Iterable<Schema.Player> players) { Map<String,Map<String,Schema.Player>> store = Maps.newHashMap(); for (Schema.Player p : players) { for (Map.Entry<String,String> id : p.id.entrySet()) { Map<String,Schema.Player> shard = store.get(id.getKey()); ...
68319962-a3b5-4793-aebd-386206879610
3
private void sendExistingRooms(ServerClient activeclient) { HashMap<String, ArrayList<String>> existingRooms = new HashMap<String, ArrayList<String>>(); for (Room r : rooms) { ArrayList<String> users = new ArrayList<String>(); for (ServerClient sc : r.getClientsInRoom()) { users.add(sc.getNickname()...
7c97fe61-a9de-44ef-81e6-d2cc8b5fe775
8
public void actionPerformed(ActionEvent e) { Object obj = e.getSource(); if(obj==bBackToMenu) mainWindow.viewManager.setView(ViewManager.MENU); else if(obj==bLeft){ editKey(tfLeft,null,borderGreen); mainWindow.activeKeys.setKey("LEFT",this); } else if(obj==bRight){ editKey(tfRight,null,borderGr...
ed3e27e8-9aab-4d26-9877-c1832ea45c4b
3
static void init() throws IOException { File downloadedUrlRecord = new File("gutenberg/url2.txt"); if (!downloadedUrlRecord.exists()) { downloadedUrlRecord.createNewFile(); } downloadedUrls = new HashSet<String>(); BufferedReader br = new BufferedReader(new FileReader( downloadedUrlRecord)); String l...
e855f26f-e37b-4f44-a32c-bacc1f44a4c0
3
public static void writeJSON(String filePath, JSONObject json) { try { File f = new File(filePath); // if the directory above the file doesn't exist, make it. :) File dir = f.getParentFile(); if (!dir.exists()) { dir.mkdirs(); } // delete the file if it exists already to completely overwrite ...
0a8061ec-09d6-4f75-8907-2ac1d515243e
7
public void check() { RunIterator iterate = iterator(); int currentIndex = 0; int[] prevRun = iterate.next(); int runLengthSum = prevRun[0]; int[] currentRun; while(iterate.hasNext()){ if (prevRun[0] <= 0) System.out.println("Run " + currentIndex + " has a length less than 1"); cu...
f582dc3b-3dfb-4d5b-a720-037c14793838
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (this.getClass() != obj.getClass()) return false; final RegExBetween other = (RegExBetween) obj; if (this.begin == null) { if (other.begin != null) return false; } else if (!...
da3659d4-f854-453d-b67e-c14146f95e6e
3
public T get(int x) { if (this.length != 0 && x < this.length) { Node<T> ele = _head; for (int i = 0; i < x; i++) ele = ele.getNext(); return ele.getData(); } return null; }
af114dac-098a-4816-8c39-6120f1946368
2
public boolean removeLocation(World world) { UUID uid = world.getUID(); Connection conn = plugin.getDbCtrl().getConnection(); PreparedStatement ps = null; try { String sql = String.format("DELETE FROM `%s` WHERE `uid` = ?", plugin.getDbCtrl().getTable(Table.LOCATION)); ps = conn.prepareStatement(sql...
8381ea4b-4761-4be7-ad97-64376f0a4679
9
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 ...
112faf02-5739-454a-9f2c-4dd50b9b9753
0
BEValue toBEValue() throws UnsupportedEncodingException { Map<String, BEValue> result = new HashMap<String, BEValue>(); result.put("failure reason", new BEValue(this.message, "UTF-8")); return new BEValue(result); }
332690ab-a66c-410a-9eca-c89639e4f606
3
public Document asDocument() throws WeiboException { if (null == responseAsDocument) { try { // it should be faster to read the inputstream directly. // but makes it difficult to troubleshoot this.responseAsDocument = builders.get().parse(new ByteArray...
1621658d-3db8-4c9b-b8db-1e4a7bc1ba10
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Usuario other = (Usuario) obj; if (login == null) { if (other.login != null) return false; } else if (!login.equals(other.login)) ret...
25d3268e-62ea-4056-849f-ec81021d1241
7
private void writeQNames(javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { if (qnames != null) { // we have to store this data until last moment since it is not possible to write any ...
d86e3eb2-2511-48c0-88fa-89b2eb782880
1
private void alustaLista() { File el = new File(elokuvanTiedot); if (!el.exists()) { elokuvat.add(new Elokuva(01,"Esimerkki elokuva", "Ohjannut Taavetti", "Nayttelijat", "Genre", "1999", "130", "JUONINININI", "KUVAURL")); tallenna(); } else { lue(); } tulosta(); ...
9c517380-711c-44a8-af3f-4defc166bbe8
4
public void mouseClicked(int button, int x, int y, int clickCount) { if (boutons[0].getShape().contains(x, y)) { game.enterState(1); } if (boutons[3].getShape().contains(x, y)) { System.exit(0); } if(boutons[2].getShape().contains(x,y)){ game.enterState(2); } if(boutons[1].getShape().contains(x,y...
ba9d807a-5076-4fab-a5d5-86842aea1ff7
9
public void loadPokemon() { String input ="savedata/"+idString+".pkmn"; try { BufferedReader in = new BufferedReader(new FileReader(input)); encryptionKey=0; Pokemon temp=new Pokemon(Pokemon.Species.BULBASAUR); String test=in.readLine(); if(VERSION.charAt(0)!=test.charAt(0)) { System.o...
3a133c1c-3272-4ecf-870d-8ee7c9266be8
4
public int getIndex(){ int numOfOptions=_map.mygraph.getCurr(); if(numOfOptions==0){ JOptionPane.showMessageDialog(null,"There isn't any location on the map!","Find",JOptionPane.ERROR_MESSAGE,null); return -1; } String[] options=new String[numOfOptions]; for(int i=0;i<numOfOptions;i++){...
948bec90-48a4-4486-9d26-12fe1e72f92f
2
public static void main(String[] args) { InMemoryAuctionService imas = new InMemoryAuctionService(); Auction a = new Auction(12, "pizza", 5); Auction a1 = new Auction(33, "something", 8); System.out.println(a.toString()); System.out.println("The auction object was printed out."); System.out.println(a.equals...
dbdfe587-0b1d-4b20-9d48-def2c366176e
1
public static String getPrimeMinister(String date) { date = date.replaceAll("-", ""); DB db = _mongo.getDB(DATABASE_NAME); DBCollection coll = db.getCollection(COLLECTION_GOVERNMENT); BasicDBObject query = new BasicDBObject(); query.put("start.date", new BasicDBObject("$lte", date)); ...
8854c53a-5ee5-460b-9bff-284f5faf9eef
1
@Test public void shouldReturnsStacksSize() { int expectedSize = 10; for (int i = 0; i < expectedSize; i++) { stack.push(randomItem()); } assertThat(stack.size(), is(expectedSize)); }
1de3c387-0b8a-4cde-bcce-c82c8b403860
7
private void generatePlaylist() { for(Song song: songs) { song.resetSelect(); } Random rand = new Random(); int i=1; int position; int min=(i-1)*10; int max=i*10; position= rand.nextInt((max - min)) + min; playlist[0]=songs.get(position); songs.get(position).selected(); while(i<6){ min=(i...
9411d76a-2328-40f2-b523-e8e84454fd07
9
@Override public void generateAmortizationScheduleTable(AmortizationSchedule input, PrintFormatHelper printFormatHelper) throws Exception { // To create the amortization table, create a loop in your program and follow these steps: // 1. Calculate H = P x J, this is your current monthly interes...
80c30ea3-f66d-4d6c-9f97-a8520c578be1
8
@Override public void reset(Map<String, Parameter> parameters) throws ManagementException { // get the start config and check its type ParameterList start; Parameter start1 = parameters.get("start"); if (start1 != null) { if (start1 instanceof ParameterList) { start = (ParameterList) start1; } else ...
051e06a6-4676-4674-8432-a596e3e3cd8d
7
public static void call(final String data) throws Exception { BuffReaderDelimParser pzparse = null; try { // delimited by a comma // text qualified by double quotes // ignore first record pzparse = (BuffReaderDelimParser) BuffReaderParseFactory.getInstanc...
d80b3de0-b2af-43a6-8415-29d974bc4e38
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Turno)) { return false; } Turno other = (Turno) object; if ((this.idTurno == null && other.idTurno != null) || ...
88b988ac-f86d-4adf-952e-521378e768c8
3
public static void setParams(PreparedStatement ps, Object... params) throws SQLException { if (ps != null && params != null) { for (int i = 0; i != params.length; ++i) { ps.setObject(i + 1, params[i]); } } }
a1683b6d-7388-4dc1-9809-140202b2394a
6
public static Cons clTranslateMakeTree(Cons tree) { { Stella_Class renamed_Class = ((Stella_Class)(Stella_Object.typify(tree.rest.value).surrogateValue)); Stella_Object classsymbol = Stella_Class.clTranslateClassName(renamed_Class); Cons otree = null; if ((classsymbol == Stella.internCommonLispSy...
9c59da91-fd02-4e08-81e0-91fc3eb09b43
2
public static void main(String[] args) { Set<String> words = new HashSet<String>(); // HashSet implements Set long totalTime = 0; Scanner in = new Scanner(System.in); while (in.hasNext()) { String word = in.next(); long callTime = System.currentTimeMillis(); ...
244358fc-d322-4054-a9dc-0444bd6ce67b
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...
9065af3c-eea7-47c4-b2f2-85784ae0ed96
9
public static <B> BeanPropertyMapFactory<B> forClass(Class<B> clazz) { synchronized (cFactories) { BeanPropertyMapFactory factory; SoftReference<BeanPropertyMapFactory> ref = cFactories.get(clazz); if (ref != null) { factory = ref.get(); if (fa...
dd51ac87-1bbb-4abf-8e9e-3bb4c12bb869
6
private void parseSavedPagesForTickers() { for (File htmlText : rawHtmlData) { String[] getTickersFrom = { " " }; try { String fromFile = FileUtils.readFileToString(htmlText); getTickersFrom = fromFile.replaceAll("\\s+", "") .split("q\\?s="); // System.out.println("\n" + htmlText.getName() +...
9585a65a-2d51-4b75-a468-efc791f37366
4
private boolean isSelected(GameContainer gc) { int mX = gc.getInput().getMouseX(); int mY = gc.getInput().getMouseY(); if (mX > x && mX < x + width) if (mY > y && mY < y + height) return true; return false; }
1996f4b0-dd29-4b65-b7d6-0f71b708a81a
3
public static void main(String[] args) { int result = 0; for (int i = 1; i < 1000; i++) { for (int j = 1; j < 1000; j++) { int k = 1000 - i - j; if (i * i + j * j == k * k) result = i * j * k; } } System.out.println(result); }
4f39f695-938c-432e-9928-dbcccd9aa648
1
@Override public void mark(int boardPosition, Cell[] cellBoard, int rows, int columns) throws IllegalMark { //Find the column. int boardPositionColumn = boardPosition % columns; if (boardPositionColumn < columns -1){ //It's not the last column. i...
484d6e47-4d52-4d37-acf3-5b820175df38
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Movie)) { return false; } Movie other = (Movie) object; if ((this.id == null && other.id != null) || (this.id !...
a4db9d85-28a9-407d-adb2-0194326d88b0
0
public void setOperator(BinaryLogicalOperator<Boolean> operator) { this.binaryLogicalOperator = operator; }
518e0e2c-fb21-4ac9-9957-eaf47b20e236
9
private Polarity polarity() { if (positiveCounter <= 0 && negativeCounter <= 0 && neutralCounter <= 0) { return Polarity.NOT_SET; } else if (positiveCounter > negativeCounter && positiveCounter > neutralCounter) { return Polarity.POSITIVE; // Positive word ...
6bf85f09-0f5f-4404-84d0-db8dc02aa005
0
private Animation createGrubAnim(Image img1, Image img2, Image img3, Image img4, Image img5, Image img6,Image img7, Image img8) { Animation anim = new Animation(); anim.addFrame(img1, 150); anim.addFrame(img2, 150); anim.addFrame(img3, 150); anim.addFrame(img4, 150); ...
ddc504d6-d4ea-4578-81d3-8d4a5b21a51a
7
@Override synchronized public void close() { if (isOpen) { try { if (serialPort != null) { if (serialPort.getInputStream() != null) { serialPort.getInputStream().close(); } if (serialPort.getOutpu...
6724f5e3-6531-4ae2-a383-0cab065b7cb6
7
public void keyPressed(KeyEvent evt) { if (DMPuzzle.getPuzzle() == null) return; int key = evt.getKeyCode(); if (key == KeyEvent.VK_ESCAPE) { GridBoardController.clearSelectedCellValue(DMPuzzle.getPuzzle()); } if (key >= KeyEvent.VK_1 && key <= KeyEvent.VK_9 ) { int color = -1; if (c...
8c9d4572-34d7-4738-889c-10fe4caa77ce
0
@Before public void setUp() { }
624c37ab-acf4-49cc-b84b-4b7ee4c0b0dc
5
@Override public void setMode(EditorMode mode) { if (getMode() != mode) { if (mode.isExec()) { if (starter_.isFree()) { try { startTimer(); } catch (Exception e) { startTimer(); e.printStackTrace(); } } } else if (!mode.isExec()) { stopTimer(); } } super.set...
65f223d2-11b8-4bfa-af9a-225013ebd0f7
3
private void setText(){ if (!realLifeShowNumbers && needToCount){ textFieldAlive.setText("? Alive"); textFieldDead.setText("? Alive"); textFieldZombie.setText("? Alive"); } else if (realLifeShowNumbers){ textFieldAlive.setText(animation.getNumberOfAlive(an...
9f7130d4-6dcd-407f-9647-a3de5dd5555a
6
private void readFinishedDataflow(String realDataflowDir) { try { BufferedReader reader = new BufferedReader(new FileReader(new File( realDataflowDir + "realDataMapper.txt"))); String[] title = reader.readLine().split("\t"); String line; while ((line = reader.readLine()) != null) { String[] val...
6ac5ea48-06cd-4c8f-a817-9286ec2087bd
9
private boolean processLog() throws UnknownPlayerException , UnknownCardException , ContradictionException { boolean tableModified = false; for (LogEntry logEntry : log) { if (logEntry instanceof Accusation) { ...
3d44e763-996f-4ad5-be42-ea244cc35e73
7
private boolean isOtherPunctuation(String str) { char ch = str.charAt(0); return ch == '~' || ch == '`' || ch == '!' || ch == '@' || ch == '#' || ch == '$' || ch == '%' || ch == '?'; }
f9f653e5-2924-40cd-a8d6-f6d915cdd962
6
public boolean getBoolean(String key) throws JSONException { Object o = get(key); if (o.equals(Boolean.FALSE) || (o instanceof String && ((String)o).equalsIgnoreCase("false"))) { return false; } else if (o.equals(Boolean.TRUE) || (o ins...
aedbf312-45a4-4ec0-bf30-e53c47bfd821
7
private static SpecialReward getRewardFromLevelAndType(int level, String type) { if(type.equals("armor")) { if(level > 7) level=7; return armors[level]; } else if(type.equals("weapon")) { if(level > 6) level=6; return weapons[level]; } else if(type.equals("head")) { if(l...
5aea04f1-15e8-477c-ad9e-8570a23848a5
1
public void testPlus_int() { Seconds test2 = Seconds.seconds(2); Seconds result = test2.plus(3); assertEquals(2, test2.getSeconds()); assertEquals(5, result.getSeconds()); assertEquals(1, Seconds.ONE.plus(0).getSeconds()); try { Seconds.MAX_V...
504a0b5b-aa26-4b2e-b26f-043eede1c38f
1
public void updateMinTotalInf(int x) throws InterruptedException { s1.acquire(); if (minTotalInf > x) minTotalInf = x; s1.release(); }
53770d7b-a651-41c3-9958-8d507f8bb950
3
@Override public void delete(Article obj) { PreparedStatement pst = null; try { pst = this.connect().prepareStatement("DELETE FROM Article where id=?;"); pst.setInt(1, obj.getId()); pst.executeUpdate(); System.out.println("suppres...
3dfac7cd-acdf-4034-98c4-f2c87c6bb565
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...
6408f54f-23b4-4cc0-8179-990fac53a053
1
public boolean IsExistInHashMap(int yValue) { if (mappedArray.containsKey(yValue)) { LinkedList<Integer> elements = mappedArray.get(yValue); return elements.contains(yValue); } else return false; }
d4c010b7-f78f-4077-8182-3937e2643c0a
4
public TopologicalSort(Digraph<?> G) { this.marked = new ListOrderedMap<>(); for (Object x : G.getAllVertices()) { this.marked.put(x, false); } this.reversePost = new Stack<>(); for (Object x : G.getAllVertices()) { if (!this.marked.get(x)) ...
5eaa9346-7287-48b3-8e05-fcc90ed09512
7
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...
46996604-debf-4345-b0d2-fcf661b05845
7
public double[][] rankedAttributes () throws Exception { int i, j; if (m_attributeList == null || m_attributeMerit == null) { throw new Exception("Search must be performed before a ranked " + "attribute list can be obtained"); } int[] ranked = Utils.sort(m_attribu...
c80bcba2-66f9-48d5-a2ab-e438b3d6ae47
1
public void lisaaUusiOpiskelu(String opiskeltava, int minuuttia){ opiskeltava = opiskeltava.toLowerCase(); // varmistetaan ettei esim. caps lock haittaa if (opiskelut.containsKey(opiskeltava)){ minuuttia += opiskelut.get(opiskeltava); } opiskelut.put(opiskelta...
f2b3eb4b-0751-4e56-a4a4-9726139e7459
9
private String readString() throws JSONException { Kim kim; int from = 0; int thru = 0; int previousFrom = none; int previousThru = 0; if (bit()) { return getAndTick(this.stringkeep, this.bitreader).toString(); } byte[] bytes = new byte[65536];...
0a5f1c71-79e1-4a59-9ceb-3252bf4d1ced
8
public static Position voisin(Position origine,int orientation){ Position position = new Position() ; switch(orientation){ case Orientation.NORD : position.setRangee(origine.getRangee()-1) ; position.setTravee(origine.getTravee()) ; break ; case Orientation.NORDEST : position.setRangee(origine...
0194de82-581a-4bf4-8fe2-079b44ce2e03
4
public static void main(String[] args) { int i, j, csCount; int csSize = MATRIX_SIZE / THREADS; if (MATRIX_SIZE % THREADS == 0) csCount = THREADS; else csCount = THREADS + 1; ReentrantLock[] lock = new ReentrantLock[csCount]; for (i = 0; i < csCount; i++) { lock[i] = new ReentrantLock(); } ma...
96a025f5-d71c-4d47-b84f-0c9973727437
5
public void countdown(Graphics g) { int i = 5 - counter; g.setColor(Color.BLACK); Font f = new Font("Ariel", Font.PLAIN, 200); g.setFont(f); if (i == 4) g.drawString("3", width / 2 + 65, 250); if (i == 3) g.drawString("2", width / 2 + 65, 250); if (i == 2) g.drawString("1", width / 2 + 60, 250); ...
e690b413-f050-4a5c-b65c-0da3c1d96497
4
void printResult(NHL nhl) { double c = 0; int amount = 0; for (int i = 0; i < 4; i++) { double profit = 0; for (int j = i * 1230; j < (i + 1) * 1230 && j < nhl.getAmountMatches(); j++) { double add = nhl.tryGetProfit(nhl.getMatch(j)); ...
166f35b6-6678-499e-a538-a31f14f85af5
6
public static int getInt(String prompt, int low, int high) { final int ALLOWABLE_INPUT_FAILURES = 3; // Avoid leaving a user stuck in here infinitely. If they fail to enter an int after 3 tries, bail out anyway. String response; int inputFailureCount = 0; while (true) { // use an infinite loop. Exit will occur ...
25b90281-3b12-481a-8aeb-7d7bd03fb28a
1
@Override public int rowsX() { return isNotPlayerInventory() ? 2 : 5; }
4c9ab56e-06b6-4f13-b0a8-081b08b8090e
6
@Test public void popFrontTest() { DoubleLinkedList l = new DoubleLinkedList(); DoubleLinkedList l1 = new DoubleLinkedList(); DoubleLinkedList other = new DoubleLinkedList(); try { l.pushFront(1); l.pushBack(2); l.pushBack(3); } catch (Exception e) { fail("Unexpected Exception"); } try { ...
220c9220-af5d-47eb-8a90-bd6e9016315f
1
public JPanel getAllFontsChangesMenu() { if (!isInitialized()) { IllegalStateException e = new IllegalStateException("Call init first!"); throw e; } return this.allFontsPanel; }
1125b8de-f237-4256-bbca-13891b52fb4c
5
private static void knnMethod() { // TODO Auto-generated method stub double distance=0; Neighbour [][] TestingData_KnnBuff_sorted = new Neighbour [TestingData2.length][K]; /* new today mon*/ for(int t=0; t<TestingData2.length; t++){ for(int m=0; m<K; m++) { ...
078981b5-9aa2-4e91-bb2d-76fa6d215e99
8
public void ShowMainMenu() throws NotBoundException, MalformedURLException, RemoteException { boolean menuSelected = false; attemptNumber = 0; if (p == null) { p = (ServerInterface) Naming.lookup("//localhost/PID"); } try { do { Scanner s ...
359f0e43-bd05-46f0-b2ce-1b26ba0bf336
7
public static void main(String[] args) throws IOException { String configuration = System.getProperty("org.lecharpentier.media.config.file"); Properties applicationConfiguration = new Properties(); if (configuration != null && Files.exists(Paths.get(configuration))) { applicationCon...
88f38c4e-9caa-4c2e-b169-cd28b174d05f
9
@Override public void keyPressed(KeyEvent e){ int keyCode = e.getKeyCode(); if (gameState == GameState.STARTED){ if (keyCode == KeyEvent.VK_UP) { model.tryRotate(); view.refresh(); } else if (keyCode == KeyEvent.VK_LEFT) { model.tryMove(-1, 0); view.refres...
876e1b11-554a-43a8-b1a8-14a6ce1832bc
3
public static boolean isWhitespace(String str) { if (str == null) return false; for (int i = 0; i < str.length(); i++) if (!Character.isWhitespace(str.charAt(i))) return false; return true; }
b02d5fda-42a1-44f0-9c48-d6da1e357922
5
private static List<PositionEntity> getMovePositionsLance(final ChessBoardEntity b, final ChessmenEntity c) { List<PositionEntity> result = null; if (c.isPromote()) { result = getMovePositionsGold(b, c); } else { result = new ArrayList<PositionEntity>(); PositionEntity p = null; int y = c.getPosition(...
ab2ab6a4-b7bb-4cda-ba07-8a523fdc0088
6
public static Ss_rPr createFromFont( Font f ) { // not using attributes: charset, family, condense, extend, shadow, scheme, outline==bold Ss_rPr rp = new Ss_rPr(); rp.setAttr( "rFont", f.getFontName() ); rp.setAttr( "sz", new Double( f.getFontHeightInPoints() ).toString() ); // boolean attributes if( f.g...
1d449cf3-4a32-4014-86b9-7e48f4ce1564
7
private void scanComponent(Component comp, DockEvent event, boolean drop, Point p, Rectangle compBounds) { int distTop = p.y - compBounds.y; int distLeft = p.x - compBounds.x; int min = Math.min(distTop, distLeft); int distRight = compBounds.x + compBounds.width - p.x; int distBottom = compBounds.y + compBoun...
22ca5717-07cf-44dc-bffb-1f3dae2deaca
4
* @param shift the number of rows by which to shift */ private void shiftRow( Row row, int shift ) { Iterator<BiffRec> cells = row.getCells().iterator(); Mulblank skipMulBlank = null; while( cells.hasNext() ) { BiffRec cell = cells.next(); if( cell == skipMulBlank ) { continue; } if( cel...
9edfcbe3-7e7c-4d42-82af-1fefdb51810c
7
protected MOB getTarget(MOB mob, String name) { if(name.equalsIgnoreCase("self")) return mob; final Room R=mob.location(); if(R==null) return null; MOB M=R.fetchInhabitant(name); if(M==null) { final PhysicalAgent I=R.fetchFromMOBRoomFavorsItems(mob, null, name, Wearable.FILTER_ANY); if(I instan...
2360746d-cc4d-4176-b4ae-a740651285ff
2
public double getOdds(Hand hand) { if (hand.getSize() == 2 && getHandValue(hand) == TWENTY_ONE) { return BJ_ODDS; } return ODDS; }
9bb881e5-92f3-4933-a959-7fd135c7db60
3
static TreeSet<Long> findPrimeFactors(long value) { TreeSet<Long> factors = new TreeSet<>(); for(long i = 2; i <= value; i++) { if(isPrime(i)) { if(evenlyDivisible(value, i)) { factors.add(i); value = value / i; factors.addAll(findPrimeFactors(value)); } } } return factors; }