method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
77cffa0e-e33f-4264-98d7-3a8a43aeef09
5
public static boolean isNodeOfType(Node node, String tagName, boolean caseSensitive) { if (!(node instanceof Element)) return false; Element nodeAsElement = (Element) node; if (caseSensitive && nodeAsElement.getTagName().equals(tagName)) return true; if (!caseSensitive && nodeAsElement.getTagName().equals...
a2c08499-0e7f-4082-9aab-61bd90a21e34
7
public void close() { if (closed) return; FileLockRemainedException fileLockException = null; if (process != null) { try { killFirefoxProcess(); } catch (FileLockRemainedException flre) { fileLockException = flre; } } ...
16076b91-8660-4583-af67-039f7618c5b5
1
private DataModule getCurrentModule() { if (fragments.isEmpty()) { return null; } return getDataModule(fragments.get(fragments.size() - 1)); }
dcd96044-1af0-4445-bc28-55b79f617c32
0
public static void main(String[] args) { System.out.println("The numbers before changing were as a:"+a +" and b is:"+b); b=b+a; a=b-a; b=b-a; System.out.println("The numbers now are as a: "+a+" and b is "+b); }
ea5214c2-c946-40f7-8ff5-e01376e9990d
9
static void checkMethodDesc(final String desc) { if (desc == null || desc.length() == 0) { throw new IllegalArgumentException( "Invalid method descriptor (must not be null or empty)"); } if (desc.charAt(0) != '(' || desc.length() < 3) { throw new IllegalArgumentException("Invalid descriptor: " + desc);...
4ffa095e-6a15-4a45-9f08-e3c627eb27f6
1
public void setCluster(int cluster) throws ClusterException { if(cluster < 0) throw new ClusterException("The cluster identifier cannot be negative!"); this.cluster= cluster; }
082e7162-10c4-495f-ade9-e9e8845257a7
5
public void guardarCambios(DefaultTableModel tabla) { abrirBase(); int i = 0; while (i < tabla.getRowCount()) { int id = (int) tabla.getValueAt(i, 0); BigDecimal deber = new BigDecimal(tabla.getValueAt(i, 3).toString()); BigDecimal haber = new BigDecimal(tabl...
5330f810-2c9d-4f78-aaf2-39724b4d0f90
9
private int[] defense() { int[] c = new int[2]; // Get neighboring positions of the opponents positions Set<Position> neighborPos = board.getPlayerNeighbors(players[1].piece); // Search for possibility of opponent win in first ply for (Position pos : neighborPos) { // Add move board.setMove(pos.getX()...
890a42f2-93bb-4097-b287-69dc8a98752f
7
private void renderPlayers(GameContainer c, Graphics g){ for(int i = 0; i < players.length;i++){ if(players[i].isAlive()){ int pos = 25; int lifes = players[i].getLives(); /* Draw players life and show where players is */ while(lifes > 0){ switch(i){ case 0 : playerLife.drawStri...
a553dbc9-1e0a-40bc-9588-b3f6b3cbc264
4
public void initCollisionList(){ for(int i = 0; i <= tileMap[0].length-1; i++){ for(int c = 0; c <= tileMap.length-1; c++){ if(tileMap[c][i] != null){ if(tileMap[c][i].hasCollision){ collisionList.add(tileMap[c][i]); } } } } }
2430c389-31cc-46a7-a91f-5fe75912b69e
7
private int subInputComment(ArrayList<PageAllParam> pageAllParams, String website){ commentFilePath=AnalysisTxt.regexPropertites.getProperty("sourcePath"); System.out.println(website); commentFilePath=commentFilePath+"/"+website.replaceAll(".*-", "")+"/"+website.replaceAll("-.*", ""); System.out.println(comment...
e2746f00-d231-4ee3-bc47-bcf3997bc013
3
private void begin () { long t__send, dt; double rate; _t_send = System.currentTimeMillis(); while (++times <= Utils.MAX) { broadcast("TEST", String.format("%d", System.currentTimeMillis())); if (times % Utils.STEP == 0) { t__send = System.currentTimeMillis(); dt = t__send - _t_send; if (dt > ...
fd9bb92c-ab50-49bb-97de-42d2ebb97272
5
@Override public String execute(HttpServletRequest request) throws Exception { CourseClient cc = new CourseClient(); ArrayList<Course> poolA = (ArrayList) Utilities.convertToCourse(request.getParameter("poolA")); ArrayList<Course> poolB = (ArrayList) Utilities.convertToCourse(request.getPara...
f72388bf-8faf-45cf-8266-ac78a9734c9f
3
public void setRight(PExp node) { if(this._right_ != null) { this._right_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); ...
36ecd25a-1f93-4b69-a9d2-f10ef9ea1541
0
private void createLogger(String loggerName, String resource, String directory, String fileName, String pattern) { setLoggerName(loggerName); setResource(resource); setDirectory(directory); setFileName(fileName); setPattern(pattern); appenders = new ArrayList<LoggerAppender>(); }
acce0924-f4b2-4ff3-a540-d655f9a07dd6
0
public static String __(String encoded) { return ChatColor.translateAlternateColorCodes('&', encoded); }
a935efbc-22d8-48db-8c17-b462bc62cc8e
7
public String convert(String s, int nRows) { if (nRows == 1) return s; StringBuilder result = new StringBuilder(s.length()); int skippyOne = nRows + nRows; int skippyTwo = -2; int alwaysSkippy = skippyOne - 2; for (int o = 0; o < nRows; ++o) { skippyOne -= 2; skippyTwo += 2; boolean always = (sk...
eac026a7-d3d0-461b-88b1-81b8baffe061
0
@Before public void init(){ sortSelection = new SortSelection(); }
917bae06-9a97-45c8-a042-870b91605594
9
private Graphics2D finishGroup(ReportGroup group, Graphics2D g, Point p) { // // Notify the report listeners that the current group has ended // ReportEvent event = new ReportEvent(ReportEvent.GROUP_FINISHED, state); event.setGroup(group); int expCount; ReportExp...
82b8a36f-5254-4141-89d8-31013d274bf2
2
public void push(double x) { if (index+1 == stack.length) { for (int i=0; i<stack.length-1; i++) { stack[i] = stack[i+1]; index = i; } } stack[++index] = x; }
ccad4465-d000-4ebf-a19f-eae542e1fe84
1
public String innerClass(int nth) { int i = innerClassIndex(nth); if (i == 0) return null; else return constPool.getClassInfo(i); }
41ad5b89-2fac-4c2e-8b3a-c2002c4e11ad
7
public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); HashMap<String, String> map = new HashMap<String, String>(...
3a190ca0-f8f3-4a8d-aebc-6e246d6b9bca
3
@Override public ResultSet fillData(String command) { try { if (connection.isClosed()) connect(); } catch (SQLException e) { connect(); } try { return connection.prepareStatement(command).executeQuery(); } catch (SQLExceptio...
61079bf0-754d-4b36-bd5d-78287d4c449f
4
public void setFrame(int fNumber, int primary){ // /* BufferedImage img; img = new BufferedImage(352, 288, BufferedImage.TYPE_INT_RGB); int pix; //System.out.println("reflected? "+fNumber); for(int i=0; i<352; i++){ for(int j=0; j<288; j++){ if(...
0eb0ba0b-5d35-4bac-ac72-13927348126e
7
public int ladderLength(String start, String end, Set<String> dict) { Queue<String> Q = new LinkedList<>(); Q.offer(start); int level = 1; int cur = 1, next = 0; while (!Q.isEmpty()) { String str = Q.poll(); char[] charseq = str.toCharArray(); cur--; for (int i = 0; i < charseq.length; i++) { ...
59cd9c06-66ca-4c9f-a421-241c846e5de0
6
public static double complementaryRegularisedGammaFunction(double a, double x) { if (a < 0.0D || x < 0.0D) throw new IllegalArgumentException("\nFunction defined only for a >= 0 and x>=0"); boolean oldIgSupress = Stat.igSupress; Stat.igSupress = true; double igf = 1.0D; if (x != 0.0D) { if (x == 1.0D / 0...
0944f0ff-ffbe-4c4d-ae2f-86ffdb078d5c
9
public Result invoke(Invocation inv) throws RpcException { if (destroyed) { throw new RpcException("Rpc invoker for service " + this + " is DESTROYED, can not be invoked any more!"); } RpcInvocation invocation = (RpcInvocation) inv; invocation.setInvoker(this); if (attachment != null && attachment.size() >...
06c2af20-5ffc-45eb-813c-b0fbe6211512
5
private void formMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseDragged double x = evt.getX() * ((double)800/(double)windowSize().width); double y = evt.getY() * ((double)600/(double)windowSize().height); boolean match = false; for (Menu menu : menus) { ...
a04bc797-7800-42c3-997b-f953285ce9fc
0
@Override public long getDelay(TimeUnit unit) { return unit.convert(submitTime - System.nanoTime(), unit.NANOSECONDS); }
163f7ef9-7779-48ab-abcf-d044ae5158ea
8
public boolean spawnPiece() { int hw = cols/2; //Half of the board's width. //PieceType type = PieceType.PIECE_LINE; //PieceType type = PieceType.fromInteger(RNG.nextInt(PieceType.numPieces)); //Playing around with random numbers. Default random class is spawning too many duplicate pieces. randomNum ^=...
055e9a3d-3b57-4b52-8cb1-121bd592e805
5
protected Token requestToken(Request request) throws IOException { HttpResponse response = safeExecute(env.sslResourceHost, request.buildRequest(HttpPost.class)); final int status = response.getStatusLine().getStatusCode(); String error = null; try { if (status == HttpStatus...
9211f332-1943-4405-9055-8443252e1da5
5
public boolean postMortem(PostMortem pm) { JSONzip that = (JSONzip) pm; return this.namehuff.postMortem(that.namehuff) && this.namekeep.postMortem(that.namekeep) && this.stringkeep.postMortem(that.stringkeep) && this.substringhuff.postMortem(that.substring...
8b5a3089-203b-4e22-b509-560b42a2cadb
8
public static void parseArguements(String[] args){ for(int position = 1; position < args.length; position++){ if(args[position].equals("-s")){ Zegana.genSize = Integer.parseInt(args[position+1]); position++; } else if(args[position].equals("-t")){ Zegana.trials = Integer.parseInt(args[positi...
5098fb7b-30ce-493b-b232-586b28c770a3
6
final int[][] method3047(int i, int i_0_) { if (i_0_ != -1564599039) return null; anInt9378++; int[][] is = ((Class348_Sub40) this).aClass322_7033.method2557(-94, i); if (((Class322) ((Class348_Sub40) this).aClass322_7033).aBoolean4035) { int i_1_ = (anInt9374 * ((anInt9379 ^ 0xffffffff) == (Class286_S...
6c3a057b-8670-478a-9e74-5817fa365e00
4
public IPlugin loadPlugin(String pluginName, /*List<*/String/*>*/ initPath) { IPlugin res = null; try { System.out.println("Chargement de "+pluginName); //for(String s: args) { System.out.println("arg: "+initPath); //} Properties pluginProperties = readPluginInit(rightPathToHome+initPath); Cla...
7dabcebe-960e-4761-97d6-7853b37c0382
8
private void drawInternal(UGraphic ug, int size, final HtmlColor foregroundColor, final HtmlColor backgoundColor) { ug.getParam().setBackcolor(backgoundColor); ug.getParam().setColor(foregroundColor); size = ensureEven(size); switch (this) { case PACKAGE_PRIVATE_FIELD: drawTriangle(ug, false, size); bre...
1e83999b-38f6-4fd9-a1c1-68238d668488
5
@Override public boolean isCellEditable(int row, int col) { if (col == 3 || col == 4 || col == 5 || col == 6 || col == 7) { return true; } return false; }
f48fa29f-69ed-45d8-89f4-35ae27079cf6
9
public int compareTo(Object obj) { if (!(obj instanceof NameRecord)) { return -1; } NameRecord rec = (NameRecord) obj; if (platformID > rec.platformID) { return 1; } else if (platformID < rec.platformID...
a572b21b-de0b-46a6-b1c9-d11b7c4bb744
6
private static String preprocessSql(String sql, Map<String, Object> params) { if (sql.contains(":map")) { StringBuilder sb = new StringBuilder(); boolean first = true; for (String key: params.keySet()) { if (!first) sb.append(", "); sb.append(k...
337ee0ec-5714-4534-a5e0-3efb7121996f
4
public void pathInfo() { if (path == null || toNode == null || fromNode == null) return; double length = 0; for (Edge e : path) { length += e.length; } System.out.println("Direct path distance: "+Node.getDistance(fromNode, toNode)); System.out.println("Distance on MST...
363f67bc-d95d-4da3-8d52-d0e6b6bf96ff
0
public ExampleTest() { super(new File(new File("tests"), "work")); }
1991cec2-4bc6-48c6-8f9b-36d88e8196f9
3
public void sinkItself(){ switch(steps){ case 0:{ setImageIcon(blowup1); steps++; break; } case 1:{ setImageIcon(blowup2); steps++; break; } ...
e8b6aee4-50b2-4fcf-8750-aa38e27c1abc
3
boolean isAttackPlaceDiagonallyAboveLeftNotHarming(int position, char[] boardElements, int dimension, int attackPlacesOnTheLeft) { int positionLeftAbove = 1; while (attackPlacesOnTheLeft > 0) { if (isPossibleToPlaceDiagLeftAbove(position, dimension, positionLeftAbove) &&...
7b13bf9e-dfdc-41d5-90b6-b0a4ae63e00e
4
public boolean collides(int xp, int yp){ if(xp > x && yp > y && xp < x + w && yp < y + h) return true; return false; }
b515b096-ec9b-478a-b80f-40c2c55a84a1
2
public void have(){ System.out.println(ip + " >> Sending have"); boolean[] piecesRecieved = torrentHandler.getRecieved(); int length = piecesRecieved.length; for(int i = 0; i < length;i++){ if(piecesRecieved[i]){ sendMessage(Message.haveBuilder(i)); System.out.println(Message.haveBuilder(i)); }...
040ed765-6479-4e8c-abdf-bcbed75035e5
4
public ArrayList<Flight> afternoonArrivingFlights(String arrivalAirport) { ArrayList<Flight> afternoonFlights = new ArrayList<Flight>(); for (int i = 0; i < flights.size(); i++) { if (flights.get(i).getArrivalAirport().equals(arrivalAirport) && Integer.valueOf(flights.get(i).getDepartureTime()) >= 1200 ...
ae1df223-2e87-4703-9f28-0a58f1a3dfe8
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...
6071eb59-58c0-4eb6-b37d-246e9b2035db
7
public void update(){ solver.interrupt(); sp = new SearchPiece[pieces.size()]; // 1=2 horizontal 2=3horizontal 3=2vertical 4=3vertical for(int i=0; i<pieces.size(); i++){ int X = pieces.get(i).getX(); int Y = pieces.get(i).getY(); int d = pieces.get(i).direction(); int size = pieces.get(i).length();...
56636bdb-8882-4897-ae3b-a3c213ca1d9f
8
protected void normalizeProbabiltiesAndUpdateModel() { for (int stateFrom = 0; stateFrom < numStates; ++stateFrom) { // Initial state probabilities. if (normFactorInitialState > 0.0) model.probInitialState[stateFrom] = probInitialStateNew .get(stateFrom) / normFactorInitialState; else model.pro...
0dfd3199-7d00-47d5-9ad0-229dfca1847a
5
public String getBanReason(String name) { try { File f = new File(plugin.getDataFolder() + File.separator + "Players" + File.separator + name + ".data"); BufferedReader br = new BufferedReader(new FileReader(f)); StringBuilder readReason = new StringBuilder(); String line; String[] line2; while ((li...
51fa4d58-79a4-42d0-86b6-6632679e4098
0
public void setDirFilterInclude(String dirFilterInclude) { this.dirFilterInclude = dirFilterInclude; }
27a5c1ad-5c1b-4f82-b826-5ab21cf52aa5
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...
82119f6a-3bd1-4836-8861-9a5f8082f725
0
public void setDescription(String description) { this.description = description; }
25ddddbe-9fb1-4552-b637-6681e5a9066f
7
public static void main(String[] args) throws IOException{ if(args.length != 2){ System.err.println("Usage: java IMClient <host ip/name> <port>"); System.exit(1); } String hostName = args[0]; int portNumber= Integer.parseInt(args[1]); try ( Socket imSocket = new Socket(hostName, portNumber); P...
67276556-bb6a-4adc-a1fa-c8fc5a7a177d
1
private GameAction getKeyAction(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode < keyActions.length) { return keyActions[keyCode]; } else { return null; } }
2915ac03-d245-4269-a2f7-7dfbf67ffe8e
8
public DynProg(List<Product> products, int sum) { int n = products.size(); /* allocate nodes */ nodes = new Node[n+1][sum+1]; for (int i = 0; i <= n; i++) for (int j = 0; j <= sum; j++) nodes[i][j] = new Node(); /* fill the 2D array */ for (int i = 1; i <= n; i++) { Product p = produ...
8852c423-f42b-4654-a0ae-6d8981baf54f
4
public void fillPattern1() { for (int row = 0; row < matrix.length; row++) { for (int col = 0; col < matrix[0].length; col++) { if (row < col) matrix[row][col] = 1; else if (row == col) matrix[row][col] = 2; else matrix[row][col] = 3; } } }
05c44e8f-0933-473f-bf22-79385a6bc631
9
final int method1708(int i, int i_5_, int i_6_, byte[] bs) throws IOException { anInt1967++; if ((i_5_ ^ 0xffffffff) > -1 || (i_6_ ^ 0xffffffff) > -1 || i_5_ + i_6_ > bs.length) { throw new IOException(); } synchronized (this) { int i_7_; if ((anInt1960 ^ 0xffffffff) <= (anInt1956 ^ 0xffffffff)) { ...
b98ce00c-1d0c-4a9f-8496-3a1d48ef2cb5
9
private Double getBidIncrements(Double price) { if (price <= .99) { return price + .05; } else if (price >= 1 && price <= 4.99) { return price + .25; } else if (price >= 5 && price <= 24.99) { return price + .5; } else if (price >= 25 && price <= 99.99) { return price + 1; } else if (price >= 100 ...
819022d4-8a2c-444b-9f99-253cf0d9ef93
4
public MazeCom readMazeCom() throws EOFException, SocketException { byte[] bytes = null; MazeCom result = null; try { String xml = this.readUTF8(); System.out.println("Empfangen"); System.out.println(xml); bytes = xml.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); resu...
c9a32d70-a618-447a-b06a-0e0b7c98cd3c
8
String getRotateXyzText() { StringBuffer sb = new StringBuffer(); float m20 = matrixRotate.m20; float rY = -(float) Math.asin(m20) * degreesPerRadian; float rX, rZ; if (m20 > .999f || m20 < -.999f) { rX = -(float) Math.atan2(matrixRotate.m12, matrixRotate.m11) * degreesPerRadian; rZ = 0; } else { ...
73d0eb1e-c0e4-4e1b-bdb3-834f14ae9fd8
8
private static void installNatives(File folder) throws Exception { if(getNameOfOS().equalsIgnoreCase("windows")) { if(!new File(folder.getPath()+"/OpenAL64.dll").exists()) { IO.copy(getFFJar("/windows/jinput-dx8_64.dll", LWJGLNatives.class), folder.getPath()+...
e4e59b8b-1e0e-4487-bab7-ce00fdc58248
3
public static boolean isIDValid(String id) { for (Contestant c : list) { if (c != null && id.equals(c.getID())) return false; } return true; }
45cd6d70-0b68-4658-9cec-eda9b67e2085
2
public static void main(String[] args) { try { Lang.init(args[0]); start(args); } catch (Throwable t) { int yesorno = JOptionPane.showConfirmDialog(new JFrame(), "ERROR.\n" + t.toString() + "\nDo you want to close this program now?", "", JOptionPane.ERROR_MESSAGE); t.printStackTrace(); if (yes...
7f50c2b4-9f1d-4283-914c-f002f15c67e7
7
void button_save_clicked(String args) { FileDialog dialog = new FileDialog(new Frame(),"Save",FileDialog.SAVE); dialog.setVisible(true); String filename = dialog.getDirectory() + dialog.getFile(); if (filename == null) return; try { DataOutputStream fp = new DataOutputStream(new BufferedOutputStream(new F...
b854720b-25c7-49d8-8171-ca0baf3942e8
3
public Iterator<T> iterator() { return new Iterator<T>() { int ix = -1; final long gen = generation; public boolean hasNext() { check(); return ix < n - 1; } public T next() { check(); if (!hasNext()) { throw new IllegalStateException("Called next when hasNext is false"); }...
615adfea-9da0-44f9-b87b-8ad21437d818
3
static Vector<BitSet> terrainToBits(TerrainTypes[] arg) { int len = arg.length; int numBits = TerrainTypes.countBits(); Vector<BitSet> result = new Vector<>(numBits); for (int j=0; j < numBits; j++) { BitSet bitset = new BitSet(len); bitset.clear(); re...
425de8b4-463f-45bf-a1f3-a1b5e1141f6e
8
public Point[] getAdjacentPoints(Point p) { ArrayList<Point> points=new ArrayList<Point>(); if (p.x>0) { if (p.y>0) points.add(map[p.x-1][p.y-1]); points.add(map[p.x-1][p.y]); if (p.y<HEIGHT-1) points.add(map[p.x-1][p.y+1]); } if (p.y>0) points.add(map[p.x][p.y-1]); if (p.y<HEIGHT-1) po...
d18eaa72-2d37-45c1-a70a-36fdb08b1b4b
3
private boolean isReadOnly() { if(cdx_file) READ_ONLY = true; if(READ_ONLY) { try { throw new IOException ("Read only mode!"); } catch (IOException e) { e.printStackTrace(); } } return READ_ONLY; }
e5a76ec1-82af-4b67-8ada-489596669d10
7
public void updateStats(Personnage perso) { panelResumePerso.removeAll(); panelResumeActions.removeAll(); if(perso != null) { labelClasse = new JLabel(); labelNom = new JLabel(); labelAge = new JLabel(); labelStatut = new JLabel(); la...
b98fae10-1b93-49cd-b1b1-465b30436b46
5
public static Scheduler startScheduler() throws SchedulerException { SchedulerFactory schedFact = new StdSchedulerFactory("Configuration/quartz.properties"); Scheduler sched = schedFact.getScheduler(); sched.start(); ArrayList<Integer> mins = new ArrayL...
2320e952-82f5-4423-84c1-e531310b1ac3
2
public void removeButtonClicked(String objektName, JComboBox removeBox){ int i = 0; while(i < ocean.getOceanObjects().size()){ if (ocean.getOceanObjects().get(i).getName().equals(objektName)){ LinkedList<OceanObject> oceanObjectsCount = ocean.getOceanObjects(); oceanObjectsCount.remove(oceanObjectsCoun...
c3f84daf-a759-4e8f-ae18-d5bbb7d2b88d
4
public MethodIdentifier(ClassIdentifier clazz, MethodInfo info) { super(info.getName()); this.name = info.getName(); this.type = info.getType(); this.clazz = clazz; this.info = info; BytecodeInfo bytecode = info.getBytecode(); if (bytecode != null) { if ((Main.stripping & Main.STRIP_LVT) != 0) inf...
b769e633-b99e-41b3-8bf1-e8620eb69c2c
0
public void setKeyLength(BigInteger value) { this.keyLength = value; }
eb7c4b6f-95ac-4cd0-a0fc-e79e19a8edb6
3
private void merge(Map<Integer, Integer> dest, Map<Integer, Integer> src) { for (Entry<Integer, Integer> e : src.entrySet()) { Integer count = dest.get(e.getKey()); if (count == null || e.getValue() > count) { dest.put(e.getKey(), e.getValue()); } } }
2c82e170-778b-4686-abcf-31c7447b30e1
7
private JButton getSubmit() { if (submit == null) { submit = new JButton(); submit.setText("查詢"); submit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (id.getText().eq...
e41d65de-0b34-4de6-b244-d2924e3131af
4
public static double[][] square( double[][] mat ) { int m = Matrix.getNumOfRows(mat); int n = Matrix.getNumOfColumns(mat); double[][] res = Matrix.newMatrix(m, m); for ( int i = 0; i < m; ++i ) { res[i][i] = 0.0; for ( int k = 0; k < n; ++k ) res[i][i] += mat[i][k] * mat[i][k]; for ( int j = 0; j < i; ++...
c4adb819-b1ab-4649-add7-920cdc2157d8
3
@Override public Event next() { String input = null; try { input = br.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //alters state if(input == null || input.equals("")){ return null; } else{ return new SearchResultsState(as, name,...
7bda1613-db5d-4a3f-9c60-98e486a4c76c
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof DomainRequest)) return false; DomainRequest other = (DomainRequest) obj; if (requestedDomain == null) { if (other.requestedDomain != null) return false; } else if ...
7c8e80e1-bde9-45ec-8d21-1a620a0957e9
7
@Override public void keyReleased(KeyEvent keyEvent) { if(keyEvent.getKeyCode() == KeyEvent.VK_LEFT || keyEvent.getKeyCode() == KeyEvent.VK_RIGHT ){ iDireccion = 0; } //si presiono P (Pausar) if(keyEvent.getKeyCode() == KeyEvent.VK_P) { ...
95211f96-b409-489d-9aa4-d3439ed85390
2
public int hashCode() { int hash = clazz == null ? 0 : clazz.hashCode(); for (int i = 0; i < ifaces.length; i++) { hash ^= ifaces[i].hashCode(); } return hash; }
e8f44601-4559-41aa-8fb2-72bcb35b2b25
3
private void drawTabs() { if (mainTab) { parent.rect(posX + 180, posY, 180, 25); parent.rect(posX + 360, posY, 180, 25); } else if (collectionTab) { parent.stroke(0); parent.rect(posX, posY, 180, 25); parent.stroke(0); parent.rect(posX + 360, posY, 180, 25); } else if (keyboardTab) { parent....
67e0a9e5-d568-4e68-9240-277a620aa48f
3
private static void readMagicItemsFromFileToArray(String fileName, Items[] items) { File myFile = new File(fileName); try { int itemCount = 0; Scanner input = new Scanner(myFile); while (input.hasNext() && itemCou...
6a380eb8-f4cc-4aea-b42a-68091ad50aa8
3
@Override public void actionPerformed(ActionEvent action) { //super.actionPerformed(action); switch(action.getActionCommand()) { case "voteCount": ConcludeVoting(); break; case "changeMode": if(serverMode == ServerMode.graphic) { setTextMode(); } else { setGraphicMode(); ...
c1b9a056-31f6-423e-a29c-4078694bbd87
3
public static void main(String[] args) { Graph G = null; try { G = new Graph(new In("tinyG.txt")); } catch (Exception e) { System.out.println(e); System.exit(1); } Cycle c = new Cycle(G); if (c.hasCycle()) { System.out.println("tinyG.txt" + " : Cycle detected"); System.out.println(c...
92671fbb-fc6d-45c0-bbb5-3fed59ca2dca
7
private void jBListarIncidentesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBListarIncidentesActionPerformed // TODO add your handling code here: int comuna = combo_comuna_reportedoble.getSelectedIndex(); int tipo = combo_tipo_reportedoble.getSelectedIndex(); if (...
50a186e9-15c3-4681-b9e6-ce3b1bad43fc
9
public double nextGamma(double shape, double scale) { if (shape < 1) { // [1]: p. 228, Algorithm GS while (true) { // Step 1: final double u = this.nextUniform(0, 1); final double bGS = 1 + shape / FastMath.E; final double p = bGS * u; if (p <= 1) { // Step 2: final double x = F...
326882d2-c83c-4962-aba6-eac5d74f5422
1
public static void main(String[] args) throws IOException { ByteBuffer bb = ByteBuffer.allocate(100); // IntBuffer ib = bb.asIntBuffer(); FileChannel ch = new FileOutputStream("/tmp/file.txt").getChannel(); bb.put((byte) 10); bb.put(new byte[] { 1, 2, 3, 4 }); bb.putInt(10); bb.flip(); System.out.prin...
6be04169-b6c8-4d5c-b9ed-e44a8884cedb
9
protected Vector<BigIntegerPoly> i2roots() { /* The vector of the factors to be returned */ Vector<BigIntegerPoly> res =new Vector<BigIntegerPoly>() ; if ( degree() < 2) return res ; BigInteger bsco = a.fir...
8f2051fc-2ccb-481f-aa4a-80e411fa2178
9
private boolean executeCommand(final String[] argv, final String sender, final String recipient) { final Module core = getCoreModule(); if (core.hasCommand(argv[0])) { // first priority is assume core module. final String[] params = Arrays.copyOfRange(argv, 1, argv.length); return core.execute(argv[0], ...
84f0323c-f372-4317-9bce-5919fd93bbbb
2
public static void main(String[] args) { Handler[] nodes = {new Handler(), new Handler(), new Handler(), new Handler()}; for (int i = 1, j; i < 10; ++i) { j = 0; while (!nodes[j].handle(i)) { j = (j + 1) % nodes.length; } } }
7cb7d799-8635-4d30-a4f6-fe7f27cccfb5
4
@Override public void networkMessage(Byte node, NetworkMessage type) { // TODO Handle messages try { switch(type) { case NEWKEEPALIVE: networkTreeMap.put(node,new TreeSet<Byte>()); this.addPath(deviceID, node); this.userNotification(node,true); send(node,buildPacket()); // System.out.print...
d847b673-979e-4c0c-a256-bef0707105d2
9
@Override public void run() { AddressDB addressDB = AddressDB.instance(); PropertiesDB propertiesDB = PropertiesDB.getInstance(); MiscProtocol miscProtocol = MiscProtocol.getInstance(); while (true) { String[] recipients = null; // When this tool is installed for the first time, recipients is // emp...
3a155fac-9735-4102-9918-3d5f97068610
4
public boolean validateSignatureFromByteArray(final byte[] sig, final byte[] data, PublicKey pKey) throws NoSuchAlgorithmException { byte[] newd; byte[] ver; MessageDigest messageDigest = MessageDigest.getInstance("MD5"); try { cipher.init(Cipher.DECRYPT_MODE, pKey); newd = cipher.doFinal(sig); } c...
fdf930f8-dea8-4d14-a1f3-081d63e711cd
7
public Set<Object> filterDescendants(Object cell) { mxIGraphModel model = graph.getModel(); Set<Object> result = new LinkedHashSet<Object>(); if (model.isVertex(cell) && cell != this.parent && model.isVisible(cell)) { result.add(cell); } if (this.traverseAncestors || cell == this.parent && model.i...
0f7342b1-6506-4408-9458-9047f89e6ca0
0
public int size() { return map.size(); }//size
5e92b2ab-34eb-4f1a-ba09-8c4451fe323e
2
public void calcDeriv(){ double p=0.0D,qn=0.0D,sig=0.0D,un=0.0D; double[] u = new double[nPoints]; d2ydx2[0]=u[0]=0.0; for(int i=1;i<=this.nPoints-2;i++){ sig=(this.x[i]-this.x[i-1])/(this.x[i+1]-this.x[i-1]); p=sig*this.d2ydx2[i-1]+2.0; this.d2ydx2[i]=(sig-1.0)/p; ...
af54dc97-fbeb-4dbc-bdb5-c7f607f14776
3
public void setStatistic(PlayerStatistic statistic) { lblUsername.setText(statistic.getNickname()); lblTotalCount.setText(statistic.play.toString()); if(statistic.draw != 0) { lblDrawCount.setText(statistic.draw + " ( " + statistic.draw*100/statisti...
57d75701-277a-4f1c-b138-cd8a5b62b65b
2
@Override public void handleMessages(Inbox inbox) { while(inbox.hasNext()) { Message m = inbox.next(); if(m instanceof MarkMessage) { this.setColor(Color.GREEN); } } }
7e6641c5-6dd4-4e8e-be14-4312e96b6c03
6
public void Expression(String name) { if(Values.getType(name).equals(("TYPENUM"))) { String value = NumExpression(); if(value != null) Values.setValue(name,value); } else if(Values.getType(name).equals(("TYPESTR"))) { String value = StrExpression(); if(value != null) Values.setValue(name,valu...