text
stringlengths
14
410k
label
int32
0
9
public void swim(int k) { /** * Checking for isGreater makes sure that the <= property of MinHeap is * satisfied. */ while (k > 1 && isGreater(k / 2, k)) { swapArrayValues(k / 2, k); k = k / 2; this.arrayAccess += 2; this.compari...
2
public static void startupStreams() { if (Stella.currentStartupTimePhaseP(0)) { { OutputStream self001 = OutputStream.newOutputStream(); self001.nativeStream = new PrintableStringWriter(java.lang.System.out); Stella.STANDARD_OUTPUT = self001; } if (!(Stella.STANDARD_WARNING != nul...
9
* @param decimalPlaces * @param a_RoundingMode * @return e^y where e is the Euler constant. The result is returned correct * to decimalPlaces decimal place precision. */ public static BigDecimal exp( BigDecimal y, Generic_BigDecimal a_Generic_BigDecimal, int d...
6
public synchronized void sendGamestate(int turnNumber, int dimension, String mapData[][], AIConnection playerlist[]){ JSONObject root = new JSONObject(); try { root.put("message", "gamestate"); root.put("turn", turnNumber); JSONArray players = new JSONArray(); for(AIConnection ai: playerl...
4
public static byte[] serializeToBytes(Object object) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { ObjectOutputStream out = new ObjectOutputStream(stream); try { out.writeObject(object); out.flush(); } finally { if (out != ...
2
public String searchAll(String name, String criteria) { String result = ""; //loop over entire table from start for(int i = 0 ; i < hashTableSize -1 ; i ++) { //if current data is not null, and equals to search add to result if(hashtable[i]!= null) { if(criteria.equals("First Name")) if(hasht...
8
public static ResultSet query(String sql,Statement stmt) { ResultSet rs = null; try { rs = stmt.executeQuery(sql); } catch (SQLException e) { e.printStackTrace(); } return rs; }
1
public void mouseDown(MouseEvent e, int x, int y) { switch (count) { case 0: { editor.showStatus("State change: Moving archer to (1,1)"); game.moveUnit(new Position(2, 0), new Position(1, 1)); break; } case 1: { ...
8
@EventHandler public void onBlockPlace(BlockPlaceEvent e){ Block block = e.getBlock(); Player player = e.getPlayer(); boolean grow = false; if(GiantTreesRevived.getSettings().allowBlockNearGrow() && GiantTreesRevived.checkPermission(player, "grow")){ if(block.getTypeId()...
8
private void loadTileSheet(String src) { try { tileSheet = ImageIO.read(getClass().getResource(src)); tileRows = tileSheet.getHeight() / (tileSize + offset * 2); tileCols = tileSheet.getWidth() / (tileSize + offset * 2); BufferedImage tile; tileSet = new Tile[tileCols][tileRows]; for(int ...
3
protected void addForumJournalsVar(final HTTPRequest httpReq, final String index, final StringBuilder str) { final String name=httpReq.getUrlParameter("FORUMJOURNAL_"+index+"_NAME"); if((name!=null)&&(name.trim().length()>0) &&(!name.trim().equalsIgnoreCase("auction"))) { if(str.length()>0) str.append("...
7
public void render(Graphics2D graphics) { graphics.setColor(Color.BLACK); graphics.drawRect(screenX, screenY, 15, 15); graphics.setColor(state.getColor()); graphics.fillRect(screenX + 1, screenY + 1, 14, 14); }
0
private MarkupItem createMarkupItem( URI id, String gi, URI ns, Collection.Type type, EARMARKNode.Type markupType) { MarkupItem markup = null; if (markupType == EARMARKNode.Type.Attribute) { markup = new Attribute(this, gi, ns, type, id); } else if (markupType == EARMARKNode.Type.Comment) { markup = n...
8
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { String commandType=""; if(commands.size()>1) { commandType=commands.get(1).toUpperCase(); } if(commandType.equals("ITEM")) { mob.location().show(mob,null,CMMsg.MSG_OK_VISUAL,L("^S<S-NAME> ...
8
private int performPeroxyFunctionalReplacement(Element groupToBeModified, Element locantEl, int numberOfAtomsToReplace) throws StructureBuildingException { List<Atom> oxygenAtoms = findFunctionalOxygenAtomsInApplicableSuffixes(groupToBeModified); if (oxygenAtoms.size()==0){ oxygenAtoms = findEthericOxygenAtomsIn...
9
public void setDateOfJoining(Date dateOfJoining) { this.dateOfJoining = dateOfJoining; }
0
public void moveToScene(String viewName) { Resource res = this.applicationContext.getResource(MessageFormat.format("views/layouts/{0}.fxml", viewName)); try { FXMLLoader loader = new FXMLLoader(res.getURL()); loader.setControllerFactory((Class<?> clazz) -> this.appli...
3
@Override public final void leftRotation() { int rowLength = WIDTH_FIELDS; int colLength = HEIGHT_FIELDS; IField[][] tmpFieldMatrix = new IField[rowLength][colLength]; for (int row = 0; row <= rowLength - 1; row++) { for (int column = 0; column <= colLength - 1; column++) { tmpFieldMatrix[row][column] ...
5
public static <T, U> String writeJson(Map<T, U> map, Object[]... typeAdaptors) { GsonBuilder gb = new GsonBuilder().setPrettyPrinting(); for(Object[] o : typeAdaptors) { if(o.length >= 2) { gb.registerTypeAdapter((Type)o[0], o[1]); } } Gson gson = gb.create(); return gson.toJson(map); }
2
public void addDload(int n) { if (n < 4) addOpcode(38 + n); // dload_<n> else if (n < 0x100) { addOpcode(DLOAD); // dload add(n); } else { addOpcode(WIDE); addOpcode(DLOAD); addIndex(n); } ...
2
private void goNext() { FalseStartLabel.getInstance().clear(); StateManager.getInstance().setState(new EndRound()); }
0
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; MavenDependency other = (MavenDependency) obj; if (artifactId == null) { if (other.artifactId != null) return false; } else if (!artifac...
9
private static void setData(Object obj, Method objMethod, Object param) { try { Class []ptt = objMethod.getParameterTypes(); if (ptt == null) { throw new ASNException(null, "Cannot find parameters in method: " + objMethod.toGenericString()); } Clas...
9
public void launchNext(final int wexp, final int ah) { Thread subExpThread; subExpThread = new Thread() { public void run() { m_remoteHostsStatus[ah] = IN_USE; m_subExpComplete[wexp] = TaskStatusInfo.PROCESSING; RemoteExperimentSubTask expSubTsk = new RemoteExperimentSubTask(); expSubTs...
9
private void waitForThread() { if ((this.thread != null) && this.thread.isAlive()) { try { this.thread.join(); } catch (final InterruptedException e) { plugin.getLogger().log(Level.SEVERE, null, e); } } }
3
public static Direction convertActToDir(MovementAction action){ switch(action){ case MOVE_DOWN: return SOUTH; case MOVE_LEFT: return WEST; case MOVE_RIGHT: return EAST; case MOVE_UP: return NORTH; case STAND: return null; default: return null; } }
5
@Override public void run() { if(!running) return; try { String msg = ""; String line; while((line = inRead.readLine()) != null) { msg += line; if(line.endsWith("{OP}")) { msg = msg.substring(0, line.length() - 4); List<String> parts = new ArrayList<String>(); parts = A...
6
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost,msg); if((msg.othersMajor(CMMsg.MASK_CHANNEL))) { final int channelInt=msg.othersMinor()-CMMsg.TYP_CHANNEL; final ChannelsLibrary.CMChannel chan=CMLib.channels().getChannel(channelInt); final boolean...
8
@Override public void removeProgram(Program program) { Double programFitness = 0.0; if(program.getFitness() == null) fitnessFunction.computeFitness(program); programFitness = program.getFitness(); int index = 0; while (index < this.programs.size() && programFitness > this.fitness.get(index)) { index++; ...
6
public static byte[] toMQttString(String s) { if (s == null) { return new byte[0]; } ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(byteOut); try { dos.writeUTF(s); dos.flush(); } catch (IOException e) { // SHould never happen; return ...
2
public static Thing lookup(String gType) { Thing stored, dupe, black; String bareGType; /* * Lookup the type. This will work most of the time... */ stored = things.get(gType); if (stored != null) { return stored; } /* * ....
9
private void getCPUUsage() { new Thread() { @Override public void run() { setName("CPU Info Thread"); setPriority(Thread.MIN_PRIORITY); while (getDeviceInfo) { // if (debug) // logger.log(Level.DEBU...
7
public static Vector selectRackID_from_rackCategory(String catname){ Vector v=new Vector(); try { ResultSet rs1=DB.myConnection().createStatement().executeQuery("select * from category where CategoryName='"+catname+"'"); while(rs1.next()){ String catID=r...
3
@Override public int attack(NPC npc, Entity target) { final NPCCombatDefinitions defs = npc.getCombatDefinitions(); int distanceX = target.getX() - npc.getX(); int distanceY = target.getY() - npc.getY(); int size = npc.getSize(); int hit = 0; int attackStyle = Utils.random(2); if (attackStyle == 0 && (di...
7
private ArrayList<Course> removeClassesWOPre(ArrayList<Course> needed, ArrayList<Course> taken) { ArrayList<Course> ret = new ArrayList<>(); for (Course course : needed) { boolean allContained = true; if (course.getPrereqs() != null && course.getPrereqs().get(0) != null) { ...
8
public MasterGameThread(NetworkGameScreen screen) throws IOException { super("MasterGameThread"); this.screen = screen; String remoteHost = ((PongWindow)screen.parent).RemotePlayer; // formato HRS-GUA-02/169.254.80.80 slaveSocket = new Socket(remoteHost.substring(remoteHost.lastIndexOf('...
0
public static int getHighestLevel(Pokemon party[], Pokemon pc[]) { int highest=0; for (Pokemon aParty : party) { if (aParty != null) { if (aParty.level > highest) highest = aParty.level; } else break; } for (Pokemon...
6
private void addRule(Document document, Rule rule) throws OutputterException { Element ele = document.createElement(Tag.RULE.getXmlTag()); if (!rule.getLabel().startsWith(DEFAULT_RULE_LABEL_PREFIX)) ele.setAttribute(Attribute.RULE_LABEL.getAttributeName(), rule.getLabel()); switch (rule.getRuleType()) { case ST...
7
public Element generateElement(Document document) { Element edge = document.createElement(mxGraphMlConstants.EDGE); if (!edgeId.equals("")) { edge.setAttribute(mxGraphMlConstants.ID, edgeId); } edge.setAttribute(mxGraphMlConstants.EDGE_SOURCE, edgeSource); edge.setAttribute(mxGraphMlConstants.EDGE_TA...
4
@Override public int compare(Integer o1, Integer o2) { return (o1>o2 ? -1 : (o1==o2 ? 0 : 1)); }
2
private void drawPodatek(Graphics g, final ArrayList al) { g.setFont(newRomanNormal); HashMap VatMap = new HashMap(7); double sumNetto = 0; double sumBrutto = 0; double sumVat = 0; for (int i = 0; i < al.size() ; i++) { DataEntry dat = (DataEntry)al.get(i); String Stawka = dat.getVatStawka...
9
public int longestValidParentheses(String s) { if(s == null || s.length() < 2 || s.indexOf(")") == -1) { return 0; } int ret = 0; int[] len = new int[s.length() + 1]; len[0] = 0; len[1] = 0; for(int i = 2; i <= s.length(); i++) { if(s.ch...
9
public Configuration[] getInitialConfigurations(String input) { /** The stack should contain the bottom of stack marker. */ Configuration[] configs = new Configuration[1]; CharacterStack stack = new CharacterStack(); stack.push("Z"); configs[0] = new PDAConfiguration(myAutomaton.getInitialState(), null, i...
0
public boolean checkSize(int min,int max, int size) { if(size>=min&&size<=max){ return true; } if(min==max&&min==UNLIMITED){ return true; } if(size<min){ System.out.println(Language.tooFewArguments); } if(size>max){ System.out.println(Language.tooManyArguments); } return false; }
6
Response doSend() throws IOException { connection.setRequestMethod(this.verb.name()); if (connectTimeout != null) { connection.setConnectTimeout(connectTimeout.intValue()); } if (readTimeout != null) { connection.setReadTimeout(readTimeout.intValue()); } addHeaders(connect...
4
public Counter(String name) { this.name = name; count = 0; }
0
private static void reachingDefDataFlow(OptFunctionNode fn, Node[] statementNodes, Block theBlocks[], int[] varTypes) { /* initialize the liveOnEntry and liveOnExit sets, then discover the variables that are def'd by each function, and those that are used before being def'd (hence liveOnEntry) */ ...
9
private ResGridlet cancel(int gridletId, int userId) { ResGridlet rgl = null; // Find in EXEC List first int found = gridletInExecList_.indexOf(gridletId, userId); if (found >= 0) { // update the gridlets in execution list up to this point in time ...
4
public confirmRemoval() { this.requireLogin = true; this.addRtnCode(405, "not removing"); }
0
public static void main(String[] args) { System.out.println("Building Huffman Tree:"); Byte[] byteArray = new Byte[] { 45, 56, 67, 78, 89, 12, 23, 34, 45, 23, 45, 67, 45 }; HuffmanTree<Byte> hTree = new HuffmanTree<Byte>(byteArray); System.out.println(); System.out.println("Printing Tree:"); hTree.pri...
5
public List<GPSData> getAccIter(List<GPSData> gpss, List<AccMagn> magns) { // TODO: add boundary conditions (if arrays.size() < 2...) long accMagnPreTimestamp = magns.get(0).getTimestamp(); int k = 0; for (int i = 0; i < gpss.size(); i++) { GPSData gpsData = gpss.get(i); long gpsTimestamp = gpsData.get...
4
public String getDate(){ String day, month, year; day = Integer.toString(time.get(5)); if (day.length()==1) day = "0" + day; month = Integer.toString(time.get(2)+1); if (month.length()==1) month = "0" + month; year = Integer.toString(time.get(1)); return day + "/" + month + "/" + year; }
2
public static int charge(String ion){ ion = ion.trim(); boolean test0 = true; boolean test1 = false; int i = 0; int charge = 0; // check entered ion against ion list while(test0){ if(IonicRadii.compareBare(ion, i)){ test0 = false; ...
4
public void setAvb(Double avb) { this.avb = avb; }
0
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player) { final WarPlayer damager = this.war.getHelper().getPlayerExact(((Player) event.getDamager()).getName()); if (!damage...
6
public static void reCalculateTFandIDFwithApproxValues(String docContents, String docName, int collectionSize, double docLength) { System.out.println("reCalculateTFandIDFwithApproxValues running"); ArrayList<String[]> currentPostingsList; String[] posting; for (int k = 0; k ...
8
TotalPanel() { this.setLayout(new GridLayout(3, 2)); this.setBorder(new TitledBorder("总流量")); getContent(); this.add(totaltitle); this.add(totalnum); this.add(tcptitle); this.add(tcpnum); this.add(udptitle); this...
0
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
6
public int getMarker() { return this.marker; }
0
public HashMap getInfo(String link){ String sourceName = "挑食网"; String html = GetHTML.getHtml(link, "utf-8"); Document doc = Jsoup.parse(html); Elements ele = doc.select("script[type]"); Element eleJson = ele.get(7); String jsonData = eleJson.html().replaceAll("\t",""); ...
7
public String predict(){ String s; if(getNext()== 1 || getNext()== 3 || getNext()== 4 || getNext()== 5 || getNext()== 9 || getNext()== 10 || getNext()== 11 || getNext()== 12 || getNext()== 15){ return s = "Head"; } else { return s = "Tail"; } }
9
public static void main(String[] args) { String[] names = { "Aman", "Amar", "Himanshu", "Piyush", "Gunjan", "Ankit", "Shruthi" }; Container nameContainer = new NameContainer(names); Iterator iterator = nameContainer.getIterator(); for (; iterator.hasNext();) { System.out.println("Name :" + iterator.ne...
1
@Override boolean canPerform(Creature cc, World w) { if(cc.canwork && cc.isAlive() && cc.stuntime==0) { if(w.getItemcollection().isRecqExist(worldObjectRecquire)==false) return false; if(this.getTasktype()==TaskEnum.walking) { ...
9
public List<String> getNouns (int idx) { List<String> nouns = new ArrayList<String>(); List<TermPos> phrase = phrases.get(idx); int i = 0; for (; i < phrase.size() && !phrase.get(i).pos.startsWith("NN"); i++); for (; i < phrase.size(); i++) { nouns.add(phrase.get(i).term); } return nouns; }
3
public static void main(String[] args){ Scanner in = new Scanner(System.in); int n=in.nextInt(); int m=in.nextInt(); isBlack = new boolean[n][m]; for(int i=0;i<n;i++){ String line = in.next(); for(int j=0;j<m;j++){ isBlack[i][j]=line.charAt(j)=='1'; // System.out.println(isBlack[i][j]); ...
4
public void calculatePerCapitas() { popCap = houseNumber * MAXHOUSECAPACITY + 5; foodPerCapita = ((double) (foodings))/population; energyPerCapita = energies/population; popDeriv = (foodPerCapita * energyPerCapita); if(foodPerCapita <= 0 && energyPerCapita <= 0) { popDeriv = 0.5; } ...
7
private void extractCircles (Mat mask, List<Circle> balls, List<BallCluster> ballClusters, List<MatOfPoint> contours) { // clear input balls.clear(); ballClusters.clear(); contours.clear(); // find the contours Imgproc.findContours(mask.clone(), contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPRO...
8
protected boolean test2 () { return true; }
0
private void parseNodeString(String nodeLine) { StringTokenizer tokenizer = new StringTokenizer(nodeLine); // number of node parameters to parse (counts at linestart) int parameters = 3; // first test to step to the next parsing-state (edges) if (nodeLine.contains("Edges:")) { // Log.printLine("found st...
7
public void SendMessageByGet(){ CloseableHttpClient client=HttpClients.createDefault(); HttpGet get=new HttpGet(url+"?"+"&user="+user+"&key="+key+"&number="+number+"&text="+text); try { System.out.println(url+"?"+"&user="+user+"&key="+key+"&number="+number+"&text="+text); HttpResponse response=client.execut...
4
private void update(String image) { switch (TODOManager.backend.getSorting()) { case TIME: time.setImage(image); break; case PRIO: prio.setImage(image); break; case TITLE: title.setImage(image); ...
4
boolean resolve(final MethodWriter owner, final int position, final byte[] data) { boolean needUpdate = false; this.status |= RESOLVED; this.position = position; int i = 0; while (i < referenceCount) { int source = srcAndRefPositions[i++]; int ...
5
public static int[] sortLogList(int[] logList) { int i, j, first, temp; for (i = logList.length - 1; i > 0; i--) { first = 0; //initialize to subscript of first element for (j = 1; j <= i; j++) //locate smallest element between positions 1 and i. { ...
3
private ScoreObject addop(ScoreObject a, ScoreObject b) { if (a.isNumeric() && b.isNumeric()) { if (a.isFloat() || b.isFloat()) return new ScoreObject(a.getAsFloat() + b.getAsFloat()); // one is an int? else if (a.isInt() || b.isInt()) return new ScoreObject(a.getAsInt() + b.getAsInt()); // must b...
8
public void keyReleased(KeyEvent w) { int code = w.getKeyCode(); if (code == KeyEvent.VK_A) { left = false; if (right) { } else { dx = 0; } } else if (code == KeyEvent.VK_D) { right = false; if (left) { ...
8
private static String loadSiteUID(){ String uid = DEFAULT_SITE_USER_ID; try{ FileInputStream fis = new FileInputStream(workingDir + SITE_UID_FILE_NAME); try{ BufferedReader reader = new BufferedReader(new InputStreamReader(fis)); try { uid = reader.readLine(); } catch (IOException e) {} r...
3
public static void main(String[] args) { TreeSet<Integer> products = new TreeSet<Integer>(); int[][] grid = readFile(System.getProperty("user.dir") + "/external/problem11.txt"); for (int i = 0; i < 20; i++) { for (int j = 0; j <= 16; j++) { products.a...
8
public void changePrice(GraphNode<T> a, GraphNode<T> b, int weight){//T siendo graphNode con elemento de tipo Base, client o hub. for(int i=0;i<aristas.getLength();i++){//checks coincidence to find link between nodes. if(((GraphNode) aristas.get(i).getInitial()).equals(a) && ((GraphNode) aristas.get...
3
public boolean isRelativeMouseMode() { return (robot != null); }
0
public void addClassificationAttempt(int trueClass, double[] classVotes, double weight) { if (weight > 0.0) { if (TotalweightObserved == 0) { reset(classVotes.length > 1 ? classVotes.length : 2); } this.TotalweightObser...
7
@Override public Source getSource(String sId) throws BadResponseException { Source s = null; JsonRepresentation representation = null; Representation repr = serv.getResource("intervention/" + interId + "/source", sId); try { representation = new JsonRepresentation(repr); } catch (IOException e) { ...
3
private static HashMap<String, Holder> getMap(String level) throws Exception { HashMap<String, Holder> map = new LinkedHashMap<String, Holder>(); BufferedReader reader = new BufferedReader(new FileReader(new File( ConfigReader.getRachSachReanalysisDir() + File.separator + "rdpAnalysis" + File.separ...
6
private Node nextIntersectionNode( Node node, K key ) { if( node == null ) { return null; } while( true ) { // Check right tree. Node ret = firstIntersectionNode( node.mRight, key ); if( ret != null ) { return ret; } ...
9
public void body() { // wait for a little while for about 3 seconds. // This to give a time for GridResource entities to register their // services to GIS (GridInformationService) entity. super.gridSimHold(3.0); LinkedList resList = super.getGridResourceList(); // in...
6
@Override public void run() throws IOException, ClassNotFoundException, SQLException { // let's create output dir DateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); String ts = df.format(new Date()); Path pathTs = Files.createDirectory(Paths.get(Config.getPathOut() + ts));...
8
private boolean won() { if (mSweeper.isDied()) return false; final int width = mField.getWidth(), height = mField.getHeight(); final byte open = mField.getMasks().getOpen().getId(), openBomb = mField.getMasks().getOpenBomb().getId(), bomb = mField.getTiles().getBomb().getId(); for (int tile = 0; tile < width *...
5
private void sendFiles(Transferable tran) throws UnsupportedFlavorException, IOException { if (fileList == null) { // If files are drag&dropped filelist will be filled at DragAndDropListener prtscr = true; if (tran.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { ...
6
@Override public int[] getInts(int par1, int par2, int par3, int par4) { int i1 = par1 - 1; int j1 = par2 - 1; int k1 = par3 + 2; int l1 = par4 + 2; int[] aint = this.parent.getInts(i1, j1, k1, l1); int[] aint1 = IntCache.getIntCache(par3 * par4); for (in...
8
public boolean isStillMaintained(Environmental thang, ShopKeeper SK, Item I) { if((I==null)||(I.amDestroyed())) return false; if(SK!=null) return SK.getShop().doIHaveThisInStock(I.Name(),null); if(thang instanceof Area) { final Room R=CMLib.map().roomLocation(I); if(R==null) return false; re...
9
private void launch() { //The method that kick starts execution of a program and manages it in standard mode pc.setPC(0); //Initialise PC to 0 for GUI display if (!pipeliningMode) { while (active) { fetchDecodeStage.run(); int opcode = fetchDecodeStage.getOpcodeValue(); if (opcode == -1) { //fe...
5
public void connectToService() { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { Remote service = Naming.lookup("//127.0.0.1:1699/quiz"); quizService = (QuizService) service; } catch (MalformedUR...
4
protected static String toHtml(String wiki) { wiki = wiki.replaceAll("<BR>|<br>", " "); wiki = wiki.replaceAll("\n", " "); wiki = wiki.replaceAll(" ", " "); int countBold = 0; int indexOfApostrophe = wiki.indexOf("'''"); while (indexOfApostrophe != -1) { if ...
4
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((frequency == null) ? 0 : frequency.hashCode()); result = prime * result + ((symbol == null) ? 0 : symbol.hashCode()); return result; }
2
public OneTangent(Craft craft, double rFinal, double transPoint) { //Faster but less efficient than a Hohmann transfer //Decrease transPoint for a shorter transfer time double grav = craft.parent.mass * Astrophysics.G; double rInitial = craft.position.clone().subtract(craft.parent.position).magnitude(); doubl...
3
public void zapImageParts(BufferedImage im, double likelihood) // change some of the image's pixels to red or yellow { if (im == null) { System.out.println("zapImageParts: input image is null"); return; } if ((likelihood < 0) || (likelihood > 1)) { ...
6
public void setDimensions(){ for(int i=0; i<books.size();i++){ BookNode book = books.get(i); int x= (int)book.getX(); int y= (int)book.getY(); int radius = (int)book.getPaddedRadius(); if(i==0 || x-radius<minX) minX=x-radius; if(i==0 || x+radius>maxX) maxX=x+radius; if(i==0 || y-ra...
9
public static void removeConnection(String username, Integer type) { Client client = getClient(username); // Check if client target client exists. if (client != null) { // Remove from GUI List. clientListModel.removeElement(username + " (" + client.g...
6
public Matrix decomposeLU(boolean LUP) { if(rows != cols) { throw new IllegalArgumentException("Matrica nije kvadratna!"); } Matrix P = new Matrix(rows); for(int i = 0; i < rows - 1; i++) { if(LUP) { // ako je LUP postupak odabran napravi pivotiranje po stupcima int pivotIndex = i; ...
9
public void removeRange(int fromIndex, int toIndex) { int numMoved = size - toIndex; System.arraycopy(data, toIndex, data, fromIndex, numMoved); size = size - (toIndex - fromIndex); }
0
public void aplicarMascarilla() throws InterruptedException { if (!mascarillaAplicada) { for (Barrillo barrillo : barrillos) { barrillo.mascarillaAplicada = true; } mascarillaAplicada = true; repaint(); semaforo.acquire(); ...
4