method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
51802de9-bb2b-4fb7-82a7-e1203861f6e9
3
public void drawCenteredStringMoveXY(String string, int x, int y, int color, int waveAmount) { if (string == null) { return; } x -= getTextWidth(string) / 2; y -= baseHeight; for (int index = 0; index < string.length(); index++) { char c = string.charAt(index); if (c != ' ') { drawCharacter(characterPixels[c], x + characterOffsetX[c] + (int) (Math.sin((double) index / 5D + (double) waveAmount / 5D) * 5D), y + characterOffsetY[c] + (int) (Math.sin((double) index / 3D + (double) waveAmount / 5D) * 5D), characterWidth[c], characterHeight[c], color); } x += characterScreenWidth[c]; } }
5f5a213a-7627-4fff-a6cb-9acb6287196a
5
private boolean checkRows() { boolean deleteThisRow; boolean retval = false; for(int i = 0; i < rows; i++) { deleteThisRow = false; for(int h = 0; h < columns; h++) { if(bricks[i][h] == null) break; if(h == columns-1) deleteThisRow = true; } if(deleteThisRow) { retval = true; rowsToDelete.add(i); } } return retval; }
fc2a7f4a-9322-4569-a437-69058dcfd101
3
private void geocentreToTopocentre(double time, Vector position, Vector velocity) { final double FL = 1.0 / 298.257; /* Flattening of the earth */ final double RE = 6378.14; /* Radius of Earth in km. */ final double OMEGA = 7.2921151467e-5; /* * Earth's rotation in * radians/second */ double f2 = (1.0 - FL) * (1.0 - FL); double cphi = Math.cos(latitude); double sphi = Math.sin(latitude); double c = 1.0 / Math.sqrt(cphi * cphi + f2 * sphi * sphi); double s = f2 * c; /* Get geocentric coordinates including elevation correction */ double pcospd = (RE * c + height * 0.001) * cphi * reciprocalAU; double psinpd = (RE * s + height * 0.001) * sphi * reciprocalAU; /* Get the position vector of the observer in AU */ double LST = erm.greenwichApparentSiderealTime(time) + longitude; Vector pTopo = new Vector(pcospd * Math.cos(LST), pcospd * Math.sin(LST), psinpd); Vector vTopo = (velocity != null) ? new Vector(-OMEGA * pcospd * Math.sin(LST) * 86400.0, OMEGA * pcospd * Math.cos(LST) * 86400.0, 0.0) : null; Matrix pMatrix = erm.precessionMatrix(ephemeris.getEpoch(), time); Matrix nMatrix = erm.nutationMatrix(time); pMatrix.transpose(); nMatrix.transpose(); pTopo.multiplyBy(nMatrix); pTopo.multiplyBy(pMatrix); position.add(pTopo); if (velocity != null && vTopo != null) { vTopo.multiplyBy(nMatrix); vTopo.multiplyBy(pMatrix); velocity.add(vTopo); } }
1b48d485-cece-4019-8812-64a8e65db2ef
1
public ArrayList<Integer> traversal(ListNode head){ ArrayList<Integer> res = new ArrayList<Integer>(); ListNode p = head; while(p != null){ res.add(p.val); p = p.next; } return res; }
26c819ef-a638-4bb6-8401-bfc294de4652
2
public static void printPattern(boolean[] pattern){ System.out.print("|"); for (int i = 0; i < pattern.length; i++){ if (pattern[i]) System.out.print(""+1); else System.out.print(""+0); System.out.print("|"); } }
d1ee1439-8b8a-4e2f-9c5b-37064157a1fa
0
@Basic @Column(name = "PRP_ID_FUNCIONARIO") public Integer getPrpIdFuncionario() { return prpIdFuncionario; }
6477d207-a764-48af-8df1-4d59886b5596
4
private void backward(int[] sequence, double[][] bwd, double[] scaling) { int T = sequence.length; int S = this.getNumberOfStates(); double[] pi = this.pi; double[][] a = this.a; double[][] b = this.b; // 1. Initialization double sc = 1.0d / scaling[T - 1]; for (int i = 0; i < S; i++) { bwd[T - 1][i] = sc; } // 2. Induction for (int t = T - 2; t >= 0; t--) { sc = 1.0d / scaling[t]; for (int i = 0; i < S; i++) { double sum = 0; for (int j = 0; j < S; j++) { sum += a[i][j] * b[j][sequence[t + 1]] * bwd[t + 1][j]; } bwd[t][i] += sum * sc; } } }
27891058-ec87-4a0d-b9ad-f63e27ff2c49
2
public boolean equals (Time t) { this.format(); t.format(); return this.day == t.day && this.hour == t.hour && this.min == t.min; }
30c7aede-8b95-41ff-a381-ee60e77c3ffc
6
@Override public Piece createPiece(Position pos, PieceType pieceType, final ChessColor color, ChessCoord initialCoord) { Piece result; switch (pieceType) { case PAWN: result = new Pawn(pos, color, initialCoord); break; case ROOK: /* * At the moment we assign kingside rooks to be the one on the right * half of the starting positions */ /* * IMPROVE This is specific to initial setups where the rooks are * actually on the respective sides of the king. To support any rook * positioning, we have to redo this */ result = new Rook(pos, color, initialCoord, initialCoord.getFile() > 3); break; case KNIGHT: result = new Knight(pos, color, initialCoord); break; case BISHOP: result = new Bishop(pos, color, initialCoord); break; case QUEEN: result = new Queen(pos, color, initialCoord); break; case KING: result = new King(pos, color, initialCoord); break; default: throw new UnsupportedOperationException( "The passed PieceType is not supported"); } return result; }
9a299b04-3488-4e36-b95f-f20e4c1f2edd
4
@Override public void deserialize(Buffer buf) { questId = buf.readUShort(); if (questId < 0 || questId > 65535) throw new RuntimeException("Forbidden value on questId = " + questId + ", it doesn't respect the following condition : questId < 0 || questId > 65535"); stepId = buf.readUShort(); if (stepId < 0 || stepId > 65535) throw new RuntimeException("Forbidden value on stepId = " + stepId + ", it doesn't respect the following condition : stepId < 0 || stepId > 65535"); }
ae932082-66ff-4f1d-bc90-434c710b7d24
9
public String[] listClasses(String packageName, boolean recurse) { List<String> ret = new LinkedList<String>(); // scan dirs final String fileSystemPackagePath = packageName.replace('.', File.separatorChar); for (File dir : dirs) { File subfolder = new File(dir, fileSystemPackagePath); if (subfolder.exists() && subfolder.isDirectory()) { addClassesInFolder(ret, subfolder, packageName, recurse); } } // scan jars final String jarPackagePath = packageName.replace('.', '/'); for (JarFile jar : jars) { for (Enumeration<JarEntry> entries = jar.entries(); entries.hasMoreElements();) { // Get the entry name String entryName = (entries.nextElement()).getName(); if (entryName.endsWith(".class") && entryName.startsWith(jarPackagePath)) { int lastSlash = entryName.lastIndexOf('/'); if (lastSlash <= jarPackagePath.length() || recurse) { String path = entryName.substring(0, lastSlash); String className = entryName.substring(lastSlash + 1, entryName.length() - 6); ret.add(path.replace('/', '.') + "." + className); } } } } return ret.toArray(new String[ret.size()]); }
f9365a04-cd0d-400f-92d7-5449c6a2ea92
9
Vector<Integer> crossCheck(Vector<Integer> possibilities, Vector<Integer> confirmations) { Vector<Integer> result = new Vector<>(6); if (possibilities.size() == 0) { for (int cellId : confirmations) { if (cellId >= 0) { result.add(cellId); } } } else if (confirmations.size() == 0) { for (int cellId : possibilities) { if (cellId >= 0) { result.add(cellId); } } } else { for (int cellId : confirmations) { if ((possibilities.contains(cellId)) && (cellId >= 0)) { result.add(cellId); } } } result.trimToSize(); return result; }
f54cf161-590e-45a2-b8ae-697d74cd5eae
4
protected Behaviour getNextStep() { if (beginTime == -1) beginTime = actor.world().currentTime() ; final float elapsed = actor.world().currentTime() - beginTime ; if (elapsed > WAIT_TIME / 2) { final Behaviour nextJob = venue.jobFor(actor) ; if (elapsed > WAIT_TIME || ! (nextJob instanceof Supervision)) { abortBehaviour() ; return null ; } } final Action supervise = new Action( actor, venue, this, "actionSupervise", Action.LOOK, "Supervising" ) ; return supervise ; }
9bc4d530-13af-41e8-8250-da77ad192940
7
public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { return; } optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if ("Save".equals(value)) { if (panel.doValidation()) { pressedYes = true; exit(); } else { JOptionPane.showMessageDialog(owner, panel.getValidationMassage()); panel.emptyValidationMassage(); } } else { pressedYes = false; exit(); } } }
c0564db0-7ed2-435e-b317-52d2bc7645ef
4
private boolean valid(int x, int y, int width, int height) { if(x < 0 || width <= x) { return false; } if(y < 0 || height <= y) { return false; } return true; }
64d94b9a-2015-45fe-bc09-3579160d75f1
8
public void checkPurchase() { if(BackerGS.storeVisible) { if(CurrencyCounter.currencyCollected < 100) { if(Greenfoot.mouseClicked(this)) { NotEnoughMoney.fade = 200; boop.play(); } } if(CurrencyCounter.currencyCollected >= 100) { if(PowerUps2.powerUp2 != 0) { if(Greenfoot.mouseClicked(this)) { YouAlreadyHaveThisPotion.yfade = 200; boop.play(); } } if(PowerUps2.powerUp2 == 0) { if(Greenfoot.mouseClicked(this)) { chaChing.play(); CurrencyCounter.currencyCollected = CurrencyCounter.currencyCollected - 100; PowerUps2.powerUp2 = 3; } } } } }
9c5c181f-485f-42de-867a-f9f01c98acfe
6
static final public void paramForms() throws ParseException { jj_consume_token(52); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEEN: case ENTIER: paramForm(); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 53: ; break; default: jj_la1[3] = jj_gen; break label_4; } jj_consume_token(53); paramForm(); } break; default: jj_la1[4] = jj_gen; ; } jj_consume_token(54); }
c971fece-ee9e-483c-93c5-224036950e2b
0
public String getFormattedDatetime() { return formattedDatetime; }
63eeb0cc-d7a4-450a-8dc2-8f40fb43a09b
9
public String toString() { // TODO: move strings to Strings String str = "Select "; if (exactly) str += "exactly "; else str += "up to "; str += count + " "; str += "cards "; switch (from) { case HAND: str += Strings.fromHand; break; case VILLAGE: str += Strings.fromVillage; break; } if (ordered) str += "in order "; if (minCost >= 0 || maxCost >= 0) { str += "that costs "; if (minCost >= 0) str += "at least �" + minCost + " "; if (maxCost >= 0) str += "at most �" + maxCost + " "; } str += "to " + header; if (isPassable) str += " (or pass)"; return str; }
572fbad5-2973-4752-b2b9-c362bafb2fc6
7
@Override public boolean tick(Tickable ticking, int tickID) { if(!super.tick(ticking, tickID)) return false; if((affected instanceof MOB)&&(invoker()!=null)) { final MOB mob=(MOB)affected; if((mob!=null) &&(!mob.amDead()) &&(CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints())<=0.10) &&(mob.location()!=null)) { mob.location().show(mob, null, CMMsg.MSG_OK_ACTION,L("<S-NAME> succumbs to the death knell...")); CMLib.combat().postDeath(invoker(), mob, null); } } return true; }
83f90b47-3124-4dca-be55-2568754af398
9
public static void merge(int startIndex, int endIndex){ System.out.println("startj: "+startIndex+" endj:"+ endIndex); Long[] arr = new Long[endIndex-startIndex+1]; int i=startIndex; int j=((endIndex+startIndex)/2)+1; int k=0; for(k=0; k<arr.length; k++){ if (i == ((endIndex+startIndex)/2)+1 || j> endIndex) break; if (lines[i] < lines[j]){ arr[k] = lines[i]; i++; } else { arr[k] = lines[j]; j++; } } if (i == ((endIndex+startIndex)/2)+1){ //Copy all of right array while(j<= endIndex){ arr[k] = lines[j]; k++; j++; } } else if (j> endIndex){ while(i<= ((endIndex+startIndex)/2)){ arr[k] = lines[i]; k++; i++; } } for (int s=0;s<arr.length;s++){ lines[startIndex] = arr[s]; startIndex++; } System.out.println("sorted sub array"+Arrays.toString(arr)); }
733551c9-0b6e-4ff5-99f6-fd63bca8d502
4
private void calculateRoughPageSize(Rectangle pageSize) { // use a ratio to figure out what the dimension should be a after // a specific scale. float width = defaultPageSize.width; float height = defaultPageSize.height; float totalRotation = documentViewModel.getViewRotation(); if (totalRotation == 0 || totalRotation == 180) { // Do nothing } // Rotated sideways else if (totalRotation == 90 || totalRotation == 270) { float temp = width; // width equals hight is ok in this case width = height; height = temp; } // Arbitrary rotation else { AffineTransform at = new AffineTransform(); double radians = Math.toRadians(totalRotation); at.rotate(radians); Rectangle2D.Double boundingBox = new Rectangle2D.Double(0.0, 0.0, 0.0, 0.0); Point2D.Double src = new Point2D.Double(); Point2D.Double dst = new Point2D.Double(); src.setLocation(0.0, height); // Top left at.transform(src, dst); boundingBox.add(dst); src.setLocation(width, height); // Top right at.transform(src, dst); boundingBox.add(dst); src.setLocation(0.0, 0.0); // Bottom left at.transform(src, dst); boundingBox.add(dst); src.setLocation(width, 0.0); // Bottom right at.transform(src, dst); boundingBox.add(dst); width = (float) boundingBox.getWidth(); height = (float) boundingBox.getHeight(); } pageSize.setSize((int) (width * documentViewModel.getViewZoom()), (int) (height * documentViewModel.getViewZoom())); }
6e4653cf-46ec-4ce5-9ce5-90dae29667aa
9
protected void optimize2() throws Exception { //% main routine for modification 2 procedure main int nNumChanged = 0; boolean bExamineAll = true; // while (numChanged > 0 || examineAll) // numChanged = 0; while (nNumChanged > 0 || bExamineAll) { nNumChanged = 0; // if (examineAll) // loop I over all the training examples // numChanged += examineExample(I) // else // % The following loop is the only difference between the two // % SMO modifications. Whereas, modification 1, the type II // % loop selects i2 fro I.0 sequentially, here i2 is always // % set to the current i.low and i1 is set to the current i.up; // % clearly, this corresponds to choosing the worst violating // % pair using members of I.0 and some other indices // inner.loop.success = 1; // do // i2 = i.low // alpha2, alpha2' = Lagrange multipliers for i2 // F2 = f-cache[i2] // i1 = i.up // inner.loop.success = takeStep(i.up, i.low) // numChanged += inner.loop.success // until ( (b.up > b.low - 2*tol) || inner.loop.success == 0) // numChanged = 0; // endif if (bExamineAll) { for (int i = 0; i < m_nInstances; i++) { nNumChanged += examineExample(i); } } else { boolean bInnerLoopSuccess = true; do { if (takeStep(m_iUp, m_iLow, m_alpha[m_iLow], m_alphaStar[m_iLow], m_error[m_iLow]) > 0) { bInnerLoopSuccess = true; nNumChanged += 1; } else { bInnerLoopSuccess = false; } } while ((m_bUp <= m_bLow - 2 * m_fTolerance) && bInnerLoopSuccess); nNumChanged = 0; } // // if (examineAll == 1) // examineAll = 0 // elseif (numChanged == 0) // examineAll = 1 // endif // endwhile //endprocedure // if (bExamineAll) { bExamineAll = false; } else if (nNumChanged == 0) { bExamineAll = true; } } }
ea7cce1e-7d11-4692-8ecd-937d24c303ab
2
@Override public boolean isSameElementAs(Element<?> element) { NoteElement other = element.adaptTo(NoteElement.class); if(other==null) { return false; } return other.getText().equals(other); }
30d4e08d-194e-48dd-8052-9bc188c9379d
7
public void updateStudents() throws ClientException{ if (logger.isDebugEnabled()){ logger.debug("Called updating student"); } String firstName = tb.getModel().getValueAt(tb.getSelectedRow(), 0).toString(); String lastName = tb.getModel().getValueAt(tb.getSelectedRow(), 1).toString(); String enrolled = tb.getModel().getValueAt(tb.getSelectedRow(), 2).toString(); String group = elemGr.toString(); Integer studentID = null; try{ for (int i = 0; i < client.getShow(currentfakulty, group).size(); i++) { if(tb.getModel().getValueAt(tb.getSelectedRow(), 0).toString().equals(client.getShow(currentfakulty, group).get(i).getFirstName()) || tb.getModel().getValueAt(tb.getSelectedRow(), 1).toString().equals(client.getShow(currentfakulty, group).get(i).getLastName())){ try{ studentID = client.getShow(currentfakulty, group).get(i).getId(); }catch(ServerException e){ logger.error("Error while getting data from server",e); throw new ClientException (e); } } } }catch(ServerException e){ logger.error("Error while updating student",e); throw new ClientException (e); } try{ client.changeStudent(currentfakulty, group, firstName, lastName, enrolled, studentID); }catch(ServerException e){ logger.error("Error while updating student",e); throw new ClientException (e); } }
08267625-814f-4548-9215-6331e5d61f1d
1
private static void printPersons(List<Person> persons) { for (Person person : persons) { System.out.println("Name :" + person.getName()); System.out.println("Gender :" + person.getGender()); System.out.println("Marital Status :" + person.getMaritalStatus()); System.out.println(); } }
03015a8c-6110-4b35-ac89-cb17ded25393
3
public Chest(PlaceableManager pm, Registry rg, String sm, String am, int x, int y, Placeable.State cs) { super(pm, rg, sm, am, x, y, cs, 8); type = "Chest"; totalBuildTime = 1; totalHitPoints = 625; powerRequired = 0; powerGenerated = 0; hitPoints = totalHitPoints; //figure out drops for chest String[] drops = new String[42]; drops[0] = "2 ThornTrap 1 1"; drops[1] = "2 ScareCrow 1 1"; drops[2] = "2 SmallFarm 1 1"; drops[3] = "2 LargeFarm 1 1"; drops[4] = "2 RobotCopperBlade 1 1"; drops[5] = "2 RobotSilverBlade 1 1"; drops[6] = "15 Wood 1 10"; drops[7] = "10 WoodBlock 1 2"; drops[8] = "15 Stone 1 10"; drops[9] = "10 StoneBlock 1 2"; drops[10] = "10 Copper 1 5"; drops[11] = "5 CopperSpear 1 1"; drops[12] = "5 CopperBlade 1 1"; drops[13] = "10 Iron 1 4"; drops[14] = "5 IronSpear 1 1"; drops[15] = "5 IronBlade 1 1"; drops[16] = "5 Silver 1 3"; drops[17] = "5 SilverSpear 1 1"; drops[18] = "5 SilverBlade 1 1"; drops[19] = "5 Gold 1 2"; drops[20] = "5 GoldSpear 1 1"; drops[21] = "5 GoldBlade 1 1"; drops[22] = "2 Platinum 1 2"; drops[23] = "5 GunPowder 1 2"; drops[24] = "10 Bow 1 1"; drops[25] = "10 Crossbow 1 1"; drops[26] = "10 Cloth 1 5"; drops[27] = "10 Leather 1 5"; drops[28] = "10 Dye 1 1"; drops[29] = "2 Sapphire 1 3"; drops[30] = "2 Ruby 1 2"; drops[31] = "1 Emerald 1 1"; drops[32] = "1 Diamond 1 1"; drops[33] = "10 Tusk 1 5"; drops[34] = "10 Web 1 5"; drops[35] = "10 Pebble 1 5"; drops[36] = "10 Flower 1 5"; drops[37] = "10 Fur 1 5"; drops[38] = "10 Thorn 1 5"; drops[39] = "10 Web 1 5"; drops[40] = "10 WheatSeed 1 5"; drops[41] = "10 PumpkinSeed 1 5"; int i = 0; int added = 0; do { i++; String drop = drops[Rand.getRange(0, drops.length - 1)]; String[] parts = drop.split(" "); int percentage = Integer.parseInt(parts[0]); if (Rand.getRange(1, 100) <= percentage) { added++; inventory.addToInventory(0, parts[1], Integer.parseInt(parts[2]), Integer.parseInt(parts[3])); } } while (i < 1000 && added < 8); }
d21a57cf-12a2-4efc-8291-7c8ed26c8efb
8
private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { String eol = System.getProperty("line.separator", "\n"); StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected.append("..."); } expected.append(eol).append(" "); } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += " " + tokenImage[tok.kind]; retval += " \""; retval += add_escapes(tok.image); retval += " \""; tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += "." + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected.toString(); return retval; }
75d2053e-d8d5-4f2e-ad24-cd99107a031b
4
private void connectTo(String name, String password, String server) throws ConnectionFailure, ClassNotFoundException { try { GameNetworkInterface gnet = Guice.createInjector(new GuiceConfig()).getInstance(GameNetworkInterface.class); gnet.connectTo(server); pfactory.sendJoinGamePacket(gnet, name, password); IPacket p = gnet.receive(TIMEOUT); if (p instanceof PlayerJoinedInterface && ((PlayerJoinedInterface) p).getName().equals(name)) { joined = true; this.getPacketFactory().setGameNetwork(gnet, name); UI.warn("Server accepted your connection request!"); } else if (p instanceof ErrorInterface) { UI.warn(((ErrorInterface) p).getText()); } else { UI.warn("Server did not respond with PlayerJoined in Time!"); } } catch (IOException e) { UI.warn("Server refused connection!"); } }
dd56060f-e6e0-42ef-a5e8-5aeba8bead2f
6
public static Keyword meanOfNumbersSpecialist(ControlFrame frame, Keyword lastmove) { { Proposition proposition = frame.proposition; Stella_Object listarg = (proposition.arguments.theArray)[0]; Stella_Object listskolem = Logic.argumentBoundTo(listarg); Stella_Object meanarg = (proposition.arguments.theArray)[1]; NumberWrapper sum = IntegerWrapper.wrapInteger(0); int numbercount = 0; lastmove = lastmove; if ((listskolem != null) && (!Logic.logicalCollectionP(listskolem))) { { System.out.println(); System.out.println("Non list appears in second argument to 'MEAN-OF-NUMBERS'"); System.out.println(); } ; return (Logic.KWD_TERMINAL_FAILURE); } { List listvalue = Logic.assertedCollectionMembers(listskolem, true); if (listvalue.emptyP()) { return (Logic.KWD_TERMINAL_FAILURE); } { Stella_Object v = null; Cons iter000 = listvalue.theConsList; for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) { v = iter000.value; if (Stella_Object.isaP(v, Logic.SGT_STELLA_NUMBER_WRAPPER)) { { sum = PlKernelKb.plusComputation(((NumberWrapper)(v)), sum); numbercount = numbercount + 1; } } else { return (Logic.KWD_FAILURE); } } } if (numbercount == 0) { return (Logic.KWD_TERMINAL_FAILURE); } else { return (Logic.selectTestResult(Logic.bindArgumentToValueP(meanarg, PlKernelKb.divideComputation(sum, IntegerWrapper.wrapInteger(numbercount)), true), true, frame)); } } } }
0a418aaa-9caa-424e-baf9-836872f5ddff
1
public void setAllParticipantsOffline() { Iterator<String> participantsIter = participants.keySet().iterator(); Participant partp; while(participantsIter.hasNext()) { partp = participants.get(participantsIter.next()); partp.setOffline(); } setChanged(); notifyObservers(ModelNotification.LIST_OF_PARTICIPANTS_CHANGED); }
88e0342c-3bec-4630-8bf1-48fb05288dd1
8
static int maxFlow(int[][] cap,int[][] cost,int[][] r,int s,int t,int C) { Arrays.fill(ants, -1); Arrays.fill(vals, MAX); Arrays.fill(visitados, false); visitados[s]=true; int c=0,p=0; cola[c++]=s; for(int u;p<c;) { u=cola[p++]; for(int v=0;v<cap.length;v++) if(!visitados[v]&&cost[u][v]<=C&&cap[u][v]-r[u][v]>0) { visitados[v]=true; cola[c++]=v; ants[v]=u; vals[v]=min(vals[u],cap[u][v]-r[u][v]); if(v==t) { p=c+1; break; } } } if(ants[t]>-1) { int f=vals[t]; for(;ants[t]>-1;t=ants[t]) { r[ants[t]][t]+=f; r[t][ants[t]]-=f; } return f; } return 0; }
e5c9ba50-8cf1-4be2-b40a-883b4f8c1989
1
public void mouseClicked(MouseEvent e) { setState(getState() == ENABLED ? DISABLED : ENABLED); InputBox.this.fireEvent(new ActionEvent()); }
51b51c54-6f7e-4ab7-a4f0-8f5020690bc3
2
public Molecule getFromMoleculeID(int[] MoleculeID, int size, int val){ if(this.getID()==0){ return this; } if (size!=0){ //System.out.printf(""+this.toStringf()+"\t\t\t"); val = MoleculeID[MoleculeID.length-size]; //System.out.printf("%d\t%d\t%d\n", val, MoleculeID.length, size); return children.get(val).getFromMoleculeID(MoleculeID, size-1, val); } else { return this; } }
2a16347a-daec-400a-b5ad-7abc1d79b860
6
private Token nextSymbol() throws IOException { StringBuilder builder = new StringBuilder(); int ich = this.reader.read(); int nchars = 0; while (ich != -1) { char ch = (char)ich; if (Character.isSpaceChar(ch) || Character.isISOControl(ch)) break; // Case #( if (ch == '(' && nchars == 0) return new Token("#(", TokenType.SEPARATOR); if (separators.indexOf(ch)>=0) break; builder.append(ch); nchars++; ich = this.reader.read(); } this.pushChar(ich); return new Token(builder.toString(), TokenType.SYMBOL); }
7f2da936-045f-45cf-afd5-a3ab13a8dccb
4
public static float pcaAngle(Collection<Vector2f> points) { // final float size = points.size(); if (size < 2) return 0.0f; // // determin mean vector. // final Vector2f mean = mean(points); // double cov00 = 0.0; double cov01 = 0.0; //double cov10 = 0.0; double cov11 = 0.0; // // determine the covariance matrix of the point cloud. // for (Vector2f p : points) { final float x = mean.x - p.x; final float y = mean.y - p.y; // cov00 += (x * x); cov01 += (x * y); //cov10 += (y * x); cov11 += (y * y); } // final double in = (size > 0.0f)?(1.0f / size):(0.0f); // cov00 *= (in); cov01 *= (in); //cov10 *= (in); cov11 *= (in); // // compute angle. // final double covd = (cov00 - cov11); if (covd == 0.0) return 0.0f; final double theta = 0.5 * Math.atan( (2.0 * cov01) / covd ); /* // // compute eigenvalues. // final double term1 = (cov00 + cov11) * 0.5; final double term2t = (4.0 * cov01 * cov01) + (covd * covd); final double term2 = Math.sqrt(term2t) * 0.5; final double lambda1 = term1 + term2; final double lambda2 = term1 - term2; System.out.println(Math.toDegrees(theta)); System.out.println(lambda1); System.out.println(lambda2); */ return (float)theta; }
9b0a0171-5d98-4e6b-a490-2490a8bc813c
4
public static boolean estPositionValide(Position position){ if(position.travee >= 0 && position.travee < Parametres.NB_TRAVEES && position.rangee >= 0 && position.rangee < Parametres.NB_RANGEES){ return true ; } else { return false ; } }
30db81bc-0653-4aab-900f-36d244d44daf
7
private ArrayList<TunnusPari> kokoaParit(ArrayList<ArrayList<String>> tunnusParit, ArrayList<Tunnus> tunnukset) { ArrayList<TunnusPari> parit = new ArrayList<TunnusPari>(); for (ArrayList<String> lista : tunnusParit) { if (lista.size() < 9) { continue; } Tunnus tunnus1 = null; Tunnus tunnus2 = null; for (Tunnus t : tunnukset) { if (t.getTunnus().equals(lista.get(0))) { tunnus1 = t; } else if (t.getTunnus().equals(lista.get(1))) { tunnus2 = t; } } if (tunnus1 == null || tunnus2 == null) { continue; } int pelit = tarkistaOnkoNumero(lista.get(2)); double pituus = tarkistaOnkoDouble(lista.get(3)); int tallennus = tarkistaOnkoNumero(lista.get(4)); int t1risti = tarkistaOnkoNumero(lista.get(5)); int t1voitto = tarkistaOnkoNumero(lista.get(6)); int t2risti = tarkistaOnkoNumero(lista.get(7)); int t2voitto = tarkistaOnkoNumero(lista.get(8)); parit.add(new TunnusPari(tunnus1, tunnus2, pelit, t1voitto, t1risti, t2voitto, t2risti, pituus, tallennus)); } return parit; }
cf8a639a-3a8e-4abd-a570-654b5ac6999b
8
public <V> Adapter.Getter<V> makeGetter(String methodName, Class<V> _class) { try { T version = (T) start.get().newVersion; final Method method = version.getClass().getMethod(methodName); return new Adapter.Getter<V>() { public V call() { try { Transaction me = Thread.getTransaction(); Locator oldLocator = Adapter.this.start.get(); T version = (T) oldLocator.fastPath(me); if (version == null) { ContentionManager manager = Thread.getContentionManager(); Locator newLocator = new Locator(); while (true) { oldLocator.readPath(me, manager, newLocator); if (Adapter.this.start.compareAndSet(oldLocator, newLocator)) { version = (T) newLocator.newVersion; break; } oldLocator = start.get(); } if (!me.isActive()) { throw new AbortedException(); } } return (V)method.invoke(version); } catch (SecurityException e) { throw new PanicException(e); } catch (IllegalAccessException e) { throw new PanicException(e); } catch (InvocationTargetException e) { throw new PanicException(e); } }}; } catch (NoSuchMethodException e) { throw new PanicException(e); } }
5ae8621c-976b-4170-83ec-f48db6b23f23
7
public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false && solvingList.getSelectedIndex() > -1) { int wordIndex = solvingList.getSelectedIndex(); // Compute the grid state at that letter Grid tempGrid = solvingGrid.clone(); for (int i = 0; i < wordIndex; i++) { tempGrid.removeLetters(solvingSolution.get(i)); } // Update the grid representation for (int i = 0; i < 117; i++) { JLabel thisCell = (JLabel) this.solvingGridPanel.getComponent(i); try { thisCell.setText("" + tempGrid.getCell(new Point(i / 13, i % 13))); thisCell.setBorder(new LineBorder(Color.LIGHT_GRAY, 1, false)); } catch (NullPointerException e2) { thisCell.setText(null); thisCell.setBorder(null); } } // Highlight the correct letters with a shiny border Collection<Point> wordPoints = solvingSolution.get(wordIndex); int red = 255; for (Point letter : wordPoints) { ((JLabel) this.solvingGridPanel.getComponent(letter.x * 13 + letter.y)).setBorder(new LineBorder(new Color(red, 100, 100), 3, false)); if (red > 100) { red -= 20; } } } }
5bef1a9c-752a-4000-99b4-03284b5476b2
1
public static String formatFilePath(String realpath) { if (StringUtil.isEmpty(realpath)) return null; realpath = realpath.replace('\\', '/'); return realpath; }
171ab007-9743-4b2c-8281-5d8413f03cf3
0
@Basic @Column(name = "PCA_ID_ELEMENTO") public Integer getPcaIdElemento() { return pcaIdElemento; }
7f704008-62b1-4928-909c-9ae2c9f730dc
7
public String ask(String sentence) { String response = defaultResponses[(int) (Math.random() * defaultResponses.length)]; if (sentence == null || sentence.length() == 0) return response; // Removing the punctuation if it is there. char punctuation = sentence.charAt(sentence.length() - 1); if (punctuation == '!' || punctuation == '.' || punctuation == '?') sentence = sentence.substring(0, sentence.length() - 1); else punctuation = 0; sentence = " " + sentence + " "; for (CategoryEntry ce : database) { String match = ce.findMatch(sentence); if (match != null) { response = ce.getRandomResponse(prevResponse); break; } } prevResponse = response; return response; }
9ad1647e-14a3-4023-b00f-75233e901eea
0
public String parentRow(){ return "<tr class=\"parent\" data-level=\"0\">"+ "<td>"+this.instance_id+"</td>"+ "<td>"+this.txid+"</td>"+ "<td>"+this.BPEL+"</td>"+ "<td>"+this.course_id+"</td>"+ "<td>"+this.course_provider+"</td>"+ "<td>"+this.state+"</td>"+ "<td>"+this.time+"</td>"+ "<td>"+this.duration+"</td>"+ "</tr>"; }
04bff872-2a06-4eb5-9fc7-d628a0645fe2
2
public void setHealth(int newHealth) { if (newHealth < health) { int scaleX = Level.getScaledX(level.getXPosition(), x); int width = Level.getScaledX(level.getXPosition(), x + 1) - scaleX; float scale = 1.0f / Constants.TILE_WIDTH * width; addEffect(new PlayerDamageEffect(getRenderCentreX(), getRenderCentreY(), scale)); if (newHealth <= 0) { addEffect(new PlayerDeathEffect(getRenderCentreX(), getRenderCentreY(), scale)); playDeathSound(); } } health = newHealth; }
98498a19-524c-4691-99fa-0370494ec247
0
public void setName(String name) { this.name = name; }
782a551f-8b92-4c15-85c9-22d1008aef31
5
public Class getTypeClass() { switch (((IntegerType) getHint()).possTypes) { case IT_Z: return Boolean.TYPE; case IT_C: return Character.TYPE; case IT_B: return Byte.TYPE; case IT_S: return Short.TYPE; case IT_I: default: return Integer.TYPE; } }
0e51f8cc-aa34-428d-96f6-308c732a5dc5
8
private void deletePair(Person man, Person woman) { //System.out.println("deleting: " + man.getName() + "," + woman.getName()); for(List<Person> list : man.getPreferences()) { List<Person> listAux = list; if(listAux.contains(woman)) { listAux.remove(woman); } if(listAux.isEmpty()) { man.getPreferences().remove(listAux); } } for(List<Person> list : woman.getPreferences()) { List<Person> listAux = list; if(listAux.contains(man)) listAux.remove(man); if(listAux.isEmpty()) { woman.getPreferences().remove(listAux); } } if(man.getPreferences().isEmpty()) { man.setPreferences(new ArrayList<List<Person>>()); } if(woman.getPreferences().isEmpty()) { woman.setPreferences(new ArrayList<List<Person>>()); } }
1af1b6e6-00a0-4b9d-808e-82d092c41b54
7
@EventHandler(priority = EventPriority.NORMAL) public void onBlockBreak(BlockBreakEvent event) { if (event.getBlock() != null) { //Will prevent an NPE if the user right-clicks air. if (event.getBlock().getState() != null) { if (event.getBlock().getState() instanceof Sign) { Sign sign = (Sign) event.getBlock().getState(); if (ChatColor.stripColor(sign.getLines()[0]).equalsIgnoreCase("[CK]")) { //if it's a colorkey sign Player player = event.getPlayer(); if (!player.isOp() && !player.hasPermission("colorkeys.sign.create") && !player.hasPermission("colorkeys.admin")) { player.sendMessage(ChatColor.DARK_RED + "You do not have permission to destroy CK signs."); event.setCancelled(true); final Location bl = event.getBlock().getLocation(); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { bl.getBlock().getState().update(); } }, 20L); } } } } } }
aa76e83d-9c23-4e58-9442-18ba6b5d323a
7
private static boolean rulesEq(boolean[] r1, boolean[] r2) { if(r1 != null && r2 != null) { if(r1.length == r2.length) { for(int i = 0; i < r1.length; i++) { if(r1[i] != r2[i]) { return false; } } return true; } else { return false; } } else if(r1 == null && r2 == null) { return true; } else { return false; } }
e658cd43-2a11-4f2d-8652-b4f4961a46f3
8
public static void main(String[] argv) { try { File index = new File("index"); boolean create = false; File root = null; String usage = "IndexHTML [-create] [-index <index>] <root_directory>"; if (argv.length == 0) { System.err.println("Usage: " + usage); return; } for (int i = 0; i < argv.length; i++) { if (argv[i].equals("-index")) { // parse -index option index = new File(argv[++i]); } else if (argv[i].equals("-create")) { // parse -create option create = true; } else if (i != argv.length-1) { System.err.println("Usage: " + usage); return; } else root = new File(argv[i]); } if(root == null) { System.err.println("Specify directory to index"); System.err.println("Usage: " + usage); return; } Date start = new Date(); if (!create) { // delete stale docs deleting = true; indexDocs(root, index, create); } writer = new IndexWriter(FSDirectory.open(index), new StandardAnalyzer(Version.LUCENE_CURRENT), create, new IndexWriter.MaxFieldLength(1000000)); indexDocs(root, index, create); // add new docs System.out.println("Optimizing index..."); writer.optimize(); writer.close(); Date end = new Date(); System.out.print(end.getTime() - start.getTime()); System.out.println(" total milliseconds"); } catch (Exception e) { e.printStackTrace(); } }
cd56f467-0c9e-42a7-b439-f9d8459bb1a5
0
String entrance(List<Milk> milks){ Collections.sort(milks); return milks.get(0).brand; }
74db739c-5fe5-43f6-a511-3d99ac01eeff
4
public float getValueAt(int row, int column) throws ElementOutOfRangeException{ if(row<0 || column<0){ throw new ElementOutOfRangeException(" The vlaues provided for row or " + " column are negative"); } if(row > this.rows || column > this.columns){ throw new ElementOutOfRangeException(" The elements you asked for are " + "bigger than the values set for this matrix"); } return this.values[row][column]; }
98678840-b053-43e6-9921-1af70c277b8d
0
private void init() { dialog.setSize(WIDTH, HEIGHT); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); button = new JButton("Cancel"); progressBar = new JProgressBar(); textArea = new JLabel("Calculating"); progressBar.setStringPainted(true); progressBar.setMinimum(PROGRESS_BAR_MIN_VALUE); progressBar.setMaximum(PROGRESS_BAR_MAX_VALUE); progressBar.setValue(PROGRESS_BAR_MIN_VALUE); GridBagLayout gridBagLayout = new GridBagLayout(); dialog.setLayout(gridBagLayout); //Create GridBagConstraints GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.SOUTHWEST; constraints.insets = DEFAULT_INSETS; constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridwidth = 2; gridBagLayout.setConstraints(progressBar, constraints); progressBar.setIndeterminate(false); constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.gridy++; gridBagLayout.setConstraints(textArea, constraints); constraints.anchor = GridBagConstraints.SOUTHEAST; constraints.fill = GridBagConstraints.NONE; gridBagLayout.setConstraints(button, constraints); dialog.add(button); dialog.add(progressBar); dialog.add(textArea); }
94110f8b-5989-4fa3-be20-95408169710d
0
public AncestorIterator(T child, Selector<T, T> selector) { this._next = child; this._selector = selector; }
24385b59-7e7a-4166-b54c-c391c6d86cce
8
public int reverse(int x) { if (x == 0) { return 0; } boolean isNegative = x < 0; x = x > 0 ? x : -x; long i = 0; while (x > 0) { i = i * 10 + (x % 10); x = x / 10; } if ((!isNegative && i > Integer.MAX_VALUE) || (isNegative && -i < Integer.MIN_VALUE)) { return 0; } return (int) (isNegative ? -i : i); }
df711ef3-6a97-4123-806d-d79d2729c1f7
6
private void CheckIfAllPlayerHaveOneCountry(List<MapChange> map, Player player1, Player player2) { boolean error = false; if (map.size() != 2) error = true; if (map.get(0).OwnedByPlayerId == player1.ID && map.get(1).OwnedByPlayerId == player1.ID) error = true; if (map.get(0).OwnedByPlayerId == player2.ID && map.get(1).OwnedByPlayerId == player2.ID) error = true; if (error) throw new RuntimeException("Need to restart test!"); }
03d203fe-467c-4b0d-9b88-11f9cdb203b5
7
public void addCountry(Country cnt) { int id; Connection con = null; PreparedStatement pstmt = null; Statement idstmt = null; try { DBconnection dbCon = new DBconnection(); Class.forName(dbCon.getJDBC_DRIVER()); con = DriverManager.getConnection(dbCon.getDATABASE_URL(), dbCon.getDB_USERNAME(), dbCon.getDB_PASSWORD()); con.setAutoCommit(false); idstmt = con.createStatement(); ResultSet rs = idstmt.executeQuery("Select ifnull(max(cnt_id),0)+1 From country"); rs.next(); id = rs.getInt(1); pstmt = con.prepareStatement("Insert Into country Values(?,?,?)"); pstmt.setInt(1, id); pstmt.setString(2, cnt.getCode()); pstmt.setString(3, cnt.getName()); pstmt.execute(); con.commit(); } catch (SQLException | ClassNotFoundException ex) { System.err.println("Caught Exception: " + ex.getMessage()); if (con != null) { try { con.rollback(); } catch (SQLException ex2) { System.err.println("Caught Exception: " + ex2.getMessage()); } } } finally { try { if (idstmt != null) { idstmt.close(); } if (pstmt != null) { pstmt.close(); } if (con != null) { con.close(); } } catch (SQLException ex) { System.err.println("Caught Exception: " + ex.getMessage()); } } }
80c21356-1953-4aff-9817-e4792b906a08
8
public void cmdCollect(CommandSender sender, String[] args) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } List<EEItemStack> stacks = getDeliveries(player.getName()); double revenue = getRevenue(player.getName()); if(stacks.size() == 0 && revenue == 0 ) { sender.sendMessage(Conf.colorMain + "You have no deliveries waiting."); return; } double tax = revenue * Conf.tax; revenue -= tax; if(econ.depositPlayer(player.getName(), revenue).transactionSuccess()) { sender.sendMessage(Conf.colorMain + "You have been paid " + Conf.colorAccent + revenue + Conf.colorMain + " in revenue."); getLogger().info(player.getDisplayName() + " paid " + revenue + " in revenue."); if(tax > 0) sender.sendMessage(Conf.colorAccent + "" + tax + Conf.colorMain + " of your revenue was taken as tax (" + Conf.colorAccent + (Conf.tax * 100) + "%" + Conf.colorMain + ")"); setRevenue(player.getName(), 0); } else { sender.sendMessage(Conf.colorWarning + "Error, for some reason we couldn't pay you your money. Don't worry, it's safe."); } Inventory inv = player.getInventory(); while(inv.firstEmpty() != -1 && stacks.size() > 0) { EEItemStack stack = stacks.get(0); inv.setItem(inv.firstEmpty(), new ItemStack(stack.material, stack.quantity)); stacks.remove(0); } if(stacks.size() == 0) sender.sendMessage(Conf.colorMain + "All items have been delivered successfully."); else sender.sendMessage(Conf.colorWarning + "Inventory full, please deposit some items in a chest and try again."); getLogger().info("Items delivered to " + player.getDisplayName()); }
48a8942a-7c6c-4408-88d8-c4e1bcf7765e
3
private Byte[] buildPacket() { ArrayList<Byte> p = new ArrayList<Byte>(); // Add timestamp to the first 8 bits. long timestamp = new Date().getTime(); lastSentPacketTimestamp = timestamp; byte[] timestampBytes = ByteBuffer.allocate(8).putLong(timestamp).array(); for(byte b : timestampBytes) { p.add((Byte)b); } // Add the host count. p.add(Byte.valueOf((byte)(networkTreeMap.size()&0xFF))); for (Entry<Byte,TreeSet<Byte>> e : networkTreeMap.entrySet()) { Byte host = e.getKey(); TreeSet<Byte> neighbours = e.getValue(); p.add(host); p.add(Byte.valueOf((byte)(neighbours.size()&0xFF))); for(Byte b : neighbours) { p.add(b); } } return toByteObjectArray(p); }
7641e52e-f14c-4fd7-b779-79f3862073a8
8
public CustomTemplate getCopy() { try { CustomTemplate template = (CustomTemplate) clone(); List<CustomElement> elements = new ArrayList<CustomElement>(); for (CustomElement e : template.elements) { elements.add(e.getCopy()); } for (CustomElement e : elements) { if (e.childElements != null && e.childElements.size() > 0) { List<CustomElement> newChildElements = new ArrayList<CustomElement>(); for (CustomElement ce : e.childElements) { for (CustomElement ne : elements) { if (ne.name.equals(ce.name)) { newChildElements.add(ne); } } } e.childElements = newChildElements; } } template.elements = elements; return template; } catch (CloneNotSupportedException e) { return null; } }
0614cccf-a0cb-4af2-aca7-0f6aedb49d66
1
public void TimeStep() { if (turnsRemaining > 0) { --turnsRemaining; } else { turnsRemaining = 0; } }
1f365c2a-232b-498b-ba33-a6264149831b
7
private void paintAntsB(Graphics2D g2d, int id, Map<Integer, Ant> ants, Color b, Color f) { for (int i : ants.keySet()) { Ant a = ants.get(i); g2d.setColor(b); if (a.isSweet()) { g2d.setColor(Color.white); g2d.drawOval(a.getX()-5, a.getY()-5, 10, 10); } g2d.setColor(b); if (id == w.getId()) { g2d.fillOval(a.getX()-4, a.getY()-4, 8, 8); } else { g2d.drawOval(a.getX()-4, a.getY()-4, 8, 8); } if (a.getHealth() > 0) { g2d.setColor(b); g2d.drawRect(a.getX()-6, a.getY()-15+(a.getTeamId()==w.getId()?30:0), 12, 2); g2d.setColor(f); g2d.drawLine(a.getX()-5, a.getY()-14+(a.getTeamId()==w.getId()?30:0), a.getX()-5+a.getHealth(), a.getY()-14+(a.getTeamId()==w.getId()?30:0)); } } }
201afa40-02e8-45c1-8632-eb60e6f694b7
4
public void copyBlock(int distance, int len) throws IOException { int pos = _pos - distance - 1; if (pos < 0) { pos += _windowSize; } for (; len != 0; len--) { if (pos >= _windowSize) { pos = 0; } _buffer[_pos++] = _buffer[pos++]; if (_pos >= _windowSize) { flush(); } } }
f8837328-2cff-49e1-944d-799e1f1d98df
4
@Override public boolean activate() { return (Game.getClientState() != Game.INDEX_MAP_LOADED || (Game.getClientState() != Game.INDEX_MAP_LOADED && ItemCombiner.stop == 1000) || ItemCombiner.client != Bot.client() || Widgets.get(640, 30).isOnScreen() ); }
f08e166b-44af-40f9-a5bc-ea57d44c5d6f
8
private Map<Integer, Double> getLastUsages(List<Bookmark> bookmarks, double timestamp, boolean categories) { Map<Integer, Double> usageMap = new LinkedHashMap<Integer, Double>(); for (Bookmark data : bookmarks) { List<Integer> keys = (categories ? data.getCategories() : data.getTags()); double targetTimestamp = Double.parseDouble(data.getTimestamp()); for (int key : keys) { Double val = usageMap.get(key); if (val == null || targetTimestamp > val.doubleValue()) { usageMap.put(key, targetTimestamp); } } } for (Map.Entry<Integer, Double> entry : usageMap.entrySet()) { Double rec = Math.pow(timestamp - entry.getValue() + 1.0, this.dValue * (-1.0)); //Double rec = Math.exp((timestamp - entry.getValue() + 1.0) * -1.0); if (!rec.isInfinite() && !rec.isNaN()) { entry.setValue(rec.doubleValue()); } else { System.out.println("BLL - NAN"); entry.setValue(0.0); } } return usageMap; }
ff078f92-928d-4b11-a1db-091a0158ee2d
4
private static double getMeanPixel(Image image, ChannelType color, int x, int y, int maskWidth, int maskHeight) { List<Double> pixelsAffected = new ArrayList<Double>(); for (int i = -maskWidth / 2; i <= maskWidth / 2; i++) { for (int j = -maskHeight / 2; j <= maskHeight / 2; j++) { if (image.validPixel(x + i, y + j)) { pixelsAffected.add(image.getPixel(x + i, y + j, color)); } } } double val = 0; for (Double var : pixelsAffected) { val += var; } return val / pixelsAffected.size(); }
0a43d6ae-29ef-43a8-a1fb-8a3adac38400
9
public ArrayList<AnyType> Merge(ArrayList<AnyType> list1, ArrayList<AnyType> list2) { int i=0; int j=0; ArrayList<AnyType> merged = new ArrayList<AnyType>(); while(i<list1.size() || j<list2.size()) { if(i<list1.size() && j<list2.size()) { if(list1.get(i).compareTo(list2.get(j))<=0) { merged.add(list1.get(i)); i++; } else { merged.add(list2.get(j)); j++; } } else if(i<list1.size()) { for(int m=i;m<list1.size();m++) { merged.add(list1.get(m)); } } else if(j<list2.size()) { for(int m=j;m<list2.size();m++) { merged.add(list2.get(m)); } } } return merged; }
03aca12b-a3bf-49a5-915d-1267fc162ccf
1
public static void sort(SimpleTrain train, Comparator<AbstractCarriage> comparator) { if(train == null){ LOG.error("Train is null"); throw new IllegalArgumentException("Train is null"); } Collections.sort(train, comparator); }
c7b7b9ac-7018-4992-964c-3ea9790cc210
8
private Component cycle(Component currentComponent, int delta) { int index = -1; loop : for (int i = 0; i < m_Components.length; i++) { Component component = m_Components[i]; for (Component c = currentComponent; c != null; c = c.getParent()) { if (component == c) { index = i; break loop; } } } // try to find enabled component in "delta" direction int initialIndex = index; while (true) { int newIndex = indexCycle(index, delta); if (newIndex == initialIndex) { break; } index = newIndex; // Component component = m_Components[newIndex]; if (component.isEnabled() && component.isVisible() && component.isFocusable()) { return component; } } // not found return currentComponent; }
af02ce00-9408-41d5-98b3-59e39d702276
7
public void randomFillMap() { int mapmiddle = 0; for (int row = 0; row < mapheight; row++) { for (int col = 0; col < mapwidth; col++) { if (col == 0) { map[col][row] = 1; } else if (row == 0) { map[col][row] = 1; } else if (col == mapwidth -1){ map[col][row] = 1; } else if (row == mapheight -1) { map[col][row] = 1; } else { mapmiddle = (mapwidth / 2); if (row == mapmiddle) { map[col][row] = 0; } else { map[col][row] = randomPercent(percentarewalls); } } } } }
4727287c-e88d-46ad-ba6b-9ee45eeb0614
3
private void btn_ContinueActionPerformed(java.awt.event.ActionEvent evt) { System.out.println("Iniciando configuraciones"); sys_productores = (Integer) jSpinnerProductores.getValue(); System.out.print(sys_productores+" sys_productores"); sys_consumidores = (Integer) jSpinnerConsumidores.getValue(); System.out.print(sys_consumidores+" sys_consumidores"); sys_commands = (Integer) jSpinnerCommands.getValue(); System.out.println(" " + sys_productores + " " + sys_consumidores + " " + sys_commands); //boolean format_type_b = (format_type.getSelectedItem().equals("Fijo")) ? true : false; if(0> sys_productores && 0> sys_consumidores && 0> sys_commands ){ /*for(int i = 0; i< sys_productores; i++){ System.out.println("LOL"); } this.setVisible(false);*/ JOptionPane.showMessageDialog(new JFrame(), "Error en la configuración", "Mensaje", JOptionPane.ERROR_MESSAGE); } else{ setVisible(false); Procesos crearProc=new Procesos(); System.out.print(sys_productores+ " sys_productores"); listaP=crearProc.crearProceso(sys_productores); System.out.print("Lista------------------------------------"); listaP.Imprimir(); System.out.print("Lista------------------------------------"); crearProc.crearImpresora(sys_consumidores); VentanaImprimir imp=new VentanaImprimir(); imp.setVisible(true); } }
5c1b38be-3159-4801-880d-2f4a59f736a1
0
public void addOsoba(Osoba osoba) { data.addElement(osoba); int updatedRow = data.indexOf(data.lastElement()); fireTableRowsInserted(updatedRow, updatedRow); }
9cff5adf-60ec-4ebd-bf24-eff4ce458025
9
public String[] getOptions() { Vector<String> options = new Vector<String>(); if ( (getUrl() != null) && (getUrl().length() != 0) ) { options.add("-url"); options.add(getUrl()); } if ( (getUser() != null) && (getUser().length() != 0) ) { options.add("-user"); options.add(getUser()); } if ( (getPassword() != null) && (getPassword().length() != 0) ) { options.add("-password"); options.add(getPassword()); } options.add("-Q"); options.add(getQuery()); StringBuffer text = new StringBuffer(); for (int i = 0; i < m_orderBy.size(); i++) { if (i > 0) text.append(", "); text.append((String) m_orderBy.get(i)); } options.add("-P"); options.add(text.toString()); if (m_inc) options.add("-I"); return (String[]) options.toArray(new String[options.size()]); }
eb49318b-6564-4d5e-9699-1e47eaf96242
5
static private String toString(Class type) { if (type == Dictionary.class) { return "dictionary"; } else if (type == ZemArray.class) { return "array"; } else if (type == ZemBoolean.class) { return "boolean"; } else if (type == ZemNumber.class) { return "number"; } else if (type == ZemString.class) { return "string"; } else { return type.getName(); } }
66582b39-5741-44a9-86b4-18e0699b2591
0
public void setDepotlegal(String oui) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
d25d5b95-ed0a-422a-9802-b8a031029e6e
2
public static void main(String[] args) { //TODO interpret arguments, for example random seed and number of cities, and brute force or genetic algorithm could be TravelingSalesman salesman = new TravelingSalesman(10, random); salesman.printCosts(); //uncomment for brute force: if(RUN_BRUTE_FORCE){ System.out.println("*** running brute force algorithm ***"); TravelingSalesmanBruteForce bruteForce = new TravelingSalesmanBruteForce(salesman); bruteForce.run(); } if(RUN_GENETIC_ALGORITHM) { System.out.println("*** running genetic algorithm algorithm ***"); Environment environment = new Environment(salesman); environment.run(); } }
9a039942-be00-4e1a-8a46-b2bf77f0ccbf
7
public static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double) o).isInfinite() || ((Double) o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); } } else if (o instanceof Float) { if (((Float) o).isInfinite() || ((Float) o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); } } } }
be23df63-a267-4904-a3a0-bf40b4600cd8
9
public static int[][] replaceMatrixElements(int a[][]) { int rows[] = new int[a.length]; int columns[] = new int [a[0].length]; for (int i=0; i<a.length; i++) { for(int j=0; j<a[i].length; j++) { if(a[i][j] == 0) { rows[i] = 1; columns[j] = 1; } } } for (int i=0; i<rows.length; i++) { if (rows[i] == 1) { for (int j=0; j<a[i].length; j++) { a[i][j] = 0; } } } for (int i=0; i<columns.length; i++) { if (columns[i] == 1) { for (int j=0; j<a.length; j++) { a[j][i] = 0; } } } return a; }
3a25cdf6-e6d3-4d66-ae81-58786faab80d
2
public boolean isTileAlreadyOccupied(PieceCoordinate coordinate) { Iterator<Entry<PieceCoordinate, HantoPiece>> pieces = board.entrySet().iterator(); PieceCoordinate next; while(pieces.hasNext()) { Entry<PieceCoordinate, HantoPiece> entry = pieces.next(); next = entry.getKey(); // if there is already a piece in the coordinate we are trying to add one to if(next.equals(coordinate)) return true; } return false; }
25504b9a-0d23-4ced-be0f-f9e9f7676827
1
public void visitAttribute(final Attribute attr) { super.visitAttribute(attr); if (fv != null) { fv.visitAttribute(attr); } }
39c12065-45e9-4bec-b1b5-26a23c4a60b2
1
public void makeShake() { if (this.calculateChances(10)) { this.setEffMult(1); } else { this.addEffMult(0.1); } }
dbadf3a2-1ca2-4ca5-9043-503c8e04ff77
8
public void renderSprite(int xPos, int yPos, Sprite sprite) { int spriteWidth = sprite.getWidth(); int spriteHeight = sprite.getHeight(); if (sprite.isFixed()) { xPos -= xOffset; yPos -= yOffset; } for (int y = 0; y < spriteHeight; y++) { int yAbs = y + yPos; for (int x = 0; x < spriteWidth; x++) { int xAbs = x + xPos; if (xAbs < 0 || xAbs >= width || yAbs < 0 || yAbs >= height) continue; int c = sprite.getPixel(x + y * spriteWidth); if (c != Colors.ALPHA_PINK) pixels[xAbs + yAbs * width] = c; } } }
814f5f0d-846b-4342-8aaa-dece38cd1543
1
public Value naryOperation(final AbstractInsnNode insn, final List values) { int size; if (insn.getOpcode() == MULTIANEWARRAY) { size = 1; } else { size = Type.getReturnType(((MethodInsnNode) insn).desc).getSize(); } return new SourceValue(size, insn); }
af16a284-7664-4e63-96e1-80a79b0809aa
9
@Override public Object getValueAt(Object object, int row, int col) { Usuario u = (Usuario) object; try { if (col == 0) { return u.getDNI(); } else if (col == 1) { return u.getNombre(); } else if (col == 2) { return u.getApellido(); } else if (col == 3) { return u.getCiudad(); } else if (col == 4) { return u.getDomicilio(); } else if (col == 5) { return u.getEmail(); } else if (col == 6) { return u.getTelefono(); } else if (col == 7) { return u.getCodPostal(); } else { return null; } } catch (UsuarioException ue) { return ue.getMessage(); } }
c43549d1-918a-48af-ba9b-3e4de62cf933
7
private static void contraction(Map<Integer, List<Integer>> expData, Integer key1, Integer key2) { List<Integer> adj1 = expData.get(key1); List<Integer> adj2 = expData.get(key2); for (Iterator<Integer> it = adj2.iterator(); it.hasNext();) { Integer current = it.next(); if (current.equals(key1)) { it.remove(); } } adj1.addAll(adj2); expData.remove(key2); for (Iterator<Integer> it = adj1.iterator(); it.hasNext();) { Integer current = it.next(); if (current.equals(key2)) { it.remove(); } else { List<Integer> currentAdj = expData.get(current); int count = 0; for (Iterator<Integer> itr = currentAdj.iterator(); itr.hasNext();) { if (itr.next().equals(key2)) { itr.remove(); count++; } } for (int i = 0; i < count; i++) { currentAdj.add(key1); } } } }
84f0e69b-edf4-4369-b5c0-c8c7e7b44a7c
7
private boolean availableArea(int southWestRowID, int southWestColID, int span) { int rowCount = this.realMap.getRowCount(); int colCount = this.realMap.getColumnCount(); for(int rowID = 0;rowID < span;rowID++){ if(!(0 <= rowID && rowID < rowCount)){ return false; } for(int colID = 0;colID < span;colID++){ if(!(0 <= colID && colID < colCount)){ return false; } if(this.realMap.getCell(southWestRowID - rowID,southWestColID + colID) == ArenaTemplate.CellState.OBSTACLE){ return false; } } } return true; }
2ad3f723-400a-422e-bacc-a349c3d54ec9
1
@Test public void opiskelunLisaaminenToimiiKunEriKuinEnnen(){ //kirjoitaOikeanmuotoinenSyote(); tiedot.LueTiedotTiedostosta(); tiedot.lisaaUusiOpiskelu("uusiopiskelu", 5); String mappiinTallennetutTiedot = ""; HashMap<String, Integer> kartta = tiedot.getOpiskelut(); for (String avain: kartta.keySet()){ mappiinTallennetutTiedot += avain + " " + kartta.get(avain) + " "; } assertEquals("uusiopiskelu 5 ", mappiinTallennetutTiedot); }
2e086af1-9312-443b-9606-d94cd364055c
9
public static void getDifficultyVariables() { if(isEasy && !isMedium && !isHard){ mobWalkSpeeds[0] = 30; mobWalkSpeeds[1] = 20; mobWalkSpeeds[2] = 60; killReward[0] = 5; killReward[1] = 2; killReward[2] = 20; } if(!isEasy && isMedium && !isHard){ mobWalkSpeeds[0] = 20; mobWalkSpeeds[1] = 15; mobWalkSpeeds[2] = 40; killReward[0] = 5; killReward[1] = 2; killReward[2] = 20; } if(!isEasy && !isMedium && isHard){ mobWalkSpeeds[0] = 18; mobWalkSpeeds[1] = 10; mobWalkSpeeds[2] = 25; killReward[0] = 3; killReward[1] = 1; killReward[2] = 5; airTowerLaserDamage = 50; airTowerRadiatorDamage = 25; airTowerCannonDamage = 150; } }
055c131b-95ab-4121-bc4e-d96a42a7684e
8
public void splitNode(BallNode node, int numNodesCreated) throws Exception { correctlyInitialized(); double maxDist = Double.NEGATIVE_INFINITY, dist = 0.0; Instance furthest1=null, furthest2=null, pivot=node.getPivot(), temp; double distList[] = new double[node.m_NumInstances]; for(int i=node.m_Start; i<=node.m_End; i++) { temp = m_Instances.instance(m_Instlist[i]); dist = m_DistanceFunction.distance(pivot, temp, Double.POSITIVE_INFINITY); if(dist > maxDist) { maxDist = dist; furthest1 = temp; } } maxDist = Double.NEGATIVE_INFINITY; furthest1 = (Instance)furthest1.copy(); for(int i=0; i < node.m_NumInstances; i++) { temp = m_Instances.instance(m_Instlist[i+node.m_Start]); distList[i] = m_DistanceFunction.distance(furthest1, temp, Double.POSITIVE_INFINITY); if(distList[i] > maxDist) { maxDist = distList[i]; furthest2 = temp; //tempidx = i+node.m_Start; } } furthest2 = (Instance) furthest2.copy(); dist = 0.0; int numRight=0; //moving indices in the right branch to the right end of the array for(int i=0, j=0; i < node.m_NumInstances-numRight; i++, j++) { temp = m_Instances.instance(m_Instlist[i+node.m_Start]); dist = m_DistanceFunction.distance(furthest2, temp, Double.POSITIVE_INFINITY); if(dist < distList[i]) { int t = m_Instlist[node.m_End-numRight]; m_Instlist[node.m_End-numRight] = m_Instlist[i+node.m_Start]; m_Instlist[i+node.m_Start] = t; double d = distList[distList.length-1-numRight]; distList[distList.length-1-numRight] = distList[i]; distList[i] = d; numRight++; i--; } } if(!(numRight > 0 && numRight < node.m_NumInstances)) throw new Exception("Illegal value for numRight: "+numRight); node.m_Left = new BallNode(node.m_Start, node.m_End-numRight, numNodesCreated+1, (pivot=BallNode.calcCentroidPivot(node.m_Start, node.m_End-numRight, m_Instlist, m_Instances)), BallNode.calcRadius(node.m_Start, node.m_End-numRight, m_Instlist, m_Instances, pivot, m_DistanceFunction) ); node.m_Right = new BallNode(node.m_End-numRight+1, node.m_End, numNodesCreated+2, (pivot=BallNode.calcCentroidPivot(node.m_End-numRight+1, node.m_End, m_Instlist, m_Instances)), BallNode.calcRadius(node.m_End-numRight+1, node.m_End, m_Instlist, m_Instances, pivot, m_DistanceFunction) ); }
17a138a7-3ecf-4276-b392-42e4ea3ef024
6
public static void main(String args[]) { Cue bigQ = new Cue(100); Cue smallQ = new Cue(4); char ch; int i; System.out.println("Using bigQ to store the alphabet."); for(i=0; i<26;i++) bigQ.put((char) ('A' + i )); System.out.println("Contents of bigQ: "); for(i = 0; i < 26; i++){ ch = bigQ.get(); if(ch != (char) 0 ) System.out.println(ch); } System.out.println("\n"); System.out.println("Using smallQ to generate errors"); for(i = 0; i < 5; i++){ System.out.println("Attempting to store " + (char) ('Z' - i)); System.out.println(); } System.out.println(); System.out.println("Contents of smallQ: "); for(i = 0; i < 5; i++){ ch = smallQ.get(); if(ch != (char) 0) System.out.print(ch); } }
e3464e74-8c89-402f-8020-86ab53371346
6
public static void modifyNames(ArrayList<Journal> journalList, Journals journals) { for(Journal journal : journalList){ String oldName = journal.getName(); boolean retry = true; while(retry){ String newName = JOptionPane.showInputDialog(getBundle("BusinessActions").getString("NEW_NAME"), oldName.trim()); try { if(newName!=null && !oldName.trim().equals(newName.trim())){ journals.modifyJournalName(oldName, newName); // //ComponentMap.refreshAllFrames(); } retry = false; } catch (DuplicateNameException e) { ActionUtils.showErrorMessage(ActionUtils.JOURNAL_DUPLICATE_NAME, newName.trim()); } catch (EmptyNameException e) { ActionUtils.showErrorMessage(ActionUtils.JOURNAL_NAME_EMPTY); } } } }
ff058450-89c1-4767-8015-d376dfebed0b
9
private void printLinks(StringBuilder sb, List<Link> links) throws IOException { for (Link link : appendPhantomLink(links)) { final IEntity entity1 = link.getEntity1(); final IEntity entity2 = link.getEntity2(); if (entity1 == entity2 && entity1.getType() == EntityType.GROUP) { continue; } if (entity1.getType() == EntityType.GROUP && entity2.getParent() == entity1.getParent()) { continue; } if (entity2.getType() == EntityType.GROUP && entity1.getParent() == entity2.getParent()) { continue; } if (entity1.getType() == EntityType.LOLLIPOP || entity2.getType() == EntityType.LOLLIPOP) { continue; } // System.err.println("outing " + link); printLink(sb, link); } }
fb0d9dde-fa09-4676-9ff6-53f78c8ca4be
7
public void initiate() { System.out.println("\u001b[1;44m *** INITIATED *** \u001b[m"); /* Identify to server */ connection.sendln("NICK " + botN); // connection.sendln("PASS " + botP); connection.sendln("USER RTFM 0 * :Microsoft Exterminator!"); // /* // * Give the server 4 seconds to identify JRobo // * Before attempting to join a channel // */ // try { // Thread.sleep(10000); // } catch (InterruptedException ex) { // Logger.getLogger(JRobo.class.getName()).log(Level.SEVERE, null, ex); // } /* * Wait for server message: * 001 JRobo :Welcome to the IRC Network * Before attempting to join a channel */ while(( received = connection.recieveln()) != null ) { this.divideTwo(); if(first.equals("PING")) { connection.sendln("PONG " + last); } if(first.contains("001")) { break; } } connection.sendln("JOIN " + botC); while( (received = connection.recieveln()) != null ) { this.divideTwo(); /* Code to Test JRobo */ /* We have received a message from the owner */ if( first.startsWith( ":BullShark" ) && ( last.charAt(0) == SYMB ) ) { connection.msgChannel(botC, MircColors.RED + "Yes Sir Chief!" + MircColors.NORMAL); } /* Handle lines like these * * Received: PING :hubbard.freenode.net * Received: :RobotCow!~User@unaffiliated/robotcow PRIVMSG ##sushi :^command * Received: :RobotCow!~User@unaffiliated/robotcow PRIVMSG ProtoAnalyzer :cmd * Received: :hubbard.freenode.net 366 ProtoAnalyzer ##sushi :End of /NAMES list. */ if(first.equals("PING")) { connection.sendln("PONG :" + last); } } System.out.println("\u001b[1;44m *** TERMINATED *** \u001b[m"); }
a0fd47b1-1e9a-41e5-a1dc-2f6c3c02de23
7
public static void main(String[] args) { // create the object DB db = new DB(); // open the database if (!db.open("casket.kch", DB.OWRITER | DB.OCREATE)){ System.err.println("open error: " + db.error()); } // store records if (!db.set("foo", "hop") || !db.set("bar", "step") || !db.set("baz", "jump")){ System.err.println("set error: " + db.error()); } // retrieve records String value = db.get("foo"); if (value != null){ System.out.println(value); } else { System.err.println("set error: " + db.error()); } // traverse records Cursor cur = db.cursor(); cur.jump(); String[] rec; while ((rec = cur.get_str(true)) != null) { System.out.println(rec[0] + ":" + rec[1]); } cur.disable(); // close the database if(!db.close()){ System.err.println("close error: " + db.error()); } }
f66f37fd-59a8-4034-9988-2bc3eb945419
9
void compress( int init_bits, OutputStream outs ) throws IOException { int fcode; int i /* = 0 */; int c; int ent; int disp; int hsize_reg; int hshift; // Set up the globals: g_init_bits - initial number of bits g_init_bits = init_bits; // Set up the necessary values clear_flg = false; n_bits = g_init_bits; maxcode = MAXCODE( n_bits ); ClearCode = 1 << ( init_bits - 1 ); EOFCode = ClearCode + 1; free_ent = ClearCode + 2; char_init(); ent = nextPixel(); hshift = 0; for ( fcode = hsize; fcode < 65536; fcode *= 2 ) ++hshift; hshift = 8 - hshift; // set hash code range bound hsize_reg = hsize; cl_hash( hsize_reg ); // clear hash table output( ClearCode, outs ); outer_loop: while ( (c = nextPixel()) != EOF ) { fcode = ( c << maxbits ) + ent; i = ( c << hshift ) ^ ent; // xor hashing if ( htab[i] == fcode ) { ent = codetab[i]; continue; } else if ( htab[i] >= 0 ) // non-empty slot { disp = hsize_reg - i; // secondary hash (after G. Knott) if ( i == 0 ) disp = 1; do { if ( (i -= disp) < 0 ) i += hsize_reg; if ( htab[i] == fcode ) { ent = codetab[i]; continue outer_loop; } } while ( htab[i] >= 0 ); } output( ent, outs ); ent = c; if ( free_ent < maxmaxcode ) { codetab[i] = free_ent++; // code -> hashtable htab[i] = fcode; } else cl_block( outs ); } // Put out the final code. output( ent, outs ); output( EOFCode, outs ); }
ad8df32f-f88e-4581-b934-a079a9d9f475
0
@Test public void testPeekAndPopOperand(){ calculator.pushOperand(4.0); calculator.pushOperand(7.0); calculator.pushPlusOperator(); calculator.evaluateStack(); assertEquals(11.0, calculator.peekOperand(), 0); assertFalse(calculator.isStackEmpty()); calculator.pushOperand(3.0); calculator.pushTimesOperator(); calculator.evaluateStack(); assertEquals(33.0, calculator.peekOperand(), 0); assertFalse(calculator.isStackEmpty()); assertEquals(33.0, calculator.popOperand(), 0); assertTrue(calculator.isStackEmpty()); }
ad014ea9-95d4-4dbe-8416-0163743b9f58
2
private void siftUp(int start, int end ) { int child = end; while (child > start) { int parent = (int) Math.floor((child-1)/2); if(array.get(parent).compareTo(array.get(child)) > 0 ) { return; } T t = array.get(parent); array.set(parent, array.get(child)); array.set(child, t); } }
e7a69f7e-4c70-45c4-b9c8-7e4f3862d977
3
public void merge(Player.Ids rhs) throws IdConflictException { ObjectNode root = (ObjectNode) id; for(String key : rhs.all()) { JsonNode lhs = root.path(key); if (lhs.isMissingNode()) { root.put(key, rhs.get(key)); } else { String leftId = lhs.getTextValue(); String rightId = rhs.get(key); if ( ! leftId.equals(rightId)) { throw new IdConflictException(key + "lhs:" + leftId + " rhs:" + rightId); } } } }
b12db946-7e77-475b-a929-de65f2d6c2da
6
public static String reverseWords(char[] s) { reverseSentence(s, 0, s.length - 1); int start = 0; int end = 0; while(start <s.length && end < s.length) { while(start < s.length && s[start] == ' ') { start ++; } end = start; while(end < s.length && s[end] != ' '){ end ++; } end --; reverseSentence(s, start, end); start = end +1; } return new String(s); }