text
stringlengths
14
410k
label
int32
0
9
public void setInt(TInt node) { if(this._int_ != null) { this._int_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); } ...
3
public boolean isAdjacentTo(Location other) { if(Math.abs(other.x - x) <2 && Math.abs(other.y - y) < 2) return true; return false; }
2
public Torrent(byte[] torrent) throws IllegalArgumentException { this.encoded = torrent; try { this.decoded = BDecoder.bdecode( new ByteArrayInputStream(this.encoded)).getMap(); this.announceUrl = this.decoded.get("announce").getString(); this.decoded_info = this.decoded.get("info").getMap(); th...
1
static Object callSecurely(final CodeSource codeSource, Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { final Thread thread = Thread.currentThread(); // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission ...
7
private static void closeResult(ResultSet rs) { if( rs != null ) { try { if( !rs.isClosed() ) { rs.close(); } } catch (SQLException e) { logger.error("Error closing the result set.", e); } } }
3
public InteractivePanel(){ addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if(e.getButton()!=MouseEvent.BUTTON1) return; double x = e.getXOnScreen(); double y = e.getYOnScreen(); Graphics g = getGraphics(); for(SUIComponent comp : components){ ...
5
public boolean containsChord(Chord chord) { // Check for tonic if (tonic.equals(chord)) { return true; } // Check all the subdominant chords for (int indx = 0; indx < subdominant.length; indx++) { if (subdominant[indx].equals(chord)) { return true; } } // Check all the dominant chords ...
5
private static ArrayList<Models.ViewModel.BillItem> getBillItems(ArrayList<Models.DatabaseModel.BillItem> billItems, ArrayList<Models.DatabaseModel.Medicine> medicines) { ArrayList<Models.ViewModel.BillItem> viewmodelbillItemArray = new ArrayList<>(); for (Models.DatabaseModel.BillItem billItem : billI...
3
@Override protected void init() { try { // check to see if the user is using a File or InputStream. This is // here for backwards compatability if (dataSourceStream != null) { final Reader r = new InputStreamReader(dataSourceStream); setDat...
7
static Color getCtryColor(String country) { // Special case: XXX means no one if (isNotACountry(country)) country = "NAT"; else country = toUpperCase(country); Color ret = ctryColorCache.get(country); if (ret == null) { ...
5
private static HashMap<String, Integer> getDocumentFrequency(String dirName, Normalizer stemmer) throws IOException{ HashMap<String, Integer> hits = new HashMap<String, Integer>(); File dir = new File(dirName); if (dir.isDirectory()) { // Liste des fichiers du répertoire // ajouter un filtre (FileNameFilter) ...
6
private final void processPrivileges(ArrayList<String> privs, PrivilegeHolder entity) { if(entity == null || privs == null) return; // Denials ArrayList<String> denials = entity.getDenials(); for(String denial: denials) { if(denial.equals("*")){ privs.clear(); break; } privs.remove(de...
7
@Test public void testNotifyAll() { final Object o = new Object(); Runnable r = new Runnable(){ @Override public void run() { assertThreadIsRunnable(); try { synchronized(o){ o.wait(); // wait can only be invoked on an object if the thread which invoked wait owns the m...
7
static void projectionTest(int n) { planner = new Planner(); Variable scale = new Variable("scale", 10); Variable offset = new Variable("offset", 1000); Variable src = null, dst = null; List<Variable> dests = new ArrayList<Variable>(); for (int i = 0; i < n; i++) { ...
7
public void grabData() { if(System.getProperty("os.name").contains("Win") || System.getProperty("os.name").contains("win")) { isWindows = true; } else { isWindows = false; } grabOSName(); grabOSVersion(); grabOSArchitecture(); }
2
public boolean hasGodmode(xAuthPlayer player, DamageCause cause) { int godmodeLength = plugin.getConfig().getInt("session.godmode-length"); Timestamp loginTime = player.getLoginTime(); if (godmodeLength < 1 || loginTime == null || cause == DamageCause.FIRE_TICK || cause == DamageCause.DROWNING) return false; ...
4
public static BigInteger factorial(int f) { BigInteger res = new BigInteger("1"); for(int i = 2; i <= f; i++) { res = res.multiply(new BigInteger("" + i)); } return res; }
1
public void testSaveGosta() { Osoba o=new Osoba(); o.setImePrezime("Alen Kopic"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { o.setDatumRodjenja(sdf.parse("1992-10-21")); } catch (java.text.ParseException p) { System.out.println(p.toString()); } o.setAdresa("Vitkovac 166...
4
public void makeNonVoid() { if (type != Type.tVoid) throw new jode.AssertError("already non void"); type = subExpressions[0].getType(); }
1
public static int getIndexFromName(ArrayList<Method> methods,String possibleSetName){ for(int i=0;i<methods.size();i++){ if(methods.get(i).getName().equalsIgnoreCase(possibleSetName)){ return i; } } return -1; }
2
public static void keySet(int i, boolean b) { if(i == KeyEvent.VK_UP) keyState[UP] = b; else if(i == KeyEvent.VK_LEFT) keyState[LEFT] = b; else if(i == KeyEvent.VK_DOWN) keyState[DOWN] = b; else if(i == KeyEvent.VK_RIGHT) keyState[RIGHT] = b; else if(i == KeyEvent.VK_SPACE) keyState[BUTTON1] = b; else if(i ...
9
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
7
public void addState(State state) { if (!this.states.contains(state)) { this.states.add(state); if (state != null) state.setTray(this); } }
2
public double[] distributionForInstance(BayesNet bayesNet, Instance instance) throws Exception { Instances instances = bayesNet.m_Instances; int nNumClasses = instances.numClasses(); double[] fProbs = new double[nNumClasses]; for (int iClass = 0; iClass < nNumClasses; iClass++) { ...
9
public String highMonth(){ double max = profit[0]; String maxMonth = month[0]; for(int i = 1; i < 12; i++){ if(max < profit[i]){ max = profit[i]; maxMonth = month[i]; } } return maxMonth; }
2
private String makeKey(String[] text, Boolean[] stresses) { StringBuilder key = new StringBuilder(); key.append(Utils.join(text, KEY_DELIM)); // If we're stress sensitive, tack the stresses on the end, note // we just use 1s and 0s to keep the string shorter than true/false would if (stressSensitive) { fo...
3
public Object getDefaultValue() { switch (typecode) { case TC_LONG: return new Long(0); case TC_FLOAT: return new Float(0); case TC_DOUBLE: return new Double(0); default: return null; } }
3
public static void toggleCommentInheritance(Node currentNode, JoeTree tree, OutlineLayoutManager layout) { CompoundUndoablePropertyChange undoable = new CompoundUndoablePropertyChange(tree); JoeNodeList nodeList = tree.getSelectedNodes(); for (int i = 0; i < nodeList.size(); i++) { toggleCommentInheritanceF...
3
public void unloadQueue(Response response) { for (Cookie cookie : queue) { response.addHeader("Set-Cookie", cookie.getHTTPHeader()); } }
1
public Upgrade[] getUpgrades() { return upgrades; }
0
public static String getDefaultRegionName(Player player, RegionType regionType) { net.sf.freecol.common.model.Map map = player.getGame().getMap(); int index = player.getNameIndex(regionType.getNameIndexKey()); if (index < 1) index = 1; String prefix = player.getNationID() + ".region." ...
6
@Override public boolean execute(CommandSender sender, String[] args) { if(sender instanceof Player == false) { sender.sendMessage("Only players can own chunks ;D"); return true; } if(!((Player)sender).getWorld().getName().equals(p.getWorld())) return true...
5
public void menuButtonClicked(String button) { if (button.equals("Start Game")) { onMenuScreen = false; startGame(); } else if (button.equals("About")) { JOptionPane .showMessageDialog( this, "<HTML>Mouse Maze Escape<br>Version: " + version + "<br>Author: Thomas Auberso...
5
public void keyTyped(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { setModelProperty(PROPERTY_NEXT_FIELD, Direction.DOWN); } else if (evt.getKeyCode() == KeyEvent.VK_UP) { setModelProperty(PROPERTY_NEXT_FIELD, Direction.UP); } else if (evt.getKeyCode() == KeyEvent.VK_LEFT) { setModelProperty...
4
private void doMain() { for (String filename : filenames) { File inputFile = new File(filename); TextExtractor te = null; try { te = parsePdf(inputFile); System.out.println(te.toXml()); } catch (IOException e) { ...
4
private void createGoal(int x, int y) { //Schnitt mit Linien pruefen for(int i=0; i<Lines.size(); i++) { float d = (float) Line2D.ptSegDist(Lines.elementAt(i)[0], Lines.elementAt(i)[1], Lines.elementAt(i)[2], Lines.elementAt(i)[3], x, y); if(d < 10){return;} } //Schnitt mit anderen Baellen pruefen f...
6
public ArrayList<Administrador> getAll(){ PreparedStatement ps; ArrayList<Administrador> admins = new ArrayList<>(); try { ps = mycon.prepareStatement("SELECT * FROM Administradores"); ResultSet rs = ps.executeQuery(); if(rs!=null){ try { ...
4
private final boolean readUntilSep(final ByteBuffer nameBuffer) throws IOException { nameBuffer.position(0); do { final int read = this.in.read(); if (read == Deserializer_3.SEPERATOR_3) { return false; } if (read == Deserializer_3.SEPERATOR_EXT_3) { return true; } nameBuffer.put((byte)...
3
public Client_Socket(String hostName, int portNumber) throws ConnectException { try { try { echoSocket = new Socket(hostName, portNumber); } catch (ConnectException e) { throw e; } catch (UnknownHostException e) { System.out.pr...
4
protected int getKnownAttributeCount() { int count = 0; if (bytecode != null) count++; if (exceptions != null) count++; if (syntheticFlag) count++; if (deprecatedFlag) count++; return count; }
4
@Override public List<Cliente> listAll() { Connection conn = null; PreparedStatement pstm = null; ResultSet rs = null; List<Cliente> clientes = new ArrayList<>(); try{ conn = ConnectionFactory.getConnection(); pstm = conn.prepareStatement(LIST); ...
3
public static Room buildRoom(EnumArray rm, int y, int x) { Room room = new Room(); switch(rm) { case PATH: Random r = new Random(); int num = r.nextInt(10); if (num < 2) room.setBehavior(new ItemBehavior(new Potion())); else if (num < 4) room.setBehavior(new ItemBehavior(new Poison())...
7
@Override public String encrypt(String str) throws IllegalBlockSizeException { try { // Encode the string into bytes using utf-8 byte[] utf8 = str.getBytes("UTF8"); // Encrypt byte[] enc = ecipher.doFinal(utf8); // Encode bytes to base64 to get a...
4
public void moveToPosition(Position nextPosition){ if(vehicle != null && mapStolen){ flyToVaderBase(); mapStolen = false; } inhabitantColl = super.getInhabitantColl(); if(inhabitantColl.objectAt(nextPosition)){ TetraGUIManager.DisplaySteps("THero " + getName() + " (ID: " + getTetId() + ") cannot mov...
9
private void method38() { for(int i = -1; i < playerCount; i++) { int j; if(i == -1) j = myPlayerIndex; else j = playerIndices[i]; Player player = playerArray[j]; if(player != null && player.textCycle > 0) { player.textCycle--; if(player.textCycle == 0) player.textSpoken = nu...
9
public GrahamScan(Point2D[] pts) { // defensive copy int N = pts.length; Point2D[] points = new Point2D[N]; for (int i = 0; i < N; i++) points[i] = pts[i]; // preprocess so that points[0] has lowest y-coordinate; break ties by x-coordinate // points[0] is an...
8
@EventHandler public void PigZombieResistance(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getPigZombieConfig().getDouble("PigZo...
6
public void deletePlayer(String lastname) { Node node = head; while(true){ if(node == null){ System.out.println("i could not found it"); break; } else if(node.getPlayer().getName().getLast().equals(lastname)){ // when found if(node == head && node =...
7
protected Validator createValidator() throws JspException { FacesContext context = FacesContext.getCurrentInstance(); Validator validator = null; ValueExpression vb = null; // If "binding" is set, use it to create a validator instance. if (binding != nul...
9
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Coordinates that = (Coordinates) o; if (x != that.x) return false; if (y != that.y) return false; return true; }
5
public void playFadeLoop() throws InterruptedException{ try { in = new FileInputStream(fade); as = new AudioStream(in); ap.player.start(as); } catch(Exception e) { System.out.println("Got an IOException: " + e.getMessage()); e.printStackTrace(); ...
1
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Symbol)) return false; Symbol symbol = (Symbol) o; if (bitMaskValue != symbol.bitMaskValue) return false; if (id != symbol.id) return false; if (name != null ? !name.equals(sy...
6
public String relevanceFeedback(TreeSet<SolrDocument> input) { // TODO make a complete list of accepted fields that should be used in // relevance feedback. ID, for example, is not wanted StringBuilder query = new StringBuilder(); for (SolrDocument doc : input) { // Collection<String> fields = do...
7
public void setAbsoluteTerminalPoint(mxPoint point, boolean isSource) { if (isSource) { if (absolutePoints == null) { absolutePoints = new ArrayList<mxPoint>(); } if (absolutePoints.size() == 0) { absolutePoints.add(point); } else { absolutePoints.set(0, point); } } else...
5
private void init(boolean flag) { int i; int a, b, c, d, e, f, g, h; a = b = c = d = e = f = g = h = GOLDEN_RATIO; for (i = 0; i < 4; ++i) { a ^= b << 11; d += a; b += c; b ^= c >>> 2; e += b; c += d; c ^= d << 8; f += c; d += e; d ^= e >>> 16; g += d; e ...
5
public static DataContainer readTableDescriptions() throws IOException { DataContainer allData = new DataContainer(); File fileDir = new File(backupFilePath); BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileDir), "UTF8")); Map<String, Row> rowsForC...
4
private void help(CommandSender s) { s.sendMessage(ChatColor.RED + "Ender's Game Commands You Can Use"); if (s.hasPermission("EndersGame.join")) s.sendMessage(ChatColor.GOLD + "/eg join [arenaID]"); if (s.hasPermission("EndersGame.join")) s.sendMessage(ChatColor.GOLD + "/eg leave"); if (s.hasPermission("EndersG...
9
public void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed String itemText = (String)jComboBox1.getSelectedItem( ); if (itemText.equalsIgnoreCase("Farenheit")) { String tester = itemText; TPT test = new TPT(); ...
3
public Tile getTile(int x, int y) { if (x < 0 || x >= width || y < 0 || y >= height) return Tile.VOID; return tileset.getTile(tiles[x + y * width]); }
4
@Override public void windowDeiconified(WindowEvent e) { }
0
public void adicionaDisciplina(String nome, String codigo) throws DisciplinaJaExisteException { boolean teste = false; for (Disciplina e : disciplina) { if (e.getCodigo().equals(codigo)) { teste = true; break; } } if (teste == false) { Disciplina disc = new Disciplina(nome, codigo); disci...
3
@Test public void insertSingleElementToAnEmptyListMinMax() { l.insert(v); assertEquals(v, l.min()); assertEquals(v, l.max()); }
0
public void keyPressed(int x, int y){ keys.clear(); for(int i = 0; i < width; i++){ for(int j = 0; j < height; j++){ Tile tile = tiles[i][j]; if(tile.getType() == 5 || tile.getType() == 6) { tiles[i][j] = new Tile(0, false, tile.x,tile.y); } } } }
4
@EventHandler public void onBlockBreak(BlockBreakEvent evt) { Player p = evt.getPlayer(); Block b = evt.getBlock(); ConfigurationSection cProfs = plugin.getConfig().getConfigurationSection("profs"); Set<String> profs = cProfs.getKeys(false); Iterator<String> i = profs.iterator(); while ( i.hasN...
6
@Override public void handleMouse(int posX, int posY, int flag) { if (!enabled) return; if ((flag & 1) != 0) texY = 57; else if ((flag & 2) != 0) clickEvent.trigger(); else texY = 109; }
3
private void saveFactsAndAllRules(Collection<Rule> rules) throws IOException { if (null == rules || rules.size() == 0) return; for (Rule rule : rules) { StringBuilder sb = new StringBuilder(); if (!rule.getLabel().startsWith(DEFAULT_RULE_LABEL_PREFIX)) sb.append(rule.getLabel()); if (!"".equals(rule.getMod...
6
public Request resolve(Request request) throws UnknownHostException{ request.getClass().cast(request); switch(request.operation){ case ADD: request.setReply(true); break; case REMOVE: request.setReply(true); break; case CHECK: request.setReply(true); break; case CHANGENAME: r...
9
@Override public boolean equals( Object other ) { if ( other == this ) { return true; } if ( !( other instanceof TByteList ) ) return false; if ( other instanceof TByteArrayList ) { TByteArrayList that = ( TByteArrayList )other; if ( that.size() !...
9
static void test13() { grid_size = 3; int num_generations = 1000; int num_atoms = 13; int population_size = 10; double max_potential; double min_potential; double[][][] population = new double[population_size][][]; double[] fitness = new double[population_...
9
public String end_graph() { return "}"; }
0
public static ArrayList<CardAccount> getAll(){ SQLiteJDBC db = new SQLiteJDBC(); ArrayList<CardAccount> card_accounts = new ArrayList<CardAccount>(); String sql = "SELECT account_num FROM card_accounts"; ResultSet resultSet = db.query(sql); try { ...
2
public Tile getTile(int x, int y) { if (x < 0 || x >= width || y < 0 || y >= height) return Tile.OBSIDIAN; return Tile.tiles[tiles[x + y * width]]; }
4
private void UpdateCharacterPosition(int rowPosition, int columnPosition, String characterName ) { int randmomMovement = new Random().nextInt( movements.length ); if( characterName == "Victim" ) { Boolean shouldVictimMove = ShouldVictimMove( rowPosition , columnPosition ); if( shouldVictimMove ==...
7
public IntBTNode getRight( ) { return right; }
0
public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final MethodCall that = (MethodCall)o; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (params != null ? !params.equal...
9
public void mouseEntered(MouseEvent e) { String str = "The mouse has entered the Frame !"; System.out.println(str); }
0
private int getVersionNumberFromFileServer(String filename, FileServerInfo info) { int version = -1; try { Socket socket = new Socket(info.getAddress(), info.getPort()); ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); oos.flush(); ObjectInputStream ois = new ObjectInputStre...
6
public static void main(String args[]){ GenericsTypeOld type = new GenericsTypeOld(); type.set("Pankaj"); // type.set(1); ClassCastException String str = (String) type.get(); //type casting, error prone and can cause ClassCastException System.out.println(str); }
0
private void generateJMenuBar() { JMenuBar jMenuBar = new JMenuBar(); JMenu file = new JMenu("File"); JMenu calculate = new JMenu("Calculate"); JMenu speed = new JMenu("Speed"); JMenuItem resetGrid = new JMenuItem("Reset Grid"); resetGrid.addActionListener(new ActionLis...
5
public String[] getSets1(){ String[] sets=null; try{ sets = textField_1.getText().split(","); if(textField_1.getText().length()<1) return null; int x = Integer.valueOf(nbrVarComboBox.getSelectedItem().toString()); x = (int) Math.pow(2, x); for(String s : sets){ int set = Integer.valueOf(s); if (!(se...
4
public static boolean getMouseUp(int mouseButton) { return !getMouse(mouseButton) && lastMouse[mouseButton]; }
1
public void run() { try { Socket socket = _ss.accept(); socket.setSoTimeout(60000); BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.ge...
3
private boolean checkUser(String user, String pass){ /** * - FOR TAM - * Database Requirements * * * CHECK IF USERNAME AND PASSWORD ENTERED ARE CORRECT. * ALSO, NEED TO GENERATE A RANDOM SESSION ID TO COUNTER MULTIPLE LOGINS. * * Example is kinda shown below. * * If the login ...
3
public Sprite getSprite(String ref) { //Check for already existing sprite if (sprites.get(ref) != null) { return (Sprite) sprites.get(ref); } //Get new sprite BufferedImage sourceImage = null; try { URL url = this.getClass().getClassLoader().getResource(ref); if (url == null){ fail("Can't...
3
public final void gameOver() { // XXX hmm. we should check out these conditions if ( inGameState("GameOver") || (!inGameState("InGame") && !inGameState("LifeLost")) ) return; // System.err.println( "Warning: gameOver() called from other state" // +" than InGame or LifeLost." ); //} clearKey(key_continue...
5
public static int floodfill( char s , int i , int j ){ Queue<Integer> x = new LinkedList<Integer>(); Queue<Integer> y = new LinkedList<Integer>(); x.add(i); y.add(j); int c = 1; v[i][j] = true; while(!x.isEmpty()){ int xa = x.poll(); int ya = y.poll(); m[xa][ya] = '&'; for (int k = 0; k < d...
8
public List<Feature> getFeatures() { return features; }
0
public static Forme L() { ArrayList<Vecteur> liste = new ArrayList<>(); liste.add(new Vecteur(1, 0)); liste.add(new Vecteur(1, 1)); liste.add(new Vecteur(1, 2)); liste.add(new Vecteur(0, 2)); Vecteur<Integer> _centre = new Vecteur(1, 2); return new Forme("L", lis...
0
public static String postData(Reader data, URL endpoint, Writer output) throws Exception { System.out.println("dfsln"); HttpURLConnection urlc = null; try { urlc = (HttpURLConnection) endpoint.openConnection(); try { urlc.setRequest...
7
public void AddToMenu() { if (Glob.instance != null) Glob.instance.paginae.add(res); }
1
public void drawIndexedSprite(int x, int y) { x += offsetX; y += offsetY; int destOff = x + y * Graphics2D.width; int srcOff = 0; int height = this.height; int width = this.width; int destStep = Graphics2D.width - width; int srcStep = 0; if (y < Graphics2D.topY) { int topMargin = Graphics2D.topY - ...
6
@Test public void getCostsTest() { TopAthlete test = null; TopAthlete test1 = null; try { test = new TopAthlete("Franz", 3); test1 = new TopAthlete("Karl", 5); } catch (Exception e) { fail("Unexpected Exception"); } try { TopAthlete test3 = new TopAthlete("Sepp", 12); } catch (ValueException...
5
void concatFiles(File file, File other) { // concatenates other to the bottom of file try { BufferedReader oreader = new BufferedReader(new FileReader(other)); BufferedWriter fwriter = new BufferedWriter(new FileWriter(file,true)); String line; while((line = oreader.readLine()) != null) { fwriter.wr...
2
private static final int method2922 (int i, int i_148_, byte[] is, int[] is_149_, int i_150_, int i_151_, int i_152_, int i_153_, int i_154_, int i_155_, int i_156_, Class348_Sub16_Sub5 class348_sub16_sub5, int i_157_, int i_158_) { if (i_157_ == 0 || ((i_154_ = i_151_ + (i_156_ - i_150_ + i_157_ - 257) / i_...
6
@Override public void run() { System.err.println("Die Acquise wurde gestartet!"); do { Cashpoint cashpoint = getNextCashpoint(); WaitingQueue waitingQueue = cashpoint.getWaitingQueue(); synchronized (waitingQueue) { Kunde kunde = new Kunde(); waitingQueue.add(kunde); cashpoint.writeToBalance(n...
3
public static void main(String[] args) { // Using Sieve of Eratosthenes to mark all primes below 2,000,000 boolean[] nums = new boolean[2000000]; long sum = 0; for (int i = 2; i < nums.length; i++) nums[i] = true; int nextPrime = 2; while (nextPrime < nums.length) { int i = nextPrime; sum += nextPr...
5
public LinkedList<Segment> getEdges() { LinkedList<Segment> edges = new LinkedList<Segment>(); for(Entry<Point, HashSet<Point>> e: graph.entrySet()) { for(Point P : e.getValue()) { edges.add(new Segment(e.getKey(), P)); } } return edges; }
2
private void list_framesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_list_framesMousePressed current_sprite=null; hitbox_index_selected=-1; frame_index_selected=Integer.parseInt(""+list_frames.getSelectedIndex()); //NodeList listOfMoves = hitboxes_doc.getElementsByTagName("Move"); ...
5
public String apply(Ast ast){ decl += ast.getClass().getSimpleName() + "_" + i + " [label=\"" + ast.getClass().getSimpleName() + "\"]\n"; int n = i++; Ast[] objs = ast.getVariables(); //System.out.println(objs[0] + " " + objs[1]); if (objs !=null) { for ( int j = 0; j<objs.length; j++){ if (objs[j] != ...
3
@Override public void executeMsg(Environmental myHost, CMMsg msg) { super.executeMsg(myHost, msg); if((msg.source()==invoker()) &&(msg.target() instanceof MOB) &&(msg.targetMinor()==CMMsg.TYP_DAMAGE) &&(msg.tool()==msg.source().fetchWieldedItem()) &&(!(""+msg.target()).equals(lastMOB))) { if((msg.tra...
7