method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
37bd6f6d-1c54-4895-af40-faa2072fd3fc
8
public void tick() { clock++; removeLosses(); draw = (draw * 49.0 + lastTickDraw) / 50.0; lastTickDraw = 0.0; if (drewFromTrack > 0) drewFromTrack--; else if (type == Type.USER && charge < (capacity / 2.0) && clock % DRAW_INTERVAL == 0) { ILinkageManager lm = CartTools.getLinkageManager(minecart.worldObj); for (EntityMinecart cart : lm.getCartsInTrain(minecart)) { if (cart instanceof IElectricMinecart) { ChargeHandler ch = ((IElectricMinecart) cart).getChargeHandler(); if (ch.getType() != Type.USER && ch.getCharge() > 0) { charge += ch.removeCharge(capacity - charge); break; } } } } }
85d3c5a2-8c85-4ebf-ab32-7dfd830462c1
1
@SuppressWarnings("unchecked") public T getLast(int i) { // check if we have enough history if (i >= count.getValue()) { throw new NoSuchElementException(); } // fetch the wanted value OverflowingInteger position = top.clone(); position.decrement(i); //System.out.println("Reading data at " + position.getValue()); return (T) data[position.getValue()]; }
1d0f6f4f-097a-48a0-ad1a-421498f9c6be
1
public static CtClass getReturnType(String desc, ClassPool cp) throws NotFoundException { int i = desc.indexOf(')'); if (i < 0) return null; else { CtClass[] type = new CtClass[1]; toCtClass(cp, desc, i + 1, type, 0); return type[0]; } }
12849d6b-f595-4d2b-b3d9-94d57891bacb
5
public void afficher (Graphics g){ // affiche l'image principale g.drawImage(board,x,y, null); for (Territory territory : boardModel.board.values()){ //display the garrisons if(territory.haveGarrison()){ displayGarrison(territory, g); } //display the neutral forces if(territory.getNeutralForce()>0){ displayNeutralForce(territory,g); } //affiche les troupes et les symboles influence presentent sur les territoires if (territory.getTroup()!=null){ showTroops(territory, g); }//maintenant on test si il y a un pion influence if (territory.getInfluenceToken()){ showInflenceToken(territory, g); } } this.showOrders(g); }
1655704b-ca62-46c0-b931-2cca43e63fa9
1
public static void testAllGeneration() throws IOException, GeneratorException { FileInputStream jsonInput = new FileInputStream("examples/json/test.json"); String jsonText = IOUtils.toString(jsonInput); String outputPath = "examples/tests/"; File dir = new File(outputPath); if (!dir.exists()) { dir.mkdir(); } outputPath+="test"; Report report = new Report(jsonText, "examples/template/test.docx", outputPath); new AllGenerator(report).generate(); File docxFile = new File(outputPath+".docx"); File pdfFile = new File(outputPath+".pdf"); File htmlFile = new File(outputPath+".html"); assertTrue(docxFile.isFile()); assertTrue(pdfFile.isFile()); assertTrue(htmlFile.isFile()); assertTrue(docxFile.delete()); assertTrue(pdfFile.delete()); assertTrue(htmlFile.delete()); FileUtils.deleteDirectory(dir); }
7de8cff9-a758-46bf-970d-464c4bdfdc0f
1
public Recipe getRecipe() { if (recipe == null) { recipe = new Recipe(); } return recipe; }
f5f20fef-9440-4b7f-aceb-9e18f2eee7e0
5
@Override public void collides(Entity... en) { if (!Exploded) { return; } for (Entity e : en) { if (e == this || e.cull()) continue; Polygon p = e.getBounds(); if (shape.intersects(e.getBounds())) { takeDamage(e.doDamage()); e.takeDamage(doDamage()); return; } } return; }
db69b024-454b-4a96-82f2-47829ee914f9
6
public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception { if (splitted[0].equalsIgnoreCase("reloadmap")) { if (splitted.length < 2) { mc.dropMessage("If you don't know how to use it. You should't be using it."); return; } int mapid = Integer.parseInt(splitted[1]); MapleMap map = c.getChannelServer().getMapFactory().getMap(mapid); map.deleteAndReloadMap(); } else if (splitted[0].equalsIgnoreCase("reloaddropspawn")) { try { TimerManager.getInstance().stop(); } catch (Exception e) { mc.dropMessage("Error : " + e); e.printStackTrace(); } finally { try { TimerManager tMan = TimerManager.getInstance(); tMan.start(); mc.dropMessage("Success"); } catch (Exception e) { mc.dropMessage("Error : " + e); e.printStackTrace(); } } } else if (splitted[0].equalsIgnoreCase("resetreactors")){ c.getPlayer().getMap().resetReactors(); } }
1179d4b9-fc78-481b-ac57-db4c92c2f480
9
private static void removeExceptionInstructionsEx(BasicBlock block, int blocktype, int finallytype) { InstructionSequence seq = block.getSeq(); if (finallytype == 3) { // empty finally handler for (int i = seq.length() - 1; i >= 0; i--) { seq.removeInstruction(i); } } else { if ((blocktype & 1) > 0) { // first if (finallytype == 2 || finallytype == 1) { // astore or pop seq.removeInstruction(0); } } if ((blocktype & 2) > 0) { // last if (finallytype == 2 || finallytype == 0) { seq.removeLast(); } if (finallytype == 2) { // astore seq.removeLast(); } } } }
9594e127-6571-4c55-aeb5-2ac39ead126f
9
public synchronized void shutdown() { super.shutdown(); try { if (this.serverSocket != null) { if (this.syslogServerConfig.getShutdownWait() > 0) { try { Thread.sleep(this.syslogServerConfig.getShutdownWait()); } catch (final InterruptedException ie) { // } } this.serverSocket.close(); } } catch (final IOException ioe) { // log? } finally { synchronized(this.sockets) { if (this.sockets != null && this.sockets.size() > 0) { for (final Socket socket : this.sockets) { try { socket.close(); } catch (final IOException e) { // log? } } } } if (this.thread != null) { this.thread.interrupt(); this.thread = null; } } }
41514bf2-4c82-4e7b-b4d0-f2948eb5c073
4
private String getFontSytle(int sytle, int flags) { // Get any useful data from the flags integer. String style = ""; if ((sytle & BOLD_ITALIC) == BOLD_ITALIC) { style += " BoldItalic"; } else if ((sytle & BOLD) == BOLD) { style += " Bold"; } else if ((sytle & ITALIC) == ITALIC) { style += " Italic"; } else if ((sytle & PLAIN) == PLAIN) { style += " Plain"; } return style; }
06d5df14-6570-4db3-b78b-2f28bc8d7073
4
public static Locale getLocale(String language) { Locale lang = new Locale("fr", ""); if (language.equalsIgnoreCase("Français")) { lang = new Locale("fr", ""); } else if (language.equalsIgnoreCase("English")) { lang = new Locale("en", ""); } else if (language.equalsIgnoreCase("Español")) { lang = new Locale("es", ""); } else if (language.equalsIgnoreCase("日本語")) { lang = new Locale("ja", ""); } return lang; }
af983f4b-5487-4c4b-800e-e0d07ac76316
5
private float diagnoseBonus() { float manners = -5 ; manners += 5 * patient.mind.relationValue(actor) ; manners += 5 * actor.mind.relationValue(patient) ; manners /= 2 ; if (actor.aboard() != theatre) return manners ; Upgrade u = null ; if (type == TYPE_FIRST_AID ) u = Sickbay.EMERGENCY_AID ; if (type == TYPE_MEDICATION ) u = Sickbay.APOTHECARY ; if (type == TYPE_PSYCH_EVAL ) { u = Sickbay.NEURAL_SCANNING ; manners *= 2 ; } if (type == TYPE_RECONSTRUCT) { u = Sickbay.INTENSIVE_CARE ; manners = 0 ; } return (((1 + theatre.structure.upgradeBonus(u)) * 5) / 2f) + manners ; }
594bad52-45cd-4f17-b4cf-3854498f3035
8
public void updateStatus() { Market mkt = Market.getInstance(); Parameter p = Parameter.getInstance(); String param = p.getParam("asset treshold"); double tresh = Double.valueOf(param); int[] n = new int[2]; double[][] list = new double[size][mkt.assets.size()]; double[] centroid = new double[mkt.assets.size()]; Collections.sort(individual); //TODO: Make sure that sorting global list does not mess up local lists! avg_fitness[currgen-1] = 0; terminals[currgen-1] = 0; bigterminals[currgen-1] = 0; nodes[currgen-1] = 0; introns[currgen-1] = 0; memevalue[currgen-1][0] = 0; memevalue[currgen-1][1] = 0; citytotal[currgen-1] = 0; for (int i = 0; i < max_X; i++) for (int j = 0; j < max_Y; j++) { ArrayList<MemeNode> m = (ArrayList<MemeNode>)terrain[i][j]; memevalue[currgen-1][0] += m.size()*Double.parseDouble(xparameter[i]); memevalue[currgen-1][1] += m.size()*Double.parseDouble(yparameter[j]); citypop[currgen-1][i][j] = m.size(); cityfitness[currgen-1][i][j] = 0; for(int k = 0; k < m.size(); k++) { cityfitness[currgen-1][i][j]+= m.get(k).fitness / m.size(); } if (m.size() > 0) citytotal[currgen-1]++; } for (int i = 0; i < size; i++) { // calculating centroid; Portfolio port = individual.get(i).generatePortfolio(); for (int j = 0; j < centroid.length; j++) { list[i][j] = port.getWeightByIndex(j); centroid[j] += list[i][j]/size; } avg_fitness[currgen-1] += individual.get(i).fitness; terminals[currgen-1] += individual.get(i).countAsset(0.0); bigterminals[currgen-1] += individual.get(i).countAsset(tresh); n = individual.get(i).countNodes(); nodes[currgen-1] += n[0]; introns[currgen-1] += n[1]; } diversity[currgen-1] = 0; for(int i = 0; i < size; i++) for(int j = 0; j < centroid.length; j++) { diversity[currgen-1] += Math.pow(centroid[j] - list[i][j],2); } max_fitness[currgen-1] = individual.get(0).fitness; avg_fitness[currgen-1] /= size; terminals[currgen-1] /= size; bigterminals[currgen-1] /= size; nodes[currgen-1] /= size; introns[currgen-1] /= size; memevalue[currgen-1][0] /= size; memevalue[currgen-1][1] /= size; }
c4dc5d81-96b0-497a-b200-c608f92c91a7
2
public Map<String, Object> getKeys() { if (this.keyList.size() == 0) { return null; } if (this.keyList.size() > 1) { throw new RetrievalIdException("getKeys方法只适用于单个主键的表结构,但当前表结构包含多个主键:" + this.keyList); } return this.keyList.get(0); }
4696a1ac-b923-40f1-9f82-22dabfe5df86
0
public synchronized double getValue() {return value;}
efd0f422-18bd-49ee-8c27-0c92e8edbafc
7
public void revealCells(AbstractState state) { if (state.getValue() == AbstractState.EMPTY_CELL_VALUE) { this.emptyCellRevealedCount++; } this.gameboard.setFlag(state, AbstractState.VISIBLE_FLAG); AbstractState neighbor; Flag neighborFlag; Temperament neighborTemperament; Iterator<AbstractState> i = state.getNeighborhoodIterator(); boolean revealNeighborhood = true; while (i.hasNext() && revealNeighborhood) { neighbor = i.next(); neighborTemperament = neighbor.getValue(); if (neighborTemperament == AbstractState.MINE_VALUE) { revealNeighborhood = false; } } if (revealNeighborhood) { i = state.getNeighborhoodIterator(); while (i.hasNext()) { neighbor = i.next(); neighborFlag = neighbor.getFlag(); if (neighborFlag != AbstractState.VISIBLE_FLAG) { this.revealCells(neighbor); } } } }
ffdda0ab-ef94-4a87-a33d-2b10f40b0d89
1
public ImageContainer(List<Player> Players){ terrain = new ImageIcon(this.getClass().getResource(ImageTag.TERRAIN.getFilePath())).getImage(); rivers = new ImageIcon(this.getClass().getResource(ImageTag.RIVERS.getFilePath())).getImage(); roads = new ImageIcon(this.getClass().getResource(ImageTag.ROADS.getFilePath())).getImage(); resources = new ImageIcon(this.getClass().getResource(ImageTag.RESOURCES.getFilePath())).getImage(); fog = new ImageIcon(this.getClass().getResource(ImageTag.FOG.getFilePath())).getImage(); mask = new ImageIcon(this.getClass().getResource(ImageTag.MASK.getFilePath())).getImage(); Alien_Extractors = new ImageIcon(this.getClass().getResource(imageTag.ALIEN_EXTRACTORS.getFilePath())).getImage(); Alien_Cities = new ImageIcon(this.getClass().getResource(imageTag.ALIEN_CITIES.getFilePath())).getImage(); Alien_Units = new ImageIcon(this.getClass().getResource(imageTag.ALIEN_UNITS.getFilePath())).getImage(); Health_Bar = new ImageIcon(this.getClass().getResource(imageTag.HEALTH_BAR.getFilePath())).getImage(); Shield = new ImageIcon(this.getClass().getResource(imageTag.SHIELD.getFilePath())).getImage(); Focus = new ImageIcon(this.getClass().getResource(imageTag.FOCUS.getFilePath())).getImage(); for(Player p : Players){ PlayerImage pi = p.getPlayerImage(); pi.setCities(colorBanners(Alien_Cities,p.playerColor)); pi.setExtractors(colorBanners(Alien_Extractors,p.playerColor)); pi.setUnits(colorBanners(Alien_Units,p.playerColor)); pi.setShield(colorBanners(Shield,p.playerColor)); } }
47bea3af-6883-4e31-b7d1-845f8108288c
7
@Override public Move getMove(Board board){ for(int i=0; i<Board.SIZE; i++){ for(int j=0; j<Board.SIZE; j++){ if(board.validMove(i, j, color)) moves.add(new Move(i,j)); } } if(moves.isEmpty()) return null; Move optimalMove = moves.get(0); char opponent = color == 'W' ? 'B' : 'W'; double maxScore = getScore(board, optimalMove, color, opponent); for(int i=1; i<moves.size(); i++){ Move move = moves.get(i); double score = getScore(board, move, color, opponent); if(score > maxScore){ maxScore = score; optimalMove = move; } } moves.clear(); return optimalMove; }
ecd91486-3c7b-4f63-8253-33d6d6868e8f
4
public void update() { up = keys[KeyEvent.VK_UP] || keys[KeyEvent.VK_W]; down = keys[KeyEvent.VK_DOWN] || keys[KeyEvent.VK_S]; left = keys[KeyEvent.VK_LEFT] || keys[KeyEvent.VK_A]; right = keys[KeyEvent.VK_RIGHT] || keys[KeyEvent.VK_D]; esc = keys[KeyEvent.VK_ESCAPE]; }
c8c0b306-8204-4401-81b8-15b63edeaa0c
2
private static String decodeComponent(String s, String charset){ if(s == null){ return ""; } try{ return URLDecoder.decode(s, charset); }catch(UnsupportedEncodingException e){ throw new UnsupportedCharsetException(charset); } }
5868ff78-7d6a-4ce5-9beb-a14a969dc955
7
public SinglyLinkedList<NodeType> merge(SinglyLinkedList<NodeType> otherList) { Node<NodeType> ownNode = this.head.next; Node<NodeType> otherNode = otherList.head.next; Node<NodeType> prevOwnNode = this.head; Node<NodeType> nextOtherNode; if (ownNode == this.tail) { // we are empty this.concat(otherList); return this; } else if (otherNode == otherList.tail) { // other list is empty return this; // noop } while(otherNode != otherList.tail) { while(ownNode != this.tail && (ownNode.value.compareTo(otherNode.value) < 0)) { prevOwnNode = ownNode; ownNode = ownNode.next; } nextOtherNode = otherNode.next; prevOwnNode.setNext(otherNode); otherNode.setNext(ownNode); if (ownNode.next == this.tail) { ownNode.setNext(otherNode); otherNode = nextOtherNode; break; } ownNode = otherNode; otherNode = nextOtherNode; } if (otherNode != otherList.tail) { this.tail.next.setNext(otherNode); this.tail = otherList.tail; } return this; }
3d618e65-ca5f-4262-870d-7e7860946b85
3
private boolean isTie() { Player[][] locations = this.board.getBoardLocations(); for (int row = 0; row < locations.length; row++) { Player[] rowLocations = locations[row]; for (int col = 0; col < rowLocations.length; col++) { Player location = rowLocations[col]; if (locations[row][col] == null) { return false; } } } return true; }
47a6c88b-bbdd-4465-89ca-d8e1c8e6b3f9
2
public ComplexMatrix getLocalPropagationMatrix(int index, double energy) { MatterInterval inl = intervals.get(index); MatterInterval next = intervals.get(index + 1); Complex k_ratio; // Double.POSITIVE_INFINITY is handled here and it assigns to real part of Complex if appears k_ratio = Complex.sqrt((energy - next.getY()) / (energy - inl.getY()) * inl.getMass() / next.getMass()); Complex kcp = k_ratio.add(1); // 1 + km_ratio Complex kcm = k_ratio.reverseSign().add(1); // 1 - km_ratio Complex kd = inl.getWaveNumber(energy).times(inl.getWidth()); if (VERBOSE) { System.out.println("k_ratio = " + k_ratio); System.out.println("kcp = " + kcp); System.out.println("kcm = " + kcm); System.out.println("kd = " + kd); } Complex i = new Complex(0, 1); Complex ni = i.reverseSign(); try { return new ComplexMatrix(new Complex[][]{ {kcp.times(Complex.exp(ni.times(kd))), kcm.times(Complex.exp(ni.times(kd)))}, {kcm.times(Complex.exp(i.times(kd))), kcp.times(Complex.exp(i.times(kd)))}}).multiplyEach(0.5); } catch (Exception e) { e.printStackTrace(); return null; } }
e37f5f40-67b3-488b-a0cc-5e0f8ed394cd
9
public void actionPerformed(ActionEvent arg0) { String[] tip = null; String[] bddlistgrpuser = new db().grpuserBDDList(dockerUserservice,dockerServeur,conn); if(arg0.getSource()==boutonLaunchappli){ new dock().copyFolderSave("copybusybox", dockerUserservice, dockerServeur, dockerRootpass); new dock().downloadImagesSel(tab_appli, dockerServeur, dockerRootpass); this.setVisible(false); new thirdFrame("Client Docker 1.0",400,250,dockerServeur,dockerRootpass,dockerUserservice,new dock().getPathdesktop(),dockerStartsession); }//end if bouton launchappli //Generation action for checkbox for(int ii=0;ii<bddlistgrpuser.length;ii++){ for(int i=0;i<new db().appliuserBDDcount(dockerUserservice,dockerServeur,bddlistgrpuser[ii],conn);i++){ tip = new db().appliuserBDDList(dockerUserservice,dockerServeur,bddlistgrpuser[ii],conn); if(((JCheckBox)arg0.getSource()).getText().equals(tip[i]) && ((JCheckBox)arg0.getSource()).isSelected()){ tab_appli[count_appli]=tip[i];count_appli++; } if(((JCheckBox)arg0.getSource()).getText().equals(tip[i]) && !(((JCheckBox)arg0.getSource()).isSelected())){ for(int p=0;p<tab_appli.length;p++){ if(tab_appli[p].equals(tip[i])){ tab_appli[p]=null; } } } }//end for appli }//end for group }
2378b565-a5ae-48b5-a8ae-c2fd62a0c792
4
protected void checkWhatInteractAction(Rectangle rectangle, String s) { if (s.contains("(CHANGEMAP)")) { String[] fields; fields = s.split(":"); String[] pos = (fields[2].split(",")); float x = Integer.parseInt(pos[0]); float y = Integer.parseInt(pos[1]); Vector2 playerPos = new Vector2(x, y); importMap(fields[1], playerPos); } else if (s.contains("(JUMP)")) { handleJump(rectangle); } else if (s.contains("(SCRIPT)")) { String[] fields = s.split(":"); int id = Integer.parseInt(fields[1]); Gdx.app.log(ChromeGame.LOG, "" + id); } else { if (Gdx.input.isKeyPressed(Keys.SPACE)) { onlyIfButton(s); } } }
f17a7b8a-7132-4e9b-abfe-71667b0e3dc2
1
private Collection<File> searchDirectory(File dir, String suffix) { @SuppressWarnings("unchecked") Iterator<File> iter = FileUtils.iterateFiles(dir, new String[] { suffix }, true); List<File> collector = new ArrayList<File>(); while (iter.hasNext()) collector.add(iter.next()); return collector; }
31e338fb-dd76-45ff-8a4d-bd644d183ca0
1
protected boolean getFlipX (Node contNode) throws ParseException { logger.entering(getClass().getName(), "getFlipX", contNode); boolean flipX = false; String strValue = getProcessingInstructionValue(contNode, "flip-x"); if (strValue != null) flipX = strValue.equalsIgnoreCase("true"); logger.exiting(getClass().getName(), "getFlipX", flipX); return flipX; }
04e794ea-7c4f-456f-bfc3-81da2a99694a
4
public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int factorion = -1; while (factorion < 0) { System.out.print("Please enter a positive integer (>=0): "); factorion = keyboard.nextInt(); } int secondFactorion = 0; for (int count = 0; count < Integer.toString(factorion).length(); count++) { int factorial = 1; for (int counter = Integer.parseInt(Integer.toString(factorion).substring(count,count+1)), insideCount = 1; insideCount <= counter; insideCount++) { factorial *= insideCount; } secondFactorion += factorial; } System.out.println("The integer " + factorion + ((factorion == secondFactorion)? " is" : " is not") + " a factorion."); }
32181df5-77a3-47c2-aec6-9aaa57182cfc
0
@Test public void singlePushPop() { s.push(0); assertTrue(0 == s.pop()); }
bd5f8957-8f50-4442-bb62-4e3d127bc7c9
5
public void tick(InputHandler input) { scroll += speed; scroll2 += speed; scroll %= height; scroll2 %= 16; distance += speed; if (speed < MAX_SPEED) { speed = (distance / 8 / 1000.0f) + 1; speed = Math.min(speed, MAX_SPEED); } for (int i = 0; i < entities.length; i++) { Entity e = entities[i]; if (e != null) { if (e.getY() + e.getHeight() < 0) { removeEntity(e); } e.tick(input, this); } } if (random.nextInt(64) < 2) { spawnEntity(new RenderEntity(random.nextInt(width - 8), height + 1, random.nextInt(6))); } player.tick(input, this); }
dd76df97-3e4a-4638-b52b-dad04174b8f6
6
public void drawImageAlpha(int i, int j) { int k = 128;// was parameter i += offsetX; j += offsetY; int i1 = i + j * DrawingArea.width; int j1 = 0; int k1 = height; int l1 = width; int i2 = DrawingArea.width - l1; int j2 = 0; if (j < DrawingArea.topY) { int k2 = DrawingArea.topY - j; k1 -= k2; j = DrawingArea.topY; j1 += k2 * l1; i1 += k2 * DrawingArea.width; } if (j + k1 > DrawingArea.bottomY) k1 -= (j + k1) - DrawingArea.bottomY; if (i < DrawingArea.topX) { int l2 = DrawingArea.topX - i; l1 -= l2; i = DrawingArea.topX; j1 += l2; i1 += l2; j2 += l2; i2 += l2; } if (i + l1 > DrawingArea.bottomX) { int i3 = (i + l1) - DrawingArea.bottomX; l1 -= i3; j2 += i3; i2 += i3; } if (!(l1 <= 0 || k1 <= 0)) { blockCopyAlpha(j1, l1, DrawingArea.pixels, pixels, j2, k1, i2, k, i1); } }
a2988060-1079-4b0a-9c02-249d4448e947
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PlayerImpl player = (PlayerImpl) o; if (name != null ? !name.equals(player.name) : player.name != null) return false; return true; }
32167c64-0f8f-4662-9362-fb503fc63c4e
3
@Override public int hashCode() { int result = nameLangKey != null ? nameLangKey.hashCode() : 0; result = 31 * result + (descLangKey != null ? descLangKey.hashCode() : 0); result = 31 * result + sort; result = 31 * result + (moduleId != null ? moduleId.hashCode() : 0); return result; }
1660be49-a0b8-4127-839c-d6a231e0585b
7
public Set<Coordinate> getLegalMoves(Coordinate startingCoord, Board board) { // three types of legal moves: // -take diagonally (if opposing color piece is present) // -move up one // -move up two (in starting position) // -ampasant - dont handle this yet Set<Coordinate> legalLocations = new LinkedHashSet<Coordinate> (); Set<Coordinate> possibleTakes = possibleTakes(startingCoord); for (Coordinate coord : possibleTakes) { if (board.contains(coord) && !board.isEmpty(coord.getCol(), coord.getRow()) && board.getPiece(coord).color != color) legalLocations.add(coord); } Set<Coordinate> possibleMoves = possibleMoves(startingCoord); for (Coordinate coord : possibleMoves) { if (board.contains(coord) && board.isEmpty(coord.getCol(), coord.getRow())) legalLocations.add(coord); else break; } return legalLocations; }
49e1849a-4002-4f54-8480-f4e454852dbd
4
public String toString() { StringBuffer sb = new StringBuffer().append(clazzAnalyzer.getClazz()) .append(".OuterValues["); String comma = ""; int slot = 1; for (int i = 0; i < headCount; i++) { if (i == headMinCount) sb.append("<-"); sb.append(comma).append(slot).append(":").append(head[i]); slot += head[i].getType().stackSize(); comma = ","; } if (jikesAnonymousInner) sb.append("!jikesAnonymousInner"); if (implicitOuterClass) sb.append("!implicitOuterClass"); return sb.append("]").toString(); }
8cfac9e1-3c74-488b-afee-923de2ebce6d
2
public Conditional getRuleAnswer(int id) { Conditional ans=null; try{ stat.setQueryTimeout(30); ResultSet rs = stat.executeQuery("SELECT * FROM Answer WHERE RuleId ="+id+";"); boolean b = rs.getInt("NotFlag") ==1 ? true : false ; ans = new Conditional(ARKS.Facts.get(rs.getInt("FactId")-1),b); }catch (Exception e){ System.out.println("Getting Rule Answer Failed"); System.out.println(e.getMessage()); } return ans; }
81713800-cf3e-4a37-b8c8-6cf068c95c65
4
@Override public void move(Point startMove, Point endMove, int canvasWidth, int canvasHeight) { if(((x + endMove.getX()-startMove.getX()) > 0) && ((y + endMove.getY()-startMove.getY()) > 0) && ((x + width + endMove.getX()-startMove.getX()) < canvasWidth) && ((y + height + endMove.getY()-startMove.getY()) < canvasHeight) ) { x += endMove.getX()-startMove.getX(); y += endMove.getY()-startMove.getY(); punkt2X += endMove.getX()-startMove.getX(); punkt2Y += endMove.getY()-startMove.getY(); } }
5cf07513-255e-4955-91cb-7a8f0ff73633
7
public ListNode reverseKGroup(ListNode head, int k) { // Start typing your Java solution below // DO NOT write main() function if (k <= 1 || head == null) return head; ListNode root = new ListNode(0); root.next = head; ListNode pre = root; ListNode cur = head; while (true) { ListNode tmp = cur; int i = 0; // whether can rotate for (i = 0; i < k; i++) { if (tmp == null) { break; } tmp = tmp.next; } if (i < k) break; // rotate ListNode remain = cur; tmp = cur.next; ListNode suf = null; for (i = 0; i < k - 1; i++) { suf = tmp.next; tmp.next = cur; cur = tmp; tmp = suf; } pre.next = cur; remain.next = suf; pre = remain; cur = suf; } return root.next; }
5d597b6c-d2bf-4cce-8bc4-5bb94139919b
9
@SuppressWarnings("rawtypes") private Class getServiceInterface(Resource resource, ClassLoader classLoader) { try { if (!resource.isReadable()) return null; AnnotationTypeFilter filter = new AnnotationTypeFilter(Remote.class); SimpleMetadataReaderFactory simpleMetadataReaderFactory = new SimpleMetadataReaderFactory( classLoader); MetadataReader metadataReader = simpleMetadataReaderFactory .getMetadataReader(resource); if (filter.match(metadataReader, simpleMetadataReaderFactory)) { String className = metadataReader.getClassMetadata() .getClassName(); if (LOGGER.isDebugEnabled()) LOGGER.debug("{} annotated with @Remote", className); return ClassUtils.forName(className, classLoader); } } catch (IOException e) { if (LOGGER.isErrorEnabled()) LOGGER.error(e.toString()); } catch (ClassNotFoundException e) { if (LOGGER.isErrorEnabled()) LOGGER.error(e.toString()); } catch (LinkageError e) { if (LOGGER.isErrorEnabled()) LOGGER.error(e.toString()); } return null; }
db27ff62-2e0b-49ea-826a-474e22d480d1
9
void processResponseHeaders(Map<String, List<String>> resHeaders) { for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) { String name = entry.getKey(); if (name == null) continue; // http/1.1 line List<String> values = entry.getValue(); if (name.equalsIgnoreCase("Set-Cookie")) { for (String value : values) { if (value == null) continue; TokenQueue cd = new TokenQueue(value); String cookieName = cd.chompTo("=").trim(); String cookieVal = cd.consumeTo(";").trim(); if (cookieVal == null) cookieVal = ""; // ignores path, date, domain, secure et al. req'd? // name not blank, value not null if (cookieName != null && cookieName.length() > 0) cookie(cookieName, cookieVal); } } else { // only take the first instance of each header if (!values.isEmpty()) header(name, values.get(0)); } } }
6beb290a-f550-43d4-9eb0-e4b371e1f756
2
private boolean writePlaneColByCol(double[][] src, byte[] tmp, int startPos, int height) { try { for (int y = 0; y < height; y++) { tmp[y] = (byte)(src[y+startPos][0] + 0.5); } dos.write(tmp); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
f72eecc0-34bb-4f52-acd8-eb66a848681e
8
public static int maximalRectangle(char[][] matrix) { int n = matrix.length; if(n == 0) { return 0; } int m = matrix[0].length; if(m == 0) { return 0; } int[][] rectangleMatrix = new int[n][m]; for(int i=0;i<m;i++) { rectangleMatrix[0][i] = Integer.valueOf(matrix[0][i])-48; } for(int j=1;j<n;j++) { for(int i=0;i<m;i++) { if(Integer.valueOf(matrix[j][i]) == 48) { rectangleMatrix[j][i] = 0; }else { rectangleMatrix[j][i] = rectangleMatrix[j-1][i] + 1; } } } int max = 0; for(int j=0;j<n;j++) { int tmp = maximalInRow(rectangleMatrix[j], m); if(tmp > max) { max = tmp; } } return max; }
4046fd05-232b-463a-8232-45589904f15b
8
@Override public void update() { if(++updateCount >= REGEN_TIME) { updateCount = 0; amount++; updateImage(); } if(amount < 0) { getWorld().removeStructure(this); } else if(amount > SPREAD) { Set<Tile> neighbours = new HashSet<Tile>(); neighbours.add(getWorld().getTile(getX()-1, getY())); neighbours.add(getWorld().getTile(getX()+1, getY())); neighbours.add(getWorld().getTile(getX(), getY()+1)); neighbours.add(getWorld().getTile(getX(), getY()-1)); neighbours.remove(null); if(neighbours.size() > 0) { List<Tile> list = new ArrayList<Tile>(neighbours); Collections.shuffle(list); Tile t = list.get(0); if(t.getStructure() == null && t.getHeight() == getWorld().getTile(getX(),getY()).getHeight()) { getWorld().addStructure(new Crystal(t.getX(), t.getY())); amount = HALF; } } updateImage(); } if(amount >= MAX) shouldOctoMine = true; if(amount <= MIN/2) shouldOctoMine = false; }
e47b180a-b844-42cc-ab7f-ab98ceeb6895
4
@Override public void update(Observable arg0, Object roomState) { status = (GameStatus)roomState; game = (Grid) arg0; if(status == GameStatus.SHOTMISSED) game.RevealRooms(); else if(status == GameStatus.SHOTHIT) game.RevealRooms(); else if(status == GameStatus.DIEDWUMPUS) game.RevealRooms(); else if(status == GameStatus.DIEDPIT) game.RevealRooms(); repaint(); }
09636763-3d5a-41f9-9a7c-7544a3daa5cc
0
public Map<String, Long> getStatistics() { throw new RuntimeException("not implemented"); }
4754e16d-24ea-4974-adab-ac6761fe71a1
8
public void setSelected(String tool, boolean yn) { int N = this.getComponentCount(); int i = 0; for (i = 0; i < N && !this.getComponent(i).getClass().equals(JButton.class); i++) ; if (i < N) { Object o = this.getComponent(i); JButton b = (JButton) o; while (i < N && !b.getActionCommand().equals(tool)) { i += 1; if (i < N) { o = this.getComponent(i); if (o.getClass().equals(JButton.class)) { b = (JButton) o; } } } if (i < N) { JXMLNoteIcon icon = (JXMLNoteIcon) b.getIcon(); icon.setSelected(yn); b.updateUI(); } } }
c86f523f-c9ec-4750-b4bb-ec97aa77b3f7
3
public synchronized int getItem() throws InterruptedException { if(warehouse.isEmpty()||warehouse.iterator().next()==null||consumedItemsCount>=warehouse.size()) wait(); return warehouse.get(consumedItemsCount++) ; }
bee6c3b8-68dc-494d-bf73-b8e9fe620f99
8
public static void main(String[] args) { String[] cards = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K","A"}; String[] faces = { "♠", "♥","♦","♣"}; int fullHouseCount = 0; for (int f = 0; f <=12; f++) { for (int i = 0; i <=1; i++) { for (int j = i+1; j <=2; j++) { for (int k = j+1; k <=3; k++) { for (int s = 0; s <= 12; s++) { if(s!=f){ for(int i1=0;i1<=2;i1++){ for (int j1 = i1+1; j1 <=3; j1++) { System.out.printf("%s%s%s%s%s%s%s%s%s%s", cards[f],faces[i], cards[f],faces[j], cards[f],faces[k], cards[s],faces[i1], cards[s],faces[j1]); System.out.println(); fullHouseCount++; } } } } } } } } System.out.println(fullHouseCount); }
fbbc3c7d-09b2-4eaa-b9ac-5a36e00e75f1
5
private void rawpath(Rectangle rec) { boolean hori = rec.width < rec.height; int doors = 0; for (int y = rec.y; y < rec.y + rec.height; y++) { for (int x = rec.x; x < rec.x + rec.width; x++) { if (data[y][x] == null) { data[y][x] = new Floor(x, y); } else { if (data[y][x] instanceof Wall) { data[y][x] = new Door(x, y, hori); doors++; if (doors >= 2) { return; } } } } } }
46281dcb-2aea-4b34-82ed-74db71b01aca
5
@Override public boolean verifier() throws SemantiqueException { super.verifier(); if(gauche.isBoolean()){ setBoolean(); if(!droite.isBoolean()) GestionnaireSemantique.getInstance().add(new SemantiqueException("Expression droite arithmetique, booleenne attendue pour le XOR ligne:"+line+" colonne:"+col)); }else{ if(droite.isBoolean()) { if(gauche instanceof Nombre && ((Nombre) gauche).getNombre()==0){ setBoolean(); ((Nombre) gauche).setNombre(1); }else GestionnaireSemantique.getInstance().add(new SemantiqueException("Expression droite booléenne, arithmetique attendu pour Soustraction ligne:"+line+" colonne:"+col)); } } return true; }
3e3f8f87-3b71-47cd-ae8b-9aa1241adabd
4
public static String displayTokens(double minimumTFIDF, double minimumIDF) { String tempOutput = ""; String output = ""; int tokenCount = 0; Iterator iterator = dictionaryMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry termEntry = (Map.Entry) iterator.next(); String key = (String) termEntry.getKey(); ArrayList<String[]> postingsList = (ArrayList) termEntry.getValue(); Double[] iDFArray = (Double[]) inverseDocFreqMap.get(key); double IDFValue = iDFArray[IDF]; if (IDFValue >= minimumIDF) { tokenCount++; tempOutput = tempOutput + "Token: '" + key + "'\n"; tempOutput = tempOutput + "iDF: " + df.format(IDFValue) + "\n"; for (int i = 0; i < postingsList.size(); i++) { if (Double.parseDouble(postingsList.get(i)[TFIDF_WEIGHT]) >= minimumTFIDF) { tempOutput = tempOutput + postingsList.get(i)[DOC_NAME]; tempOutput = tempOutput + "; tf: " + df.format(Double.parseDouble(postingsList.get(i)[TERM_FREQ])); tempOutput = tempOutput + "; tf-idf: " + df.format(Double.parseDouble(postingsList.get(i)[TFIDF_WEIGHT])) + "\n"; } } tempOutput = tempOutput + "\n"; } } output = output + "Total tokens: " + tokenCount + "\n\n" + tempOutput; return output; }
df0a4cab-468c-419b-96ca-2f8eb9c89803
4
public void move(){ x=x+xspeed; y=y+yspeed; if(x>1600) {isFired=false;x=0;y=0;} if(x<0) {isFired=false;x=0;y=0;} if(y>1000) {isFired=false;x=0;y=0;} if(y<0) {isFired=false;x=0;y=0;} }
5f088d2a-3b8a-4c37-899d-4ad09df093c9
8
public Color get_field_as_colour( String section, String field ) throws NoSuchKeyException, NoSuchSectionException, BadFormatException { String s; s = get_field( section, field ); s = s.toLowerCase().trim(); if( s.equals( "black" )) { return ( Color.black ); } if( s.equals( "white" )) { return ( Color.white ); } if( s.equals( "red" )) { return ( Color.red ); } if( s.equals( "green" )) { return ( Color.green ); } if( s.equals( "blue" )) { return ( Color.blue ); } if( s.equals( "yellow")) { return ( Color.yellow); } if( s.equals( "cyan" )) { return ( Color.cyan ); } if( s.equals( "magenta")) { return ( Color.magenta ); } StringTokenizer tok = new StringTokenizer( get_field( section, field ), "," ); int r = Integer.parseInt( tok.nextToken() ); int g = Integer.parseInt( tok.nextToken() ); int b = Integer.parseInt( tok.nextToken() ); return new Color( r,g,b ); }
0f4b2c72-af9a-48b1-a8cb-5c04dd9bc9e9
8
public static long getPermutationCount( final List<LocationList> variations ) { if (( null == variations ) || ( 0 == variations.size() )) return 0; long count = 0; for ( int variationi = 0; variationi < variations.size(); variationi++ ) { LocationList enharmonics = variations.get( variationi ); if ( count == 0 ) { if (( null != enharmonics ) && ( 0 < enharmonics.size() )) count = enharmonics.size(); } else { if (( null != enharmonics ) && ( 0 < enharmonics.size() )) count *= enharmonics.size(); } } return count; }
beb74c9f-22a8-46fa-9713-88ea36946dd7
3
@Override public int getNumWolves() { int tempInt = 0; while(true){ tempInt = getIntFromUser("PLEASE CHOOSE HOW MANY OF WOLVES"); if((tempInt <= 0) || (tempInt >= this.players)) { displayError("You must have at least one wolf,\n " + "but fewer than the total number of players"); } else { break; } } this.wolves = tempInt; return wolves; }
59fa0f22-2d12-4124-9fc1-923abd5aaa6b
2
private void saveMenuItem_actionPerformed(ActionEvent event) { JFileChooser fileChooser = createFileChooser(); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); fileChooser.showSaveDialog(this); File file = fileChooser.getSelectedFile(); if (file != null) { defaultDirectory = fileChooser.getCurrentDirectory(); try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) { randomAccessFile.writeBytes(receivedText.getText()); randomAccessFile.close(); } catch (Exception ex) { Logger.getLogger(MonitorConsole.class.getName()).log(Level.SEVERE, "saveMenuItem_ActionPerformed", ex); } } }
9c7eaeb5-082c-4dba-85e4-b46914d1518e
0
public Encargo(int idEncargo, int cliente, GregorianCalendar fechaEncargo, String horaEncargo, String fechaRecogida, String horaRecogida, int ubicacion, double total, double entrega) { this.idEncargo = idEncargo; this.cliente = cliente; this.fechaEncargo = fechaEncargo; this.horaEncargo = horaEncargo; this.fechaRecogida = fechaRecogida; this.horaRecogida = horaRecogida; this.ubicacion = ubicacion; this.total = total; this.entrega = entrega; }
7369567a-a7de-41b6-b6f0-56ed79655c98
4
public Controls(GameWindow gameWindow) { boolean test = false; if (test || m_test) { System.out.println("Controls :: Controls() BEGIN"); } setGameWindow(gameWindow); int width = getGameWindow().getDrawing().gameBoardGraphics .getSquareWidth(); GameBoardControls boardControls = new GameBoardControls(width,width, this); getGameWindow().getDrawing().getGridPanel().addMouseListener( boardControls); if (test || m_test) { System.out.println("Controls :: Controls() END"); } }
28ee6c2e-79bc-4edc-be1f-a94dfd233acc
3
public Map<String, String> buildKeyWordMap(File indexFile) { Map<String, String> result = new HashMap<String, String>(); try { BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream(indexFile))); String s; while((s = reader.readLine()) != null) { String[] indexArray = s.split("\t"); String keyWord = indexArray[0].toLowerCase(); String index = indexArray[1].replaceFirst(Constants.SPLIT_FLAG, ""); if (result.containsKey(keyWord)) { index = index + Constants.SPLIT_FLAG + result.get(keyWord); } result.put(keyWord, index); } reader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
a320f2e0-1fe1-4165-8553-1714bc780b21
5
*/ public static String askForHighScore() { String playerName = ""; goToPostRaceScreen = false; try { while (!exit && !goToPostRaceScreen) { // If the display is not visible (minimised), add much more // delay if (!Display.isVisible()) { Thread.sleep(200); } // If the display is requested to close, exit the program else if (Display.isCloseRequested()) exit = true; // Otherwise, make the thread delay for a bit to let other // threads catch up else Thread.sleep(10); // Update the timer, handle the inputs (and reset the player // name), draw and update the screen updateTimer(); playerName = handleAskHighScoreInputs(playerName); drawAskHighScore(playerName); Display.update(); } } catch (Exception exception) { System.out.println("exitPrompt().run() error: " + exception); } return playerName; }
30e6f8a5-5aaf-409d-a7f3-37a6116fe68f
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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(FloatParameterEditDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(FloatParameterEditDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(FloatParameterEditDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(FloatParameterEditDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FloatParameterEditDialog().setVisible(true); } }); }
86b50131-8969-4529-a695-e01668d91e47
0
public CreditCard(int amount) { this.acceptability = new AcceptedEverywhere(); this.balance = 0; this.creditLimit = amount; }
e91613d6-832c-4c7f-9152-3a719c53d1ae
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Literal literal = (Literal) o; if (id != literal.id) return false; if (!Arrays.equals(entries, literal.entries)) return false; return true; }
e591a62e-3f34-4b0b-8abf-0028f1eeebee
2
private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterActionPerformed if (!txtUsername.getText().trim().isEmpty() && !new String(txtPassword.getPassword()).trim().isEmpty()) { this.cp.username = txtUsername.getText(); this.cp.password = new String(txtPassword.getPassword()); txtUsername.setEnabled(false); txtPassword.setEnabled(false); btnLogin.setEnabled(false); btnRegister.setEnabled(false); btnRegister.setText("Loading..."); this.currentState = LauncherState.REGISTERING; LoadCaptchaWorker lcw = new LoadCaptchaWorker(cp, txtUsername.getText(), new String(txtPassword.getPassword())); lcw.execute(); } }//GEN-LAST:event_btnRegisterActionPerformed
2b2a1b13-24c4-4922-a832-51d1da98c29b
1
public static BufferedImage loadSingle(String s) { BufferedImage img; try { img = ImageIO.read(Images.class.getResourceAsStream(s)); return img; } catch (IOException e) { e.printStackTrace(); Print.say("Error Loading single image"); } return null; }
b649879c-55b1-495e-933c-50ad34d42125
9
Page readPageData(RandomAccessFile raf) throws IOException { PageId pid; Page newPage = null; String pageClassName = raf.readUTF(); String idClassName = raf.readUTF(); try { Class<?> idClass = Class.forName(idClassName); Class<?> pageClass = Class.forName(pageClassName); Constructor<?>[] idConsts = idClass.getDeclaredConstructors(); int numIdArgs = raf.readInt(); Object idArgs[] = new Object[numIdArgs]; for (int i = 0; i<numIdArgs;i++) { idArgs[i] = new Integer(raf.readInt()); } pid = (PageId)idConsts[0].newInstance(idArgs); Constructor<?>[] pageConsts = pageClass.getDeclaredConstructors(); int pageSize = raf.readInt(); byte[] pageData = new byte[pageSize]; raf.read(pageData); //read before image Object[] pageArgs = new Object[2]; pageArgs[0] = pid; pageArgs[1] = pageData; newPage = (Page)pageConsts[0].newInstance(pageArgs); // Debug.log("READ PAGE OF TYPE " + pageClassName + ", table = " + newPage.getId().getTableId() + ", page = " + newPage.getId().pageno()); } catch (ClassNotFoundException e){ e.printStackTrace(); throw new IOException(); } catch (InstantiationException e) { e.printStackTrace(); throw new IOException(); } catch (IllegalAccessException e) { e.printStackTrace(); throw new IOException(); } catch (InvocationTargetException e) { e.printStackTrace(); throw new IOException(); } return newPage; }
f5253aad-f124-42b6-a868-6c39d8fd4152
6
private int buildHistory(ColumnSet set, JPanel panel) { NumberFormat formatter = new DecimalFormat("##.##"); int numRows = getNumRows(set); int numChildren = getNumChildren(set); for (int r=0; r<numRows; r++) { Color backColor; if (r % 2 == 0) backColor = darkColor; else backColor = lightColor; int index = 0; for (int p=0; p<set.getNumParents(); p++) { ColumnParent parent = set.getParent(p); for (int c=0; c<parent.getNumChildren(); c++) { JPanel columnPanel = new JPanel(); JLabel columnLabel = new JLabel(); ColumnChild child = parent.getChild(c); String data = ""; if (r >= child.getNumData() || child.getData(r) == null) data = ""; else data = child.getData(r); columnLabel.setText(data); columnLabel.setForeground(Color.black); columnLabel.setHorizontalAlignment(SwingConstants.CENTER); columnPanel.add(columnLabel); columnPanel.setBackground(backColor); GridBagConstraints constraints = getChildConstraints(index == (numChildren - 1)); gridbag.setConstraints(columnPanel, constraints); panel.add(columnPanel); index++; } } } return numRows; }
2f0c8475-a4bd-4c04-ba7d-9c0207fcb59a
0
public SootClass getViewClass() { return this.viewClass; }
1f4f6d8c-2a16-4b87-a3d9-6eaee04d36ce
2
public List<Material> getEatableItems() { List<String> fakeMaterials = mainConfig.getStringList("Eatable items"); List<Material> realMaterials = new ArrayList<Material>(); for (String fakeMaterial: fakeMaterials) { Material mat = Material.getMaterial(fakeMaterial.toUpperCase().trim()); if (mat != null) { realMaterials.add(mat); } } return realMaterials; }
ec1b1566-3962-4c90-a59c-b0b9101b5d5f
2
private int max(int[] values) { int max = 0; for (int i=0; i<values.length; i++) { if (values[i] > max) { max = values[i]; } } return max; }
bc078ac9-4303-4d0e-9c5b-51d258d3c078
6
public void getInterfaces(Object calledObj, String methodName, Class[] paramTypes, Object[] paramValues) { this.calledObj = calledObj; this.paramTypes = paramTypes; this.paramValues = paramValues; Class classObj = (calledObj instanceof Class) ? (Class)calledObj : calledObj.getClass(); Class[] interfaces = classObj.getInterfaces(); for (int i=0; i< interfaces.length; i++) { try { calledMethod = interfaces[i].getMethod(methodName, paramTypes); System.out.println("callerMethod from " + interfaces[i].getName() + " = " + calledMethod.getName()); } catch(NoSuchMethodException exp) { continue; } catch(SecurityException exp) { exp.printStackTrace(); return; } } //If called method was not found in interfaces, then //try to find that in object // if (calledMethod==null) try { calledMethod = classObj.getMethod (methodName, paramTypes); System.out.println("callerMethod from Class= " + calledMethod.getName()); }catch (Exception e) { e.printStackTrace(); } System.out.println("The final value of calledMethod is "); }
5abdf541-2273-4dba-8bf3-6929c576c199
4
private void readAndPrint() throws IOException { PushbackInputStream f = new PushbackInputStream(System.in, 3); int c, c1, c2; while ((c = f.read()) != 'q') { switch (c) { case '.': System.out.print((char) c); if ((c1 = f.read()) == '0') { if ((c2 = f.read()) == '0') { System.out.print("**"); } else { f.unread(c2); f.unread(c1); } } else { f.unread(c1); } break; default: System.out.print((char) c); break; } } f.close(); }
587fce9c-f8cd-467b-8b28-9618ce8c83ad
2
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { // Check that the row is not selected. JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (!isSelected) { label.setBackground(row % 2 == 0 ? Color.LIGHT_GRAY : Color.WHITE); } return label; }
43f8a9a6-d01f-4a6f-8186-5d179274b4b3
1
public String toString(){ String str = identifier.getNewName(false); if(expression != null) str += "=" + expression.toString(); return str; }
7d99e3b9-4f90-4165-9ddc-c51fcde31468
9
public int[][] floyd(int[][] g) { int[][] x = getG(); for (int[] x1 : x) { for (int j = 0; j < x.length; j++) { if (x1[j] == 0) { x1[j] = -1; } } } for (int k = 0; k < g.length; k++) { for (int i = 0; i < g.length; i++) { for (int j = 0; j < g.length; j++) { if (i != j) { if (x[i][k] != -1 && x[k][j] != -1) { x[i][j] = Math.min(x[i][j], x[i][k] + x[k][j]); } } } } } return x; }
79fbcd87-b5a3-4e57-a91a-1ac0a11056b3
4
private void deepCleanTrees(Model mod){ for(int i=0;i<mod.getDamiera().getDim();i++) for(int j=0;j<mod.getDamiera().getDim();j++) if(!mod.getDamiera().isFreePos(new Posizione(i,j)) && !mod.getDamiera().getPezzo(new Posizione(i,j)).isNullAM()){ mod.getDamiera().getPezzo(new Posizione(i,j)).getAlberoMosse().clean(); } }
9a40c1bc-f018-4657-ac61-be1d0aee1271
3
private static void activateIndexHTML(Request request, Response response) throws Exception { if (isCookeOK(request)) { response.setRedirect("/smtp/main.html", request.GetHttpVer()); return; } if (request.getParams().get(COOKE_PARAM) != null) { if (Helper.EmailValidator(request.getParams().get(COOKE_PARAM))) { response.addHeader("Set-Cookie", COOKIE_NAME + request.getParams().get(COOKE_PARAM)); } response.setRedirect(Server.prop.getProperty("defaultPage"), request.GetHttpVer()); return; } }
f07d6dcf-e5b2-462e-bb98-d258a2418f3a
6
public void Drop() { //assume the block can drop unless we find otherwise boolean movable = true; for( int i = 0; i < 4; i++ ) { int newLevel = currentBlock.yvalues[i] - 1; //if there is something below currentBlock then it can't //go any further down if( currentBlock.yvalues[i] == 0 || colorGrid[newLevel][currentBlock.xvalues[i]].isSet == true ) movable = false; } //if it can move then decrement the y values if( movable ) { for( int j = 0; j < 4; j++ ) currentBlock.yvalues[j] -= 1; currentBlock.yposition--; } //otherwise set it into the grid else { for( int k = 0; k < 4; k++ ) { colorGrid[currentBlock.yvalues[k]][currentBlock.xvalues[k]].isSet = true; colorGrid[currentBlock.yvalues[k]][currentBlock.xvalues[k]].r = currentBlock.red; colorGrid[currentBlock.yvalues[k]][currentBlock.xvalues[k]].g = currentBlock.green; colorGrid[currentBlock.yvalues[k]][currentBlock.xvalues[k]].b = currentBlock.blue; } BlockIsActive = false; //since the block has been added to the //grid it is no longer active } }
5154cfc7-8c7b-49d2-927e-084626fa5534
9
protected void zsort (Vector v, int lo0, int hi0) { int lo = lo0; int hi = hi0; double mid; if (hi0 > lo0) { mid = ((dlentry) v.elementAt ((lo0 + hi0) / 2)).zvalue (); while (lo <= hi) { while ((lo < hi0) && (((dlentry) v.elementAt (lo)).zvalue () < mid)) ++lo; while ((hi > lo0) && (((dlentry) v.elementAt (hi)).zvalue () > mid)) --hi; if (lo <= hi) { Object temp; temp = v.elementAt (lo); v.setElementAt (v.elementAt (hi), lo); v.setElementAt (temp, hi); ++lo; --hi; } } if (lo0 < hi) zsort (v, lo0, hi); if (lo < hi0) zsort (v, lo, hi0); } }
833befb3-9f50-4d85-a6b4-0d7fff6380b0
9
public int pit1(Block set, Material m, BlockFace bf) { int x = 1; int a = gen.nextInt(30); if (a < 12) { a = 12; } while (x < a) { int newx = x - 1; Block otherset = set.getRelative(bf, newx); Block clr10 = otherset.getRelative(BlockFace.DOWN, 1); Block clr20 = otherset.getRelative(BlockFace.DOWN, 2); Block clr30 = otherset.getRelative(BlockFace.DOWN, 3); Block clr40 = otherset.getRelative(BlockFace.DOWN, 4); Block clr50 = otherset.getRelative(BlockFace.DOWN, 5); Block clr60 = otherset.getRelative(BlockFace.DOWN, 6); Block clr70 = otherset.getRelative(BlockFace.DOWN, 7); Block set1 = otherset.getRelative(BlockFace.SOUTH, 1); Block clr1 = set1.getRelative(BlockFace.DOWN, 1); Block clr2 = set1.getRelative(BlockFace.DOWN, 2); Block clr3 = set1.getRelative(BlockFace.DOWN, 3); Block clr4 = set1.getRelative(BlockFace.DOWN, 4); Block clr5 = set1.getRelative(BlockFace.DOWN, 5); Block clr6 = set1.getRelative(BlockFace.DOWN, 6); Block clr7 = set1.getRelative(BlockFace.DOWN, 7); Block set2 = set1.getRelative(BlockFace.SOUTH, 1); Block clr11 = set2.getRelative(BlockFace.DOWN, 1); Block clr21 = set2.getRelative(BlockFace.DOWN, 2); Block clr31 = set2.getRelative(BlockFace.DOWN, 3); Block clr41 = set2.getRelative(BlockFace.DOWN, 4); Block clr51 = set2.getRelative(BlockFace.DOWN, 5); Block clr61 = set2.getRelative(BlockFace.DOWN, 6); Block clr71 = set2.getRelative(BlockFace.DOWN, 7); Block set1111 = set2.getRelative(BlockFace.SOUTH, 1); Block clr111 = set1111.getRelative(BlockFace.DOWN, 1); Block clr211 = set1111.getRelative(BlockFace.DOWN, 2); Block clr311 = set1111.getRelative(BlockFace.DOWN, 3); Block clr411 = set1111.getRelative(BlockFace.DOWN, 4); Block clr511 = set1111.getRelative(BlockFace.DOWN, 5); Block clr611 = set1111.getRelative(BlockFace.DOWN, 6); Block clr711 = set1111.getRelative(BlockFace.DOWN, 7); Block set2111 = set1111.getRelative(BlockFace.SOUTH, 1); Block clr1111 = set2111.getRelative(BlockFace.DOWN, 1); Block clr2111 = set2111.getRelative(BlockFace.DOWN, 2); Block clr3111 = set2111.getRelative(BlockFace.DOWN, 3); Block clr4111 = set2111.getRelative(BlockFace.DOWN, 4); Block clr5111 = set2111.getRelative(BlockFace.DOWN, 5); Block clr6111 = set2111.getRelative(BlockFace.DOWN, 6); Block clr7111 = set2111.getRelative(BlockFace.DOWN, 7); Block set3111 = set2111.getRelative(BlockFace.SOUTH, 1); Block clr11111 = set3111.getRelative(BlockFace.DOWN, 1); Block clr21111 = set3111.getRelative(BlockFace.DOWN, 2); Block clr31111 = set3111.getRelative(BlockFace.DOWN, 3); Block clr41111 = set3111.getRelative(BlockFace.DOWN, 4); Block clr51111 = set3111.getRelative(BlockFace.DOWN, 5); Block clr61111 = set3111.getRelative(BlockFace.DOWN, 6); Block clr71111 = set3111.getRelative(BlockFace.DOWN, 7); Block set4111 = set3111.getRelative(BlockFace.SOUTH, 1); Block clr5111111 = set4111.getRelative(BlockFace.DOWN, 5); Block set3 = otherset.getRelative(BlockFace.SOUTH, 1); Block clr111111 = set3.getRelative(BlockFace.DOWN, 1); Block clr211111 = set3.getRelative(BlockFace.DOWN, 2); Block clr311111 = set3.getRelative(BlockFace.DOWN, 3); Block clr411111 = set3.getRelative(BlockFace.DOWN, 4); Block clr511111 = set3.getRelative(BlockFace.DOWN, 5); Block clr611111 = set3.getRelative(BlockFace.DOWN, 6); Block clr711111 = set3.getRelative(BlockFace.DOWN, 7); int other = gen.nextInt(3); set3.setType(m); set3.setData((byte)other); int ran2 = gen.nextInt(3); otherset.setType(m); otherset.setData((byte)ran2); int ran = gen.nextInt(3); set1.setType(m); set1.setData((byte)ran); int ran1 = gen.nextInt(3); set2.setType(m); set2.setData((byte)ran1); int ran1111 = gen.nextInt(3); set1111.setType(m); set1111.setData((byte)ran1111); int ran2111 = gen.nextInt(3); set2111.setType(m); set2111.setData((byte)ran2111); int ran3111 = gen.nextInt(3); set3111.setType(m); set3111.setData((byte)ran3111); int ran4111 = gen.nextInt(3); set4111.setType(m); set4111.setData((byte)ran4111); Block set5 = set4111.getRelative(BlockFace.DOWN, 1); Block set6 = set5.getRelative(BlockFace.DOWN, 1); Block set7 = set6.getRelative(BlockFace.DOWN, 1); Block set8 = set7.getRelative(BlockFace.DOWN, 1); Block set51 = set8.getRelative(BlockFace.DOWN, 1); Block set61 = set51.getRelative(BlockFace.DOWN, 1); Block set71 = set61.getRelative(BlockFace.DOWN, 1); Block set81 = set71.getRelative(BlockFace.DOWN, 1); int ran3 = gen.nextInt(3); int ran7 = gen.nextInt(3); int ran5 = gen.nextInt(3); int ran6 = gen.nextInt(3); set5.setType(m); int rtorch1 = gen.nextInt(5); if (rtorch1 == 1) { byte flags = 5; set5.setType(Material.TORCH); set5.setTypeIdAndData(50, flags, true); } set5.setData((byte)ran3); set6.setType(m); set6.setData((byte)ran7); set7.setType(m); set7.setData((byte)ran5); set8.setType(m); set8.setData((byte)ran6); int ran31 = gen.nextInt(3); int ran71 = gen.nextInt(3); int ran51 = gen.nextInt(3); int ran61 = gen.nextInt(3); set51.setType(m); int rtorch11 = gen.nextInt(5); if (rtorch11 == 1) { byte flags = 5; set5.setType(Material.TORCH); set5.setTypeIdAndData(50, flags, true); } set51.setData((byte)ran31); set61.setType(m); set61.setData((byte)ran71); set71.setType(m); set71.setData((byte)ran51); set81.setType(m); set81.setData((byte)ran61); Block set9 = set81.getRelative(BlockFace.NORTH, 1); Block set10 = set9.getRelative(BlockFace.NORTH, 1); Block set11 = set10.getRelative(BlockFace.NORTH, 1); Block set12 = set11.getRelative(BlockFace.NORTH, 1); Block set91 = set12.getRelative(BlockFace.NORTH, 1); Block set101 = set91.getRelative(BlockFace.NORTH, 1); Block set111 = set101.getRelative(BlockFace.NORTH, 1); Block set121 = set111.getRelative(BlockFace.NORTH, 1); Block set122 = set1.getRelative(BlockFace.NORTH, 2); int ran11 = gen.nextInt(3); int ran8 = gen.nextInt(3); int ran9 = gen.nextInt(3); int ran10 = gen.nextInt(3); set9.setType(m); set9.setData((byte)ran11); set10.setType(m); set10.setData((byte)ran8); set11.setType(m); set11.setData((byte)ran9); set12.setType(m); set12.setData((byte)ran10); int ran91 = gen.nextInt(3); int ran101 = gen.nextInt(3); int ran111 = gen.nextInt(3); int ran121 = gen.nextInt(3); set91.setType(m); set91.setData((byte)ran91); set101.setType(m); set101.setData((byte)ran101); set111.setType(m); set111.setData((byte)ran111); set121.setType(m); set121.setData((byte)ran121); set122.setType(m); set122.setData((byte)ran1); Block set13 = set121.getRelative(BlockFace.UP, 1); Block set14 = set13.getRelative(BlockFace.UP, 1); Block set15 = set14.getRelative(BlockFace.UP, 1); Block set16 = set15.getRelative(BlockFace.UP, 1); Block set17 = set16.getRelative(BlockFace.UP, 1); Block set18 = set17.getRelative(BlockFace.UP, 1); Block set19 = set18.getRelative(BlockFace.UP, 1); Block set20 = set19.getRelative(BlockFace.UP, 1); int ran12 = gen.nextInt(3); int ran13 = gen.nextInt(3); int ran14 = gen.nextInt(3); int ran15 = gen.nextInt(3); set13.setType(m); set13.setData((byte)ran12); set14.setType(m); set14.setData((byte)ran13); set15.setType(m); set15.setData((byte)ran14); set16.setType(m); set16.setData((byte)ran15); int ran17 = gen.nextInt(3); int ran18 = gen.nextInt(3); int ran19 = gen.nextInt(3); int ran20 = gen.nextInt(3); set17.setType(m); set17.setData((byte)ran17); set18.setType(m); set18.setData((byte)ran18); set19.setType(m); set19.setData((byte)ran19); set20.setType(m); set20.setData((byte)ran20); if (x == 1) { clr1.setType(Material.SMOOTH_BRICK); clr10.setType(Material.SMOOTH_BRICK); clr11.setType(Material.SMOOTH_BRICK); clr111.setType(Material.SMOOTH_BRICK); clr1111.setType(Material.SMOOTH_BRICK); clr11111.setType(Material.SMOOTH_BRICK); clr111111.setType(Material.SMOOTH_BRICK); clr2.setType(Material.SMOOTH_BRICK); clr20.setType(Material.SMOOTH_BRICK); clr21.setType(Material.SMOOTH_BRICK); clr211.setType(Material.SMOOTH_BRICK); clr2111.setType(Material.SMOOTH_BRICK); clr21111.setType(Material.SMOOTH_BRICK); clr211111.setType(Material.SMOOTH_BRICK); clr3.setType(Material.SMOOTH_BRICK); clr30.setType(Material.SMOOTH_BRICK); clr31.setType(Material.SMOOTH_BRICK); clr311.setType(Material.SMOOTH_BRICK); clr3111.setType(Material.SMOOTH_BRICK); clr31111.setType(Material.SMOOTH_BRICK); clr311111.setType(Material.SMOOTH_BRICK); clr4.setType(Material.SMOOTH_BRICK); clr40.setType(Material.SMOOTH_BRICK); clr41.setType(Material.SMOOTH_BRICK); clr411.setType(Material.SMOOTH_BRICK); clr4111.setType(Material.SMOOTH_BRICK); clr41111.setType(Material.SMOOTH_BRICK); clr411111.setType(Material.SMOOTH_BRICK); int w = 1; while (w < 8) { Block clearer = set122.getRelative(BlockFace.DOWN, w); clearer.setType(Material.SMOOTH_BRICK); w++; } clr5.setType(Material.SMOOTH_BRICK); clr50.setType(Material.SMOOTH_BRICK); clr51.setType(Material.SMOOTH_BRICK); clr511.setType(Material.SMOOTH_BRICK); clr5111.setType(Material.SMOOTH_BRICK); clr51111.setType(Material.SMOOTH_BRICK); clr511111.setType(Material.SMOOTH_BRICK); clr5111111.setType(Material.SMOOTH_BRICK); clr6.setType(Material.SMOOTH_BRICK); clr60.setType(Material.SMOOTH_BRICK); clr61.setType(Material.SMOOTH_BRICK); clr611.setType(Material.SMOOTH_BRICK); clr6111.setType(Material.SMOOTH_BRICK); clr61111.setType(Material.SMOOTH_BRICK); clr611111.setType(Material.SMOOTH_BRICK); clr7.setType(Material.SMOOTH_BRICK); clr70.setType(Material.SMOOTH_BRICK); clr71.setType(Material.SMOOTH_BRICK); clr711.setType(Material.SMOOTH_BRICK); clr7111.setType(Material.SMOOTH_BRICK); clr71111.setType(Material.SMOOTH_BRICK); clr711111.setType(Material.SMOOTH_BRICK); } else if (x + 1 == a) { clr1.setType(Material.IRON_FENCE); clr10.setType(Material.IRON_FENCE); clr11.setType(Material.IRON_FENCE); clr111.setType(Material.IRON_FENCE); clr1111.setType(Material.IRON_FENCE); clr11111.setType(Material.IRON_FENCE); clr111111.setType(Material.IRON_FENCE); clr2.setType(Material.IRON_FENCE); clr20.setType(Material.IRON_FENCE); clr21.setType(Material.IRON_FENCE); clr211.setType(Material.IRON_FENCE); clr2111.setType(Material.IRON_FENCE); clr21111.setType(Material.IRON_FENCE); clr211111.setType(Material.IRON_FENCE); clr3.setType(Material.IRON_FENCE); clr30.setType(Material.IRON_FENCE); clr31.setType(Material.IRON_FENCE); clr311.setType(Material.IRON_FENCE); clr3111.setType(Material.IRON_FENCE); clr31111.setType(Material.IRON_FENCE); clr311111.setType(Material.IRON_FENCE); clr4.setType(Material.IRON_FENCE); clr40.setType(Material.IRON_FENCE); clr41.setType(Material.IRON_FENCE); clr411.setType(Material.IRON_FENCE); clr4111.setType(Material.IRON_FENCE); clr41111.setType(Material.IRON_FENCE); clr411111.setType(Material.IRON_FENCE); int w = 1; while (w < 8) { Block clearer = set122.getRelative(BlockFace.DOWN, w); clearer.setType(Material.IRON_FENCE); w++; } clr5.setType(Material.IRON_FENCE); clr50.setType(Material.IRON_FENCE); clr51.setType(Material.IRON_FENCE); clr511.setType(Material.IRON_FENCE); clr5111.setType(Material.IRON_FENCE); clr51111.setType(Material.IRON_FENCE); clr511111.setType(Material.IRON_FENCE); clr5111111.setType(Material.IRON_FENCE); clr6.setType(Material.IRON_FENCE); clr60.setType(Material.IRON_FENCE); clr61.setType(Material.IRON_FENCE); clr611.setType(Material.IRON_FENCE); clr6111.setType(Material.IRON_FENCE); clr61111.setType(Material.IRON_FENCE); clr611111.setType(Material.IRON_FENCE); clr7.setType(Material.IRON_FENCE); clr70.setType(Material.IRON_FENCE); clr71.setType(Material.IRON_FENCE); clr711.setType(Material.IRON_FENCE); clr7111.setType(Material.IRON_FENCE); clr71111.setType(Material.IRON_FENCE); clr711111.setType(Material.IRON_FENCE); } else { clr1.setType(Material.AIR); clr10.setType(Material.AIR); clr11.setType(Material.AIR); clr111.setType(Material.AIR); clr1111.setType(Material.AIR); clr11111.setType(Material.AIR); clr111111.setType(Material.AIR); clr2.setType(Material.AIR); clr20.setType(Material.AIR); clr21.setType(Material.AIR); clr211.setType(Material.AIR); clr2111.setType(Material.AIR); clr21111.setType(Material.AIR); clr211111.setType(Material.AIR); clr3.setType(Material.AIR); clr30.setType(Material.AIR); clr31.setType(Material.AIR); clr311.setType(Material.AIR); clr3111.setType(Material.AIR); clr31111.setType(Material.AIR); clr311111.setType(Material.AIR); clr4.setType(Material.AIR); clr40.setType(Material.AIR); clr41.setType(Material.AIR); clr411.setType(Material.AIR); clr4111.setType(Material.AIR); clr41111.setType(Material.AIR); clr411111.setType(Material.AIR); int w = 1; while (w < 8) { Block clearer = set122.getRelative(BlockFace.DOWN, w); clearer.setType(Material.AIR); w++; } clr5.setType(Material.AIR); clr50.setType(Material.AIR); clr51.setType(Material.AIR); clr511.setType(Material.AIR); clr5111.setType(Material.AIR); clr51111.setType(Material.WATER); clr511111.setType(Material.AIR); clr5111111.setType(Material.IRON_FENCE); clr6.setType(Material.WATER); clr60.setType(Material.WATER); clr61.setType(Material.WATER); clr611.setType(Material.WATER); clr6111.setType(Material.WATER); clr61111.setType(Material.WATER); clr611111.setType(Material.WATER); clr7.setType(Material.WATER); clr70.setType(Material.WATER); clr71.setType(Material.WATER); clr711.setType(Material.WATER); clr7111.setType(Material.WATER); clr71111.setType(Material.WATER); clr711111.setType(Material.WATER); } newx++; x++; } return a; }
b4ae4331-bd98-4e9c-b8bd-5684658693cc
1
private boolean checkForUpdate(String current, String online) { if (current.equals(online)) { return false; } return checkUpdate(getVersionInts(current), getVersionInts(online)); }
887b36b5-bedd-433a-9e51-50a627fa2098
3
public static void addTopicsLevelsRec(Topic root, int level, int n_topics, int iter, List<String> addedList) { int d = root.Get_depth(); if (d < level) { //System.out.println("At Level: " + root.Get_depth()); EM.preE(root);// k ArrayList<Float> float[][] edgeweight = root.Get_edgeweight(); //float[][] thetai = root.clone2df(root.Get_thetai()); //System.out.println("Theta i in build tree now" ); long startTime = new Date().getTime(); EM.EM_run(root, iter); long endTime = new Date().getTime(); //root.Set_name(); //-----Printing the edge weight for each sub topics for root at Level 0----// if (d ==0 ){ System.out.println("Time taken to Run the EM at the root level(milliseconds): " + ((endTime - startTime))); // // System.out.print(" " + " "); // for(int k = 0; k< edgeweight[0].length; k++){ // System.out.print( "Topic " + (k+1) + " "); // } // System.out.println(""); // List<SparseMatrix> edges = root.Get_edgeset(); // Iterator<SparseMatrix> it = edges.iterator(); // // for(int i = 0; i< edgeweight.length; i++){ // SparseMatrix curredge = it.next(); // System.out.print(curredge.getwordid1()); // System.out.print(" ~~ " + curredge.getwordid2() + " "); // //System.out.println(""); // int n=0; // while(n<20){ // for(int j = 0; j< edgeweight[0].length; j++){ // System.out.print(edgeweight[i][j] + " "); // } System.out.println(""); // n++; // } // } // } ArrayList<ArrayList<Float>> edgeMul_children = root.ArraytoArrayList(root.Get_edgeweight()); float[][] edgeweight1 = Random_gen.generator(root.Get_edgesetSize(), n_topics); for (int i = 0; i < n_topics; i++) { Topic child = new Topic(root.Get_edgeset(),edgeMul_children.get(i), edgeweight1, n_topics); // use topic constructor with value fetched after the EM run root.Set_Child(child); child.Set_depth(root.Get_depth() + 1); child.Set_edgeweight(); addedList.add(child.Get_name()); addTopicsLevelsRec(child, level, n_topics, iter, addedList); } } }
34985d97-1f65-4400-ac1d-8abed5428839
6
private static void gerarRelatorios() { Funcionario funcionario = new Funcionario(); ControleAcessoService controleAcesso = new ControleAcessoServiceImpl(); Scanner input = new Scanner(System.in); System.out.print("Informe seu CPF: "); String cpf = input.nextLine(); funcionario.setCpf(cpf); boolean controle = controleAcesso.verificaAcesso(funcionario); if (controle){ System.out.println("--------------------------------------------------------------------"); System.out.println("-------------------------- RELATÓRIOS ------------------------------"); System.out.println("--------------------------------------------------------------------"); System.out.println("SELECIONE UMA DAS OPÇÕES DO MENU:"); System.out.println("(1) - TOTAL DE INGRESSOS VENDIDOS"); System.out.println("(2) - TOTAL DE INGRESSOS VENDIDOS POR SEÇÃO DO EVENTO"); System.out.println("(3) - TOTAL DE INGRESSOS VENDIDOS POR EVENTO"); System.out.println("(4) - LOGOUT"); System.out.println("(5) - FECHAR"); System.out.println("--------------------------------------------------------------------"); String o = input.next(); int opcao = Integer.parseInt(o); switch (opcao) { case 1: { gerarTotalVendidos(); break; } case 2: { gerarTotalVendidosSecao(); break; } case 3: { gerarTotalVendidosEvento(); break; } case 4: { logout(); break; } case 5: { sair(); break; } default: System.out.println("Opção inválida!"); menuprincipal(); break; } }else{ System.out.println("Você não tem permissão para gerar relatórios."); menuprincipal(); } }
b54e4e74-f4ef-4b8d-a204-cbd470f0f006
4
public static void main(String[] args) { try { Display.setDisplayMode(new DisplayMode(1000,1000)); Display.create(); load(); setColorMap(); if (use3D) setup3D(); else setup2D(); while(!Display.isCloseRequested()) { if (use3D) render3D(); else render2D(); } Display.destroy(); } catch (LWJGLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
0cdf712f-74b3-44c9-9949-bea6ac24970b
1
public void remove() { try { Thread.sleep(2000); } catch (Exception e) { LOGGER.log(Level.WARNING, "Just to shutup SonarB", e); } floorFrame.dispose(); }
7a4121df-2a73-45fc-8b94-23c7ea30687f
5
public void update(Game G){ // updates the balls position in the level if (Px + Vx > G.getWidth()-radius-1){ // if the ball is hitting the right side of the screen, make it bounce off Px = G.getWidth()-radius-1; Vx = -Vx*energyLoss; }else if (Px+Vx < radius){ Px = radius; Vx = -Vx*energyLoss; }else{ Px += Vx; } if (Py == G.getHeight()-radius-1){ // if the ball is on the ground slow the ball Vx *= friction; if (Math.abs(Vx) < 0.2){ // if the ball is moving slow enough stop the ball Vx = 0; } } if(Py > G.getHeight()-radius-1){ Py = G.getHeight()-radius-1; Vy *= energyLoss; Vy = -Vy; }else{ // velocity formula Vy += gravity*dt; // position formula Py += Vy*dt + 0.5*gravity*dt*dt; } }
fe8122ec-d67e-4797-981e-6ffd89d91e79
7
private int excelByAgingSort(int start, int end, int rid, ArrayList<Borrower> list, HSSFWorkbook workbook, HSSFSheet sheet) { int _rid = rid; // 生成一行显示“多少天账龄”提示,可以注释掉,下面代码可注释 sheet.addMergedRegion(new CellRangeAddress(_rid, _rid, 0, 9)); HSSFRow row = sheet.createRow(_rid); HSSFCell cell = row.createCell(0); if (start >= 60) { cell.setCellValue("大于" + start + "天账龄"); } else { cell.setCellValue(start + "~" + end + "天账龄"); } cell.setCellStyle(cellStyle.cellFontBoldCenterBorderStyle); _rid++; double[] subtotal = { 0.0, 0.0, 0.0 };// 小计统计 // 上面代码可注释 for (int i = 0; i < list.size(); i++) {// 借款信息集合 try { Borrower borr = (Borrower) list.get(i);// 获取每一条借款信息 if (borr.getAging() >= start && borr.getAging() < end) { System.out.println(borr); row = sheet.createRow(_rid); int j = 0; excelUtils.setCellValue(borr.getBorrId(), workbook, j++, row, cellStyle.cellBorderStyle);// 借款人 excelUtils.setCellValue(borr.getBorrDate(), workbook, j++, row, cellStyle.cellBorderStyle);// 日期 excelUtils.setCellValue(borr.getPurpose(), workbook, j++, row, cellStyle.cellBorderStyle);// 借款用途 excelUtils.setCellValue(borr.getOriginalCurrency(), workbook, j++, row, cellStyle.cellBorderStyle);// 原币 excelUtils.setCellValue(borr.getVerification(), workbook, j++, row, cellStyle.cellBorderStyle);// 已核销 excelUtils.setCellValue(borr.getOriginalCurrencyBalance(), workbook, j++, row, cellStyle.cellBorderStyle);// 原币余额 excelUtils.setCellValue(borr.getAging(), workbook, j++, row, cellStyle.cellBorderStyle); excelUtils.setCellValue(null, workbook, j++, row, cellStyle.cellBorderStyle);// 情况说明单元格赋空值 excelUtils.setCellValue(null, workbook, j++, row, cellStyle.cellBorderStyle); excelUtils.setCellValue(null, workbook, j++, row, cellStyle.cellBorderStyle); subtotal[0] += borr.getOriginalCurrency();// 累计原币 subtotal[1] += borr.getVerification();// 累计已核销 subtotal[2] += borr.getOriginalCurrencyBalance();// 累计原币余额 if (borr.getPurpose() != null && borr.getPurpose().length() > purposeColLength) {// 记录借款用途最长字符串长度 purposeColLength = borr.getPurpose().length(); } _rid++; } } catch (Exception e) { e.printStackTrace(); } } // 总计 total[0] += subtotal[0]; total[1] += subtotal[1]; total[2] += subtotal[2]; setSubtotalRow("小计", _rid++, subtotal, workbook, sheet);// 小计行 return _rid++; }
af87f812-2bef-4ce4-9067-25eaabf01c7e
6
private static void maxComSubStrLen(int m, int n, String strA, String strB, int[][] intC, int[][] intB) { int i, j; for (i = 0; i <= m; i++) { intC[i][0] = 0; } for (i = 1; i <= n; i++) { intC[0][i] = 0; } for (i = 1; i <= m; i++) { for (j = 1; j <= n; j++) { if (strA.charAt(i-1) == strB.charAt(j-1)) { intC[i][j] = intC[i - 1][j - 1] + 1; intB[i][j] = 1; } else if (intC[i - 1][j] >= intC[i][j - 1]) { intC[i][j] = intC[i - 1][j]; intB[i][j] = 2; } else { intC[i][j] = intC[i][j - 1]; intB[i][j] = 3; } } } }
aa571d2f-e7e2-4fe0-be67-79765b0032fd
7
public void launchURL(String url) { String osName = System.getProperty("os.name"); try { if (osName.startsWith("Mac OS")) { Class fileMgr = Class.forName("com.apple.eio.FileManager"); Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class}); openURL.invoke(null, new Object[] {url}); } else if (osName.startsWith("Windows")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); else { String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape", "safari" }; String browser = null; for (int count = 0; count < browsers.length && browser == null; count++) if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0) browser = browsers[count]; if (browser == null) { throw new Exception("Could not find web browser"); } else Runtime.getRuntime().exec(new String[] {browser, url}); } } catch (Exception e) { pushMessage("Failed to open URL.", 0, ""); } }
664ea2da-e92f-45cc-a6e7-27626d2afaa3
1
public void sendDeadline(){ graphicsContainer.get().sendDeadline(); for(AIConnection client: globalClients){ client.sendDeadline(); } }
471f3e28-f2ff-4dc8-87e4-535424acd50b
3
public HashMap getInfo(String link){ String sourceName = "什么值得买-海淘"; String html = GetHTML.getHtml(link,"utf-8"); Document document = Jsoup.parse(html); Elements allEles = document.select("div.leftWrap").select("article[itemtype]"); String catagories = document.select("div.leftLayer").select("a.fav").select("em").text(); String shop = allEles.select("div.article_picwrap").select("span.mall").text(); if(shop.length()==0) shop = allEles.select("div.article_picwrap").select("a.mall").text(); if(shop.length()==0) shop = allEles.select("div.article_picwrap").select("div.buy").select("a.mall").text(); Elements detailEles = allEles.select("p[itemprop]"); ArrayList<String> detail =null; ArrayList<String> detailPic = null; ArrayList<String> bodyPieces= null; ContextUtils contextUtils = new ContextUtils(); try { bodyPieces = contextUtils.getBodyPieces(detailEles); HashMap bodyMap = contextUtils.combineBodyText(bodyPieces); detail = (ArrayList<String>)bodyMap.get("bodyText"); detailPic = (ArrayList<String>) bodyMap.get("bodyPic"); } catch (IOException e) { e.printStackTrace(); } String like = document.select("div.score_rateBox").select("div.score_rate").select("span#rating_worthy_num").text(); String dislike = document.select("div.score_rateBox").select("div.score_rate").select("span#rating_unworthy_num").text(); String goStraightLink = allEles.select("div.article_picwrap").select("div.buy").select("a").attr("href"); HashMap article = new HashMap(); HashMap hashMap = new HashMap(); hashMap.put("content",detail); hashMap.put("goStraightLink",goStraightLink); hashMap.put("releasetime",""); hashMap.put("bodyPicPieces",detailPic); hashMap.put("source",sourceName); hashMap.put("smalldesc",""); return hashMap; }
a985b682-4922-4107-b4a1-a1239273e1bc
3
private boolean jj_3_57() { if (jj_3R_73()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_56()) { jj_scanpos = xsp; break; } } return false; }
3ebd8bc4-7b22-410d-ad14-b61274570bba
0
public void setTableName(String tableName) { this.tableName = tableName; }
89368387-2e08-4574-be10-8d2a30921837
3
public void setState(int state) { // Is the correct state? if (config.isAccept()) state = ACCEPT; if (state < 0 || state >= TEXT.length) state = NORMAL; // setText(TEXT[state]); // setForeground(STATE_COLOR[state]); // setBackground(STATE_COLOR[state]); this.state = state; }
cf220dbc-3dec-4a06-9da3-3b7ade1a5f30
1
@Override public Object clone() { NodeSet nodeSet = new NodeSet(); for (int i = 0, limit = nodes.size(); i < limit; i++) { nodeSet.addNode(nodes.get(i).cloneClean()); } return nodeSet; }
cd1dae3f-7a6f-43a4-96ab-395067973093
8
public Point2D.Double nextPosition() { assert n % 2 == 1; final int halfN = (n - 1) / 2; final Point2D.Double result = new Point2D.Double(x, y); i++; if (seg == 'A') { x++; if (x > halfN) { seg = 'B'; x = halfN; y = -halfN + 1; } } else if (seg == 'B') { y++; if (y > halfN) { seg = 'C'; x = halfN - 1; y = halfN; } } else if (seg == 'C') { x--; if (x < -halfN) { seg = 'D'; x = -halfN; y = halfN - 1; } } else if (seg == 'D') { y--; if (y == -halfN) { n += 2; i = 0; x = -((n - 1) / 2); y = x; seg = 'A'; } } else { throw new UnsupportedOperationException(); } return result; }
0386c846-211b-42fe-9881-4476fbf5667c
9
private void refreshMonLocsSepPopSickmons() { double numSickMons = this.getAlpha()*this.numMonitors; double numPopMons = this.numMonitors - numSickMons; monitoredLocs = new HashSet<Integer>(this.numMonitors); boolean allAtMin = this.calcWeights(); // Add Sick monitors if (!allAtMin) { WeightedRandPerm perm = new WeightedRandPerm(rand, this.sickEdgeWeight); perm.reset(this.sickEdgeWeight.length); for (int i = 0; perm.hasNext() && i < numSickMons;) { int index = perm.next(); if (this.sickEdgeWeight[index] != Double.MIN_VALUE && !this.isClosed(trackLocsByIndex[index], this.mySim.curTime)) { monitoredLocs.add(trackLocsByIndex[index]); i++; } } } // Add pop monitors WeightedRandPerm perm = new WeightedRandPerm(rand, this.popWeight); perm.reset(this.popWeight.length); for (int i = 0; perm.hasNext() && i < numPopMons;) { int index = perm.next(); if (!monitoredLocs.contains(trackLocsByIndex[index]) && !this.isClosed(trackLocsByIndex[index], this.mySim.curTime)) { monitoredLocs.add(trackLocsByIndex[index]); i++; } } }
48dd3772-3bb0-4bfe-b33d-7997383bd352
5
public RoomPanel initRoomPanel() { HashMap<String, ArrayList<String>> rooms = this.getOtherRooms(); while (rooms == null) { rooms = this.getOtherRooms(); try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } } for (Entry<String, ArrayList<String>> pair : rooms.entrySet()) { Object[] usersOfRoom = new Object[pair.getValue().size()]; // Liste mit activen useren im Raum der durch for läuft boolean imThere = false; for (int i = 0; i < pair.getValue().size(); i++) { usersOfRoom[i] = pair.getValue().get(i); if (pair.getValue().get(i).equals(nickname)) { imThere = true; } } rp.addRoom(usersOfRoom, pair.getKey(), this, imThere); } return rp; }
6bf3d6c1-3279-4328-8e5c-7563f7abe344
9
public void Draw(Mesh mesh, Texture t) { // for(int m = 0; m < s.getMesh().length; m++){ /* * if(s.hasMesh() && s.getMesh()[0].getMat() != null){ * s.getMesh()[0].getMat().getTexture().bind(); }else * if(s.getTexture().getTexture() != null){ * s.getTexture().getTexture().bind(); }else * if(s.getTexture().getColor() != null){ glDisable(GL_TEXTURE_2D); * //glColor3f(0.0f, 0.0f, 0.0f); }else{ * //model.getMaterial("pack").getTexture().bind(); } */ if(mesh.getMat() != null){ mesh.getMat().getTexture().bind(); }else if(t != null){ t.bind(); }else if(nullTex != null){ nullTex.bind(); }else{ System.out.println(mesh.getName()); } glBegin(GL_QUADS); for (int f = 0; f < mesh.getFaces().size(); f++) { Face face = mesh.getFaces().get(f); if (face.isQuad()) { for (int v = 0; v < face.getVertex().size(); v++) { glTexCoord2f(face.getVertex(v).getOffsetTexX(), -face .getVertex(v).getOffsetTexY()); glVertex3f(face.getVertex(v).getX(), face.getVertex(v) .getY(), face.getVertex(v).getZ()); } } } glEnd(); glBegin(GL_TRIANGLES); for (int f = 0; f < mesh.getFaces().size(); f++) { Face face = mesh.getFaces().get(f); if (face.isTri()) { for (int v = 0; v < face.getVertex().size(); v++) { glTexCoord2f(face.getVertex(v).getOffsetTexX(), -face .getVertex(v).getOffsetTexY()); glVertex3f(face.getVertex(v).getX(), face.getVertex(v) .getY(), face.getVertex(v).getZ()); } } } glEnd(); /* * glBegin(GL_TRIANGLES); for(int f = 0; f < * model.getSpriteList().get(i).getMesh()[m].getFaces().size(); f++){ * Face face = * model.getSpriteList().get(i).getMesh()[m].getFaces().get(f); * if(face.isTri()){ for(int v = 0; v < face.getVertex().size(); v++){ * glTexCoord2f(face.getVertex(v).getTexX(), * -face.getVertex(v).getTexY()); glVertex3f(face.getVertex(v).getX(), * face.getVertex(v).getY(), face.getVertex(v).getZ()); } } } glEnd(); */ // } }