method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
02e8e297-518b-46cd-907c-20b457110fca
7
public static int discrete(double[] a) { double EPSILON = 1E-14; double sum = 0.0; for (int i = 0; i < a.length; i++) { if (a[i] < 0.0) throw new IllegalArgumentException("array entry " + i + " is negative: " + a[i]); sum = sum + a[i]; } if (sum > 1.0 + EP...
0da789fa-3818-4ff5-a334-1dc2a6ac0812
3
public void pullWeights(DisposableIterator<?> iterator) { if (sharedWeights.isEmpty() == false) { while (iterator.hasNext()) { Object weightedItem = iterator.next(); setNewValueForWeightedItem(weightedItem); } } }
e4c6f3e9-a647-452c-9f6f-7cbfaf1b3edb
7
private void setObstacleBoundary(float[][] x) { for (int i = 1; i < nx1; i++) { for (int j = 1; j < ny1; j++) { if (!fluidity[i][j]) { if (fluidity[i - 1][j]) { x[i][j] = x[i - 1][j]; } else if (fluidity[i + 1][j]) { x[i][j] = x[i + 1][j]; } if (fluidity[i][j - 1]) { x[i][...
3f2e277c-2668-49bd-9521-f55ab303529b
0
public StackPane initContent() { StackPane content = new StackPane(); content.setAlignment(Pos.TOP_LEFT); content.setPadding(new Insets(8, 5, 5, 5)); content.getStyleClass().add("popUpBody"); content.setMinHeight(50); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPaddin...
d03522f9-8046-45c1-9fb1-dece02d7ba71
2
public boolean isHomogeneous(int col) { double val = getRow(0).get(col); for (int i = 1; i < getNumRows(); i++) { if (val != getRow(i).get(col)) { return false; } } return true; }
84163bd9-c4ae-4629-b18b-b07b28e09504
2
private boolean hasTag(String version) { for (final String string : Updater.NO_UPDATE_TAG) { if (version.contains(string)) { return true; } } return false; }
730cbb34-1ca3-429f-8da2-dca23ea0464c
8
public Lexer(PushbackReader in) { this.in = in; if(gotoTable == null) { try { DataInputStream s = new DataInputStream( new BufferedInputStream( Lexer.class.getResourceAsStream("lexer.dat"))); //...
e9411ba4-64aa-44ac-a361-3953559143b1
3
public static int enemySwitchPokemon() { System.out.println("Enemy Initiated Pokemon Switch"); int temp=0; do { temp=(int)(Math.random()*enemyNumOfPokemon); } while(!Mechanics.isAlive(enemy[temp].health)); enemy[enemyIndex].atkStage=0; enemy[enemyIndex].defStage=0; enemy[enemyIndex].speedStage=0...
19c99ea0-d5e1-472a-8604-ce8ff9388a21
6
public static String[] split(String toSplit, char delim, boolean ignoreEmpty) { StringBuffer buffer = new StringBuffer(); Stack stringStack = new Stack(); for (int i = 0; i < toSplit.length(); i++) { if (toSplit.charAt(i) != delim) { buffer.append((char) toSplit.charAt(i)); } else { ...
236c6ca1-0c4e-46fa-9efe-2989605e77c4
2
public void createDeck() { final String[] values = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"}; final String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"}; // iterate values and suites to create each card; stop at deckSize fo...
439f141e-fc2c-410c-8cb9-dc5c390dd05b
2
public void autonomousInit() { shooter.enable(); new SpinDown().start(); SmartDashboard.putBoolean("Enabled", true); if (teleop != null) { teleop.cancel(); } autonomouse = (Command) chooser.getSelected(); if (autonomouse != null) { autonomo...
29ef48d3-2231-4cdc-ac78-e74312317008
6
public static void buildLocalGame(Checkmate c, GameType g, int t, Difficulty d1, Difficulty d2) { GameModel gm = setupGameType(g,t); c.setGameModel(gm); gm.addObserver(c); if (d1 == Difficulty.HUMAN && d2 == Difficulty.HUMAN) { LocalPlayer lp1 = new LocalPlayer(gm, c, true); LocalPlayer lp2 = new LocalPla...
c0f98512-dc0e-451d-af70-af4216d15426
0
public GotoTransitionTool(AutomatonPane view, AutomatonDrawer drawer, LRParseDerivationController controller) { super(view, drawer); this.controller = controller; }
645d98ce-a547-4ab5-85ae-cc3521cdc61d
5
static AccessClassLoader get (Class type) { ClassLoader parent = getParentClassLoader(type); // 1. fast-path: if (selfContextParentClassLoader.equals(parent)) { if (selfContextAccessClassLoader == null) { synchronized (accessClassLoaders) { // DCL with volatile semantics if (selfContextAccessClassLoad...
23542333-ba49-44f0-be68-a8229a435655
8
public void updatePosition(Vec2 maximumMovement){ boolean isNearLeftEdge = xOnMap <= StatePanel.PWIDTH / 2; boolean isNearRightEdge = xOnMap >= mapWidth - StatePanel.PWIDTH / 2; if(left){ if (isNearLeftEdge) { xOnMap = (xOnMap + maximumMovement.getX() >= 0) ? ...
b9c30a71-3d4b-4772-8de7-d58682e49c0d
7
public static String findLongestCommonSubstring(String s1, String s2) { int length[][] = new int[s1.length()+1][s2.length()+1]; int maxLength = Integer.MIN_VALUE; int max_end = -1; //base case .. Empty string matches length[0][0] = 1; for(int i=0; i <= s1.length(); i++)...
dbc0e65f-af5d-40a6-bc92-6bcad8b7ddb5
2
public static DHCPOption newOptionAsInetAddress(byte code, InetAddress val) { if ((!isOptionAsInetAddr(code)) && (!isOptionAsInetAddrs(code))) { throw new IllegalArgumentException("DHCP option type ("+code+") is not InetAddress"); } return new DHCPOption(code, inetAddress2Bytes(va...
abba7e9a-33ed-43de-bb5b-5654dc7e8cfc
8
protected MOB possibleCatalogSwap(final MOB editorMOB, final MOB me) throws IOException { if(!CMLib.flags().isCataloged(me)) return me; final MOB cataM=CMLib.catalog().getCatalogMob(me.Name()); if(cataM!=null) { final Session session = editorMOB.session(); for(final Enumeration<Item> i=cataM.items();i...
3d60ce66-77ba-46a1-a791-050ddf8d98f2
2
public static void clear() { Keyboard.destroy(); try { Keyboard.create(); } catch (LWJGLException e1) { e1.printStackTrace(); } for(Keybind e : Keybind.values()) { e.key.setPressed(false); } }
88e94996-34fa-4e40-bcc2-e6ea705890a8
4
public void addCurrency(Player player, int amount) throws PlayerNotFoundExeption { String formatAmount = Matcher.quoteReplacement(plugin.economyHandler.format(Math.abs(amount))); if (!plugin.economyHandler.has(player.getName(), amount)) { languageHandler.sendMessage(player, "trade.currency.no-balan...
ed66a89f-fa61-471f-b5bc-98e331c7d47c
2
public static final long extractDateTime(String text) { if (text != null) { Matcher matcher = DATE_TIME_PATTERN.matcher(text); if (matcher.find()) { Calendar cal = Calendar.getInstance(); cal.clear(); int year = Numbers.extractInteger(matcher.group(1), 0, false); int month = Numbers.extractInteg...
5faf5879-46b9-43d9-b92d-2e7fd4cb81ea
4
private void closeAll(InputStream fileReader, Socket clientSocket, Object obj) { if (fileReader != null) try { fileReader.close(); } catch (IOException e) { e.printStackTrace(); } if (clientSocket != null) try { clientSocket.close(); } catch (IOException e) { e.printStackTrace(); }...
787f1aad-d70a-4a67-8b37-17e90f9ed0c0
5
public void insertAt(int index, int val) throws InvalidAccessException { if (index - 1 < 0) { throw new InvalidAccessException("Index < 0"); } if (this.head == null) { DLNode n = new DLNode(); this.head = n; this.tail = n; } if (this.countElements() - 1 > index - 1) { if (isNodeInitialized(in...
3be28c08-81a8-4486-b06c-954d8c636644
4
public void setSign(String sign) { if (sign == null) signButtonGroup.clearSelection(); else if(sign.equals(AData.PLUS)) signButtonGroup.setSelected(plusButton.getModel(), true); else if(sign.equals(AData.MINUS)) signButtonGroup.setSelected(minusButton.getModel(), true); if (signButtonGroup....
e4782059-8599-4fa0-950f-cc3635800d9a
9
public void validaOperadora(KeyEvent e) { char c = e.getKeyChar(); c = (c + "").toLowerCase().charAt(0); System.out.println(c); if ((c < 'a' || c > 'z') && c != 'ñ' && c != ' ' && c != 'á' && c != 'é' && c != 'í' && c != 'ó' && c != 'ú') { e.consume(); } }
50130bb6-9f9b-4ade-93e1-06c0d3984357
4
public static void main( String[] args ) { while ( !vol_sortir_del_programa ) { seleccionaDriverAProvar(); if ( ha_seleccionat_driver && !vol_sortir_del_programa ) { while ( !vol_sortir_al_menu_principal ) { seleccionaMetodesAProvar(); } vol_sortir_al_menu_principal = false; } }...
d618e761-d2a0-4ab5-bb62-3c5f7043b4c8
6
void setExampleWidgetForeground () { if (colorAndFontTable == null) return; // user cannot change color/font on this tab Control [] controls = getExampleControls (); if (!instance.startup) { for (int i = 0; i < controls.length; i++) { controls[i].setForeground (foregroundColor); } } /* Set the foreg...
00612eaf-a5c8-4e70-8590-3af58b7ef153
8
public void cycleLetter(Joystick j) { switch (j) { case UP: if (letter == 'z') letter = ' '; else if (letter == ' ') letter = '.'; else if (letter == '.') letter = 'a'; else letter += 1; break; case DOWN: if (letter == 'a') letter = '.'; else if (letter == '.') letter ...
2a9f4076-8561-401a-b9af-0176ba0254ba
3
public void act(){ if(getWorld()!=null){ setRotation((int)angle); move((int)velocity); updateSpeed(); updateRotation(); if(isAtEdge()||isTouching()){ getWorld().removeObject(this); } } }
e3e705b3-2537-485d-a9a3-d33335e79df9
4
public static void write(String fileName) { DocumentBuilder builder = null; try { builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); org.w3c.dom.Document document = builder.newDocument(); org.w3c.dom.Element root = document.createElement("华农"); org.w3c.dom.Element wang = document.creat...
43a85abb-1755-4017-831b-5f98fa2bd1d0
7
public void studentCategorySubscribe(String userid, String categoryName){ int catId = CategoryDao.getCategoryIdByName(categoryName); int id = PersonDao.fetchPersonId(userid); //deleteSubscribedCategories(id); ResultSet rs=null; Connection con=null; PreparedStatement ps=null; try{ String sql="INSERT ...
55657faf-a4ab-481a-99a9-c33d48257ce6
9
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof PrerrequisitoPK)) { return false; } PrerrequisitoPK other = (PrerrequisitoPK) object; if ((this.idpropuesta == ...
fbf8917b-f203-49e8-a305-b180a85191ec
4
public void draw(Graphics g, PositionTransformation pt) { Position p1 = startNode.getPosition(); pt.translateToGUIPosition(p1); int fromX = pt.guiX, fromY = pt.guiY; // temporarily store Position p2 = endNode.getPosition(); pt.translateToGUIPosition(p2); if((this.numberOfMessagesOnThisEdge == 0)&& (t...
cf485c65-754a-4289-81cd-5cbbbbce628b
1
public StoreType getType(){ if(type==null) return StoreType.NORMAL; return type; }
0f86029d-827d-4b7e-8d3f-cf0e5676cda2
5
private void btn_ContinueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ContinueActionPerformed System.out.println("Iniciando configuraciones"); sys_productores = (Integer) jSpinnerProductores.getValue(); sys_consumidores = (Integer) jSpinnerConsumidores.getValue(...
7344cdb3-1610-4522-83cd-0886eaf9e724
9
private void startMorse(){ boolean valeurValide; while(true){ valeurValide = true; String chaineACoder = ""; int choix = 1; System.out.println("Entrez la phrase à coder en morse: "); chaineACoder = sc.nextLine(); System.out.println("Choisissez le mode de codage"); System.out.println("1: Normal ...
20d4233b-8cc4-40b0-9b41-db6ea2209aef
7
public static int stirling( int n, int k ) { if ( ( n > 0 && k == 0 ) || k > n ) return 0; if ( stirling.length <= n ) { int[][] newStirling = new int[n+1][n+1]; for ( int i = 0; i <= n; i++ ) { if ( i < stirling.length ) { System.arraycopy( st...
26fe9b4f-f062-4d9e-8727-52ee91c57b26
4
public void passiveRequest(int id, int type) { if (clientInstance.caches[0] == null) return; if (versions[type][id] == 0) return; if (filePriorities[type][id] == 0) return; if (highestPriority == 0) return; OnDemandData onDemandData = new OnDemandData(); onDemandData.dataType = type; onDemandD...
c6896a8f-b547-4e93-9154-e892bf7f98f8
7
private String dumpKeyTypes(Object newVal, Object oldVal) { StringBuilder buf = new StringBuilder(); Set<Class<?>> types = new HashSet<Class<?>>(); for (Object o : _set) { if (o != FREE && o != REMOVED) { if (o != null) types.add(o.getClass()); ...
67c2508d-cdb3-4864-9f41-b36edb40fcbf
0
public static void main(String args[]) { RegExFind sf = new RegExFind(args); }
003aa9a4-d5f7-4c32-ac68-baf4dae26180
2
public final void roll(double angle) { if (YAXIS_ANGLE == -angle) { YAXIS_ANGLE = angle; YAXIS_TURN.entry[0][2] = -YAXIS_TURN.entry[0][2]; YAXIS_TURN.entry[2][0] = -YAXIS_TURN.entry[2][0]; } else if (YAXIS_ANGLE != angle) { // Cache it! YAXIS_ANGLE = angle; angle = Math.toRadians(angle); double...
5d7207cc-02ca-4dae-af69-cd8977cf6558
4
public static InputStream processTransSync(URL pipelineUrl, InputStream docStream) throws EnrycherException { try { HttpURLConnection connection = (HttpURLConnection)pipelineUrl.openConnection(); connection.setRequestMethod("POST"); connection.setConnectTimeout(timeout); connection.setReadTimeout(time...
c192950b-ae7e-4a47-afb2-17528611f6bb
5
public static Version parse(String s) throws VersionFormatException { if (s == null) { throw new NullPointerException(s); } else if (s.equals("*")) { return ALL; } else { try { Modifier m = Modifier.Release; final int i = s.indexOf('-'); if (i > 0) { m = Modifier.parse(s.substring(i + 1)...
3ff61b5e-a2e1-4ea2-873c-b49756764a80
5
public boolean consumeDepository(ResourceItem res) { boolean flag = false; if (res != null && !res.isItemEmpty()) { synchronized (instance) { if (depository.containsKey(res.getResourceName()) && depository.get(res.getResourceName()) >= res.getResourceNum()...
b960e04e-8386-4877-9b52-1144ef43f402
9
@Override public void run(CommandSender sender, String maincmd, String[] args) { if (sender instanceof Player && !sender.hasPermission("mobmanager.checkmobs")) { sender.sendMessage(ChatColor.DARK_RED + "You do not have permission to use /mm checkmobs"); return; } if (!(sender instanceof Player)) { ...
1694f925-17ca-44a6-9459-bcaa4be65f4d
5
public static void printLCS(int[][] c, char[] x, int i, int j) { if(i == 0 || j == 0){ return; } if(c[i][j] != c[i - 1][j] && c[i][j] != c[i][j - 1]){ printLCS(c, x, i - 1, j - 1); System.out.print(x[i - 1]); }else if(c[i][j] == c[i - 1][j]){ printLCS(c, x, i - 1, j); }else{ printLCS(c, x,i,...
5bdbba4c-643b-4e82-9aa6-8f2d3124a814
4
private byte getBorderTypeBiomes(Tile tile, Point[] surrPoints) { for (Point p : surrPoints) { Tile t = MyzoGEN.getOutput().getTile(p); if (t != null && t.tile != tile.tile && Tiles.getPrecedence(t.tile) > Tiles.getPrecedence(tile.tile)) { return t.tile; } } return (byte) 255; }
bcda981a-40f9-4696-8e1f-06babd1c81c5
7
private Dimension layoutSize(Container target, boolean preferred) { synchronized (target.getTreeLock()) { // Each row must fit with the width allocated to the containter. // When the container width = 0, the preferred width of the container // has not yet been calculated so l...
d699f481-5681-4faa-a40e-b49743863038
8
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } GenericTreeNode<?> other = (GenericTreeNode<?>) obj; if (data == null) { if (other.data != null) { return false; } ...
e050cb23-4fa8-4c33-882e-c1ee7b7a14a0
5
public static List<GroupDetailInfo> getGroupDetailByQuery(String keyword) throws HibernateException { List<GroupDetailInfo> queryResultList = null; Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try { // Begin unit of work session.beginTransaction(); String hqlString = "sele...
b25a4c27-b5bb-41ad-afe2-05b02853ea30
1
public GUI(){ super("DNS DB with B+ Tree"); setDefaultCloseOperation(EXIT_ON_CLOSE); dnsDB = new DNSDB(); setLayout(new BorderLayout()); ipText = new JTextField(); ipText.setColumns(15); ipText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { validateButton(); } ...
8b19f413-e9fd-469a-8419-d5699a5842b5
8
public MazeNode movePlayer(MazeEnums.Direction direction) { switch(direction){ case EAST: if(eastNode.enter()) return eastNode; break; case NORTH: if(northNode.enter()) return northNode; break; case SOUTH: if(southNode.enter()) return southNode; break; case WEST: if(westNode.e...
4a6322f9-b414-4e04-a0bb-9a77a639f20f
7
public static int getDayOfYear(Calendar cal, int type) { int jday = cal.get(Calendar.DAY_OF_YEAR); int mo = cal.get(java.util.Calendar.MONTH) + 1; if (type == CALENDAR_YEAR) { return jday; } else if (type == SOLAR_YEAR) { int day = cal.get(Calendar.DAY_OF_MONTH); ...
fc1a5e41-7c55-42bd-92dd-c16f469ef833
1
public void setPercentage(double percentage) { this.percentage = Math.min(1.0, percentage); if(this.percentage > 0.99) { this.percentage = 1.0; } curValue = Math.min((long)Math.ceil(percentage * maxValue), maxValue); }
8013bc85-0feb-4d3e-b665-024691f7f169
9
public static GregorianCalendar lireDate(String date) { boolean ok = false; String[] champsDate ; int jour = 1; int mois = moisCourant(); int an = anneeCourante(); GregorianCalendar dateSaisie = null ; // Conversion de la chaîne en 2 variables mois, an. champsDate = date.split("/"); // O...
fc299577-fdce-4573-8f3b-fa39b48c5e22
0
public void commitEdit() throws ParseException { commitTime(); super.commitEdit(); }
883ef2b9-b552-4729-b738-f4d600144e6f
7
@Override public int compare(Cell<?> cell1, Cell<?> cell2) { int thisRow = cell1.getRow(); int otherRow = cell2.getRow(); int cmp = (thisRow < otherRow ? -1 : (thisRow > otherRow ? 1 : 0)); if (cmp == 0) { int thisCol = cell1.getColumn(); ...
a03fff1d-9f53-44fd-b351-45d0960f5b93
6
private void valid(int areaOne, int areaOneForth, int areaOneSixteenth) throws AxisWithoutMeaningErrorException { if (areaOne < minOne || areaOne > maxOne) { throw new AxisWithoutMeaningErrorException(); } if (areaOneForth < minOneForth || areaOneForth > maxOneForth) { ...
3499c2df-a760-4dae-b446-df1e6662871b
1
private String buildJsonData(String username, String message) { JsonObject jasonObject = Json.createObjectBuilder().add("message", username + ": " + message).build(); StringWriter stringwriter = new StringWriter(); try (JsonWriter jsonwriter = Json.createWriter(stringwriter)) { jsonw...
7ff99801-a9fc-4cb6-9bea-f604ce5e3977
1
public String getColumn() { if (column == null) { throw new RuntimeException("missing column name."); } return column; }
677f5ead-2ad0-4f6d-b125-0fac80320476
3
public void ordinaryChars(int low, int hi) { if (low < 0) low = 0; if (hi >= ctype.length) hi = ctype.length - 1; while (low <= hi) ctype[low++] = 0; }
efce11bb-8980-4f57-a3bd-dc1a84ef07a5
1
private void addToIncludedBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToIncludedBtnActionPerformed List<File> ls = excludedList.getSelectedValuesList(); Model m = controller.getModel(); for(File f : ls){ m.getFilesToInclude().add(f); m.getFilesToExclude().remove(f); } update...
481ee75b-79f3-4a01-9751-7fa02e83d209
9
public int checkDGR() { if(cornerMap.get("D").equals("D") && cornerMap.get("G").equals("G") && cornerMap.get("R").equals("R")) { return SOLVED; } if(cornerMap.get("D").equals("R") && cornerMap.get("G").equals("D") && cornerMap.get("R").equals("G")) { return CW; } if(cornerMap.get("D...
30291568-6239-4658-af5b-988897e938e8
1
public FAT32DIRElement(byte[] bytes) throws UnsupportedEncodingException { if (bytes.length == DIR_ELEMENT_SIZE) { bytesOfFAT32Element = bytes; init(); } else { System.out.println("ERROR: FAT32DIRElement can't be greater or lesser than 32 bytes!"); } }
7694096e-f08d-4aa9-aaec-120f24f5e3ad
2
public List<PlayerAction> ApplicableActions(GameState inState){ ArrayList<PlayerAction> output = new ArrayList<PlayerAction>(); for(PlayerAction Action : AllActions){ if(Action.isRelevant(inState)) output.add(Action); } return output; }
b15dbd3d-9c5c-45cf-bc9a-4865d39c2af3
8
public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = 1; String s; while ((s = br.readLine()) != null) { String[] temp = s.split(" "); int N = Integer.parseInt(temp[0]); ...
fb4c1c0e-4024-4824-8005-7e871821e673
1
public static boolean isCreated(){ if (Carte.AuxQuatresCoinDuMonde ==null) return false; else return true; }
5eb51b79-2eae-42d7-ab88-1b48374f6edd
1
@Test public void sample_test() { RoleDecider rd = new RoleDecider(mock(Players.class)); for (int i = 0; i < 10; i++) { //rd.getRoleToBeAssigned(); } }
c243c203-4d38-4ffd-aaf1-bc9b382273b6
6
public static void removeNonRepairers() { ArrayList<Unit> toRemoveList = new ArrayList<>(); for (Unit unit : repairers) { if (unit == null || !unit.isExists() || !unit.isMoving() || !unit.isRepairing() || unit.isIdle()) { toRemoveList.add(unit); repairersToBuildings.remove(unit); } } repair...
10585f73-06db-4b72-bcaf-621bfe158481
8
public String getAnswer() { String input = "08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08\n" + "49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00\n" + "81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65\n" + "52 70 95 23 04 60 11 4...
48244c7a-afe3-464b-a2ab-3dc18de6b702
1
private void startOutput(String fileName){ forefathersNodeFile = new java.io.File(fileName + ".forefathers.txt"); leavesNodeFile = new java.io.File(fileName + ".leavesNode.txt"); leavesContentFile = new java.io.File(fileName + ".leavesContent.txt"); try { forefathersNodeFileWriter = new FileWriter(forefather...
e88b6d5e-9891-4d60-adf9-83d20ae2fe7c
9
public void run() { Iterator<Byte> iter; Byte tAck; byte rStack; boolean resend = false; while (true) { this.lock.lock(); iter = this.oneToOne.keySet().iterator(); while(iter.hasNext()) { rStack = iter.next(); resend = true; tAck = this.ACKReceived.get(rStack); byt...
2fdc175c-ecb2-437e-b5c9-cf8e40f159ef
6
LocalSocket(Socket socket, PassthroughConnection ptc, int worldHeight) { this.ptc = ptc; this.socket = socket; DataInputStream inLocal = null; DataOutputStream outLocal = null; try { inLocal = new DataInputStream( socket.getInputStream() ); } catch (IOException e) { ptc.printLogMessage("Unable to open...
4705a690-69be-40a6-abd5-5bcef27e075e
5
public ArrayList<TreeNode> subGen(int l, int r, HashMap<String, ArrayList<TreeNode>> dp) { ArrayList<TreeNode> res = new ArrayList<TreeNode>(); if (l > r) { res.add(null); return res; } String str = String.valueOf(l) + "_" + String.valueOf(r); if (dp.containsKey(str)) return dp.get(str); for (in...
33188160-0188-4bd2-8170-1017b7cbe494
6
public int initialize(byte[] data, int offset) { this.offset = offset; List dsftBinSpriteList = new ArrayList(); boolean moreRecords = true; boolean readSetHeader = false; while(moreRecords) { DsftBinSprite dbs; try { ...
75b6efac-d2d6-4be6-b56c-17aa3d503f22
2
private TreeNode insertAVL(T element, TreeNode node) { if (node == null) { return new TreeNode(element); } if (element.compareTo(node.element) < 0) { node.node1 = insertAVL(element, node.node1); } else { node.node2 = insertAVL(element, node.nod...
8dba58e5-fa31-4b51-b23a-1430bbc8093e
5
public static void pathSumHelper(ArrayList<ArrayList<Integer>> result, ArrayList<Integer> list,TreeNode node, int sum, int tempSum) { if(node == null) return; tempSum += node.val; list.add(node.val); //copy the list ArrayList<Integer> newCopyListL = new ArrayList<Integer>(); ...
76500783-6961-4718-a2fd-9ddfef3d4d85
8
@Override public V put(K key, V value) { if(key==null) throw new NullPointerException("Keys cannot be null"); int code=System.identityHashCode(key); int hash =hash(code); hash &=mask; // System.out.println(Integer.toHexString(hash)+"\t"+Integer.toHexString(hash2)+"\t"+Integer.toHexString(hash3)...
f0ccd25e-26ec-42d8-85c0-5fba4401f3bb
6
boolean won(Piece piece) { for (int i = 0; i < 3; i++) if (getNumEachPiece(board[i], X)[0] == 3) return true; for (int j = 0; j < 3; j++) if (getNumEachPiece(getColumn(j), X)[0] == 3) return true; if (getNumEachPiece(getBottomUpDiag(), X)[0] == 3 || getNumEachPiece(getTopDownDiag(), X)[0] == 3) ...
391d89f0-b504-4c5a-b7e8-3ed5b38be3b4
5
@Override public void atribuirJogo(String cod_jogo, String cod_equipa) { String[] aux = cod_jogo.split("_"); int jogo = Integer.parseInt(aux[2]); if (jogo / 2 == 0) { int jornada = Integer.parseInt(aux[1]) + 1; if (this.getJogos().containsKey(aux[0] + "_" + jornada +...
31af0162-ffcf-47f9-b713-a5e4d5a752ad
9
public static List<Class<?>> getClassNamesFromJAR(File jar, ICondition<Class<?>> condition) throws IOException, ClassNotFoundException { List<Class<?>> out = new ArrayList<Class<?>>(); // if the condition is null get a default condition if (condition == null) { condition = ConditionHelper.createDefault(...
5aef18a3-1df8-43ce-9d15-da478823f107
1
@Override public QName getName() { if(isText()) return null; else return name; }
330dbeff-1d08-4cd1-9836-a08d16b593f6
3
public void setBounds() { if(isEmpty()) { setBounds(0, 0, 1, 1); } else if(size() == 1) { UIBounds initBounds = get(0).getBounds(); setBounds(initBounds.getXAsSupplier(), initBounds.getYAsSupplier(), initBounds.getWidthSupplier(), initBounds.getHeightSupplier()); } else { for(UIElement e : uiElements)...
71e99b6a-c1d9-4333-a939-0d5e8f0a66f0
3
public void showProduct(String nome) { if (this.getQuantity() > 0) { for (Product p : this.products) { if (p.getName().equals(nome)) { System.out.println(p); } } } else { System.out.println("Seu carrinho ainda não possui produtos.\n"); } }
3f8bd190-74ba-45be-9ec0-a5b796f71a29
6
synchronized public boolean insert(T item) { int initHashIdx = alg.hash(item); if(initHashIdx < 0) { // Failed to get hash index return false; } int hashIdx = initHashIdx; int retry = 0; while(bucket[hashIdx]!=null) { retry++; if(bucket[hashIdx].equals(item)) { System.out.println("Item is...
76f6f568-58c2-4a9a-bead-69f172a60b6f
3
public int inputToInt() { int inputValue = 0; while (true) { try { inputValue = this.in.nextInt(); break; } catch (NumberFormatException e) { System.out.println("That wasn't an int value. Try another one..."); this.in.nextLine(); } catch (InputMismatchException e) { System.out.println("...
7882396e-bf84-4071-9ba3-032e2f1bdf75
0
public static boolean isApplicable(Object object) { return true; }
6c9d4b3c-7841-4bad-b446-a97a256f0007
5
@DBCommand public boolean spawn(CommandSender sender, Iterator<String> args) { if(!sender.hasPermission("db.spectate")) { sender.sendMessage(RED + "You don't have permission to use this command!"); return true; } if(!(sender instanceof Player)) { sender.se...
362c1b98-5763-4452-aa71-5fc63fcf5806
1
private static boolean deleteEmployee(Employee bean, PreparedStatement stmt) throws SQLException{ stmt.setString(1, bean.getUsername()); int affected=stmt.executeUpdate(); if(affected==1){ System.out.println("Employee with username "+bean.getUsername()+" has been Removed from database."); } else { ...
7665927a-c671-4e17-959c-a2f2e3a6b85c
8
public static final ParameterizedCommand generateCommand(Command command, Map parameters) { // no parameters if (parameters == null || parameters.isEmpty()) { return new ParameterizedCommand(command, null); } try { ArrayList parms = new ArrayList(); Iterator i = parameters.keySet().iterator(); ...
83501943-464e-4a61-9beb-4d287931582c
4
private void btExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExcluirActionPerformed int linhaSelecionada = -1; linhaSelecionada = tabela.getSelectedRow(); if (linhaSelecionada >= 0) { int i = (JOptionPane.showConfirmDialog(null, "Tem certeza que deseja e...
4e4114e9-7501-45c8-87bf-f0b34c7e8d9f
2
public int compareTo(MessageStatussDTO other) { if (this.getDate().equals(other.getDate())) { return 0; } else if (this.getDate().compareTo(other.getDate()) == 1) { return -1; } else { return 1; } }
94f5bd7d-bee2-41cd-9653-80e72718d561
8
private void updateSurroundings() { for (int r = -3; r < 3; r++) { for (int c = -3; c < c; c++) { int rr = getLocation().getRow(); int cc = getLocation().getCol(); int rrr = rr+r; int ccc = cc+c; if (rrr >= 0 && ccc >= 0 && ccc < 2*PavoHelper.getGameWidth(getManager().getWorld().getWorldSize())...
d6143175-e864-4baa-9f29-081f11a30af5
4
public final void grow(int size) { if (locals != null) { size += count; if (size > locals.length) { int nextSize = locals.length * 2; // GlobalOptions.err.println("wanted: "+size+" next: "+nextSize); LocalInfo[] newLocals = new LocalInfo[nextSize > size ? nextSize : size]; System.arraycopy...
921930aa-4724-43b8-8251-d82e02395502
6
@Override public void unsafe_set(int row, int col, double val) { if( row == 0 ) { if( col == 0 ) { a11 = val; return; } else if( col == 1 ) { a12 = val; return; } } else if( row == 1 ) { if( col == 0 ) { ...
33426f61-e724-4216-9c90-2cf389fa65d1
0
public String getUri() { return uri; }
31d623da-6ac7-4a76-91bf-ecf53e9884dd
1
public static GameFont getFont(String font) { if(fonts.containsKey(font)) return fonts.get(font); return fonts.get("DEFAULT"); }
cdb9553c-2d6a-49e9-950a-fa9a3f94277a
7
private boolean Formula_0() { begin(""); if (!next('(')) return rejectInner(); if (!Formula()) return rejectInner(); if (!Space()) return rejectInner(); if (!BinaryCon()) return rejectInner(); if (!Space()) return rejectInner(); if (!Formula()) return rejectInner(); i...
152ddfa6-a833-46d4-8d1c-791b0129fbb7
8
@Override public InputStream send() { this.parameterMap.put("page", Integer.toString(currentPage)); //Prepare parameters prepare(); try { HttpURLConnection con = prepareConnection(new URL(String.format(URL_FORMAT, this.url, this.parameters))); String linkHeader = con.getHeaderField(LINK_HEADER); th...
e408102b-a3d3-445d-bcf1-23fdb137b17c
4
private static TextureResource LoadTexture(String fileName) { try { BufferedImage image = ImageIO.read(new File("./res/textures/" + fileName)); int[] pixels = image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth()); ByteBuffer buffer = Util.CreateByteBuffer(image.getHeight() * ...