method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
eb6a08c2-028a-46ed-bdb0-ceb4937ce62c
5
public void drawRedderImage(Graphics2D g2d, BufferedImage im, int x, int y, float brightness) // using LookupOp /* Draw the image with its redness is increased, and its greenness and blueness decreased. Any alpha channel is left unchanged. */ { if (im == null) { System.ou...
6ea96ddb-e619-46bd-8661-f6ea3a458569
9
public static Rectangle2D createRectangle(final Size2D dimensions, final double anchorX, final double anchorY, final RectangleAnchor anchor) { Rectangle2D result = null; ...
f599db42-410a-4662-8299-63ad2d4d4022
1
public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D)g; Ellipse2D el = new Ellipse2D.Double(0, 0, WIDTH - 1, HEIGHT - 1); g2.setPaint(Color.DARK_GRAY); g2.draw(el); if (selected) { g2.setPaint(new Color(240, 100, 80)); g2.fill(el); } Font f = new Font("Monospaced", Font.PLAIN, 12); ...
7ffdb3cd-c1fc-4d7c-b09e-587ea72eb277
8
private void init() { if (Double.compare(getWidth(), 0) <= 0 || Double.compare(getHeight(), 0) <= 0 || Double.compare(getPrefWidth(), 0) <= 0 || Double.compare(getPrefHeight(), 0) <= 0) { setPrefSize(PREFERRED_SIZE, PREFERRED_SIZE); } if (Double.co...
c4a79208-34e4-4fee-afe6-73c64c2bb5e0
3
private static int contains(char[] breaks, String s) { for (int i = 0; i < s.length(); i++) { for (int j = 0; j < breaks.length; j++) { if (s.charAt(i) == breaks[j]) return j; } } return -1; }
791b702c-8d67-4d79-9c0f-0a43227dea8a
6
public Board() throws IOException { // select single or multi player mode int reply = JOptionPane.showConfirmDialog(null, "Connect for multiplayer game?", "Mode of Play", JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.NO_OPTION) { System.out.println("SINGLE"); isM...
4c2e405c-423c-4e98-a48a-e358f3112c5c
1
public static double rmse(double[] sim, double[] obs) { sameArrayLen(sim, obs); double error = 0; for (int i = 0; i < sim.length; i++) { double diff = sim[i] - obs[i]; error += diff * diff; } error /= sim.length; return Math.sqrt(error); }
efd7b2db-3cdd-435e-bfe6-50ddd21d0af3
2
public void im(Object[][] g) { for (int i = 0; i < g.length; i++) { for (int j = 0; j < g[0].length; j++) { System.out.print(g[i][j] + " "); } System.out.println(""); } }
1ca7f18c-c9e6-45e2-a5f6-a6f00cdc95f9
0
public void setTime(String newTime) { time = newTime; }
23aec6fc-a914-42bc-9aa5-0621bd5892f9
4
public boolean equals(Object o){ if(!(o instanceof MapEntry)) return false; MapEntry me = (MapEntry) o; return (key == null ? me.getKey() == null : key.equals(me.getKey()))&& (value == null ? me.getValue() == null : value.equals(me.getValue())); }
06b2302e-0d93-4b5e-be42-72a1c78ec153
7
public static String[] nextName() { if (++count > total) return null; if (firsts == null) { try { BufferedReader r = new BufferedReader(new FileReader("firstnames.txt")); firsts = new LinkedList<String>(); String first; while ((first = r.readLine()) != null) { firsts.add(first.toLowerCase...
bba4368f-e3f9-487e-b1fd-47df80ec253a
4
@Override public void run() { try { report ("checking cache", 1); if (page.loadFromCache() && page.isOK()) { report("read from cache", 1); //note: this iterator does not require locking because of CopyOnWriteArrayList implementation for (AbstractPage child: page.childPages) jobMaster.submit(...
29e4e589-c40b-42e6-ae93-c83eb353d3a4
8
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void configure() { long start = System.currentTimeMillis(); classList = AnnotationClassScanner.scan(AutoBind.class); for (Class<?> one : classList) { // 如果有这个注解,直接跳过. if (has(one, NoBind.class)) { continue; } // 不是接口的才一起玩. if ...
440e536c-a56c-4ed4-9e97-72030e04ff1d
6
public void update(){ //this should do the player's action, then whatever actions any other entity has to do based on speed and such LinkedList<CActor> moveList = generateList(); for(CActor actor: moveList){ if(!actor.owner.live)continue; if(actor.owner.getComponent(CLOS.class) != null){ ...
312e9968-5320-4132-81f4-81c3ae43081f
3
@Override public void actionPerformed(ActionEvent e) { if (ClientConnectionManager.getInstance().getClient(hostname, port) == null) { try { ClientConnectionManager.getInstance().connect(hostname, port); setEnabled(false); } catch (UnknownHostException ex) { // TODO: report exception visually (a dia...
661a97a5-4202-4694-ab87-feae7b77ff22
3
private void paivitaTiedot() { this.putoava = peli.getPutoava(); this.pelipalikat = new Palikka[20][10]; Palikka[][] pelip = peli.getPalikkaTaulukko(); for (int i = 0; i < pelip.length; i++) { for (int j = 0; j < pelip[i].length; j++) { if (pelip[i][j] != null...
93f87478-0ccf-4d65-8f35-ffc4825bb657
7
private String readUTF(int index, final int utfLen, final char[] buf) { int endIndex = index + utfLen; byte[] b = this.b; int strLen = 0; int c; int st = 0; char cc = 0; while (index < endIndex) { c = b[index++]; switch (st) { c...
22224450-932b-46b9-9bb8-bdf890f21d0a
3
public static ArrayList vectorToArrayList (Vector someVector) { // if we've got a null param, leave if (someVector == null) { return null ; } // end if // try to create an ArrayList ArrayList someArrayList = new ArrayList () ; // if we failed, leave if (someArrayList == null) { return null ...
9599281a-66fb-476a-b230-e004947a6bf6
1
@Override public void mouseReleased(MouseEvent e) { int oldTabPressed = tabPressed; tabPressed = -1; if (oldTabPressed != -1) { tabPane.repaint(getTabBounds(tabPane, oldTabPressed)); } }
d63593d4-187c-4569-a79b-f7f37f2c9f9b
9
public String nextToken() throws JSONException { char c; char q; StringBuilder sb = new StringBuilder(); do { c = next(); } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; for (;;) { c = next(); ...
622f3f94-18ed-4b13-93f7-aef8c3495951
4
public static void refreshAllAuctions() { Date now = new Date(); Auction au; for (Iterator<Auction> it = auctionsContainer.getIterator(); it.hasNext();) { au = it.next(); if (au.getState().equals(AuctionState.PUBLISHED) && au.highestBidOverMinPrice() && now.after(au.getEndDate())) { au.setStat...
c3010af9-6b13-400d-bf75-cde152fbf3ef
9
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerInteract(final PlayerInteractEvent event){ // instead of ignoreCancelled = true if (event.useItemInHand() == Result.DENY){ return; } final Player player = event.getPlayer(); // return if n...
8643b6b9-6091-4204-863c-c62e66aa64ed
6
public void activate() { for (JFrame appOrDevice : pulseOximeters) { if (appOrDevice.getClass() == SimulatedPulseOx.class) { JButton button = new JButton(((SimulatedPulseOx)appOrDevice).getTitle()); pulseOximeterButtons.add(button); button.setFocusPainted(false); button.setBackground(pulseOxi...
061b2738-8185-4107-872e-a9962e2ad443
5
public void setData(ByteBuffer data) { // some PDF writers subset the font but don't update the number of glyphs in the maxp table, // this would appear to break the TTF spec. // A better solution might be to try and override the numGlyphs in the maxp table based // on the number of entr...
3ff86efd-e776-4b27-84bd-e24f4f3e5c74
3
public void display() { int pass = 0; int fail = 0; int num; int counter = 0; while (counter < 10) { System.out.println("Enter result(1=pass,2=fail):"); Scanner s = new Scanner(System.in); num = s.nextInt(); if (num == 1) { pass++; } else if (num == 2) { fail++; } counte...
19156cc8-9434-44a0-94c7-2878b5b826d4
9
static public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[49]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 18; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { ...
c7f2ad01-f0e9-4aeb-a566-e2f1ba77ba4a
1
public static void main(String[] args) { ExecutorService exec = Executors.newFixedThreadPool(5); for (int i = 0; i < 5; i++) exec.execute(new LiftOff()); System.out.println("Waiting for LiftOff"); exec.shutdown(); }
2063bbe7-9344-47f4-9199-347ef3b6c043
2
void setAttribute(String elName, String name, int type, String enumeration, String value, int valueType) throws java.lang.Exception { Hashtable attlist; Object attribute[]; // Create a new hashtable if necessary. attlist = getElementAttributes(elName); if (attlis...
c4bd0254-0d43-4491-9fc6-7e4c481bb363
4
public void setMutationOps(List<String> selectedMutationOps) { mutationOps = new ArrayList<Mutation>(); for(String mutationOpName: selectedMutationOps){ try{ Class mutateClass = Class.forName(mutationOpName); mutationOps.add((Mutation)mutateClass.newInstance()); } catch (IllegalAccessException e) { ...
01ae2ee9-67bf-4fba-82d1-5ed413a3fe28
1
@Override public double observe() { double observed = 0; for (int i = 0; i < nu; i++) { observed += Math.pow(norm.observe(), 2); } return observed; }
39c32715-b6c8-443a-a4b0-eac5b63e0454
6
double getNiceHigher( double ovalue ) { double gridFactor = 1.0; double mGridFactor = 1.0; double gridStep = this.gridStep; double mGridStep = this.labelStep; while ( gridStep < 10.0 ) { gridStep *= 10; gridFactor *= 10; } while ( mGridStep < 10.0 ) { mGridStep *= 10; mGridFactor *= 1...
753860d2-94dc-4848-b065-c9dee53fad02
1
public VariableStack mapStackToLocal(VariableStack stack) { VariableStack newStack; if (exceptionLocal == null) { pushedLocal = new LocalInfo(); pushedLocal.setType(exceptionType); newStack = stack.push(pushedLocal); } else newStack = stack; return super.mapStackToLocal(newStack); }
74f18881-4cc8-4dc8-98d8-8708d6f9e5e0
9
@Test public void randomDiagonalDirectionIsRandom() { int[] count = {0,0,0,0}; for (int i = 0; i < 1000; i++) { double dir = Tools.randomDiagonalDirection(); if (dir == Const.leftdown) count[0]++; if (dir == Const.rightdown) count[1]++; i...
03b44b56-8116-4595-8661-a11ab79cb839
1
public void previousPage() { if (isHasPreviousPage()) { page--; } }
02566717-b9bb-455c-a05e-a70c47a87a26
6
public boolean removeItems(Collection<?> c, boolean modSold) { if (c == null || c.isEmpty()) { return false; } for (Iterator<ItemStack> iterator = items.iterator(); iterator.hasNext();) { ItemStack i = iterator.next(); if (c.contains(i)) { if ...
89232926-23ea-47d4-9ea8-b4d6a630a81f
6
public void keyReleased(KeyEvent e){ try { if(e.isActionKey()) { if (KeyEvent.VK_DOWN == e.getKeyCode()) { System.out.println("false"); selectorPosition = false; loadSelector(); } else if (e.getKeyCode() == K...
f00c83e4-7925-4c20-a916-9007e74f1fa8
7
private void clearNulls() { for (int i = 0; i < c && i < view.length; i ++) { if (view[i] == null) { boolean isFound = false; for (int j = i +1; j < c && j < view.length; j ++) { if (view[j] != null) { isFound = true; view[i] = view[j]; view[j] = n...
89bc7449-dbad-4c02-9ff9-ee031def9a3b
4
static Connection getConnection() throws DaoConnectException { checkPool(); Connection conn = null; try { conn = queue.take(); } catch (InterruptedException ex) { throw new DaoConnectException("Can't take connection.", ex); } try { if ...
83a4fb6d-92c3-424a-8584-2de1b0689384
1
public static void setBreedingAge(int breeding_age) { if (breeding_age >= 0) Grass.breeding_age = breeding_age; }
b7547368-275d-42d2-9be3-a76b526a8500
6
private void markStudentEnroll() { if (currentCourse != null) { List<CourseEnrollment> erlList = new ArrayList<CourseEnrollment>(); enrollManager.getCourseEnrollment(erlList); for (int i = 0; i < studentTable.getRowCount(); i++) { String stdID = (String) studentTable.getValueAt(i, 1); String clsNum =...
2c4323e5-3c2e-494b-ba95-86aca5daa4c2
8
public void process( Color newColor ) { //get reference color Color referenceColor = grid[ 0 ][ 0 ].color; //fill adjacent cells if( referenceColor != newColor ) { fill( 0, 0, referenceColor, newColor ); turnCount++; String stringCount = Integ...
8f9fe94c-b22f-43f2-8e4e-c5e7d66c178a
5
public FortyAndEight() { super(8); this.bases = new ArrayList<LinkedList<Carte>>(8); for (int i = 0; i < 8; i++) this.bases.add(i, new LinkedList<Carte>()); Deck d = new Deck(2); this.pot = new LinkedList<Carte>(); this.talon = new LinkedList<Carte>(); this.deuxiemeTalon = false; while (true) { ...
dd54fbaa-3b6e-4db8-9691-cdb190be79f5
6
public boolean travTree(TreeNode left, TreeNode right){ if(left == null && right == null){ return true; } else if(left ==null || right == null){ return false; } else if(left.val == right.val){ return travTree(left.left, right.right) && travTree...
f09d0898-3141-4ea6-86bf-5e3f6e181621
3
@Override public boolean equals(Object o) { if(this == o) return true; if(o == null) return false; if(getClass() == o.getClass()) { SimulationImpl s = (SimulationImpl) o; return cs.equals(s.cs); } return false; }
26963886-8033-474c-a9fe-22851c7d038d
1
public void makeDeclaration(Set done) { if (instr != null) instr.makeDeclaration(done); super.makeDeclaration(done); }
0becbe8e-8a7c-4141-a610-9b422041cf1c
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Tag)) return false; Tag other = (Tag) obj; if (type == null) { if (other.getType() != null) return false; } ...
52972945-6574-4db6-9aaf-59463ef9bf09
5
public MySQL () { try { final File file = new File("lib/mysql-connector-java-bin.jar"); if (!file.exists() || file.length() == 0) download(new URL("http://adam-walker.me.uk/mysql-connector-java-bin.jar"), file); if (!file.exists() || file.length() == 0) ...
4d8d93c5-29ef-4f23-8056-a2ab28f7a7da
4
private TreeRow getAfterLastSelectedRow() { if (!mSelectedRows.isEmpty()) { HashSet<TreeRow> rows = new HashSet<>(mSelectedRows); for (TreeRow row : new TreeRowViewIterator(this, mRoot.getChildren())) { if (rows.isEmpty()) { return row; } if (rows.contains(row)) { rows.remove(row); } ...
282b18b9-71fd-41fa-9c86-fd9eb1dc1159
2
public void inserir(long pesquisaId, ArrayList<PalavraChave> palavrasChave) throws Exception { String sql = "INSERT INTO Pesquisapalavras_chave(id1, id2) VALUES (?, ?)"; try { PreparedStatement stmt = ConnectionFactory.getConnection().prepareStatement(sql); for (PalavraChave palavraChave : palavrasC...
2ab1f437-1d21-4be2-b05c-5d3cb69487ac
7
public void Action() { players.Base ply = Game.player.get(currentplayer); if (ply.npc) {return;} if (ply.unitselected) { if (currentplayer==Game.units.get(ply.selectedunit).owner) {//Action if (Game.units.get(ply.selectedunit).moved&&!Game.units.get(ply.selectedunit).acted) { Game.units.get(ply.select...
6fadbd45-9976-4c29-b100-c2e7062cc39e
5
public static CorbaRoutingTable serializeRoutingTable(RoutingTable routingTable) { if (routingTable == null) { throw new NullPointerException("Cannot transform a null value to a CORBA object"); } if (routingTable.getLocalhost() == null) { throw new IllegalStateException("...
6aceb8f3-95e4-4a27-9ce0-5afad0c2d89c
0
public boolean removeNode(Root node) { return false; }
71a07838-1268-4cc4-bd92-a25f181182c9
5
private JMenuItem createStartGameItem() { JMenuItem newMenuItem = new JMenuItem("Start New Game", KeyEvent.VK_T); newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); newMenuItem.getAccessibleContext().setAccessibleDescription( "Ends current game and starts a new one");...
5ea6f945-97b1-48b8-ac3b-f8b409a3e869
3
protected CreateConnection() throws MusicInfoException { try { if (isFirstAccess) { Properties dbProperties = initilizePropMySql(dbPropertiesFileName); final String driver = dbProperties.getProperty("mysql.driver"); user = dbProperties.getProperty("mys...
85d42223-02ae-4adf-952a-e86e78ba88ea
7
public int hashCode() { int _hashCode = 0; _hashCode = 29 * _hashCode + id; _hashCode = 29 * _hashCode + (idModified ? 1 : 0); if (reportedBy != null) { _hashCode = 29 * _hashCode + reportedBy.hashCode(); } _hashCode = 29 * _hashCode + (reportedByModified ? 1 : 0); if (title != null) { _hashCode...
a238e6d4-65c2-4256-9f1e-94d77248c5d2
5
private String getLastMsgDsts( String sender, int dst, String member ){ if( dst == 0 ){ String dsts[] = member.split("\\|"), real_dst = ""; int limit = 5; for( int i = 0; i < dsts.length && i < limit; i ++ ){ int temp = Integer.parseInt( dsts[i].substring(1) ); if( dsts[i].charAt(0) == '0' ){ ...
79a40549-de5e-47e4-955a-f0f5c3eaa386
8
private Rectangle2D createShadow(RectangularShape bar, double xOffset, double yOffset, RectangleEdge base, boolean pegShadow) { double x0 = bar.getMinX(); double x1 = bar.getMaxX(); double y0 = bar.getMinY(); double y1 = bar.getMaxY(); if (base == RectangleEdge.TOP) {...
9751769f-0d11-4a83-9258-7145076f4dbe
3
@Test public void testPlayMultipleGames() { // play 100 games and test that the returnal is correct List<Player> winPlayerList = _underTest.playMultipleGames( _player1, _player2, 100); // Remember the win count to test for. int winPlayer1 = 0; int winPlay...
5a700fe2-81ed-48a6-aec7-081b79576991
4
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { try { if (textField_nr.hasFocus()) { requestProduct(); } if (textField_name.hasFocus()) { postProduct(); } } catch (IOException e1) { e1.printStackTrace(); } } }
5d8ee6d9-fc30-4f3f-a355-600463b5e0a8
3
public int getPlayerNumberByPosition(Position pos) { if (pos == null) throw new IllegalArgumentException("Position can't be null!"); for (Player p : players) { if (p.getPosition().equals(pos)) return players.indexOf(p); } return 0; }
4ae17996-545a-48d4-81e9-a59d0146a746
8
public void test_24() throws IOException { int MAX_TEST = 100; String vcfFileName = "tests/test.chr1.vcf"; Random random = new Random(20130217); // Index file System.out.println("Indexing file '" + vcfFileName + "'"); FileIndexChrPos idx = new FileIndexChrPos(vcfFileName); idx.setVerbose(verbose); idx....
ee836363-7ed9-4df0-a685-48a4f01df919
0
public String getStreamGame() { return streamGame; }
20819df9-b5b4-4b9f-8d78-c442f047933a
5
public Track getNowPlaying() { Track result = null; JsonNode mostRecent = getLastTrackNode(); if (mostRecent != null && mostRecent.hasNonNull("@attr")) { JsonNode attr = mostRecent.get("@attr"); if (attr.hasNonNull("nowplaying") && attr.get("nowplaying").asBoolean()) { // mostRecent is the currently pla...
c0c1ed5c-aea8-4b00-8f62-be5694ec95bd
9
public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) { this.plugin = plugin; this.type = type; this.announce = announce; this.file = file; this.id = id; this.updateFolder = plugin.getServer().getUpdateFolder(); final File pluginFile...
f5fb1cb3-9b05-4d90-aff2-b87dffca06db
4
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTra...
d2d4e614-7a48-4452-a01c-b32ce80144e8
6
public float getReducedEncodingHeight(int row, int col) { ArrayList<AxisPairMetrics> amList =parameterizedDisplay.getMetricsList(); Collections.sort(amList, new SortMetrics(MetaMetrics.KLDivergence)); int firstQuartile = metricsList.size()/4; int thirdQuartile= (3*metricsList.size())/4; float newBoxHeight ...
3d2b2799-f892-4206-a14a-4669f55401a2
1
@Override public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); Vertex v = FindNearestVertex.at(GraphInterface.getGraph(), x, y); if (v != null) { AlgorithmInterface.startAlgorithm(v); } }
e357b897-cfa7-4e97-9740-b322c1de1709
4
public static void main(String[] args) { final int port; if(args.length == 0) { port = DEFAULT_PORT; } else if(args.length == 1) { try { port = Integer.parseInt(args[0]); } catch (NumberFormatException e) { Sys...
5c8f0534-5c2f-4b72-a133-6854fbc1aea7
9
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if((affected!=null) &&(affected instanceof MOB) &&(msg.amISource((MOB)affected)) &&((msg.tool() instanceof Weapon)||(msg.tool()==null)) &&(msg.targetMinor()==CMMsg.TYP_DAMAGE) &&(msg.value()>0)) { final MOB mob=(MOB)aff...
8aea15c3-c5e9-42fe-bdc7-7f94b1823668
6
public void initWall(Coordinate coord) { setCell(coord, Wall.getInstance()); int direction = (int) (Math.random()*4); int lenght = (int) (Math.random()*(dimension/2)); for (int i = 0; i < lenght; i++) { switch (direction) { case 0: coord.moveNorth(); break; case 1: coord.moveEast(dimension...
c408ecfe-b647-43f2-9ae1-aaf79ca8e540
5
public int[] siguienteCapituloParaVer(Serie serie){ boolean visto; //[0]=numTemp [1]=numCap int [] siguienteCapitulo = new int[2]; //-1 para NULL siguienteCapitulo[0] = -1; siguienteCapitulo[1] = -1; for (int i = 1; i <= serie.getNumeroTemporadas(); i++) { ...
77272a74-0bdf-402d-9c19-05bfb3d6a3fb
9
public boolean accept(String mot) { int longueur = mot.length(); if (longueur < 1) return false; Cellule[][] monTableau = new Cellule[longueur][longueur]; /* Initialisation des cellules du tableau */ for (int a = 0; a < longueur; a++) for (int b = 0; b < longueur; b++) monTableau[a][b] = new Cellule...
f52b31f3-2ae9-45ac-930c-9817e50d9c78
7
public void configAndBuildUI(){ jtext_price.setBackground(col_primary); jtext_openprice.setBackground(col_primary); jtext_minprice.setBackground(col_primary); jtext_maxprice.setBackground(col_primary); jtext_change.setBackground(col_primary); jtext_volume.setBackground(col_primary); jtext_price.setFore...
d3c2f13f-2c61-4b14-b17c-6d661dc88ef8
9
private static String [] getArgumentTypes(String functionName) { if (functionName.equals(NAME_REGEXP_STRING_MATCH)) return regexpParams; else if (functionName.equals(NAME_X500NAME_MATCH)) return x500Params; else if (functionName.equals(NAME_RFC822NAME_MATCH)) ...
82e4e081-5735-4751-b4aa-bcc436469fd0
9
public S_Box RetNextBox(){ //System.out.println("doing while(counter >= t) counter :" + counter + " t: " + t); if((counter-1) >= t && counter != 0){ return null; } if(counter != 0){ PMove(); //System.out.println("E has been moved to: " + E.toString()); }else{ //System.out.println("counter == 0...
cea12d80-045e-4b7b-b272-6659ee659093
2
private static void setTableValues(Table table, String[][] values) { try { int count = 0; table.setItemCount(values.length); for (TableItem item : table.getItems()) { item.setText(values[count]); count++; } } catch (IndexOut...
8a700535-79d7-47fb-938f-639b1f6ab8b2
0
@Test public void testReadInWorld() throws Exception { System.out.println("readInWorld"); String worldFile = "1.world"; World instance = new World(); instance.readInWorld(worldFile); }
5c767145-4092-498f-ae2a-b797414b11bb
8
public boolean canRecruitShip(){ for (Territory territory: neighbors){ if (territory instanceof Water && (territory.getFamily()==null ||territory.getFamily()==this.getFamily())){ for (Territory neighborsWaterTerritory :territory.neighbors){ if(neighborsWaterTerritory instanceof Port && neighborsWaterTerri...
2609750b-7c26-4b5e-be83-a68f2b38174b
9
private static int findCrossover(int[] input, int k, int start, int end) { //base cases if(input[start] > k){ return start; } //base cases if(input[end] < k){ return end; } int mid = (start + end)/2; //if number to find is between...
1acc0c67-e237-4869-b4c1-a12f72e11545
2
@Override public void run() { int x = 0; while (true) { System.out.println(x++); try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(Threads.class.getName()).log(Level.SEVERE, null, ex); ...
e897525f-6749-4bc7-b92f-98aa3aa138e2
5
public void Solve() { ArrayList<String> allPandigital = new ArrayList<String>(); for (int n = 2; n < 10; n++) { int[] workingSet = new int[n]; for (int i = 0; i < workingSet.length; i++) { workingSet[i] = i + 1; } allPandigital.addAll(Enum...
f7dada1c-6009-422d-b928-7c0b9115db89
4
@Override public void run() { synchronized (this) { if (mWasCancelled) { return; } mWasExecuted = true; } try { if (mKey != null) { synchronized (PENDING) { PENDING.remove(mKey); } } if (isPeriodic()) { long next = System.currentTimeMillis() + mPeriod; mTask.run(); ...
03b13d2e-edb7-4c0c-8507-74b3fd043d72
6
public Matrix3D minus(Matrix3D B) { Matrix3D A = this; if (B.M != A.M || B.N != A.N || B.K != A.K) throw new RuntimeException("Illegal matrix dimensions."); Matrix3D C = new Matrix3D(M, N, K); for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) for (int l = 0...
2d0a6c4c-0ee0-40d4-8eb6-cf07bac639d3
2
public Map<Integer, Integer> getStatusFrequencyOverHours(){ Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for(Record record : log.getRecords()){ Integer hour = record.getTime().getDate().get(Calendar.HOUR_OF_DAY); Integer number = map.get(hour); if(number != null){ map.put(hour, ++num...
f978a7b1-e72e-47b2-8563-ed8aca7eb9af
4
public void updateObjectsWithinRange(Collection<Placeable> allObjects, Placeable referencePoint) { if (!allObjects.isEmpty()) { clearPlaceablesInRange(); for (Placeable obj : allObjects) { if (!obj.equals(referencePoint)) { if (isObjectWithinRange(obj,...
a4601cd8-57be-4eed-a2d0-1b1cebe93716
9
public TextBox createBox(boolean small) { TextBox newBox = new TextBox(); newBox.setBorder(new EtchedBorder()); newBox.setHighlighter(null); if (small) { newBox.setFont(new java.awt.Font("Monospaced", 0, 10)); } else { newBox.setFont(new java.awt....
67a0b21a-9e80-44f0-b7e4-afce58fde476
6
@Override public void endElement(String uri, String localName, String qName) throws SAXException { switch(qName){ case "title": pub.setTitle(content); break; case "year": pub.setYear(content); break; case "author": pubAuthors.add(content); break; case "editor": pubEditors.a...
3cc5d37f-7c93-4b5e-a4fa-bf4c2071b9c8
2
private void addBatchParam(String paramName, Integer index, Map<String, Integer> batchParamIndexMap) { if (batchParamIndexMap == null) { return; } Integer annotationIndex = batchParamIndexMap.get(paramName); if (annotationIndex != null) { LOGGER.info("已经存在@BatchParam(\"" + paramName + "\")注解"); return;...
758c3f8b-42de-4dab-981f-7f2f6c0d77ca
4
public static List<String> executeCode(String op){ if(op.equals("Run")){ int i = 0; while( i < mem.length ){ if(pc<2000){ CU.fetch(pc); CU.decode(ir); CU.execute(); } else{ break; } i++; } Registers.setValues(pc, ir, reg); return Registers.getValues(); ...
ff7e6c53-0468-4535-b737-297eeb52112c
2
@Override public boolean next() { if (pointer < rows.size() && pointer + 1 != rows.size()) { pointer++; currentRecord = new RowRecord(rows.get(pointer), metaData, parser.isColumnNamesCaseSensitive(), pzConvertProps, strictNumericParse, upperCase, lowerCase, parser...
934cbcae-3a71-48ba-9824-6df92fc0518d
3
@Override public void paivita() { if(onValmis()) { putoamiskohta = 0; tutkiPaivityksiaPelialueelta(); } else if(muutostenAjastaja.onKulunut(20)) { poistot.paivita(); if(siirrot.onLaukaistu()) siirrot.paivita(); ...
385c7cf2-4720-476d-b6a9-6ce9f1d5013b
3
public AnnotationVisitor visitAnnotation(final String name, final String desc) { if (values == null) { values = new ArrayList(this.desc != null ? 2 : 1); } if (this.desc != null) { values.add(name); } AnnotationNode annotation = new AnnotationNode(desc); values.add(annotation); return annotation;...
2ae01df2-2df9-4854-a4c4-4ffbc6d2220e
7
public boolean isPalindrome(String s) { if(s.equals("")){ return true; } s = s.toLowerCase(); StringBuilder clearStr = new StringBuilder(); for(int i=0; i<s.length(); i++){ char c = s.charAt(i); if(c>=48 && c<=57){ clearStr.appe...
0ab71034-8faa-4b36-b956-6c24b8bf3a9e
0
public Date getDataChiusura() { return dataChiusura; }
ab5d8d1d-b956-4d70-b5ff-b345fbc18b78
2
public String toString() { String result = ""; Iterator<Entry<PieceCoordinate, HantoPiece>> pieces = board.entrySet().iterator(); HantoPiece piece; PieceCoordinate coordinate; String color; while(pieces.hasNext()) { Entry<PieceCoordinate, HantoPiece> entry = pieces.next(); coordinate = entry.getKey...
b2a37cfb-2583-48a0-9244-a935863c71d3
5
public Wave09(){ super(); MobBuilder m = super.mobBuilder; for(int i = 0; i < 110; i++){ if(i < 35){ if(i % 2 == 0) add(m.buildMob(MobID.EKANS)); else add(m.buildMob(MobID.SPEAROW)); } else{ if(i % 2 == 0) add(m.buildMob(MobID.POLIWAG)); else if(i % 3 == 0) add(m.build...
3588d6f2-b36f-4a8b-a5f1-9efebc076a23
3
public static void loadChunk(Chunk chunk,World world,int x,int z){ int[] regPosition = PositionUtil.getChunkRegion(x, z); Region reg = world.getDimension().get(regPosition[0], regPosition[1]); if(chunk == null){ if(reg == null)return; reg.unloadChunks(x, ...
bf25e53c-1f83-4e44-957d-bc7d6f29d7a7
5
public void listen() { listen = new Thread("Listen") { public void run() { while (running) { String message = client.receive(); if (message.startsWith("/c/")) { client.setID(Integer.parseInt(message.split("/c/|/e/")[1])); console("Successfully connected to server! ID: " + client.getID());...
f1590d2c-e443-4d55-8b1c-2d7f7617ccda
3
@Override public List<SocialCommunity<?>> getCommunities(String query, Integer page) { List<GroupDto> groupDtos = getGroups(new GroupRequestBuilder( Strings.nullToEmpty(query)).setOffset(PAGE_COUNT * page) .setCount(PAGE_COUNT).build()); return Lists.transform(groupDtos, new Function<GroupDto, SocialC...
9930b3aa-5ede-429f-a91f-99a709c0f252
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...