method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
a75fb7cb-c6b5-4966-8f2c-536693e839d8
6
public boolean containsEntry(Entry entry) { if (entry instanceof EnvelopeEntry) { return entries.contains(entry); } else if (entry instanceof PrimitiveEntry) { for (Iterator it = entries.iterator(); it.hasNext(); ) { Entry e = (Entry) it.next(); if (e.equals(entry))...
b75e30dd-3534-446f-807e-528d48a8bb2e
7
public GameEntity getEntityAt(int x, int y) { GameEntity entity = null; if (x >= 0 && x < width && y >= 0 && y < height) { MapSquare square = mapSquares[x][y]; if (square.isOccupied()) { entity = square.getActor(); } else if (square.isPortal()) { ...
79f114c3-178f-4640-9262-d789d7135ac2
3
byte crc8( byte[] dat, int begin, int len ) { int crc = 0; int idx=0; while( len-- != 0 ) { int inbyte = dat[begin+idx]; idx++; for(int i=8; i!=0; i--) { int mix = (( crc ^ inbyte) & 0x01); crc >>=1; if( mix != 0 ) { crc ^=0x8C; } inbyte >>=1;...
033ecda7-7624-473c-8a01-5ff1d82bb91b
7
public final void gen_if() throws RecognitionException { try { // Python.g:436:7: ( 'if' test ( gen_iter )? ) // Python.g:436:9: 'if' test ( gen_iter )? { match(input,85,FOLLOW_85_in_gen_if3879); if (state.failed) return; pushFollow(FOLLOW_test_in_gen_if3881); test(); state._fsp--; if (state.f...
8faefde5-0977-4541-8b54-4a5a977454c0
0
public int getRightScore() { return rightScore; }
db940d66-55ec-4e82-95ea-4c66cc035a9f
6
private static ClassLoader getContextClassLoader() { ClassLoader classLoader = null; if (classLoader == null) { try { // Are we running on a JDK 1.2 or later system? Method method = Thread.class.getMethod("getContextClassLoader", (...
e5d486e1-2ca6-4622-a50c-ee0f35b1b5a6
5
public void setBoard()// Fills theBoard with starting coords. { ats = true; dollas = true; timeSinceJump = 0; // getPlayers(); for (int r = 0; r < FILE; r++) { for (int f = 0; f < RANK; f++) { if ((f + r) % 2 == 1)// checking t...
f35111c4-fb75-4db5-a73c-45af0d6bb3d2
1
public void conectarA_B(Rama_Hoja A,String AHC, Rama_Hoja B,String BHC){ if(_nElementos == 0){ this.conectarPrimerElemento(A); } else{ A.conectar(AHC, B); B.conectar(BHC, A); } }
f64731c0-b2c9-4bf8-9a62-378384332127
1
public double getFullLength() { double length = 0; for (Edge edge : edges) length += edge.getLength(); return length; }
953f764d-0f81-4c47-a08c-59260a1f08b2
8
public static void main( String [ ] args ) { DeterministicSkipList<Integer> t = new DeterministicSkipList<Integer>( 100000000 ); final int NUMS = 400000; final int GAP = 37; System.out.println( "Checking... (no more output means success)" ); for( int i = GAP; i != 0; i = ( i + GAP ) % NUMS )...
6a8d7c73-dfb7-498c-b0d6-adb024a6bf6e
7
public boolean hasNext() { if (left.hasNext()) return true; else if (right.hasNext()) return true; else if (last_choice == null) return false; else if (last_choice == left && !rightEOF) return ((Comparable)left.current()).compareTo(right.current()) < 0; else if (last_choice == right && !leftEOF)...
38009e26-72f3-476b-b9a6-a061900f45e6
7
public double[][] getP() { double[][] P = new double[dimension][dimension]; for (int d1 = 0; d1 < dimension; d1++) { for (int d2 = 0; d2 < dimension; d2++) { P[d1][d2] = new Double(pIn[d1][d2].getText()).doubleValue(); } } // Check that the transit...
a0d12ef8-49e2-4b72-86a1-918457211ddd
5
public static void main(String[] args){ ConsoleHandler handler = new ConsoleHandler(); handler.setLevel(Level.FINEST); handler.setFormatter(new ConsoleHandlerFormator()); log.setUseParentHandlers(false); log.addHandler(handler); log.setLevel(Level.FINEST); log.add...
8bc00c6d-7475-4d59-b8f2-c10b49c83730
5
private void quickSortPolynomial(int start, int end){ int red = start - 1; int white = end + 1; int blue = end + 1; Term pivot = polynomial.get((start+end)/2); if(start < end){ while(red < white - 1){ Term t = polynomial.get(white - 1); ...
7fb9ed99-dbfa-43a8-a3e4-cec2e6c32a37
5
private void outgoingVehicleMonitor(Vehicle v) { if (v instanceof MotorCycle) numMotorCycles--; else if (v instanceof Car && ((Car) v).isSmall() == true) { numSmallCars--; numCars--; } else if (v instanceof Car && ((Car) v).isSmall() == false) { numCars--; } }
5554205f-3911-4bb1-9193-d415ee1a7d76
2
public void testGet_DateTimeFieldType() { LocalDate test = new LocalDate(); assertEquals(1970, test.get(DateTimeFieldType.year())); assertEquals(6, test.get(DateTimeFieldType.monthOfYear())); assertEquals(9, test.get(DateTimeFieldType.dayOfMonth())); assertEquals(2, test.get(Date...
0001dacd-429d-47ea-9b0d-20c7c8abb17b
2
private void display() { num = getArray(); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { System.out.print(num[i][j] + " "); } System.out.println(); } }
8cdf9868-1d8d-4d56-a803-85d88ac87e9a
1
public void deleteHostFromMatch(String hostName){ try { cs = con.prepareCall("{call DELETE_HOST_FROM_MATCH(?)}"); cs.setString(1, hostName); cs.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } }
0f32f56c-f582-451d-89cd-9a48f7766e0c
5
static Poker[][] sort(Poker[] pokers){ int len = pokers.length; Poker[][] ps = new Poker[4][len]; int[] counters = new int[4]; for (int i = 0; i < len; i++){ for (int j = 0; j < 4; j++){ if (pokers[i] != null && pokers[i].getColor().equalsIgnoreCase(colors[j])...
d2311f1b-fac3-46a0-8a31-9c7e3bdec433
7
public void parse(PsdInputStream stream) throws IOException { // read layer header info int length = stream.readInt(); int pos = stream.getPos(); if (length > 0) { int size = stream.readInt(); if ((size & 0x01) != 0) { size++; } ...
3d7a939f-7f3e-4442-8406-cbbdee2ad849
4
public Object invokeConstructor() { Class[] types = c.getParameterTypes(); Object[] values = new Object[types.length]; for (int i = 0; i < types.length; i++) { values[i] = makeDefaultValue(types[i]); } if (types.length > 0...
3682d962-bae8-4648-9fbf-8a0bc7e09bd8
3
private String result(int i) { switch(sim40.memory[i]){ case 1: /* print */ return (""+sim40.memory[Simulator.ACCUMULATOR_ADDRESS]); case 2: /* printch */ return (""+(char)sim40.memory[Simulator.ACCUMULATOR_ADDRESS]); case 3: /* printb */ return (Integer.toBinaryString(sim40.memory[Simulator.ACCUMUL...
8984e36a-834c-41f6-ab2c-2296ce29f50b
8
public void printConditionStats() { for(int i = 0; i < conditionCount.length; i++) { for(int j = 0; j < conditionCount[i].length; j++) { if(i == 3 && j == 2) { break; } switch...
8674920f-2974-4296-b58c-a9097e79af3a
1
public void testMultipliedBy_int() { Hours test = Hours.hours(2); assertEquals(6, test.multipliedBy(3).getHours()); assertEquals(2, test.getHours()); assertEquals(-6, test.multipliedBy(-3).getHours()); assertSame(test, test.multipliedBy(1)); Hours halfMax = Hours...
d70c15a5-182d-40af-bc0a-26b52679f742
1
private boolean jj_2_52(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_52(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(51, xla); } }
e5b7e32e-d3ed-414d-9ac6-1fa959b7e437
5
public String fechaHoraActualNumerosLineal() { Date actual = new Date(); String dia = actual.getDate() < 10 ? "0" + actual.getDate() : String.valueOf(actual.getDate()); String mes = (actual.getMonth() + 1) < 10 ? "0" + (actual.getMonth() + 1) : String.valueOf(actual.getMonth() + 1); Stri...
f31751b2-603a-4521-8df2-b5366ed8ba31
1
public T next() { if (next == null) { throw new NoSuchElementException(); } T obj = next; advance(); return obj; }
ca3bb9b4-c5af-4a5d-9336-68cacb37306c
6
@Override public boolean isClicked() { if (!enabled) return false; Mouse mouse = Game.mouse; if (dir == RIGHT || dir == LEFT) { if (mouse.getX() > x && mouse.getX() < x + WIDTH) { hover = true; if (mouse.isLeftClicked()) return true; } else hover = false; } return false; }
d514a320-5c58-4f34-be4e-4c6947b30539
6
public void method210() { for(int i = 0; i < anInt292; i++) { for(int j = 0; j < anInt293; j++) if(i == 0 || j == 0 || i == anInt292 - 1 || j == anInt293 - 1) anIntArrayArray294[i][j] = 0xffffff; else anIntArrayArray294[i][j] = 0x1000000; } }
67a69d5d-ed9f-447b-ac17-5738815b5b54
0
public void event() { }
1fe2a7cc-ffde-4217-a657-497125b9ad2f
6
@Override public T addChildToParent(T parent, T child) { if (child == null) { throw new IllegalArgumentException("Child shouldn't be null"); } if (node.getData() != null && parent == null) { throw new IllegalArgumentException("Root already exists"); } ...
7ac024f5-49e7-4ce4-be8c-4c5ac617bf75
0
public void reload() { vampires = UVLoad.load(getDataFolder() + File.separator + "vampires.bin"); reloadConfig(); }
d1cfeb38-12f9-401d-9893-ea358017d26b
1
public void testUnmatchedClosedParenthesis() throws Exception { String openParenString = "3 + 5)"; try { new Expression(openParenString); fail("Did not throw exception"); } catch (MalformedParenthesisException mpe) {} }
02eff50f-960b-4a0f-bbe0-8fcc51bbef62
3
private <N> void doExpansion (List<N> leafNodes, int id, NodeGetter<N> plex) { List<NodeGetter<N>> toExpand = new ArrayList<NodeGetter<N>> (); toExpand.add (plex); while (!toExpand.isEmpty ()) { NodeGetter<N> ng = toExpand.remove (0); while (ng.hasMoreNodes ()) { leafNodes.add (ng.getNextNode (bra...
b8452731-8c35-417c-8526-17b0270c4839
9
private void announceWinners(Environmental host) { final DVector scores=determineAllSortedScores(false); if(scores.size()>0) { final MOB winner=(MOB)scores.elementAt(scores.size()-1,1); communicate(host,null,"The winner is "+winner.name()+", who has "+describeHand(((Integer)scores.elementAt(scores.size()-1...
75a1b0c7-1861-4679-b1d9-632c17e723d3
7
public static String getURI(DTRequest domainToolsRequest){ String uri; if(domainToolsRequest.getProduct().isEmpty()) uri = domainToolsRequest.getDomain(); else{ if(domainToolsRequest.getProduct().equals("whois") || domainToolsRequest.getProduct().equals("whois/live") || domainToolsRequest.getProduct().equals("...
e79b51d6-52b9-4ad0-b0f8-d23feb3e2ab9
9
private void parseMeshRenderer(String line) { int intIndex; intIndex = line.indexOf("mPath=\""); String tpath = "", mpath = ""; if (intIndex == -1) System.out.println("MeshRenderers require a model path!"); else { int t = intIndex + 7; ...
356461a7-8168-4cbe-aa65-180070352e64
0
public Result(String name, double score, int index) { this.Name = name; this.Score = score; this.Index = index; }
8d09cbe6-5e03-4226-81d2-ea0be929e7c5
4
protected final void onButtonClick(Button var1) { if(var1.active) { if(var1.id == 0 && this.name.trim().length() > 1) { Minecraft var10000 = this.minecraft; int var10001 = this.id; String var2 = this.name.trim(); int var3 = var10001; Minecraft v...
a47e565e-90a5-4130-aed3-4938f31df5be
0
public SaveGraphGIFAction(Environment environment, JMenu menu) { super("Save Graph as GIF", null); this.environment = environment; this.myMenu = menu; }
6787ed0b-12e8-48da-a7c9-e63427d3f677
1
public String doValidate(Object value) { if (!PresenceCheck.isPresent(value)) return null; return msg; }
b9629429-d68d-40e3-b123-bccd6e85c13f
3
public String substVars(String inString) { StringBuffer sb = new StringBuffer(); // System.out.printf("VariableMap.substVars(%s)%n", inString); Matcher m = varsPatt.matcher(inString); while (m.find()) { String varName = m.group(1); String replText = get(varName); // System.err.printf("VariableMap.su...
93488343-06bd-406e-b887-bc1a7a01d97e
2
public void addShadow() { for (int r=0; r<rows; ++r) { for (int c=0; c<cols; ++c) { grid.getImageStack(r, c).setLayer(5, new gui.WidgetImage("image/markers/shadow.png")); } } }
0984e23e-8d4d-4893-b740-fd9239bcd6d8
4
@Override public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals("editDataFileName")) { FileNameExtensionFilter filter = new FileNameExtensionFilter( "JPG & GIF Images", "jpg", "gif"); fc.setFileFilter(filter); int returnVal = fc.showOpenDialog(this); ...
94b22fcf-cc5e-423e-ab6d-a1b70c5792fd
0
public void setCalle(String calle) { Calle = calle; }
d0ff2668-d9c4-453f-9006-499388fb9065
5
private void bfsTravel(TreeNode root, int level, List<List<Integer>> result){ Queue<TreeNode> maintain = new LinkedList<TreeNode>(); Queue<TreeNode> visited = new LinkedList<TreeNode>(); List<Integer> list = null; TreeNode tmp = null; maintain.offer(root); while(!maintai...
ea91591e-090a-4b1c-bfc7-1ee39cf9e3ee
5
public void extract_naive2() throws IOException { build_dicos(); Tuple<Sentence_tree,String> st = build_next_sentence_tree(); Hashtable<String, LinkedList<Triple<String,String,String>>> relations = new Hashtable<String,LinkedList<Triple<String,String,String>>>(); while(st != null){ for(int index = 0; ind...
b9635e8a-e2aa-4fe6-aea1-173e48ca3c85
6
private void evaluateDependencies() { boolean enabledMode = false; if (activeRegion != null) { if (activeRegion.isBoxValid()) { if ((activeRegion.startX % 2 == 0) && (activeRegion.startY % 2 == 0) && (activeRegion.endX % 2 == 0) && (activeRegion.endY % 2 == 0)) { enabledMode = true; } } } oam...
ec547b85-7856-42eb-adad-443df1bd78e7
1
static public void deleteMarker() { if(markers>0){ markersArray[markers]=null; markers--; Marker.decTrigger(); } }
d62bcf90-d631-45bc-8d71-6344c07f54ab
5
public void addCard(Card c) { this.cards[this.cardindex] = c; this.cardindex++; if (c.values().length == 2) { this.aces++; for (int i = 0; i < this.totalvalues.length; i++) { this.totalvalues[i] = this.totalvalues[i] + c.values()[i]; } } else { for (int i = 0; i < this.totalvalues.length; i++) {...
9f6910cd-602d-4e3d-badc-e7f4b69184e5
0
public VariableDependencyGraph() { super(); }
d2f99ef5-71ba-4351-a12e-d2c8fa0c5c1f
3
@Override public boolean queueBuffer( byte[] buffer ) { // Stream buffers can only be queued for streaming sources: if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING, "Buffers may only be queued for streaming sources." ) ) return false; ...
3d51f90a-c507-42fc-b1e7-b14dcd389f95
8
private void handlePackage(ByteBuffer data) { PackageReader pr = new PackageReader(data); MainCommands mc = MainCommands.values()[pr.readInt()]; switch (mc) { case CLOSE: { ServerClient sc = ServerClient.values()[pr.readInt()]; if (sc == ServerClient....
ce5a3cfa-cb3c-4fc4-8d0c-335dc4119979
1
private JButton getJButton1() { if (jButton1 == null) { jButton1 = new JButton(); jButton1.setText("BACK"); jButton1.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { jButton1MouseMouseClicked(event); } }); } return jButton1; }
888233db-6757-4af4-b9a2-bf9ce353cf60
6
public byte[] getConfigStructure() { byte[] cfg = new byte[CFG_SIZE + ACC_CODE_SIZE]; if(fixed != null) System.arraycopy(fixed, 0, cfg, CFG_FIXED_OFFS, fixed.length); if(uid != null) System.arraycopy(uid, 0, cfg, CFG_UID_OFFS, uid.length); if(key != null) System.arraycopy(key, 0, cfg, CFG_KEY_OFFS, key.lengt...
2bf6fdac-644b-4770-9b85-665cbb9b3460
9
public XMLConfiguration upload(QcRequest request, String fileName) throws QcException, Exception { log.debug("Requested Url :" + request.getURL()); XMLConfiguration xmlResponse = null; //Open HTTP connection to the url HttpUR...
1caa74e0-eba0-4ce9-a80a-efadf8847d63
4
public String mapDesc(String desc) { Type t = Type.getType(desc); switch (t.getSort()) { case Type.ARRAY: String s = mapDesc(t.getElementType().getDescriptor()); for (int i = 0; i < t.getDimensions(); ++i) { s = '[' + s; } return s; case Type.OBJECT: String newType = map(t.getInternalName());...
e74902fc-8f92-4a46-83d3-431e918f594b
9
public static void main(String[] args) { String filename = args[0]; String separator = args[1]; In in = new In(filename); ST<String, Queue<String>> st = new ST<String, Queue<String>>(); ST<String, Queue<String>> ts = new ST<String, Queue<String>>(); while (in.hasNextLi...
7aedf91e-3766-4bff-9c6d-94a78fe5719f
7
protected String generateJavadoc(int index) throws Exception { String result; OptionHandler handler; String optionStr; result = ""; if (index == 0) { if (!canInstantiateClass()) return result; if (!ClassDiscovery.hasInterface(OptionHandler.class, getInstance().getClass...
b7019278-8be4-42b8-9739-819fa6a2283e
2
public HashMap<String,String> getUsers(){ HashMap<String,String> users = new HashMap<String,String>(); Statement st; ResultSet rs; String query; query = "SELECT * FROM people"; try{ st = conn.createStatement(); rs = st.executeQuery(query); while (rs.next()){ users.put(rs.getString(1),rs.getStri...
4e1d7735-d89e-4830-a898-d635225bdd38
9
public double getDataTypePercentageSingleKey(String key, int dataType){ double res = 0; String[] attributes = key.split(","); String selectClause = "SELECT "; String caseClause = "CASE "; String when1 = ""; String when2 = ""; String when3 = ""; String fr...
11300d24-d64c-4e64-a1d8-c46af9541b6f
8
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Endereco other = (Endereco) obj; if (this.codigo != other.codigo) { return false; } ...
8b880f0e-4aef-4b66-831c-2c8fdd45b3e2
9
static 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...
03bc4b23-437f-4c03-a2a9-f426ec228da0
9
public boolean addTagByCommunity(String name, String appId, String userId, String communityId) { //Tag validation and parameters checking if(!validateTag(name)) return false; if(appId == null || appId.equals("")) return false; if(userId == null || userId.equals("")) return false; if(communityId =...
5f02e67d-fd23-4c27-9745-2b1b41be6fc1
1
public void addAllGlieder(List<SchlangenGlied> glieder) { glieder.add(this); if (nextGlied != null) { nextGlied.addAllGlieder(glieder); } }
0c67ff83-1661-4d6c-bd90-fa63ac082aa4
0
@Test public void testFindString_function() throws Exception { Assert.assertEquals( "html", _xpath.findString("local-name(/*[1])") ); }
db4bc3f9-1633-4e98-aa3d-ddd0157a540f
2
public TWMSentence( String sentence ) throws Exception { super(sentence); temperature = Double.parseDouble( getWord( 0 ) ); //convert C to kelvin if( this.getWord( 1 ).indexOf('C') != -1 ) temperature += 273.15; //convert F to kelvin if( this.getWord( 1 ).indexOf('F') != -1 ) temperature = ( t...
26d341a4-8012-4ce7-949a-a0c0ad481e8c
4
public JPanel getMenu(Menu menu) { switch (menu) { case MAINMENU: return mainMenu; case MULTIMENU: return multiMenu; case OPTIONMENU: return optionMenu; case HOSTMENU: return hostMenu; default: return null; } }
167a0709-bb72-479c-823e-802499264dc5
3
public void searchCidade() { facesContext = FacesContext.getCurrentInstance(); requestContext = RequestContext.getCurrentInstance(); List<Cidade> listCidade; try { listCidade = genericDAO.searchObject(Cidade.class,"cidade", null, null, new String[]{"ci...
f60dbb63-52fb-4d8c-ae0c-811e1eb69b1a
6
public String getParameterString(){ String retString = ""; try{ if(url!=null) retString+="&url="+URLEncoder.encode(url,"UTF-8"); if(html!=null) retString+="&html="+URLEncoder.encode(html,"UTF-8"); if(text!=null) retString+="&text="+URLEncoder.encode(text,"UTF-8"); if(customParameters!=null) retString+=c...
ce631bdc-c2a9-4946-8ec8-dd6dd83752f6
1
public void resurectHero(Hero hero) { if (deadHeroes.remove(hero)) { heroes.add(hero); } }
ce38b8f2-73b2-4f77-b36a-924ed23e2980
4
private static int divide(int beingDiv, int divNum, List<Integer> prevStates){ if (beingDiv % divNum == 0) return 0; //non-recurring int nextState = (beingDiv%divNum) * 10; int length = 0; for(int i=0;i<prevStates.size();i++){ if (nextState == prevStates.get(i)){ length = prevStates.size()-i; break; ...
4e2ec4a0-d51a-4005-a9b5-9d7a44ec3cc4
7
public GuiSlotStatsBlock(GuiStats par1GuiStats) { super(par1GuiStats); this.field_27274_a = par1GuiStats; this.field_27273_c = new ArrayList(); Iterator var2 = StatList.objectMineStats.iterator(); while (var2.hasNext()) { StatCrafting var3 = (StatCrafting...
3d44e891-1f9a-467d-8571-51384fd18686
5
@Override public void actionPerformed(ActionEvent e) { switch(e.getActionCommand()){ case "search": LibrarianActionsControl.searchForItems(this, new String[]{textField.getText(), (String) comboBox.getSelectedItem()}); break; case "edit": CardLayout layout = (CardLayout) this.getParent().getLayout()...
e9db9c22-dbd3-450b-bef5-e2a74e3da4f6
2
private int getNextNode( int i ) { while (++i < nodes.getLength()) { if (nodes.item( i ).getNodeType() == type) { return i; } } return -1; }
3d35d4f7-9943-4355-9f89-885cc2f5c628
4
@Override public Double getScalarValue(Word word) { for (Word word1:wordList) { if (word1.getKeyWord().equals(word.getKeyWord())){ if(word1.getSpamLabel().equals(word.getSubkey())){ return word1.getSpamCount(); }else if(word1.getGenuineLabel()...
0a28de79-1fb2-45f9-8651-1a835304cd23
6
public static int findParameterClose(String methodCommand) { // System.out.println("methodCommand = " + methodCommand); int bracketLevel = 1; boolean isQuoteEnclosed = false; int index = methodCommand.length() - 2; while (bracketLevel != 0) { char currentChar = meth...
6b626416-369f-4e79-aa2d-2c19f4c7f2aa
2
private void checkHardness() { if (count == 15) hardness = Level.MEDIUM; else if(count == 30) hardness = Level.HARD; }
52b210e0-49ba-4f72-be9b-939274671fce
7
public ArrayList<Photo> getPhotosByTag(ArrayList<String> tags){ ArrayList<Photo> photos = new ArrayList<Photo>(); String splitted[]; for(int i=0; i<tags.size(); i++){ splitted = tags.get(i).split(":"); if(splitted.length==2){ //Complete Tag Information String tagType = splitted[0].toUpperCase(...
5c04baa4-0d58-4263-886f-6fd0456a8df5
2
private void render(Graphics g) { g.clearRect(0, 0, getWidth(), getHeight()); if (g instanceof Graphics2D) { Graphics2D g2d = (Graphics2D) g; try { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } catch (Exception e) { System.err.println("A...
d282f1e3-b5cc-4567-bd99-14fbead651e5
4
public void partition(char[] str) { int gt = -1; char pivot = str[0]; // System.out.println(s[1]); for (int i = 1; i < str.length; i++) { if (str[i] > pivot) { gt = gt > 0 ? gt : i; } else { if (gt >= 0) { char t = str[i]; str[i] = str[gt]; str[gt] = t; gt++; } } } }
60f8c612-6832-450f-8546-6aef5fa7df35
4
public boolean waitForPress(int timeout) { if (timeout == 0) timeout = 0; int curr = 0; while (!okClicked) { if (curr > timeout) return false; curr += 25; try { Thread.sleep(25); } catch (InterruptedException e) { e.printStackTrace(); } } return true; }
7e82efba-ab39-419e-bc52-d4379122e2fe
0
private ConnectionPool() { }
dd94aa16-5df8-4898-85be-2afb1852e6c6
2
private static ArrayList<int[]> findEdges(int[] naboliste, int start) { ArrayList<int[]> edgeList = new ArrayList<int[]>(); for (int i = 0; i < naboliste.length; i++) { int weight = naboliste[i]; if (weight != INF) { edgeList.add(new int[]{i, weight}); } } return edgeList; }
00359f4e-9fb2-4a5f-b183-55a7aa119151
5
public static <T extends Comparable<? super T>> void sort(T[] array) { int min; T temp; //We can skip the last element here because it'll be the biggest one. for (int j = 0; j < array.length - 1; j++) { min = j; for (int i = j + 1; i < array.length; i++) { ...
73fbbfc9-1e21-4c2b-bd6a-410fd9cad707
5
private boolean gatherFreePointers(){ String keys; try{ keys = fileToString(freeSpace); } catch (RuntimeException e){ System.out.println("Can't read free space storage, perhaps it's empty"); return false; } String pos = ""; Str...
ca3e2dc2-d144-498f-b0f7-81531d1e461e
6
private static boolean parseCommandArguementsIsSuccesful(String[] args) { switch (args.length) { case 0: System.err.println(usageMessage); return false; case 1: case 2: if (!checkThatArguementsAreValid(args)) { System.err.println("ERROR - All Arguements must be integers"); return false; ...
b65f17f8-8c50-4e7a-b4ee-f0d96f5a63ce
7
public Set getResourcePaths(String path) { if (documentRoot == null) { return null; } // Enforce the leading slash restriction if (!path.startsWith("/")) { throw new IllegalArgumentException("The specified path ('" + path + "') does not start...
d28899bd-bf24-4279-ae6b-9db5fc405e4a
1
public static void main(String[] args){ String address = args[0]; int port = Integer.parseInt(args[1]); try{ new AudioClient(new Socket(address, port)); } catch (Exception e) {} }
c0954cb8-8e15-431d-afb2-0fd10432a2fa
4
private void complain(Exception e) { if (e != null) e.printStackTrace(); String message = (e != null && e.getMessage() != null && !e.getMessage().equals("null")) ? e.getMessage() : "unable to save; you probably entered an invalid file name."; JOptionPane.showMessageDialog( dialog, "Error: "+ m...
0fbe3bc2-0ef4-48de-8d3f-127a31eff3e8
2
public void run() { try { calc.run(); while(Glory.getInstance().shouldThreadBeRunning()) ; } catch(Exception e) { } calc.setVisible(false); }
52adb218-df51-4122-a51d-54e65904bed3
9
@FXML public void buttonsHandler(ActionEvent event) { Button clicked = (Button) event.getSource(); String windowName; switch (clicked.getId()) { case "btnNewIncome": windowName = "newTransaction.fxml"; break; case "btnShowIncome": windowName = "incomingReport.fxml"; break; case "btnNewExpense":...
7b422217-00e6-4b18-bc31-c363eee80f2a
6
static public Spell getDarkSpell(int i) { switch (i) { default: case 0: return new Darkness(); case 1: return new DarkSoulBall(); case 2: return new DarkAura(); case 3: return ...
0284b15d-a682-45de-b534-31e98c725f58
2
public static String getChemin(String nom) { String str = null; Connection connexion; java.sql.Statement requete; ResultSet resultat = null; try { Class.forName("org.sqlite.JDBC"); connexion = DriverManager.getConnection("jdbc:sqlite:dbged"); requete = connexion.createStatement(); resultat = reque...
c6557afa-ca79-404b-967f-6c5e0f72695e
5
public void updateLocation( int id, List<Object> list ){ if( !handler_location.initialize() ){ System.out.println( "LocationServer : failed to initialize location handler!" ); return; } int result = 0, min_rssi = 1000; for( int i = 0; i < list.size(); i += 2 ){ String mac = (String)list.get(i); Loca...
7c219bbc-01e0-4d73-8f8f-07d0279b5d34
3
@Override protected void draw(Graphics2D g) { this.initCLassifier(); // set matching rendering margin // this actually overrides any custom margin this.setBottomMargin(this.m_PointRenderer.getBottomMargin()); this.setLeftMargin(this.m_PointRenderer.getLeftMargin()); this.setRightMargin(this.m_PointRende...
b9b4648b-9913-4074-8d36-14ec7687b5bc
5
private boolean readExponent() throws IOException { if (!readChar('e') && !readChar('E')) { return false; } if (!readChar('+')) { readChar('-'); } if (!readDigit()) { throw expected("digit"); } while (readDigit()) { } return true; }
ab24b59c-2af3-4bf1-9e38-ea91e8a5661c
0
protected int getFoodLevel() { return foodLevel; }
4950cd05-26a6-4510-a32c-a804d7c430b5
9
private String buildFullMessage(String msg, Object arg0, Object arg1, Object arg2, Object[] argArray) { StringBuilder sb = null; int lastIndex = 0; int argC = 0; while (true) { int argIndex = msg.indexOf(ARG_STRING, lastIndex); // no more {} arguments? if (argIndex == -1) { break; } if (sb ==...
96312742-d62f-4804-91e8-9e5febd0b3a0
8
private int getColumn() { Scanner inFile = new Scanner(System.in); String column = null; boolean valid = false; while (!valid) { column = inFile.nextLine(); //gets input if ("1".equals(column) || "2".equals(column) || "3".equals(column) ...