method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
f9c4785c-35fe-426f-8806-44f4aa5bf45c
3
public void reportGroup(GroupSettings group, int count, Location location) { StringBuilder builder = mReport.get(group); if(builder == null) { builder = new StringBuilder(); mReport.put(group, builder); } if(builder.length() != 0) builder.append(", "); if(count >= group.getMaxEntities()) ...
0611ee51-464c-42a9-a5cf-41e4f02d3fa7
3
/* */ public void fire(int targetX, int targetY) { /* 200 */ if ((this.magazine > 0) && (this.autoFire) && (this.elapsed >= this.nextShot)) { /* 201 */ Core.projectiles.add(new Projectiles(this.x + 8, this.y + 8, targetX, targetY - /* 202 */ Core.offsetY, 16, this.r.nextInt(5) + 16, this)); /* ...
52b22c81-f598-4048-8f9b-986f0c399c10
2
private static Usuarios searchUser(String n){ for (Usuarios x : users){ if (x.getNombre().equalsIgnoreCase(n)) return x; } return null; }
205e7657-a2c2-4746-a5cb-b3da5cf1e609
6
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{ input = gc.getInput(); // If there's not a Word List already. if (!wordListGenerated){ generateWordList(); } if (!paused && started){ calcTime(gc, sbg, delta); } // Update the score when a target is hit. an...
51f59f6d-f844-4a6d-bcb6-55cb42b71d1a
7
public static final String intToLabeledString(long number, int divisionValue, final String[] suffixes) { int i = 2; String temp; StringBuilder sb = new StringBuilder(); // Negative if (number < 0) { sb.append("-"); number = -number; } // 1 if (number == 1) { sb.append("1"); i = 1; } el...
bdfcb0ac-92e4-40e6-af30-5e0870a1f5f6
6
private void recomputeDomination(Block root) { Queue<Block> queue = new LinkedList<Block>(); queue.add(root); while (!queue.isEmpty()) { Block blk = queue.remove(); if (blk == null) { continue; } if (blk.getNextBlock() != null) { if (!blk.getNextBlock().isBackEdgeFrom(blk)) { blk.getNextB...
5ed2fa38-40c8-433b-b742-da46312cc779
9
private int excelByAgingSort(int start, int end, int rid, ArrayList<Borrower> list, HSSFWorkbook workbook, HSSFSheet sheet, HSSFRow row) { int _rid = rid; double[] subtotal = { 0.0, 0.0, 0.0 };// 小计统计 // 生成一行显示“多少天账龄”提示,可以注释掉,下面代码可注释 sheet.addMergedRegion(new CellRangeAddress(_rid, _rid, 0, 9)); row = sheet.c...
8c9ddb11-3216-47d2-ab57-a1929f915d5c
7
@Override public void parse() { StringBuilder paramWord = new StringBuilder(); for (int i = 0; i < (textBasis.length()-5); i++) { char character = textBasis.charAt(i); if (character == '\\') { while (textBasis.charAt(i) != ' ') { para...
e353e84a-608d-4885-9a22-b1b99400658c
5
public void add() { if( getEngine().getNivelDeDificuldade() == 0 ) return; for(int x=0; x<Engine.NUM_COLUMNS; x++) { for(int y=0; y<Engine.NUM_LINES; y++) setTabuleiro(x, y, false); } for(int i=0; i<5; i++) { int x = aleatorio.nextInt(Engine.NUM_COLUMNS); int y = aleatorio.nextInt(Engine....
faff9064-94db-4a99-a81c-e0379f867fe6
8
@Override public int getIdLastComponent() { Connection conn = null; PreparedStatement st = null; ResultSet row = null; int id = 0; try { conn = OracleDAOFactory.createConnection(); st = conn.prepareStatement(GET_ID_LAST_COMPONENT); row = st.executeQuery(); if (row.next()) { id = row.getInt(1)...
3004668d-4930-4440-bf07-6ca6337dfeae
5
private static ListItem binarySearchArray(ListItem[] items, String target) { System.out.println("Binary Searching for " + target + "."); ListItem currentItem = new ListItem(); boolean isFound = false; int counter = 0; int low = 0; int high = items.length-1; // because 0-based ...
f96df983-f9e8-42dd-850a-ea984cfc1b66
8
private void mustCapture(List<Piece> team) { boolean foundCapture = false; for (int i = 0; i < team.size(); i++) { Piece current = team.get(i); for (Square s : current.getLegalDests()) { if (s.isOccupied()) { foundCapture = true; break; } } if (foundCapture) break; } ...
12a88de9-5a28-4fc7-8212-ddf99ee4e815
1
public void fireChanged() { value = VOLATILE; for (Iterator i = listeners.iterator(); i.hasNext();) ((ConstantListener) i.next()).constantChanged(); listeners = null; }
f2118c28-2963-45ad-97bf-aa2b43dade7f
7
@Override public void rightMultiply(IMatrix other) { // TODO Auto-generated method stub for(int i=0;i<4;i++) for(int j=0;j<4;j++) copy[i][j]=0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { copy[i][j]=copy[i][j] + this.get(k, i) * other.get(j, k...
b5845eef-9183-49a7-989a-a04effb691e4
1
public Poisson(double lambda) throws ParameterException { if (lambda <= 0) { throw new ParameterException("Poisson parameter lambda > 0."); } else { this.lambda = lambda; } }
5a6d4322-18c5-46dd-a803-bd091a6188f3
8
public int getSelection() { if(selectionOvalY == 3) return 1; else if(selectionOvalY == 27) return 2; else if(selectionOvalY == 51) return 3; else if(selectionOvalY == 75) return 4; else if(selectionOvalY == 99) return 5; else if(selectionOvalY == 123) return 6; else if(se...
d25accb3-5f43-4b1d-9d25-fac40461b42c
2
protected void confirmOrder(ArrayList<Product> order) { if (productSvc == null) { productSvc = GWT.create(ProductService.class); } AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() { public void onFailure(Throwable caught) { } public void onSuccess(Boolean valid) { if(valid) { ...
2d91c7f2-548f-41a6-92df-ed6852c24a0a
2
public static void writeBytesToFile(File theFile, byte[] bytes) throws IOException { BufferedOutputStream bos = null; try { FileOutputStream fos = new FileOutputStream(theFile); bos = new BufferedOutputStream(fos); bos.write(bytes); } finally { if...
84560cd1-2bf1-4b29-a567-7d4a772fcc1f
7
public static void main(String[] args) { Scanner input = new Scanner (System.in); ArrayList <Integer> List = new ArrayList <Integer>(); double one,two; System.out.println("Enter a double: "); one = input.nextDouble(); System.out.println("Enter a second double: "); two = input.nextDouble(); i...
43ec68db-b965-4f17-8f49-ce8b8df3f6f2
1
public E peek() { if ( this.isEmpty() ) { throw new EmptyHeapException(); } return heap[TOP]; }
e20bba01-9ff8-4e42-9dc6-f5ea75274281
1
public void updateDrawAreaNext ()//advance the month { if (currentMonth.getNum()==12)//end of the year { updateNewYear(); } else { ArrayList <Month> list = currentYear.getMonths(); currentMonth = list.get(CalendarFunctions.nextMonth(currentMonth.getNum())-1); } updateBoxes(); Day cursorD...
db6dcd89-59c7-43d5-8854-fadb832626fa
6
public TenCCompiler(String[] args) { if (args.length > 0) { int pointer = 0; while (pointer < args.length) { final String arg = args[pointer]; if (arg.equalsIgnoreCase("--in")) { ...
d226010b-692b-4148-97af-74a08a6a787b
4
public static String doGET(String URLstring) { try { String returnVal = ""; URL url = new URL(URLstring); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/json"); if (conn.getResponseCode() != 200) { ...
66883254-be95-45bc-8ae9-2fe63de94d1e
6
@Override public int compare( Object o1, Object o2 ) { long[] key1 = (long[]) o1; long[] key2 = (long[]) o2; if( key1[0] < key2[0] ) { return -1; } if( key1[0] > key2[0] ) { return 1; } if( key1[0] == key2[0] ) { if( key1[1] == key2[1] ) { return 0; // equals } if( key1[1]...
62766d2a-3420-4ac3-a418-3480f7b9e2a0
4
public boolean execute(CommandSender par1Sender, Command par2Command, String par3Args, String[] par4Args) { Player player; if (par4Args.length < 1) { if (!(par1Sender instanceof Player)) { Util.Message(par1Sender, i18n._("cmdillegalargument"), null); return false; } else { player = (Player) par...
e803ac9c-3fa6-40f1-aa07-f8aba1161074
6
public boolean saveCustomer(ArrayList<Customer> customer, Connection con) { boolean didItWork = false; int tal = 0; String SQLString1 = "insert into kunde values(?,?,?,?,?,?,?)"; String SQLString2 = "select kundeseq.nextval from dual"; PreparedStatement statement = null; ...
37f61a70-3072-4269-95c4-15fa50935669
8
@Override public void actionPerformed(ActionEvent e) { //gets source of button click JButton button =(JButton) e.getSource(); Dimension size = button.getSize(); // gets the x,y coordinates of the button that was hit and an empty label int labelX = label.getX(); int labelY = label.getY(); int butt...
4e8ea4e8-979e-40c1-bf0f-0b86edece000
4
@Override public final void endElement(final String uri, final String localName, final String elementEndName) throws SAXException { // if closing tag "maptile" is detected get the 9 fields of each tile if (elementEndName.equalsIgnoreCase("maptile")) { for (int i = 0; i < fie...
0b3134aa-8281-4675-98da-e14b8d5a2451
1
private String buildKey(int[] arr) { StringBuilder sb = new StringBuilder(); for (int i : arr) { sb.append(i); } return sb.toString(); }
708b3b2e-210b-4527-a870-98aecd6d1bf0
3
@Override public String execute(SessionRequestContent request) throws ServletLogicException { String page = ConfigurationManager.getProperty("path.page.edithotel"); request.setSessionAttribute(JSP_PAGE, page); new CountryCommand().formCountryList(request); new CityCommand().formCityL...
f0abe440-9eb6-4623-8c4a-1a52b8c1ab38
4
@Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); if (e.getButton() == MouseEvent.BUTTON1) movePoint(draggedFromVertex); else if (e.getButton() == MouseEvent.BUTTON2 && draggedToVertex.getClass() == Point.class) vertices.invertShape((Poin...
cd5a0af0-e81d-495b-ac49-538d518176c7
4
/* */ public void checkOutOfBounds() /* */ { /* 70 */ if ((this.x < 0.0F) || (this.x > 850.0F)) { /* 71 */ this.alive = false; /* */ } /* 73 */ if ((this.y < -2000.0F) || (this.y > 480.0F)) /* 74 */ this.alive = false; /* */ }
1a50f182-000c-402d-809b-9afdf17085c3
4
public void createConfig() { if (!dataFolder.exists()) { try { dataFolder.mkdir(); } catch (Exception e) { Injector.getLogger().log(Level.SEVERE, "Unable to create plugin data folder at " + dataFolder + " for " + getClass().getName(), e); } ...
da7260bb-5073-49c1-a570-3305c9f062fb
0
public void setDocument(Document doc) {this.doc = doc;}
04113c67-49c2-47c6-a748-b6a9cbf8bc67
0
private void setEnabledStates() { myBackButton.setEnabled(myCurrentPosition != 0); myStartButton.setEnabled(myCurrentPosition != 0); myForwardButton .setEnabled(myCurrentPosition != myURLHistory.size() - 1); }
e6ecae5e-7975-489b-95ea-532660ca27c0
1
public static CanvasKeyboard getInstance() { if (instance == null) instance = new CanvasKeyboard(); return instance; }
800b5b75-f630-43eb-aa9d-16fc63b9a2df
7
public int maxSet(int[] cost, int[] features, int[] fixTimes){ n = cost.length; graph = new boolean[n][n]; numbered = new int[n]; int[] degree = new int[n]; for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(cost[i]>cost[j] && features[i]<features[j] &...
93affe5b-9c24-4b7e-bc14-2daafa9f26de
2
public void increaseSpeed() { if (vx > 0) { vx++; } else { vx--; } if (vy > 0) { vy++; } else { vy--; } }
ec0cd72d-bee8-43b9-98ff-3e85194677b6
4
@Override protected void run() { long startTime = System.currentTimeMillis(); long elapsedTime = 1; GA ga = (GA) algorithms.get("GA"); int sameCounter = 0; ga.run(); runBestIndividual = ga.getBestIndividual(); System.out.println(); boolean reset = false; while (elapsedTime < 86400000) ...
94e1c4c1-c907-4e05-b329-025ca46390ca
9
public static void main(String[] args) throws Exception { HashMap<String, AnnotationHolder> annotationMap = AddNamesToROutput.getAnnotationMap(); HashMap<String, GffParser> gffMap = FindGeneForMappedSequence.getGeneFileMap(); File topDir = new File(ConfigReader.getJobinLabRNASeqDir()); for(Str...
4bdddcc6-1317-439c-8097-dcbac787ce09
2
public final void setTotalHrsForYear(double totalHrsForYear) { if(totalHrsForYear < 0 || totalHrsForYear > 5000) { throw new IllegalArgumentException(); } this.totalHrsForYear = totalHrsForYear; }
00bb0212-c55c-4dee-8e8c-62bca099b7fd
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 fe...
dbb2294b-58d3-4a49-a144-d495dc0a7da4
3
public void retreating() { if (isHitByOpponent()) { setState(STATE_DEFENDING, "I've been shot by an opponent while retreating"); return; } if (getDistanceToTarget() > SEEKING_TO_ATTACKING_DISTANCE) { setState(STATE_SEEKING, "distance to " + target + " is outside attacking distance while retreating"); ...
28a6b111-ac02-4f78-8f34-8226c110857f
8
public static void pprintRelationProposition(Proposition self, org.powerloom.PrintableStringWriter stream) { { int nargs = self.arguments.length(); stream.print("("); OntosaurusUtil.pprintObject(self.operator, stream); Native.setIntSpecial(OntosaurusUtil.$PPRINT_INDENT$, ((Integer)(OntosaurusUtil...
02bc8322-c98c-4d53-b585-496359270506
9
public void initRodAvailables() { rodAvailables = new Hashtable<Rod, Boolean>(); switch( gameType ){ case ONEVSONE: rodAvailables.put(Rod.GARDIEN, true); rodAvailables.put(Rod.DEFENSE, true); rodAvailables.put(Rod.MILIEU, true); rodAvailables.put(Rod.ATTAQUE, true); break; case ONEVSTWO: ...
298c8081-30f1-41a9-b734-0d4b68ac9962
4
private static char lookChar() { // return next character from input if (buffer == null || pos > buffer.length()) fillBuffer(); if (buffer == null) return EOF; else if (pos == buffer.length()) return '\n'; else return buffer.charAt(pos); }
988cfac7-2987-4e79-9702-5e350b7ae1b1
5
@Override public void timeExpired(Participant p) { if (p == null) screen.setLegend(""); if (p instanceof Ship) { bulletLimiter = false; } if (p instanceof Bullet) { screen.removeParticipant(p); bulletIndex--; } if (p instanceof Star) { //p.on(); } if (p instanceof Debris) { screen.rem...
87a77627-50f2-46fb-817a-bf927575b527
1
public void run() { running = true; bind(); while(running){ accept(); } }
a0726236-d840-434e-8703-bb74aadb7887
5
private void sortSlides() { // quick and dirty bubble sort, never going to be many slides so speed // not a problem for (int range = slideShow.getTree().size() - 1; range >= 0; range--) { int pos = 0; while (pos < range) { TreeEntity slide = slideShow.getTree().get(pos); TreeEntity nextSlide = slide...
c3964c13-c183-4a54-972b-39589ed6614c
2
public void visitEnum(final String name, final String desc, final String value) { buf.setLength(0); appendComa(valueNumber++); if (name != null) { buf.append(name).append('='); } appendDescriptor(FIELD_DESCRIPTOR, desc); buf.append('.').append(value); text.add(buf.toString()); if (av != null) { ...
75d4f2eb-a22c-4f76-815d-a2b996484a4e
9
public static void main(String[] strings) throws IOException { File firstFile = new File(strings[0]); File secondFile = new File(strings[1]); System.out.println("Comparing " + firstFile + " and " + secondFile); System.out.println(); RandomAccessFile firstRandomAccessFile = null; try { firstRando...
fd64cd42-34ee-4072-a8a9-fc578914f24d
1
private ItemContextListener global() { return new ItemContextListener() { @Override public void contextAction( ItemContextEvent event ) { for( ItemContextListener listener : getListeners() ) { listener.contextAction( event ); } } }; }
956744e0-bc6d-4821-b8a6-6b8f62bc79e8
6
public void nextTurn() { //Check For Winner if(isWinner()){ return; } playerInTurn = turnDeterminer.nextTurn(); //Roll Dice diceRollDeterminer.rollDice(); int[] dRoll = diceRollDeterminer.getDiceRoll(); if(turns == 0){ while(dRoll.length > 2){ diceRollDeterminer.rollDic...
90707828-e51b-40ca-9421-4b59b0946456
4
public void start() throws Exception { ServerSocket ss = null; try { ss = new ServerSocket(serverPort); ss.setSoTimeout(DEFAULT_TIMEOUT); } catch(IOException e) { throw new Exception("Can't create socket for server."); } Syste...
f57afd97-b2b5-44c9-866c-83c6b9aa4ffc
0
public final URL getCurrentUrl() { return currentUrl; }
df0cdaf9-0ea2-4b53-8219-f3c224b90256
9
private Articles queryArticles(Category category, Subcategory subcategory, String query, int count, DateTime since, ArticleOrder order, boolean titleOnly, Culture culture) { WebTarget target = root; if (category != null) { target = target.path("categories").path( Integer.toString(category.getId())); ...
384f17fc-0654-4182-a2b8-2827b93f00c6
8
public int checkMate() { // checks if in checkmate or if have checkmated; int checkmate = 0; Board b = new Board(); Bobby BoardLords = new Bobby(true, b); ArrayList<ArrayList> a = BoardLords.getMoves(); // check if we have been checkmated, checkmated = -1 int index = -1; for (int x = 0; x < a.size(); ...
73eb61e5-34ab-4e4b-8ec3-df73563b2b64
1
private static boolean isNumberFP(final Class<? extends Number> nc) { return FP_CLASSES.contains(nc); }
c231bef3-13cd-436f-9f30-bef9e5d1c1f0
4
private void checkBlackList() { try{ BufferedReader in = new BufferedReader(new FileReader(fileName+"BlackList.txt")); String temp = in.readLine(); String blackInTFList= ""; int num = 0; if(temp!=null) { String[] blackList = temp.split(", "); for(String blackWord : blackList) { if (TFF...
a555120d-32dc-4d46-9bdd-87ab864015c8
8
public static void main(String[] args) throws IOException { Logger.info("Starting route server..."); ServerSocket sock = new ServerSocket(50001); final ArrayList<String> open = new ArrayList<>(); final Random rand = new Random(); while (true) { final Socket conn = sock.accept(); new Thread() { publi...
8378a895-089b-4c25-bc9e-4b4e977a941d
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Suit other = (Suit) obj; if (color == null) { if (other.color...
ee5d6d58-1229-4e9c-aa88-67277e6d4b1f
5
public boolean almostEquals(Object obj){ if (this == obj) return true; if (getClass() != obj.getClass()) return false; Expression other = (Expression) obj; if (termList == null) { if (other.termList != null) return false; } else if (!termList.equals(other.termList)) return false; return true...
fe8f087e-2a0b-4f32-936d-67dd69770dd3
8
private static void printExceptPublicMembers(Member[] mems){ for (Member m : mems) { Annotation[] annotations = new Annotation[0]; if (m instanceof Field) { annotations = ((Field)m).getAnnotations(); } if (m instanceof Constructor) { annotations = ((Constructor<?>)m).getAnnotations(); } if ...
b16b36aa-9dfa-420a-ac51-d4b7f7211df6
2
public void start(){ if(running){ return; } if(createConfigLater){ new ConfigLoader(false, this); } //**To initialize and register all of the tiles*/ new TileManager(); running = true; engine.start(); }
2b81544b-f11e-46ec-ad0a-f8c6edf7d784
8
public static boolean isEmpty(Object o) { if (o == null) { return true; } if (o instanceof Character) { if (((Character) o).charValue() == '\0') { return true; } } if (o instanceof String) { if (((String) o).equalsIgnoreCase(null)) { return true; } } if (o instanceof Collec...
ecc5ddc8-edcd-42c2-ab8e-fe3697953c42
7
public boolean ignoreClass(final Type type) { // First, check to see if we explicitly ignore it. If not, check // to see if we ignore its package. The ladies always seem to // ignore my package. if (ignoreClasses.contains(type)) { return (true); } else if (type.isPrimitive()) { addIgnoreClass(type); ...
752bce6a-449a-46cb-b2f5-87c67a02179d
5
public static Character firstNonRepeat(String input) { Map<Character, Boolean> charHash = new HashMap<Character, Boolean>(); // build a character hash table for (int i = 0; i < input.length(); i++) { char ch = input.charAt(i); Boolean getChar = charHash.get(ch); if (getChar == null) { charHash...
f3cb216c-78f5-496f-ab37-e7b884b935d8
3
public static boolean isEncrypted(PDFObject dict) throws IOException { PDFObject filter = dict.getDictRef("Filter"); if (filter == null) { // just apply default decryption return dict.getDecrypter().isEncryptionPresent(); } else { // apply filter...
76e40cbd-e00f-4981-9038-40b39da647d7
4
public void load(String jasparMatrixFile) { pwms = new HashMap<String, Pwm>(); if (verbose) Timer.showStdErr("Loading jaspar matrix from file " + jasparMatrixFile); String lines[] = Gpr.readFile(jasparMatrixFile, true).split("\n"); for (int i = 0; i < lines.length;) { String name = lines[i++]; String i...
a85e7a2f-b467-4593-bbed-ce6b43f47881
5
@Test public void runtimes() { final int START = 10000; final int MAX = 2000000; IStack listStack = new u6a2.ListStack(); IStack chunkedStack = new u6a4.ChunkedStack(); long listTotal = 0; long chunkedTotal = 0; System.out.println("Size\t\tListStack\tChunke...
007566a5-4943-47a3-8517-fd334e322b71
3
@Test public void testShareMethode() { try { for (int i = 0; i < 2; i++) { account.buyShare("daniel", "BMW", 2); account.buyShare("daniel", "Opel", 2); account.buyShare("daniel", "Merzedes", 2); account.sellShare("daniel", "BMW", 2); account.sellShare("daniel", "Opel", ...
495a1edc-0af9-45c9-b7b2-4317c651d446
1
public static void main(String args[]){ Date d = new Date(); Time t1 = new Time(d.getHours(), d.getMinutes(), d.getSeconds()); Time t2 = new Time((long)0.0); System.out.print("Hello world!\n"); DataOutput log = new DataOutput("log.txt", true); try{ log.writeToFile( St...
f6e87082-be5b-4cea-b68a-2d3b965e6a51
0
public void setId(long id) { this.id = id; }
e0f18b68-a45e-4a38-b856-f3a7e40e8ebe
5
protected ValueExtractor fetch ( long startTime, long endTime, long resolution, int reduceFactor ) throws IOException, RrdException { if ( rrd == null ) openRrd(); int dsSize = 0; String[] dsNames, vNames; long rrdStep = rrdDef.getStep(); FetchData[] result = new FetchData[datasources.length]; ...
34ba683a-cdd0-4c45-bcc8-7a0a590a57a9
8
void prefetch_all_headers(Info first_i, Comment first_c, int dataoffset) throws JOrbisException{ Page og=new Page(); int ret; vi=new Info[links]; vc=new Comment[links]; dataoffsets=new long[links]; pcmlengths=new long[links]; serialnos=new int[links]; for(int i=0; i<links; i++){ ...
b4cbb0c9-1f1d-4217-b9b0-6b326f8b0dc2
0
public List<Chromo<T>> getIndividuals() { return individuals.stream() .map(chromo -> new Chromo<>(chromo.getGenes(), chromo.getFitness())) .collect(Collectors.toList()); }
0a49eed1-7567-4f3e-b7e5-56684929be4b
8
private void getData_without_index(ByteBuffer buf, final int index, OnDataListener dataListener) { int offset = index; final int idx[] = new int[6]; getIndex(buf, offset * 10, idx); int wordid = -1; if ((idx[3] == 0) && ((idx[5] - idx[1]) > 0)) { //word wordid = dataListener.OnWordData(WordFl...
abd15d86-9794-410f-af44-1e282668585d
5
public DefaultMutableTreeNode buildTree() { DefaultMutableTreeNode root; DefaultMutableTreeNode grandparent; DefaultMutableTreeNode parent; File fileRoot = new File(System.getProperty("resources") + "/tiles"); File[] fileGrandparent = fileRoot.listFiles(); File[] fileParent; root = new Defa...
4f8d4c7e-029a-416d-acd2-173bf5c59628
2
private static void reverseWords(String input) { StringBuilder output = new StringBuilder(); char[] inputStrArray = input.toCharArray(); //first reverse the complete char array reverseCharArray(inputStrArray,0,inputStrArray.length); //now iterate over it for each wor...
ddc9fd3c-b5bc-4865-8261-30cd1f4cad8d
0
public float getMPRatio() { return (float) mp / maxMP; }
2a9cd032-2e74-40ac-b11c-77b418dcfc8e
6
private void askForNewGame() { Game prevGame = objectTron; if (prevGame != null) prevGame.removeEventListener(this); while (objectTron == prevGame) { GridSizeDialog dialog = new GridSizeDialog(); int answer = dialog.show(); if (answer == JOptionPane.CANCEL_OPTION) { System.exit(0); } else if (a...
076b862b-d327-4655-a52c-a899c8c39f4f
8
private void editarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarActionPerformed // TODO add your handling code here: boolean validacion = true; String codigo_act = codigo_area_editar.getText(); String nombre,descripcion; nombre = nomb...
b3d359b6-7c4e-4c8c-88d6-9c8078f7990a
8
private Cell getBottomRightNeighbour(int i, int j) { Cell cell = null; if (i < Game.CELLS_COUNT - 1 && j < Game.CELLS_COUNT - 1) cell = cells[i + 1][j + 1]; else if (i == Game.CELLS_COUNT - 1 && j < Game.CELLS_COUNT - 1) cell = cells[0][j + 1]; else if (i < Game.C...
46b1c8af-4390-450d-8363-3ee6362ece68
5
public java.util.ArrayList processar(String tipo, String arquivo){ java.util.ArrayList lista = new java.util.ArrayList(); try { SAXParserFactory parserFactor = SAXParserFactory.newInstance(); javax.xml.parsers.SAXParser parser = parserFactor.newSAXParser(); SAXHandler handler = new SAXHandler(tipo); /...
f894c9c9-0a1a-45b5-986e-fe723daf1679
0
@Override public String toString(){ return node + " " + character + " -> " + leftChildren + " " +rightChildren ; }
bf4d935e-0386-4f9a-a617-d9841cf6ed6d
6
public void buildPreviewPanel(String name) { if (rsi == null) { return; } if (preview == null) { preview = new JPanel(new BorderLayout()); preview.setBorder(new TitledBorder("Preview")); } if (disabledPanel == null) { disabledPanel = new JPanel(new SpringLayout()); } addPanel(disabledPanel, na...
c72b2ccd-b1d0-4473-900e-9cb7c0990326
8
public static void main(String[] args) throws IOException { BattleCompletedEvent result; String tankNameString = "sample.SuperTank"; String enemyNameString = "sample.Crazy"; String shortTankName = "SuperTank"; FileOperator fOperator = new FileOperator(); SuperTank superTank = new SuperTank(); // DodgeRobot...
dfa5cbd9-f23c-4e56-bd46-a6b7ea1972c3
8
public void mostrarRespuesta(List<String> respuesta) { if (respuesta == null) { lblResultado .setText("Respuesta nula, hubo un error en el procesamiento de la consulta"); } else if (respuesta.get(0).equals("0")) { lblResultado.setText("No se ha obtenido ninguna tupla"); } else if (respuesta.get(0).equa...
417eabfd-6a65-4211-878c-396646884b17
6
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); int[] h = new int[10001]; while ((line = in.readLine()) != null && line.length() != 0){ int[] info = readInts(line...
732ce349-5f5a-499e-b394-3171ca7f1ba7
1
public Onderdeel getHuidigeOnderdeel() { if (huidigOnderdeel > _onderdelen.size() - 1) return null; return _onderdelen.get(huidigOnderdeel); }
29aaed34-1593-42c4-bc5d-7e6bf4f7d6b3
7
@Override protected boolean xhas_in () { // There are subsequent parts of the partly-read message available. if (more) return true; // If there's already a message prepared by a previous call to zmq_poll, // return straight ahead. if (has_message) ...
9c16e9cd-c205-4fbf-a2cf-38d0290beee6
0
public String getName() { return name; }
144dd408-44df-4b14-887a-aff3e307b74e
2
public static void setSerialVersionUID(CtClass clazz) throws CannotCompileException, NotFoundException { // check for pre-existing field. try { clazz.getDeclaredField("serialVersionUID"); return; } catch (NotFoundException e) {} // check if th...
e83b069c-0971-44ee-8cb7-5807e5807d17
9
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String uname=request.getParameter("newusername"); String pass=re...
d3f33218-5af1-4d63-92e0-adc5b1cae19b
2
@Override public BigDecimal calculate(Expression expression) { BigDecimal leftOperand = expression.getLeftValue(); BigDecimal rightOperand = expression.getRightValue(); if(leftOperand == null || rightOperand == null){ return null; } BigDecimal result = leftOperand.subtract(rightOperand); return...
e9483db5-e39f-4166-b810-473c3caa1e39
4
public int count(int[] s, int[] t) { int n = s.length; int a = 0; for(int i = 0;i < n;i++){ for(int j = i + 1;j < n;j++){ if(!(s[i] > t[j]||t[i] < s[j])){ a++; } } } return a; }
4bfeb815-942b-4cd1-af37-0c0c31a239a7
4
@Override public void paint(Graphics g){ super.paint(g); Iterator<Path> pathIterator = city_graph.getPathIterator(); while(pathIterator.hasNext()){ Path tmpPathRef = pathIterator.next(); g.drawLine(tmpPathRef.getFirstCity().getXLocation(), tmpPathRef.getFirstCity().getYLocation(), ...
b7e05cf6-3be8-4ef6-8021-7cf3edcd532c
8
public boolean addLeaf(C leafvalue) { if (leafToNode.containsKey(leafvalue)) return false; MerkleTree.Node curNode = root; MerkleTree.Node leafNode = new MerkleTree.Node(); leafNode.hash = leafvalue; leafToNode.put(leafvalue, leafNode); if (root.left == null) { assert root.right == null; r...
bc433e85-9a7c-4d31-9e6e-a620fd1f5a8c
9
private void getTemplateInfoForPrecompiledTemplates() { StringTokenizer paths = new StringTokenizer( System.getProperty("java.class.path"), File.pathSeparator, false); while(paths.hasMoreTokens()) { String name = paths.nextToken(); if (!name.endsWith(".jar")) ...
bea48339-c720-4ca0-975d-adf43b11bfc4
7
protected Class findClassFromURL(String name, CacheClassLoader loader) throws ClassNotFoundException { URL url = null; InputStream in = null; try { if(resourceURL.toString().endsWith("/")) { url = new URL(resourceURL.toString() + CacheClassLoader.getClassFileName(name)); ...