method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
eb5cf582-35a5-4b01-9f19-43393e9f3e60
2
@Override public void finalize( Connection connection, DefaultBox<?> source, DefaultBox<?> target ) { AbstractConnection con = (AbstractConnection) connection; con.setSourceItem( source ); con.setTargetItem( target ); }
d3477c4a-455c-49ff-a2c5-c921e368e33a
4
public String getProperty(String property){ try { r = new BufferedReader(new FileReader(config)); } catch (IOException e) { } String temp; try { while((temp = r.readLine()) != null){ if(temp.startsWith(property)){ return temp.replace(property + ": ", ""); } } } catch (IOException e) { ...
883f3ff9-afdf-4cfe-acc8-b79874ddc248
4
public String toString() { String temp = ""; for (int y = rows-1; y > -1; y--) { for (int x = 0; x < cols; x++) { if (board[x][y].getState() == EMPTY) { temp = temp + "-"; } else if (board[x][y].getState() == PLAYER_ONE) { temp = temp + "O"; } else { temp = temp + "X"; ...
a8ae5762-9bbe-4240-94e3-76180a37b11e
8
public int calculateSelectedAttribute(TreeNode node) { int selectedAttribute = -1; double minRelativeEntropy = 999999; for(int i : node.unProcessedAttributes) { int total = node.Y.size(); int count[][] = new int[attributePossibleValues[i]][classValues]; for(int j = 0; j < total; j++) { count[node.X.g...
4f9b9cc4-d342-495f-b6ec-ed8eca11f8d9
2
public void Set_edgeweight() { int ni = t_partialedgeweight.length; int nj = t_partialedgeweight[0].length; for (int i = 0; i < ni; i++) { for (int j = 0; j < nj; j++) { Float temp = t_edgemultiplier.get(i); t_edgeweight[i][j] = t_partialedgeweight[i][j] * temp; } } }
7dcf3bb1-a5ae-460f-868d-23445db08ba6
7
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { CalendarUtility cu = new CalendarUtility(); // Params int weekNum; try { weekNum = Integer.parseInt(request.getParameter("week")); } catch (Exception e) { weekNum = cu.getCurrentWee...
4ed52ccd-c250-4715-a280-1760b443e646
4
public static boolean isHavePositionCloseToCenter(Polygon polygon, Integer distance) { if (distance == null) return false; for (Position position : polygon.getPositions()) { Position centerPosition = MathService.positionOfCenter(polygon); // if (position.getDistanceTo...
a2dadd59-60f3-4680-b203-4fce251b0b69
4
public void actionPerformed(ActionEvent e) { if (e.getSource() == cancelButton) { do_cancelButton_actionPerformed(e); } if (e.getSource() == btnVerificaComunicacao) { try { try { do_button_actionPerformed(e); } catch (InterruptedException e1) { e1.printStackTrace(); } } catch (IOExc...
5059f61e-722a-445b-a13d-be2ba50eb3fe
5
public void edit(Usuario usuario) throws NonexistentEntityException, Exception { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); usuario = em.merge(usuario); em.getTransaction().commit(); } catch (Exception ex) ...
0bad1797-bb65-4dea-a6ad-4d57aa7a94e6
0
public void setP(Product p) { this.p = p; this.prezzo = p.getPrice(); }
939d0f0a-f014-4bfc-bdb6-aee92038f6a0
1
public Tessellator( int fraction, float smooth, Color color, long seed ) { this.fraction = fraction; if ( fraction % 2 != 0 ) this.fraction--; this.color = color; this.smooth = smooth; this.noise = NoiseHelper.generatePerlinNoise( fraction + 1, fraction + 1, 5, seed ); Mesh model = calculateTesselator()...
bf3de1ca-2612-4741-aa86-3458f8025bc1
4
public static ArrayList<String> getDoors(int roomId) { ArrayList<String> doors = new ArrayList<String>(); if(getNextRoomId("north", roomId) != 0) { doors.add("North"); } if(getNextRoomId("east", roomId) != 0) { doors.add("East"); } if(getNextRoomId("south", roomId) != 0) { doors.add("South"); } if...
a86ade2d-2b8d-4fee-b31c-b7fafa65b41a
2
public boolean deleteNode(Node node) { if (this.next == null) { return false; } else if (this.next.data.equals(node.data)) { this.next = next.next; next.previous = this; return true; } else { return this.next.deleteNode(node); } }
5b234f4a-842d-4561-b1af-44de2cba345f
7
private Column getLengthColumn( Token token ) { LengthColumn column = new LengthColumn(); if ( token.equals( FieldType.LONG ) ) { column.setType( FieldType.LONG ); } else if ( token.equals( FieldType.INTEGER ) ) { column.setType( FieldType.INTEGER ); } ...
5be247d6-2ecd-419a-9385-63f55b60b565
5
private void loadFromFile() { URI uri; try { uri = ResourceLoader.loadData(ResourceLoader.MASTER_FILENAME) .toURI(); File masterFile = new File(uri); BufferedReader bfr = new BufferedReader(new FileReader(masterFile)); String line = ""; int y = 0; while ((line = bfr.readLine()) != null) { ...
c8b30539-571b-4ac1-b9a7-d344ebd85400
7
public void parseInput(String fileName) { InputStream is = null; BufferedReader br = null; try { is = Thread.currentThread().getContextClassLoader().getResourceAsStream("input.txt"); br = new BufferedReader(new InputStreamReader(is)); String line...
55181450-546d-41c6-bbc6-c0d95cb4b6e6
0
public InputStream getData() { return data; }
b1ae9595-3392-4fa0-a4c6-c43e52598c37
6
@Override public void keyTyped(KeyEvent ke) { char c = ke.getKeyChar(); if (c == '\n' || c == '\r') { lastKey = "enter"; } else if (c == '\t') { lastKey = "tab"; } else if (c == '\b') { lastKey = "backspace"; } else if (c == ' ') { ...
a89b3126-df52-441f-a088-7aec0083ef3c
1
public String getcalibParam() { if (calibParam == null) { throw new RuntimeException("missing calibParam name."); } return calibParam; }
1ec38d40-aff8-46e7-be41-451add92ba08
0
public boolean isMember(InfoRequest infoRequest) throws MailChimpException { String post = post("/lists/member-info", infoRequest, new Function<InfoRequest, String>() { @Override public String apply(InfoRequest input) { return gson.toJson(input); } }); System.out.println(post); retur...
fc8d4ac6-f4aa-4c08-8a8b-d068cdc1b496
3
@Override public void deserialize(Buffer buf) { fightId = buf.readInt(); if (fightId < 0) throw new RuntimeException("Forbidden value on fightId = " + fightId + ", it doesn't respect the following condition : fightId < 0"); int limit = buf.readUShort(); alliesId = new int...
3bd10fb5-3b53-4f76-bc90-67997b5d3f55
9
public List<GeneratedImage> buildCreatedFiles() throws IOException, InterruptedException { boolean error = false; final List<GeneratedImage> result = new ArrayList<GeneratedImage>(); for (File f : dir.listFiles()) { if (error) { continue; } if (f.isFile() == false) { continue; } if (fileToP...
e9a07625-64dc-481f-8b50-996b35b88300
0
public void run() { openDoor(); closeDoor(); startPower(); touchPower(); }
a294dbdc-fc31-4775-af77-b9fec70940a4
0
public void clearLabels(){ Labels.clear(); }
86a82f4a-6eb5-4f92-a930-72446df187f2
2
protected LinkedList[] createAdjacentLinkedListGraph(int n,int[][]edges){ LinkedList[] adjacentList=new LinkedList[n]; for(int i=0;i<n;++i) adjacentList[i]=new LinkedList(); for(int i=0;i<edges.length;++i){ adjacentList[edges[i][0]].add(edges[i][1]); adjacentList[edges[i]...
f7a1a42d-8f8c-4add-850c-0d2bdfebd6e0
6
public boolean isMoveAllowed(int fromX, int fromY, int toX, int toY) { if(toX >= 0 && toY >= 0 && toX < map.getWidth() && toY < map.getHeight()) { final int code = map.get(1, toX, toY); final int feature = FeatureCodes.getFeature(code); return ...
19cb63cc-2187-4016-bbc0-54d8a8e1c15e
6
public Boardable[] entrances() { if (entrances != null) return entrances ; entrances = new Boardable[4] ; final Tile o = origin() ; final World world = o.world ; final int h = size / 2, s = size ; entrance = null ; entrances[0] = world.tileAt(o.x + h, o.y + s) ; entrances[1] = world...
2c1e097d-5b78-4f71-aecd-dae4fc57d703
6
private void quicksort(int low, int high) { int i = low, j = high; // Get the pivot element from the middle of the list int pivot = numbers[pivot(numbers, low, high + 1)]; // Divide into two lists while (i <= j) { // If the current value from the left list is smaller...
748c5e35-3daa-48d1-aab6-54568211bac2
9
public static String getMessageDigestForUrl(String fileUrl) throws FileNotFoundException, IOException { String messageDigest = null; if (fileUrl != null && !fileUrl.isEmpty()) { try { InputStream fis = new URL(fileUrl).openStream(); MessageDigest md5 = MessageDigest.getInstance("SHA"); byte[] byte...
6f2c04af-bea8-42dc-ae1e-a21fcc10f0ee
4
static void initFeature() { Random rand = new Random(); for(int i = 0; i < DataInfo.userNumber; i++) for(int j = 0; j < DataInfo.featureNumber; j++) DataInfo.userFeature[i][j] = 0.01 * rand.nextDouble(); for(int i = 0; i < DataInfo.itemNumber; i++) for(int j = 0; j < DataInfo.featureNumber; j++...
772e1e7e-773c-4fda-b0e1-7381b3f9d780
4
@SuppressWarnings({ "rawtypes", "unchecked" }) private final static PrivilegeHolder getPrivilegeHolder(String name, ArrayList privilegeHolders) { if(name == null || privilegeHolders == null) { return null; } for(PrivilegeHolder privilegeHolder: (ArrayList<PrivilegeHolder>)privilegeHolders) { if(privileg...
5c89fae4-bedb-4561-8097-fd87a49fe074
3
private static byte[] getPKCS1BytesFromPKCS8Bytes(byte[] bytes) { /* * DER format: http://en.wikipedia.org/wiki/Distinguished_Encoding_Rules * PKCS#8: http://tools.ietf.org/html/rfc5208 */ int bIndex = 0; // Start with PrivateKeyInfo::=SEQUENCE // 0x30 Sequenc...
32c21794-6a00-4c8b-abaf-c3ac1fe31175
5
public Deplacement ProchainDeplacement(int i) { Deplacement deplacementProchain = null; Tour touractuelle = null; int j =0; for (Tour tour : historiqueToursJoueur) { touractuelle = tour; for (Deplacement deplacement : tour.getListDeplacement()) { j++; if(j == (i)) { deplacementProchain =...
377dd4a9-b4bb-4c1a-a878-640a2f7d2392
2
void close () throws USBException { if (fd < 0) return; try { // make sure this isn't usable any more long status = closeNative (fd); if (status < 0) throw new USBException ("error closing device", ...
5a6c48c7-c2d4-4a07-9fe9-d55be899468e
7
private void quickSortMostly0(int[] a, int low, int high) { //the valid elements of the list are [low, high] if (high - low <= a.length / 10) return; int n = high - low; //number of elements in the list. int p = low + 1; //median of three; pivot's index. int pivot = a[p]; //...
9b958043-fadd-4748-b324-376c7d8f4af4
6
public static void main(String args[]) { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); ...
f4e5a42f-f199-4912-88dd-b701cfc1d1ad
6
public void populateMapWidget() { Random ran = new Random(); for (int i=0; i<6; ++i) { core.Point p = new core.Point(ran.nextInt(getWidth()-6)+3, ran.nextInt(getHeight())); MapObject o = ran.nextBoolean() ? MapObject.TREE : MapObject.MOUNTAINS; obstacles.add(p); mapWidget.objectAt(p.y, p.x).setLayer(2,...
5c7ef826-6781-4256-b1a4-46d728eac178
9
public void openImplicitChannel() throws CardException { if (scpVersion == SCP_02_0A || scpVersion == SCP_02_0B || scpVersion == SCP_02_1A || scpVersion == SCP_02_1B) { CommandAPDU getData = new CommandAPDU(CLA_GP, GET_DATA, 0, 0xE0); ResponseAPDU data = channel.transmit(getData); byte[] result = data.getBy...
e3be1051-b39c-4733-8bf6-fc2bfed23eb9
8
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(target,null,null,L("<S-NAME> <S-IS-...
88d68d3a-8abe-4c57-a496-3468381ddd4b
3
public void actionPerformed(ActionEvent ev) { try { InstituicaoCooperadora objt = classeView(); if (obj == null) { long x = new InstituicaoCooperadoraDAO().inserir(objt); objt.setId(x); JOptionPane.showMessageDialog(null, "Os dados foram inseridos com sucesso", "Sucesso", JOptionPane.INF...
159e3b1e-b571-4ccb-88ed-174c2d6ad21b
3
@RequestMapping(value = "/addFlashcard", params = {"deckId"}, method = RequestMethod.POST) public String addFlashcard( @RequestParam("file") MultipartFile file, @RequestParam("deckId") int deckId, @ModelAttribute Flashcard flashcard, HttpSession session, Model model) { if(session.getAttribute("user...
e4cc6dbf-88ef-4c46-83c9-5935ff73a229
2
public LoadMenu(){ try { registerFont = Font.createFont(Font.TRUETYPE_FONT, getClass().getClassLoader().getResource("res/narrow.ttf").openStream()); } catch (FontFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } intro = Toolkit.getDefaultToolkit().getImag...
5c137204-f40f-42bd-b162-152d4ae65894
9
@Override public void configure(AbstractCommand command, String[] args) { int page = 0; String search = null; boolean listReverse = false; boolean listSimple = false; if (args.length == 3) { page = Integer.parseInt(args[0]); search = args[1]; ...
c4bf7232-3bfe-4464-9250-22c11c26ad6b
9
@Override protected Void doInBackground() throws Exception { currentPlayer = this; if (medias.length > 1) Gui.getInstance().getStopButton().setVisible(true); for (MediaElement item : medias) { if (cancelPlayer) break; if (!item.getVisible()) continue; Stri...
2c54ab75-5ea8-4fe3-9e6a-c07c600107ed
4
public Message build() { try { Message record = new Message(); record.to = fieldSetFlags()[0] ? this.to : (java.lang.CharSequence) defaultValue(fields()[0]); record.from = fieldSetFlags()[1] ? this.from : (java.lang.CharSequence) defaultValue(fields()[1]); record.body = fieldSetFla...
2f6a08b0-2845-479a-bdaa-e8ec4cb9c28b
9
@Override public void run() { try { // Создаём Selector Selector selector = SelectorProvider.provider().openSelector(); // Открываем серверный канал ServerSocketChannel serverChannel = ServerSocketChannel.open(); // Убираем блокировку s...
b7b93044-d885-4ef6-a79e-10246da3113a
9
public void update() { boolean p1ReadyE = false; boolean p2ReadyE = false; for (int i = 0; i < model.length; i++) { if (selection[i] == 1) { p1ReadyE = true; p1Character[i].setEnabled(false); p1Character[i].setBackground(Color.RED); p2Character[i].setEnabled(false); p2Character[i].setBackgr...
34c9c0a0-f308-487e-838b-560a4214d2f8
7
private Object readJSON() throws JSONException { switch (read(3)) { case zipObject: return readObject(); case zipArrayString: return readArray(true); case zipArrayValue: return readArray(false); case zipEmptyObject: return new JSONO...
8e781cb7-01fc-4308-b5fe-d2e2ee9c0482
2
public boolean hasPreferences(String module) { module += '.'; for (Enumeration<Object> keys = mPrefs.keys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); if (key.startsWith(module)) { return true; } } return false; }
77ffa7b4-2b53-44ed-9f9f-9f019c87c89d
9
public static String[] split(String str, char separatorChar, boolean preserveAllTokens) { if (str == null) { return null; } int len = str.length(); if (len == 0) { return new String[0]; } List<String> list = new ArrayList<String>(); int i = 0, start = 0; boolean match = false; boolean lastMatch ...
7737ad0e-7ed7-4d48-aad4-5ca017a7718b
6
@EventHandler public void SpiderResistance(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getSpiderConfig().getDouble("Spider.Resi...
42782f35-3a70-4758-b1fe-30c9fdd436cc
1
public void addAccount(BankAccount account) throws IllegalArgumentException { if (! canHaveAsAccount(account)) throw new IllegalArgumentException(); accounts.add(account); }
6d6a18e8-705c-48d0-a6ab-06fafabd7ece
0
public boolean isDirty() { getExpression().asString(); // Force resolution of reference. return super.isDirty(); }
c77bea01-c09b-4595-a583-9160582fb88a
0
public int getX(){ return x; }
32ce3059-b026-401d-8fe2-8c61cdee2d13
8
private String getDriverProfile() { /** * The temporary profile Selenium/Firefox creates should be * located at java.io.tmpdir. On Windows it is %TEMP% * Search is based on the presence of the file which name is the same as the name of the profile. * This file was manually placed in profile directory. ...
a0b84eb7-309e-4fa7-ba0c-062373fe4f38
1
public static void main(String[] args) { Application app = Application.get(); if(!app.init()) { System.out.println("Error with initialization! :("); System.exit(-1); } app.run(); }
8aaaf8c5-4324-4017-8fdd-c679d7e621b2
0
public List<EventComment> findAfterEventCommentsByHallEventId(final Long hallEventId) { return new ArrayList<EventComment>(); }
c6ff38b2-b13c-4a4c-8d22-b61145af59a9
4
public Object getValueAt(int row, int col) { Account account = accounts.getBusinessObjects().get(row); if (col == 0) { return account; } if (col == 1) { if(account==null) return null; if(account.getType().isInverted()) return account.getSaldo().negate(); else return account.getSaldo(); // TOD...
aa623783-7877-4084-aeb6-ebf9ff359218
2
public ArrayList<String> locateAllAt(int p_X, int p_Y) throws Exception { String around = "locate(What," + p_X + "," + p_Y + ")."; ArrayList<String> what = new ArrayList<String>(); SolveInfo info = m_Engine.solve(around); while(info.isSuccess()) { String...
905aaff5-a02e-40ee-96a8-8aa56fd36bd1
9
public static void main( String[] args ) throws Exception { Scanner scanner = new Scanner( System.in ); System.out.println( "Enter grid size:" ); int gridSize = scanner.nextInt(); StringBuilder[] grid = new StringBuilder[gridSize]; System.out.println( "Enter location of text file...
35716b5c-644b-4e2d-802f-51ca793f60ed
8
@Override public void unInvoke() { final MOB mob=(MOB)affected; if((canBeUninvoked())&&(mob!=null)) if(mob.location()!=null) { mob.location().show(mob,null,CMMsg.MSG_OK_VISUAL,L("<S-NAME> dissipate(s).")); final Vector<Item> V=new Vector<Item>(); for(int i=0;i<mob.numItems();i++) V.addElement(mob...
8ee4732c-a97a-4b47-aec4-5c6699247964
2
public static ValueFormatType fromValue(String v) { for (ValueFormatType c: ValueFormatType.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
355c48e4-1800-43ec-80cd-f9c2bd506b4e
4
public void readInPupils() throws InvalidDataException { ArrayList <String> ErrorPupil = new ArrayList(); try { // TODO code application logic here Scanner scan = new Scanner(new File("D:/Pupils.csv")); while (scan.hasNextLine()) { ...
430f5249-4d7b-4f9a-8853-c392429898bd
0
public static void main(String[] args) { int i = 32768; short s = (short) i; System.out.println("i = " + i + ", s = " + s); // i = 32768, s = -32768 }
e2a14b05-91c9-4a70-ba7a-310190ef6df0
9
public static void main(String[] args) { WeatherService weatherService = new WeatherService(); Report myReport = weatherService.getReport("newark, de"); List<Forecast> myForecasts = myReport.getForecasts(); System.out.println(myForecasts.size()); Forecast firstForecast = myForeca...
8ba3d0d9-85de-4d32-9e3a-f1414be7fc01
3
private Value term() throws Exception { Value previous, rval; previous = rval = factor(); while(scan.sym == Token.mul || scan.sym == Token.div) { Token op = scan.sym; scan.next(); previous = rval; Value next = factor(); Instruction ins; ...
7e180462-79c3-415b-a2e9-7f3caaf612dd
8
public boolean bootstrap() { String userId = node.getUserId(); boolean bootstrapped = false; System.out.println(userId + " - Bootstrapping..."); if (bootstrapList.isEmpty()) //CA wasn't contacted { //bootstrap list is get from formerly known contacts ...
57d67a8c-e3ae-4c0d-9521-0287d8f6105e
0
private void putCallObj(Long key, IRemoteCallObject object) { sync.put(key, object); }
01fd2c6e-3b65-4aa7-a6ba-d2352256d415
2
public static void main(String[] args) { Hand p1Hand = findHandFromCardSet(convertToCardSet(args[0].trim(), args[2].trim())); Hand p2Hand = findHandFromCardSet(convertToCardSet(args[1].trim(), args[2].trim())); System.out.println("Player one has " + p1Hand.toString()); System.out.println("Player two has " + p2H...
7af7c2b7-d6c5-450a-b45c-12b5febdf895
3
ProvinceListDialog(java.awt.Frame parent) { super(parent, "Provinces", false); ProvinceData.Province[] provs = Main.provinceData.getAllProvs(); String[][] provNameTable = new String[provs.length][3]; int i = 0; boolean pti = true; ...
dca115d7-b2cc-48c0-99d4-039dcea6a914
7
private void tryToFall(World var1, int var2, int var3, int var4) { if(canFallBelow(var1, var2, var3 - 1, var4) && var3 >= 0) { byte var8 = 32; if(!fallInstantly && var1.checkChunksExist(var2 - var8, var3 - var8, var4 - var8, var2 + var8, var3 + var8, var4 + var8)) { EntityFallingSand...
751816a2-529e-40b9-8c38-5d548c47708e
6
public String getType(Symtab st) { if (exp1Type.equals("message") || exp2Type.equals("message")) return "message"; if (exp1Type.equals("String") || exp2Type.equals("String")) return "String"; else if (exp1Type.equals("decimal") || exp2Type.equals("decimal")) return "decimal"; else return "int"; }
87153533-d822-419b-8787-84fbfac76c49
6
public String POST_Request(String url, String url_params) { StringBuffer response; String json_data = ""; HttpsURLConnection con = null; try { con = (HttpsURLConnection) set_headers(url); con.setDoOutput(true); con.setRequestMethod("POST"); con.setRequestProperty("User-Agent", "Mozilla/5.0 ( compati...
3b2f8074-d87f-4a1d-8a62-f5e0d4514d60
2
public boolean removeAt(int index) { if (indexOK(index)) { if (index == 0) { shiftArrayBy(-1); } else { System.arraycopy(array, index + 1, array, index, array.length - index - 1); expandArrayCapacityBy(-1); } return true; } return false; }
42b0dae7-3b45-43e0-9a9f-2a6587a45e7d
7
private void frequencyTable(ServletOutputStream out, TimerInfoStats stats, String sort, String baseurl) throws IOException { Set<TimerInfoItem> treeSet; if ("perf".equalsIgnoreCase(sort)) { treeSet = new TreeSet<TimerInfoItem>(new AverageComparator()); } else if ("uri".eq...
8e7bc78f-8910-47de-81b5-8fa2c01bc586
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://do...
62d10272-2d63-4ee8-ae35-0bad098b3f94
8
public boolean isBlack(String dir) throws IOException { Vector<String> black_id = new Vector<String>(); List<String> black_edges = getBlackEdges(); if (black_edges != null) { for(int i=0; i < black_edges.size(); i++) { String [] vals = black_edges.get(i).split("\\...
0e1f877b-e4a3-4576-96dd-5583e9b3e8f4
9
private final String lock2key(String lock) { String key_return; int len = lock.length(); char[] key = new char[len]; for (int i = 1; i < len; i++) key[i] = (char) (lock.charAt(i) ^ lock.charAt(i - 1)); key[0] = (char) (lock.charAt(0) ^ lock.charAt(len - 1) ^ lock.charAt(len - 2) ^ 5); for (int i = 0; i <...
9bdd0953-ae76-43b8-8424-e740bd459894
5
@Override public void run() { String command = ""; while (running) { try { if (jLine) { command = consoleReader.readLine(">", null); } else { command = consoleReader.readLine(); ...
efaded19-0b18-4628-9298-b0571a430fe9
5
public static void main(String[] args) { double ran = Math.random(); if(ran < .33) { f = new File("dungeon.wav"); s = new SoundPlayer(f); } else if (ran > .66) { f = new File("angel.wav"); s = new SoundPlayer(f); } else ...
a860e08d-9f4d-47cf-99ff-7bcf31e7c3c5
9
private void setCircleDefault(Attributes attrs) { // find the value to be set, then set it if (attrs.getValue(0).equals("fill")) circleDef.setFill(Boolean.valueOf(attrs.getValue(1))); else if (attrs.getValue(0).equals("color")) circleDef.setColor(new Color((Integer.valueOf(attrs.getValue(1) .substring(...
f02e1cf3-e3ab-41bd-82ea-c3a1bac60204
8
public String strStr_BF(String haystack, String needle) { if (haystack == null || needle == null) return null; char[] h = haystack.toCharArray(), n = needle.toCharArray(); if (h.length < n.length) return null; if (n.length == 0) return haystack; for ...
36eb1903-6590-4bbd-8dd3-9a9e0f2db389
2
public static void equipWeapon(WeaponType type, CharacterSheet sheet) { switch (type) { case mel_sword: sheet.atk_dmg = 10; sheet.damageType = DamageType.SLASHING; sheet.range = 1; break; case rng_bow: sheet....
4ccc9c5b-3962-4156-bd6e-87218abe8420
5
@Override public void update(int delta) { lifetime += delta; if(type == ASTEROID) y += 0.1f * delta; if(first && lifetime >= MAX_LIFETIME) isAlive = false; if(lifetime >= MAX_LIFETIME){ lifetime = 0; first = true; if(type == PLAYER) Game.getPlayer().hide(); } }
8750d0c1-3bb4-49f4-bd48-6d600b232194
6
private void layoutHorizontal(int top, int bottom, int left, int right) { int leftX = paddingLeft; int height = bottom - top; int childBottom = height - paddingBottom; int availableHeight = height - paddingTop - paddingBottom; for (int i = 0; i < getChildCount(); i++) { ...
7e245c7d-1988-4537-bcbb-5917cd869a3d
9
private HashMap<Date, Double> readTideDataFromService() { // Log a message logger .debug("readTideDataFromService called and params are currently :"); logger.debug("-> Location = " + tideLocation); logger.debug("-> Location URL Fragment = " + tideLocationUrlFragment); logger.debug("-> Start D...
97bdcc70-9a2b-4c4a-b4e5-2aedba43e8d5
0
public void clickTutorial() { System.out.println("Please choose characters that you would like to play with in this game."); //Plus more info on how the game is played in itself }
ae3304dd-61bb-4a74-aedb-00eb80e0cb1e
5
static char getOption() { System.out.print("\tChoose action: "); System.out.print("(1) students at a school, "); System.out.print("(2) shortest intro chain, "); System.out.print("(3) cliques at school, "); System.out.print("(4) connectors, "); System.out.print("(q)uit? =>...
291a601b-1c79-4687-aa46-42e1e55871a9
3
public void setupMenu(){ edgeDetection = new JMenuItem("Edge Detector"); angle = new JMenuItem("Determine Angle"); threshold = new JMenuItem("Threshold"); topView = new JMenuItem("Add Top View"); lateralView = new JMenuItem("Add Lateral View"); frontView = new JMenuItem("Add Front View"); figureVoxels = ...
c05257d3-a075-4185-89a2-fd8bc9bc8319
4
public boolean peutCreerLien(ZElement elem1, ZElement elem2) { return super.peutCreerLien(elem1, elem2) && (elem1 instanceof MCDAssociation && elem2 instanceof MCDEntite || elem2 instanceof MCDAssociation && elem1 instanceof MCDEntite); }
62ce5186-f52f-44a5-953d-b49da18a516a
4
public void propertyChange( PropertyChangeEvent evt ) { if ( evt.getSource() == topPanel ) { int hash = evt.getPropertyName().hashCode() ; if ( hash == "reload".hashCode() ) { loadOptions() ; } else if ( hash == "save".hashCode() ) { saveOptions( true ) ; //...
b579d614-8a76-4a33-99e4-ca109b6efa3a
3
public List<Double> run() { List<Double> res = new Vector<Double>(ANN.outputNeuronCount); for (Layer l : layers) { for (Neuron n : l.getNeurons()) n.preCalc(); } for (Neuron o : layers.get(layers.size() - 1).getNeurons()) { res.add(o.getValue()); } return res; }
40b4ea9c-baee-458d-a8bb-fd33b55582fc
2
public boolean equals(Vector3f r) { return m_x == r.GetX() && m_y == r.GetY() && m_z == r.GetZ(); }
8dffb2fb-c401-4c3e-b398-4c970ac48e15
5
public String toStringHtmlHeader() { StringBuilder sb = new StringBuilder(); sb.append("<script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script>"); sb.append("<script type=\"text/javascript\"> google.load('visualization', '1', {packages: ['corechart']}); </script>\n"); sb.append("<script t...
fa8efb8b-d66d-406a-9e96-c9f60e240ee5
5
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Posizione other = (Posizione) obj; if (x != other.x) return false; if (y != other.y) return false; return true; }
268e26bd-9e85-4af1-b309-27fa2098ac80
3
public void DnaSequenceBaseAt(int len) { // Create a random sequence char bases[] = new char[len]; for (int i = 0; i < bases.length; i++) { char base = GprSeq.BASES[(int) (Math.random() * 4)]; bases[i] = base; } String sequence = new String(bases); DnaSequence DnaSequence = new DnaSequence(sequence);...
e7d7dc89-dcf8-4a1c-adca-072fc02861a9
7
public void Solve() { List<Integer> primes = Euler.GetPrimes(_max); int longestSequence = 0; int startSequenceIndex = 0; for (int startIndex = 0; startIndex < primes.size(); startIndex++) { int currentNumber = primes.get(startIndex); for (int endIndex = startInde...
babb68b4-9992-4799-b6cb-1d417607a79b
7
private final boolean cons(int i) { switch (b[i]) { case 'a': case 'e': case 'i': case 'o': case 'u': return false; case 'y': return (i==0) ? true : !cons(i-1); default: return true; } }
c79c3b97-940b-47dd-ad97-083365da1ebc
5
public void run() { try { JavaDBAccess = new DatabaseAccess(props); TARGET_PHP_FILES_RUNS_FUNCTIONS_ID = 0; long startTime = System.currentTimeMillis(); // client streams (make sure you're using streams that use // byte arrays, so things like GIF and...
74ca662b-2e52-43a4-b941-c6ee29191b16
5
private void handleKey(SelectionKey key) throws IOException{ // dealing with canceled keys if( ! key.isValid() ){ return; } KeyAttachment attach = ((KeyAttachment) key.attachment()); IoHandler handler = attach.handler; if( key.isAcceptable() ){ handler.accept(key); // keys that are acceptable wil...