text
stringlengths
14
410k
label
int32
0
9
public CheckResultMessage check20(int day) { return checkReport.check20(day); }
0
private boolean isPerfectMatching() { // check that xy[] is a perfect matching boolean[] perm = new boolean[N]; for (int i = 0; i < N; i++) { if (perm[xy[i]]) { StdOut.println("Not a perfect matching"); return false; } perm[xy[i]] = true; } // check that xy[] and yx[] are inverses for (int j = 0; j < N; j++) { if (xy[yx[j]] != j) { StdOut.println("xy[] and yx[] are not inverses"); return false; } } for (int i = 0; i < N; i++) { if (yx[xy[i]] != i) { StdOut.println("xy[] and yx[] are not inverses"); return false; } } return true; }
6
public ArrayList<ArrayList<Integer>> levelOrderBottom(treeNode root) { ArrayList<ArrayList<treeNode>> listLevelNodes = new ArrayList<ArrayList<treeNode>>(); ArrayList<ArrayList<Integer>> listLevelValuesBottomUp = new ArrayList<ArrayList<Integer>>(); if (root == null) return listLevelValuesBottomUp; ArrayList<treeNode> newList = new ArrayList<treeNode>(); newList.add(root); listLevelNodes.add(newList); int curLevel = 0; treeNode curNode = null; while (true) { // for each level newList = new ArrayList<treeNode>(); for (int i = 0; i < listLevelNodes.get(curLevel).size(); i++) { curNode = listLevelNodes.get(curLevel).get(i); if (curNode.leftLeaf != null) newList.add(curNode.leftLeaf); if (curNode.rightLeaf != null) newList.add(curNode.rightLeaf); } if (newList.isEmpty()) { break; // end of tree traversal } else { listLevelNodes.add(newList); curLevel++; } } // set the values from bottom up in the new array array; for (int nodeLevel = listLevelNodes.size() - 1; nodeLevel >= 0; nodeLevel--) { ArrayList<Integer> valueList = new ArrayList<Integer>(); for (int j = 0; j < listLevelNodes.get(nodeLevel).size(); j++) { // j // is // nodes // in // the // same // level curNode = listLevelNodes.get(nodeLevel).get(j); valueList.add(new Integer(curNode.value)); } listLevelValuesBottomUp.add(valueList); } return listLevelValuesBottomUp; }
8
@Override public void run() { Runtime.getRuntime().addShutdownHook(new onShutdown(this)); try { bridge = new Bridge(true, false); server = new CommandServer(InetAddress.getLocalHost().getHostAddress(), 53789, this); } catch (UnknownHostException e) { System.err.print("UnknownHostException when creating listening server: " + e.getMessage()); System.exit(-1); } catch (Exception e) { System.err.print("Unknown Exception creating listening server: " + e.getMessage()); System.exit(-1); } server.start(); while (!this.masterStop) { this.bridge.execute(poll()); } this.server.halt(); this.bridge.shutdown(); }
3
public void mouseDragged(MouseEvent e) { if(clickable) { if(e.getX()>x && e.getX()<x+width) { if(e.getY()>y && e.getY()<y+height) { t1 = System.nanoTime(); clicked=true; } } } }
5
public void produceUsers(){ users.removeAll(users); try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { System.out.println("Where is your MySQL JDBC Driver?"); e.printStackTrace(); } PreparedStatement ps = null; Connection con = null; ResultSet rs; try { con = DriverManager.getConnection("jdbc:mysql://mysql2.cs.stonybrook.edu:3306/mlavina", "mlavina", "108262940"); if (con != null) { con.setAutoCommit(false); try { String sql = "SELECT * FROM customer C, Person P Where C.id = P.Id;"; ps = con.prepareStatement(sql); ps.execute(); rs = ps.getResultSet(); while (rs.next()) { users.add(new TableUser(rs.getInt("id"),rs.getInt("accountNo"), rs.getString("creditcardno"),rs.getString("email"), rs.getDate("creationDate"), rs.getString("FirstName"), rs.getString("LastName"), rs.getString("Address"), rs.getString("City"),rs.getString("State"), rs.getInt("ZipCode"))); } con.commit(); } catch (Exception e) { System.out.println("SQL Rollback"); System.out.println(e); con.rollback(); } } } catch (Exception e) { System.out.println(e); } finally { try { con.setAutoCommit(true); con.close(); ps.close(); } catch (Exception e) { e.printStackTrace(); } } }
6
@Override public Query parse() { if(!this.prepared) { this.prepared = true; String P_KEY = null; StringBuilder sB = new StringBuilder(); sB.append("CREATE TABLE "); sB.append(this.t.replace("#__", this.db.getPrefix())); sB.append("\n"); sB.append(" (\n"); int i = 0; for(Column f : this.fL) { if(i > 0) { sB.append(", \n"); }else{ ++i; } if(!f.isParsed()) { f.parse(); } sB.append(f.getParsedColumn()); if(f.hasPrimaryKey()) { if(null == P_KEY) { P_KEY = f.getName(); }else{ P_KEY = P_KEY + ", " + f.getName(); } } } if(null != P_KEY) { sB.append(", \nPRIMARY KEY("); sB.append(P_KEY); sB.append(")"); } for(ForeignKey fk : this.fkL) { if(!fk.isParsed()) { fk.parse(); } sB.append(", \nCONSTRAINT "); sB.append(fk.getName()); sB.append(fk.getParsedFK()); } sB.append("\n);"); this.query = sB.toString(); } return this; }
9
private void initialize() { setUserPreferences(new UserPreferences()); try { UIManager.setLookAndFeel(getUserPreferences().getLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } setController(new Controller(this, getUserPreferences())); setFrame(new JFrame()); setMainPanel(new MainPanel(getUserPreferences())); if (getUserPreferences().getHeight() != 0 && getUserPreferences().getWidth() != 0) { getFrame().setSize(getUserPreferences().getHeight(), getUserPreferences().getWidth()); } else { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); getFrame().setSize((int) ((0.75) * d.width), (int) ((0.75) * d.height)); } if (getUserPreferences().isMaximazed()) getFrame().setExtendedState(JFrame.MAXIMIZED_BOTH); getFrame().setLocationRelativeTo(null); getFrame().setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); getFrame().addWindowListener(new WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { getUserPreferences().setMaximazed( getFrame().getExtendedState() == Frame.MAXIMIZED_BOTH); try { getUserPreferences().savePreferences(); } catch (Exception e1) { e1.printStackTrace(); } getController().exit(); } }); ; getFrame().setTitle("KS Boolean Expression"); getFrame().setIconImage(programIcon); getFrame().getContentPane().setLayout(new BorderLayout(0, 0)); createActions(); createMenuActions(getUserPreferences(), getController()); createPopupMenu(); panel = new JPanel(); getFrame().getContentPane().add(panel, BorderLayout.CENTER); panel.setLayout(new BorderLayout(0, 0)); setTabbedPane(new JTabbedPane(JTabbedPane.TOP)); addTab(true); mainPanel.getTextField().setFont( new java.awt.Font("Calibri", java.awt.Font.ITALIC, 12)); mainPanel.getTextField().setText( Tools.getLocalizedString("EXAMPLE") + " (ABCD+ABC*!D)|(B*!C*D+A/E)"); mainPanel.getTextField().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { mainPanel.getTextField().setText(""); mainPanel.getTextField().setFont( new java.awt.Font("Calibri", java.awt.Font.PLAIN, 12)); mainPanel.getTextField().removeMouseListener(this); } }); mainPanel.getTextField().setComponentPopupMenu(popupMenu); mainPanel.getTextField().addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent arg0) { } public void mouseEntered(MouseEvent event) { } public void mouseExited(MouseEvent event) { } public void mousePressed(MouseEvent event) { } public void mouseReleased(MouseEvent event) { if (event.isPopupTrigger()) popupMenu.show(event.getComponent(), event.getX(), event.getY()); } }); panel.add(getTabbedPane(), BorderLayout.CENTER); panel.add(createToolBar(), BorderLayout.NORTH); JMenuBar menuBar = createMenuBar(getUserPreferences(), getController()); getFrame().getContentPane().add(menuBar, BorderLayout.NORTH); JMenuBar homeMenuBar = createMenuBar(getUserPreferences(), getController()); getFrame().add(homeMenuBar, BorderLayout.NORTH); getFrame().setVisible(true); }
6
private boolean waitForPin(GpioPinDigitalInput pin, boolean waitforHigh, long timeout) { Timer timer = new Timer(timeout, true); while (waitforHigh ? !pin.isHigh() : !pin.isLow()) { Tools.waitForMs(10); if (timer.hasExpired()) { return false; } } return true; }
3
private void run() { isRunning = true; int frames = 0; int frameCounter = 0; final double frameTime = 1.0 / FRAME_CAP; long lastTime = Time.getTime(); double unprocessedTime = 0; while (isRunning) { boolean render = false; long startTime = Time.getTime(); long passedTime = startTime - lastTime; lastTime = startTime; unprocessedTime += passedTime / (double) Time.SECOND; frameCounter += passedTime; while (unprocessedTime > frameTime) { render = true; unprocessedTime -= frameTime; if (Window.isCloseRequested()) stop(); Time.setDelta(frameTime); game.input(); Input.update(); game.update(); if (frameCounter >= Time.SECOND) { System.out.println("FPS: " + frames); frames = 0; frameCounter = 0; } } if (render) { render(); frames++; } else { try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } } } cleanup(); }
6
public static ActionArray createActionArray(int setType) { switch (setType) { case ActionArrayFactory.BLANKARRAY: return new BlankActionArray(); case ActionArrayFactory.DEFAULTARRAY: return new DefaultActionArray(); case ActionArrayFactory.DEFAULTALTARRAY: return new DefaultAltActionArray(); case ActionArrayFactory.DEFAULTCTRLARRAY: return new DefaultCtrlActionArray(); } return null; }
4
private JPanel thumbnails(final String path) { final JPanel thumb = new JPanel(); thumb.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { for(int i=0;i<6;i++){ if(pnlImagensCarregadas.getComponent(i) instanceof JPanel){ ((JPanel)pnlImagensCarregadas.getComponent(i)).setBorder(BorderFactory.createEmptyBorder()); } } imagemSelecionada=new File(path); thumb.setBorder(BorderFactory.createLineBorder(Color.RED, 2)); } @Override public void mousePressed(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseReleased(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseEntered(MouseEvent e) { setCursor(new Cursor(Cursor.HAND_CURSOR)); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseExited(MouseEvent e) { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); thumb.setLayout(new BorderLayout()); PnlImagem image = new PnlImagem(path, 1000, 1000); thumb.add(image, BorderLayout.CENTER); lbRemover = new JLabel(bundle.getString("remover")); lbRemover.addMouseListener(new MouseListener() { Font original; String nomeFicheiro; @Override public void mouseClicked(MouseEvent me) { for (int i = 0; i < paths.size(); i++) { if (paths.get(i).equals(path)) { paths.remove(i); nomeFicheiro = paths.get(i).getName(); } } File imagemExistente = new File(path); if (path.startsWith("imagens")) { if (imagemExistente.exists()) { imagemExistente.delete(); } } pnlImagensCarregadas.remove(thumb); indiceImagem--; pnlImagensCarregadas.add(new JLabel(" ")); imagemSelecionada=null; revalidate(); repaint(); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mousePressed(MouseEvent me) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseReleased(MouseEvent me) { me.getComponent().setFont(original); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); me.getComponent().setForeground(Color.BLACK); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseEntered(MouseEvent me) { original = me.getComponent().getFont(); Map attributes = original.getAttributes(); attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); me.getComponent().setFont(original.deriveFont(attributes)); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); me.getComponent().setForeground(Color.RED); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void mouseExited(MouseEvent me) { me.getComponent().setFont(original); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); me.getComponent().setForeground(Color.BLACK); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); lbRemover.setHorizontalAlignment(JLabel.CENTER); JPanel pnlFundo = new JPanel(); pnlFundo.add(lbRemover); thumb.add(pnlFundo, BorderLayout.PAGE_END); return thumb; }
6
public void doAdd() { String item = JOptionPane.showInputDialog(this, "Please enter item to add to queue.", ""); boolean itemAdded = false; if(item == null || item.equals("")) { textArea.setText("Unable to add item to queue: Item must not be an empty String."); return; } if(!(queueList.isFull())) { itemAdded = queueList.add(item); if(itemAdded) { textArea.setText("The following item was successfully added to the " + "queue: " + item + "\n\n" + "Current queue contents:\n" + queueList); updateSetSizeField(); updateSetSpaceField(); } else { textArea.setText("Unable to add the following item to queue: " + item + "\n\n" + "Current queue contents:\n" + queueList); } } else //if(queueList.isFull()) { textArea.setText("Unable to add item to queue: Queue is full."); } return; }//end doAdd()
4
DodsV findDodsV(String name, boolean useDone) { for (DodsV dodsV : children) { if (useDone && dodsV.isDone) continue; // LOOK useDone ?? if ((name == null) || (dodsV == null) || (dodsV.bt == null)) { logger.warn("Corrupted structure"); continue; } if (name.equals(dodsV.bt.getName())) return dodsV; } return null; }
7
public boolean onLaudalla(Ruutu sijainti){ if (sijainti==null) { return false; } return sijainti.getX()>0&&sijainti.getX()<= koko && sijainti.getY() > 0 && sijainti.getY() <= koko; }
4
public final void setDecimals(final int DECIMALS) { final int dec = DECIMALS > 5 ? 5 : (DECIMALS < 0 ? 0 : DECIMALS); if (null == decimals) { _decimals = dec; } else { decimals.set(dec); } }
3
void updateScrollBar() { DNAScrollerModel dnamodel = getModel(); if (dnamodel == null) return; if (dnamodel.getDNA() == null) { scrollBar.setValue(0); return; } if (!scrollBar.isVisible()) { scrollBar.setVisible(true); } int index = dnamodel.getCurrIndex(); int startindex = dnamodel.getStartWindowIndex(); int w = minWidth; int ncodonsinscroller = w / getCodonWidth(); if (index < startindex) { int oldValue = scrollBar.getValue(); if (index > 0) { dnamodel.setStartIndexToCurrent(); } else { dnamodel.setStartWindowIndex(0); dnamodel.setCurrIndex(0); } setOpOffset(); startindex = dnamodel.getStartWindowIndex(); if (oldValue * 3 == startindex) { scroller.repaint(); scrollBar.repaint(); } else { scrollBar.setValue(startindex / 3); } } else if (index >= startindex + ncodonsinscroller * 3) { dnamodel.setStartWindowIndex(index - ncodonsinscroller * 3 + 3); setOpOffset(); scrollBar.setValue(dnamodel.getStartWindowIndex() / 3); } else { setOpOffset(); scroller.repaint(); scrollBar.repaint(); } }
7
private void writeSerializable(YamlFile yamlFile, String key, Class<?> value) { ConfigurationSerializable serializable = getSerializable(value); Map<String, Object> serialized = serializable.serialize(); Map<String, String> serializedTypes = new HashMap<>(); for(String s : serialized.keySet()) { serializedTypes.put(s, serialized.get(s).getClass().getName()); } yamlFile.set(key, serializedTypes); }
2
public String getAccessProperty(String type) { String path = this.getPath(); // /domain/ path = path.substring(8); String dpath = null; int pos = path.indexOf("/"); if (pos!=-1) { dpath = "/domain/"+path.substring(0,pos); path = path.substring(pos); } else { dpath = "/domain/"; } if (path.endsWith("/")) path = path.substring(0,path.length()-1); // remove last '/' if attached boolean finished = false; FsNode node = null; while (!finished) { if (Fs.isMainNode(dpath+path)) { node = Fs.getNode(dpath+path+"/.access"); } else { node = Fs.getNode(dpath+path); } if (node!=null) { String result = node.getProperty("access_"+type); if (result!=null) { return result; } } pos = path.lastIndexOf("/"); if (pos!=-1) { path = path.substring(0,pos); } else { finished = true; } } return null; }
7
@EventHandler public void CaveSpiderFireResistance(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.getCaveSpiderConfig().getDouble("CaveSpider.FireResistance.DodgeChance") / 100; final double ChanceOfHappening = random.nextDouble(); if (ChanceOfHappening >= randomChance) { dodged = true; }dodged = true; if (plugin.getCaveSpiderConfig().getBoolean("CaveSpider.FireResistance.Enabled", true) && damager instanceof CaveSpider && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) { Player player = (Player) e; player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, plugin.getCaveSpiderConfig().getInt("CaveSpider.FireResistance.Time"), plugin.getCaveSpiderConfig().getInt("CaveSpider.FireResistance.Power"))); } }
6
private void runUpdater() { if (this.url != null && (this.read() && this.versionCheck())) { // Obtain the results of the project's file feed if ((this.versionLink != null) && (this.type != UpdateType.NO_DOWNLOAD)) { String name = this.file.getName(); // If it's a zip file, it shouldn't be downloaded as the plugin's name if (this.versionLink.endsWith(".zip")) { name = this.versionLink.substring(this.versionLink.lastIndexOf("/") + 1); } this.saveFile(name); try { this.copyFileUsingStream(this.updateFolder.listFiles()[0], new File(this.plugin.getDataFolder().getParent(), this.file.getName())); delete(updateFolder); } catch (IOException e) { e.printStackTrace(); } } else { this.result = UpdateResult.UPDATE_AVAILABLE; } } if (this.callback != null) { new BukkitRunnable() { @Override public void run() { runCallback(); } }.runTask(this.plugin); } }
8
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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(JRestauranteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(JRestauranteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(JRestauranteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(JRestauranteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new JRestauranteFrame().setVisible(true); } }); }
6
public Point[] getAll(Texture tx) { //how much to increment the array by each time. final int increment = 20; //make array size 0 Point[] result = new Point[0]; Point[] temp; int row = 0; int col = 0; byte lightCount = 0; //while iteration is incomplete while (col < cols && row < rows) { //if out of space, resize the array if (lightCount == result.length) { temp = new Point[result.length + increment]; for (int i = 0; i < temp.length; i++) { if (i < result.length) { temp[i] = result[i]; } } result = temp; } //Advance through the array row++; if (row >= rows) { row = 0; col++; } //add to array if matching if (getCell(col, row) == tx) { result[lightCount] = new Point(col * CELL_SIZE, row * CELL_SIZE); lightCount++; } } //crop array to minimum size temp = result; result = new Point[lightCount]; for (int i = 0; i < lightCount; i++) { result[i] = temp[i]; } //return result return result; }
8
@Override public int hashCode() { int result = asOf != null ? asOf.hashCode() : 0; result = 31 * result + (trendAt != null ? trendAt.hashCode() : 0); result = 31 * result + (trends != null ? Arrays.hashCode(trends) : 0); return result; }
3
public double value(StateObservationMulti a_gameState) { boolean gameOver = a_gameState.isGameOver(); Types.WINNER win = a_gameState.getMultiGameWinner()[id]; double rawScore = a_gameState.getGameScore(id); if(gameOver && win == Types.WINNER.PLAYER_LOSES) rawScore += HUGE_NEGATIVE; if(gameOver && win == Types.WINNER.PLAYER_WINS) rawScore += HUGE_POSITIVE; return rawScore; }
4
public Scanning(int height, GC gc) { y = height; intersectionPoints = new ArrayList<Point2D>(); int i, j; Edge edge; for (i = 0; i < Main.shapes.size(); i++) { for (j = 0; j < Main.shapes.get(i).edges.size(); j++) { edge = Main.shapes.get(i).edges.get(j); if (edge.isIntersectLine(y) && edge.isVisible()) { if (!Double.isNaN(edge.getIntersectionX(y))) { intersectionPoints.add(new Point2D(edge.getIntersectionX(y), y, j)); } } } } if (intersectionPoints.size() != 0) sortIntersections(); if (previousIntersectionPoints == null) { previousIntersectionPoints = intersectionPoints; } else if (isSameIntersections()) { fastDraw = true; } else { fastDraw = false; previousIntersectionPoints = intersectionPoints; } drawLines(gc); }
8
private void setDeathShape( int type, Shape [] array ) { Random rng = new Random(); int startX = 80; int inc = 96; if ( thePlayer.hasGun() && type == 1 && rng.nextInt() % 2 == 1 ) { // HANDLE IT! rockSound.playAsSoundEffect(1, 1, false); array[0] = new Death( startX , -16, 16, 16, 1, rock[0] ); array[1] = new Death( startX + inc, -16, 16, 16, 1, rock[0] ); array[2] = new Death( startX + inc * 2, -16, 16, 16, 1, rock[0] ); array[3] = new Death( startX + inc * 3, -16, 16, 16, 1, rock[0] ); array[4] = new Death( startX + inc * 4, -16, 16, 16, 1, rock[0] ); } else if ( thePlayer.hasInk() && type == 0 && rng.nextInt() % 2 == 1 ) { // DO YOU LIKE TO PLAY WITH FIRE!!! fireSound.playAsSoundEffect(1, 1, false); array[0] = new Death( startX , HEIGHT + 16, 16, 16, 1, fireball ); array[1] = new Death( startX + inc, HEIGHT + 16, 16, 16, 1, fireball ); array[2] = new Death( startX + inc * 2, HEIGHT + 16, 16, 16, 1, fireball ); array[3] = new Death( startX + inc * 3, HEIGHT + 16, 16, 16, 1, fireball ); array[4] = new Death( startX + inc * 4, HEIGHT + 16, 16, 16, 1, fireball ); } else { for ( int i = 0; i < 5; i++ ) { Integer rand = rng.nextInt(); Integer xPos = Math.abs( rand % ( WIDTH - 80 ) ); // If we want a new random rock if ( type == 1) array[i] = new Death( xPos + 32, (-16) - i * (HEIGHT / 5), 16, 16, 1, rock[ Math.abs(rng.nextInt() %3)] ); else array[i] = new Death( xPos + 32, HEIGHT + 16 + i * (HEIGHT / 5), 16, 16, 0, fireball); } } }
8
private void nextLine() { // TODO Auto-generated method stub for(int i = 0; i < threads.length; i++){ threads[i].getLinha().getOsc().getEnvelope().addSegment((float) 0.0, 1.f); } for(int i = 0; i < 5; i++){ alpha[i] = (int) random(0, 11); System.out.println(alpha[i]); threads[(int) alpha[i]].getLinha().setAlpha(1); } }
2
public String getKey() { return key; }
0
public void busquedaRecursiva(Nodo<T> lista, T x){ if(lista != null){ if(lista.getInfo() == x){ System.out.println("El elemento se encuentra en la lista"); }else{ this.busquedaRecursiva(lista.getLiga(),x); } }else{ System.out.println("EL elemento no se encuentra en la lista"); } }
2
public Lru(int[] refList, int size, int frames) { int[] pages = new int[refList.length]; // Will hold the page reference list after converted to page numbers. int faults = 0; int[] frame = new int[frames]; int[] lastUsed = new int[frames]; // Will keep track of the last use for each page int hit = -1; int oldest; // Pointer to the oldest frame. // Change the refList array to an array of pages using division. for (int i = 0; i < refList.length; ++i){ pages[i] = refList[i] / size; } // Initialize all frames to -1. for (int i = 0; i < frame.length; ++i) { frame[i] = -1; lastUsed[i] = 0; } // Loop through the pages list and check for hits and misses. for (int i = 0; i < pages.length; ++i) { for (int j = 0; j < frame.length; ++j) { if (pages[i] == frame[j]) { hit = j; // Keep track of where exactly the hit took place } } // If not a hit, find the oldest used value and replace it with this one if (hit < 0) { oldest = 0; for (int k = 0; k < lastUsed.length; ++k) { if (lastUsed[k] > lastUsed[oldest]) { oldest = k; } ++lastUsed[k]; // Increment all the lastUsed values while you're looping anyway. } // Put the current page value into the oldest frame. frame[oldest] = pages[i]; lastUsed[oldest] = 0; // Reset the age on that frame. ++faults; // Keep track of faults. } // If there was a hit, increment all the lastUsed values and set the hit one to 0 else { for (int k = 0; k < lastUsed.length; ++k) { ++lastUsed[k]; } lastUsed[hit] = 0; } hit = -1; } // Print out the results. System.out.print(size + "\t" + frames + "\tLRU\t"); System.out.printf("%.2f",(double)(faults*100)/pages.length); System.out.print("%\n"); }
9
public ExponentialDistribution(int NumberOfTimesPacketsAreDeliverd, long SEED) { super(NumberOfTimesPacketsAreDeliverd, SEED); //initialize the distribution array EDarray = new ArrayList(); //initialize the queue for output q=new LinkedList(); }
0
private static boolean checkCommandLine(CommandLine cli) { boolean error = false; Mode mode = getMode(cli); if (mode == null) { System.err.println("Es wurde kein Modus angegeben"); error = true; } if ((mode == Mode.ZIPANDWRAP) || (mode == Mode.ZIP)) { if (!cli.hasOption('d')) { System.out.println("Es ist kein Zielverzeichnis angegeben"); error = true; } if (!cli.hasOption('s')) { System.out.println("Es ist kein Quellverzeichnis angegeben"); error = true; } } if (mode == Mode.UNWRAP) { if (!cli.hasOption('f')) { System.out.println("Es ist kein Dateiname angegeben"); error = true; } } return error; }
7
private void printlResult() { /*for(Entry<String, Category> entry : cateMap.entrySet()) { System.out.println(entry.getValue().toString()); } System.out.println();*/ List<Entry<String, Set<String>>> dinstinctKeywords = new ArrayList<Entry<String, Set<String>>>(); List<Entry<String, Set<String>>> duplicatedKeywords = new ArrayList<Entry<String, Set<String>>>(); for(Entry<String, Set<String>> entry : keywordCatesMap.entrySet()) { if(entry.getValue().size() > 1) { duplicatedKeywords.add(entry); } else { dinstinctKeywords.add(entry); } } System.out.println("========== dinstinct keywords:"); for(Entry<String, Set<String>> entry : dinstinctKeywords) { System.out.println(kwEntryToString(entry)); } System.out.println("========== duplicated keywords:"); for(Entry<String, Set<String>> entry : duplicatedKeywords) { System.out.println(kwEntryToString(entry)); } /*for(Entry<String, Set<String>> entry : duplicatedKeywords) { String keyword = entry.getKey(); for(Category cate : cateMap.values()) { cate.keywords.remove(keyword); } }*/ System.out.println("==========="); for(Category cate : cateMap.values()) { System.out.println(cate.toString()); } System.out.println("==========="); for (Category cate : cateMap.values()) { for (Keyword keyword : cate.keywords.values()) { System.out.println(String.format("addKeywordRelation(\"%s\", \"%s\",%d);", keyword.key, cate.name, keyword.count)); } } }
7
@Override public void takeDamage(int damage) { if (Math.random() > getAvoidPercent()) { this.curHP -= damage - defense; } }
1
public boolean canGoto(int x, int y, Entity entity){ for(int i=0; i < world.entities.size(); i++){ for(Tile tiles : world.tiles){ if(CollisionLibrary.testAABBAABB(entity.aabb, tiles.aabb)){ return false; } else { return true; } } } return false; }
3
@Test public void testSetListenThreadClient() { LOGGER.log(Level.INFO, "----- STARTING TEST testSetListenThreadClient -----"); boolean flag1 = false; boolean flag2 = false; if (server2.getState() == Server.CLIENT) { flag1 = true; } if (flag1) { try { server2.setPort(23231); } catch (InvalidArgumentException e) { exception = true; } try { server2.setListenThread(); } catch (IOException | ServerSocketCloseException | TimeoutException e) { exception = true; } if (server2.getState() == Server.LISTEN) { flag2 = true; } } Assert.assertFalse(exception, "Exception found"); Assert.assertTrue(flag2, "Client server's state has not been set as listen Server. listen_thread may have not been created correctly. Server state is " + Integer.toString(server2.getState())); LOGGER.log(Level.INFO, "----- TEST testSetListenThreadClient COMPLETED -----"); }
5
public static final InkChromaticity get(Chromaticity chromaticity) { for (InkChromaticity one : values()) { if (one.getChromaticity() == chromaticity) { return one; } } return MONOCHROME; }
2
@Override public void handle() throws IOException { DataInputStream dis = new DataInputStream(player.getInputStream()); short size = dis.readShort(); List<Point> coords = new ArrayList<Point>(size); for (int i = 0; i < size; i++) { short x = dis.readShort(); short y = dis.readShort(); coords.add(new Point(x, y)); } dis.readByte(); Set<Player> players = gamePlay.getPlayers(); for (Player p : players) { if (!p.equals(player)) { DataOutputStream dos = new DataOutputStream(p.getOutputStream()); dos.writeByte(Protocol.DRAW_COORD_BULK); dos.writeShort(coords.size()); for (Point point : coords) { dos.writeShort(point.getX()); dos.writeShort(point.getY()); } dos.writeByte(Protocol.END); } } }
4
private void initonce() { if(initedonce) return; initedonce = true; try { Resource.addurl(new URL("https", getCodeBase().getHost(), 443, "/res/")); } catch(java.net.MalformedURLException e) { throw(new RuntimeException(e)); } if(!Config.nopreload) { try { InputStream pls; pls = Resource.class.getResourceAsStream("res-preload"); if(pls != null) Resource.loadlist(pls, -5); pls = Resource.class.getResourceAsStream("res-bgload"); if(pls != null) Resource.loadlist(pls, -10); } catch(IOException e) { throw(new Error(e)); } } }
6
public void ComputeSmallWindowStatisticByToeflDataSet() throws IOException{ int correctAnswers = 0; File testFile = new File("toefl.tst"); BufferedReader testReader = new BufferedReader(new FileReader(testFile)); String rdline; int LineNo = 0; String[] question = new String[6]; while ((rdline = testReader.readLine()) != null){ if (LineNo % 7 != 6) question[LineNo % 7] = rdline; if (LineNo % 7 == 5){ float autoPMI; String questionWord = morpha.stem(new Word(question[0])).value(); String synonym = morpha.stem(new Word(question[5])).value(); try { autoPMI = model2.getPMI(questionWord, questionWord); } catch (Exception e) { // TODO Auto-generated catch block autoPMI = 0; } FloatElement[] sortedPMIWords = model2.getSortedPMIWords(questionWord); float highestPMI = sortedPMIWords[0].value; int rank = -1; for (int i=0; i < sortedPMIWords.length; i++ ){ if (sortedPMIWords[i].word.equals(questionWord)){ rank = i; break; } } float synonymPMI; try { synonymPMI = model2.getPMI(questionWord, synonym); } catch (Exception e) { // TODO Auto-generated catch block synonymPMI = 0; } if (questionWord.length() <= 6) System.out.println(questionWord + ",\t\t\t" + autoPMI + ",\t" + highestPMI + ",\t" + (highestPMI - autoPMI) + ",\t" + rank + ",\t" + synonymPMI + ",\t" + (autoPMI - synonymPMI)); else if (questionWord.length() == 7) System.out.println(questionWord + ",\t\t" + autoPMI + ",\t" + highestPMI + ",\t" + (highestPMI - autoPMI) + ",\t" + rank + ",\t" + synonymPMI + ",\t" + (autoPMI - synonymPMI)); else System.out.println(questionWord + ",\t\t" + autoPMI + ",\t" + highestPMI + ",\t" + (highestPMI - autoPMI) + ",\t" + rank + ",\t" + synonymPMI + ",\t" + (autoPMI - synonymPMI)); } LineNo ++; } System.out.println("total correct answers: " + correctAnswers); testReader.close(); }
9
public int getBlockLength(int offset) { for(int i = 0; i < this.blockOffsets.length; i++){ if(offset == this.blockOffsets[i]) return this.blockLengths[i]; } return -1; }
2
public void actionPerformed(ActionEvent ae) { // // Process the action command // // "create graph" - Create the graph // "done" - All done // try { switch (ae.getActionCommand()) { case "create graph": Date startDate, endDate; if (!startField.isEditValid() || !endField.isEditValid()) { JOptionPane.showMessageDialog(this, "You must specify start and end dates", "Error", JOptionPane.ERROR_MESSAGE); } else { startDate = (Date)startField.getValue(); endDate = (Date)endField.getValue(); if (endDate.compareTo(startDate) < 0) { JOptionPane.showMessageDialog(this, "The end date is before the start date", "Error", JOptionPane.ERROR_MESSAGE); } else { createGraph(startDate, endDate); } } break; case "done": setVisible(false); dispose(); break; } } catch (Exception exc) { Main.logException("Exception while processing action event", exc); } }
6
public void testForOffsetHours_int() { assertEquals(DateTimeZone.UTC, DateTimeZone.forOffsetHours(0)); assertEquals(DateTimeZone.forID("+03:00"), DateTimeZone.forOffsetHours(3)); assertEquals(DateTimeZone.forID("-02:00"), DateTimeZone.forOffsetHours(-2)); try { DateTimeZone.forOffsetHours(999999); fail(); } catch (IllegalArgumentException ex) {} }
1
@Override public Object getValueAt(int rowIndex, int columnIndex) { if (params == null) return null; Parameter p = params.get(rowIndex); if (columnIndex == 0) return p.getName(); else if (columnIndex == 1) return p.getFormula(); else return p.getValue(); }
3
@Override public String toString() { // StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder(); // Intellij IDEA advised to use StringBuilder instead of StringBuffer sb.append("ComplexMatrix [\n"); for (int i = 0; i < getRowsNum(); i++) { sb.append(" ["); for (int j = 0; j < getColsNum(); j++) { try { sb.append(getElem(i, j).toString()); } catch (Exception e) { System.out.println("Exception in ComplexMatrix s.append(getElem(i, j).toString())"); e.printStackTrace(); } if (j < getColsNum() - 1) { sb.append(", "); } } sb.append("]\n"); } sb.append("]"); return sb.toString(); }
4
public String getMetaHeaders(HttpServletRequest request) { System.out.println("Euscreenxlitem.getMetaHeaders()"); String id =request.getParameter("id"); //System.out.println("ITEMID="+id); ipAddress=getClientIpAddress(request); String uri = "/domain/euscreenxl/user/*/*"; browserType = request.getHeader("User-Agent"); if(browserType.indexOf("Mobile") != -1) { String ua = request.getHeader("User-Agent").toLowerCase(); isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); } FSList fslist = FSListManager.get(uri); List<FsNode> nodes = fslist.getNodesFiltered(id.toLowerCase()); // find the item if (nodes!=null && nodes.size()>0) { FsNode n = (FsNode)nodes.get(0); n.getPath(); // daniel check for old euscreen id String pub = n.getProperty("public"); if (!((pub==null || !pub.equals("true")) && !this.inDevelMode())) { String metaString = "<link rel=\"alternate\" type=\"application/rdf+xml\" href=\"http://lod.euscreen.eu/data/" + id + ".rdf\">"; metaString += "<title>EUscreen - " + n.getProperty(FieldMappings.getSystemFieldName("title")) + "</title>"; metaString += "<meta name=\"Description\" CONTENT=\"Provider: " + n.getProperty(FieldMappings.getSystemFieldName("provider")) + ", Title: " + n.getProperty(FieldMappings.getSystemFieldName("title")) + ", Title " + n.getProperty(FieldMappings.getSystemFieldName("language")) + ": " + n.getProperty(FieldMappings.getSystemFieldName("originalTitle")) + ", Topic: " + n.getProperty(FieldMappings.getSystemFieldName("topic")) + ", Type: " + n.getProperty(FieldMappings.getSystemFieldName("materialType")) + "\"/>"; metaString += "<meta property=\"og:title\" content=\"" + n.getProperty(FieldMappings.getSystemFieldName("title")) + "\" />"; metaString += "<meta property=\"og:site_name\" content=\"EUscreenXL\" />"; metaString += "<meta property=\"og:url\" content=\"http://euscreen.eu/item.html?id=" + id + "\" />"; metaString += "<meta property=\"og:description\" content=\"" + n.getProperty(FieldMappings.getSystemFieldName("summaryEnglish")) + "\" />"; metaString += "<meta property=\"og:image\" content=\"" + this.setEdnaMapping(n.getProperty(FieldMappings.getSystemFieldName("screenshot"))) + "\" />"; metaString += "<meta name=\"fragment\" content=\"!\" />"; return metaString; } } return ""; // default is empty; }
6
public View(Model m) { _model=m; //setting sizes Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int screenWidth = (int) 700; int screenHeight = (int) 700; this.setSize(screenWidth,screenHeight); //setting elements c=getContentPane(); c.setLayout(new GridLayout(2,2)); memo=new JTextArea(15,30); scrollBar = new JScrollPane(memo); send=new JButton("Send"); active=new JButton("Active"); card=new JLabel(); message=new JTextField(40); gamePanel=new GamePane(); chatPanel=new ChatPane(); cardPanel=new CardPane(); JPanel grouping =new JPanel(); chatPanel.setBackground(Color.LIGHT_GRAY); gamePanel.setBackground(new Color(234,212,124)); cardPanel.setBackground(Color.GRAY); chatPanel.add(scrollBar); chatPanel.add(message); chatPanel.add(send); cardPanel.add(card); cardPanel.add(active); gamePanel.setLayout(new GridLayout(3,3)); grouping.setLayout(new GridLayout(1,2)); grouping.add(cardPanel); grouping.add(chatPanel); c.add(gamePanel); c.add(grouping); }
0
public void onModuleLoad() { Panel panel = new HorizontalPanel(); VerticalPanel consulterEventsPanel = new VerticalPanel(); Label title = new HTML("<h3>Consulter les événements</h3>"); consulterEventsPanel.add(title); consulterEventsPanel.add(searchWidget()); tableEvents = new TableWidget(); consulterEventsPanel.add(tableEvents.addTableWidget()); consulterEventsPanel.addStyleName("tableWidget"); panel.add(consulterEventsPanel); panel.add(addEventWidget()); root.add(panel); }
0
private int objectNextFree (int i, ArrayList<ObjetGraal> liste){ int result = -1; Boolean bExiste=false; for(ObjetGraal objet :liste){ if (objet.getType().equals(DefObjetGraal[i][0])){ if(i==(DefObjetGraal.length-1)) i=0; else i++; result = objectNextFree(i,liste); bExiste=true; break; } } if(!bExiste){ result = i; } return result; }
4
public treeNode getMinNode(treeNode root) { if (root == null) return null; treeNode leftMax = null; treeNode rightMax = null; treeNode minNode = root; if (root.leftLeaf != null) { leftMax = getMinNode(root.leftLeaf); if (leftMax.value < minNode.value) { minNode = leftMax; } } if (root.rightLeaf != null) { rightMax = getMinNode(root.rightLeaf); if (rightMax.value < minNode.value) { minNode = rightMax; } } return minNode; }
5
static private void gatherStatistics(String[] lineArray) { String token = ""; for(int j=0 ; j < numberLines ; j++) { StringTokenizer st = new StringTokenizer(lineArray[j], " \t", true); while(st.hasMoreTokens()) { token = st.nextToken(); boolean isWord = true; for(int i = 0; i<token.length(); i++) { numberChars++; if(Character.isUpperCase(token.charAt(i))) { numberUpper++; } else if(Character.isLowerCase(token.charAt(i))) { numberLower++; } else if( Character.isDigit(token.charAt(i))) { numberDigits++; isWord = false; } else if(token.equals(" ")) { numberSpaces++; isWord = false; } else if(token.equals("\t")) { numberTabs++; isWord = false; } else { numberSpecial++; } } if(isWord){numberWords++;} } } }
9
public final boolean more() throws JSONException { char nextChar = next(); if (nextChar == 0) { return false; } back(); return true; }
1
@Override public String execute() throws Exception { try { Map session = ActionContext.getContext().getSession(); user = (User) session.get("User"); Criteria ucri = myDao.getDbsession().createCriteria(User.class); ucri.add(Restrictions.not(Restrictions.eq("emailId", "admin@adzappy.com"))); ucri.add(Restrictions.or(Restrictions.like("emailId", s + "%"), Restrictions.like("userName", s + "%"))); ucri.setMaxResults(50); setAlluserlist((List<User>) ucri.list()); addActionMessage(getAlluserlist().size() + "\t\tResults Found"); return "success"; } catch (HibernateException e) { addActionError("Server Error Please Try Again "); e.printStackTrace(); return "error"; } catch (NullPointerException ne) { addActionError("Server Error Please Try Agains "); ne.printStackTrace(); return "error"; } catch (Exception e) { addActionError("Server Error Please Try Again "); e.printStackTrace(); return "error"; } }
3
public static List<MoleculeState> getIsomers(int carbons, Bond primaryBond) { List<MoleculeState> states = new ArrayList<>(); final HashSet<String> existing = new HashSet<String>(); Queue<MoleculeState> currentStates = new LinkedList<MoleculeState>() { @Override public boolean add(MoleculeState state) { if(existing.contains(state.getName())) return false; existing.add(state.getName()); return super.add(state); } @Override public boolean addAll(Collection<? extends MoleculeState> states) { for(MoleculeState state : states) add(state); return true; } }; MoleculeState origin = new MoleculeState(new Molecule(1), false, primaryBond); currentStates.offer(origin); while(!currentStates.isEmpty()) { MoleculeState state = currentStates.poll(); if(state.getSize() == carbons) { states.add(state); continue; } currentStates.addAll(state.nextStates()); } ListIterator<MoleculeState> snipper = states.listIterator(); while(snipper.hasNext()) { if(snipper.next().needsSignificantBond()) snipper.remove(); } return states; }
7
@Override public void unInvoke() { // undo the affects of this spell if(affected==null) return; if(!(affected instanceof Room)) return; if((shooter==null)||(parameters==null)) return; if(canBeUninvoked()) { shooter = (Ability)shooter.copyOf(); final MOB newCaster=CMClass.getMOB("StdMOB"); newCaster.setName(L("the thin air")); newCaster.setDescription(" "); newCaster.setDisplayText(" "); newCaster.basePhyStats().setLevel(invoker.phyStats().level()+(2*getXLEVELLevel(invoker))); newCaster.recoverPhyStats(); newCaster.recoverCharStats(); newCaster.setLocation((Room)affected); newCaster.addAbility(shooter); try { shooter.setProficiency(100); shooter.invoke(newCaster,parameters,null,false,invoker.phyStats().level()+(2*getXLEVELLevel(invoker))); } catch(final Exception e){Log.errOut("DELAY/"+CMParms.combine(parameters,0),e);} newCaster.delAbility(shooter); newCaster.setLocation(null); newCaster.destroy(); } super.unInvoke(); if(canBeUninvoked()) { shooter=null; parameters=null; } }
7
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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Calculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Calculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Calculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Calculator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Calculator().setVisible(true); } }); }
6
public void moveToTouch(OrthographicCamera camera) { // TODO Auto-generated method stub // The bloody camera and touch position is in a different orientation than the batch.draw orientation. It's a nightmare. if(currentForm!=4){ Vector3 touchPos = new Vector3(); touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0); camera.unproject(touchPos); int moveBuffer= 2; if(Gdx.input.getX()<ship.x && touchPos.x-ship.x<moveBuffer*-1)ship.x-=speed*Gdx.graphics.getDeltaTime(); else if(Gdx.input.getX()>ship.x && touchPos.x-ship.x>moveBuffer)ship.x += speed*Gdx.graphics.getDeltaTime(); if(touchPos.y-16<ship.y && (touchPos.y-16)-ship.y<moveBuffer*-1)ship.y +=(speed*Gdx.graphics.getDeltaTime()*-1); else if(touchPos.y-16>ship.y && (touchPos.y-16)-ship.y>moveBuffer)ship.y-=(speed*Gdx.graphics.getDeltaTime()*-1); } }
9
@Override public void keyPressed(KeyEvent event) { //Match hotkeys: switch (event.getKeyCode()) { case KeyEvent.VK_ESCAPE : match.cancelCurrentAction(); break; //Escape : cancel action/deselect unit. case KeyEvent.VK_E : if (event.isControlDown()) { //Ctrl-E : end turn. match.endTurn(); } break; //TODO: Add more hotkeys if necessary. } }
3
public void run() { while (!threadTerminate) { // If we are not processing a request and we have a query, handle it if (!processingQuery && queryRequests.size() > 0) processQuery(); // This thread should only check requests every few seconds or so // The thread should not be demanding at all try { Thread.sleep(1000); } catch (InterruptedException e) { } } }
4
public Sound(String mp3Filename) { this.filename = mp3Filename; }
0
@Override protected Long getContentLength(String s, MediaType contentType) { if (contentType != null && contentType.getCharSet() != null) { Charset charset = contentType.getCharSet(); try { return (long) s.getBytes(charset.name()).length; } catch (UnsupportedEncodingException ex) { throw new InternalError(ex.getMessage()); } } else { return null; } }
3
public void paintComponent(Graphics g) { //BlackBG - VOID; should not be seen. g.setColor(Color.black); g.fillRect(0, 0, width, height); // // Map map.paint(g); // -- // Player Run.player.paint(g); // -- // MENUS //Start menu if (!Run.gameStarted) startMenu.paint(g); // //Pause menu if (Run.gamePaused) pauseMenu.paint(g); // // // Screen messages screenMsg.paint(g); // -- }
2
public static int fetchPersonId(String userid){ int personId=0; ResultSet rs = null; Connection con = null; PreparedStatement ps = null; boolean result = true; try { String sql = "SELECT ID FROM PERSON WHERE userid=?"; con = ConnectionPool.getConnectionFromPool(); ps = con.prepareStatement(sql); ps.setString(1, userid); rs = ps.executeQuery(); if(rs.next()){ personId = rs.getInt("ID"); } } catch (Exception ex) { ex.printStackTrace(); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } if (ps != null) { try { ps.close(); } catch (SQLException e) { e.printStackTrace(); } } if (con != null) { try { ConnectionPool.addConnectionBackToPool(con); } catch (Exception e) { e.printStackTrace(); } } } return personId; }
8
public void add(String word) { char[] wordChars = word.toCharArray(); for (int i = 0; i < wordChars.length; i++) { char before = wordChars[i]; wordChars[i] = (char) 0; String key = String.valueOf(wordChars); HashSet<String> valueSet = graph.get(key); if (valueSet == null) { valueSet = new HashSet<String>(); graph.put(key, valueSet); } valueSet.add(word); wordChars[i] = before; } }
2
@Override public int attack(double agility, double luck) { if(random.nextInt(100) < luck) { System.out.println("I just cast a storm of meteorites!"); return random.nextInt((int) agility) * 2; } return 0; }
1
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if((myHost==null) ||(!(myHost instanceof MOB))) return super.okMessage(myHost,msg); final MOB mob=(MOB)myHost; if((msg.amISource(mob)) &&(mob.charStats().getClassLevel(this)>4)) { if(((msg.sourceMinor()==CMMsg.TYP_BUY) ||(msg.sourceMinor()==CMMsg.TYP_LIST)) &&(msg.tool() instanceof Potion)) { mob.basePhyStats().setDisposition(mob.basePhyStats().disposition()|PhyStats.IS_BONUS); mob.recoverPhyStats(); mob.recoverCharStats(); } else if((mob.basePhyStats().disposition()&PhyStats.IS_BONUS)==PhyStats.IS_BONUS) { mob.basePhyStats().setDisposition(mob.basePhyStats().disposition()-PhyStats.IS_BONUS); mob.recoverPhyStats(); mob.recoverCharStats(); } } return super.okMessage(myHost,msg); }
8
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof MatchPairing)) { return false; } MatchPairing other = (MatchPairing) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; }
5
public void printArg(){ System.out.print("("); for(Argument e : arrayarg){ System.out.print(e.getId() + " : " + e.getType()); } System.out.print(")"); }
1
private Element getOrCreateCollection(String collectionName) throws Exception { if(this.doc == null) { this.doc = Utilities.createDocument(); } Element docElem = this.doc.getDocumentElement(); if(docElem == null) { docElem = Utilities.createElement(this.doc, "c", "settings", this.namespaces); } else { if(!docElem.getLocalName().equals("settings") || !docElem.getNamespaceURI().equals(Settings.DEFAULT_NAMESPACE)) { throw new Exception("Document element is not correct."); } } NodeList children = docElem.getChildNodes(); Element elem = null; for(int i = 0; i < children.getLength(); ++i) { Node child = children.item(i); if(child.getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) child; if(e.getLocalName().equals(collectionName) && e.getNamespaceURI().equals(Settings.DEFAULT_NAMESPACE)) { elem = e; break; } } } if(elem == null) { elem = this.doc.createElementNS(Settings.DEFAULT_NAMESPACE, collectionName); elem.setPrefix("c"); docElem.appendChild(elem); } save(); return elem; }
9
public String getNoteContent(int noteId) throws SQLException { NoteDatabaseManager dm = new NoteDatabaseManager(); String s_noteId = Integer.toString(noteId); String sql = "select note_content from note where note_id = " + s_noteId + ";"; ResultSet rs = dm.sqlQuery(sql); String noteContent = null; while (rs.next()) { noteContent = rs.getString("note_content"); } return noteContent; }
1
public void makeTable(ArrayList<String> fNames) throws IOException{ TextFile in = null; String line = ""; String[] splLine; int index = 0; //table with only counts table = new float[trSize][samplesSize]; readsPerSample = new float[samplesSize]; featureExpressed = new boolean[trSize]; GeneNameConverter converter = null; if (convertGeneName != null) converter = new GeneNameConverter(convertGeneName); int curId = 0; System.out.println("Started generating the expression table"); String trId; for (String fName : fNames){ int rCount=0; in = new TextFile(fName, false); System.out.println("\nProcessing file: " + fName); //get number of mapped reads from filtered sam file if (normalize) readsPerSample[curId] = getNumMappedReads(fName); while ((line = in.readLine()) != null){ //read the expression from simple txt or from gtf splLine = readExpressionLine(fName, line); float count = Float.valueOf(splLine[1]); //skip not expressed transcripts if (count == 0) continue; if (convertGeneName != null) trId = converter.getHugoName(splLine[0]); else trId = splLine[0]; if (trId != null){ //get the transcript position in all transcripts list index = Collections.binarySearch(allTranscr, trId); if (index >= 0){ //if transcript found featureExpressed[index] = true; //set this feature as expressed rCount+=count; //junk table[index][curId] += count; } } } curId++; System.out.println("overall number of reads=" + rCount); System.out.println("overall number of mapped reads=" + readsPerSample[curId - 1]); in.close(); } }
8
private final void step6() { j = k; if (b[k] == 'e') { int a = m(); if (a > 1 || a == 1 && !cvc(k - 1)) { k--; } } if (b[k] == 'l' && doublec(k) && m() > 1) { k--; } }
7
private static int maxSum(int[] a){ int max = Integer.MIN_VALUE; int temp=0; int m = Integer.MIN_VALUE; int linit = 0; for(int i=0;i<a.length;i++){ temp+=a[i]; m = Math.max(m, a[i]); if(temp<0){ temp=0; linit = i+1; } else if(temp>max){ max = temp; l = linit; r = i; } } if(max==Integer.MIN_VALUE){ allneg = true; } return max==Integer.MIN_VALUE?m:max; }
5
@Test public void equals2_test() { try{ double []vec1= {1.0,2.0,3.0}; double []vec2= {1.0,2.0}; boolean result= Vector.equals(vec1, vec2); Assert.assertFalse(result); } catch (Exception e) { // TODO Auto-generated catch block fail("Not yet implemented"); } }
1
public static List<String> parseTexteVersMot(String pathInput) { List<String> result = new ArrayList<>(); try { Scanner scanner = new Scanner(new FileReader(pathInput)); String mot; while (scanner.hasNext()) { mot = scanner.next().replaceAll("[!,.;?\":\\[\\]\\{\\}]", " "); String[] mots = mot.split(" "); for (String mot1 : mots) { if (!mot1.equals("")) { result.add(mot1); } } } } catch (FileNotFoundException ex) { Logger.getLogger(MorphingTools.class.getName()).log(Level.SEVERE, null, ex); } return result; }
4
private void updateSaveIssueButtonState() { boolean disable = true; if (saveIssue != null && table != null) { final boolean nothingSelected = table.getSelectionModel().getSelectedItems().isEmpty(); disable = nothingSelected; } if (disable == false) { disable = computeSaveState(new DetailsData(), getSelectedIssue()) != SaveState.UNSAVED; } if (saveIssue != null) { saveIssue.setDisable(disable); } }
4
public static Component getComponentForDialog(Object obj) { return obj instanceof Component ? (Component) obj : null; }
1
public void run () { int W=job.getPageDimension().width,H=job.getPageDimension().height; int D=W*2/3/S,O=W/6; if (D%2!=0) D++; font=new Font("SansSerif",Font.BOLD,D/2); g.setFont(font); fontmetrics=g.getFontMetrics(font); g.setColor(Color.black); int i,j; // Draw lines int y=O; int h=fontmetrics.getAscent()/2-1; for (i=0; i<S; i++) { String s=""+(S-i); int w=fontmetrics.stringWidth(s)/2; g.drawString(s,O+S*D+D/2-w,y+D/2+h); y+=D; } int x=O; char a[]=new char[1]; for (i=0; i<S; i++) { j=i; if (j>7) j++; a[0]=(char)('A'+j); String s=new String(a); int w=fontmetrics.stringWidth(s)/2; g.drawString(s,x+D/2-w,O+S*D+D/2+h); x+=D; } for (i=0; i<S; i++) for (j=0; j<S; j++) { update1(g,O+D*i,O+D*j,i,j,D); } g.dispose(); job.end(); }
6
public static boolean isGetter(String name){ if(name.contains("get")) return true; else return false; }
1
public boolean isWeaponUnlocked(UnlockType type){ if(type == UnlockType.DEFAULT) return true; else if(type == UnlockType.DAMAGE_OVER_TIME) return unlockedDOT; else if(type == UnlockType.MAGIC) return unlockedMagic; else return false; }
3
private void setupMenu() { setJMenuBar(menuBar); menuBar.add(connect); connect.add(connectNew); connectNew.setToolTipText("Create a new connection."); connectNew.addActionListener(this); connect.add(connectRecent); if(RecentConnections.hasRecentConnections()) { ArrayList<InetSocketAddress> recentConnections = RecentConnections.getClientRecent(); for(InetSocketAddress isa : recentConnections) { expandRecentConnectionsMenu(isa.getHostName() + ":" + isa.getPort()); } } else { connectRecent.setEnabled(false); connectRecent.setToolTipText("You do not have any recent connections."); } }
2
public static int getPriceOfAPlace(int zone) throws BDException{ String requete = "select prix from lescategories c, leszones z where c.nomc = z.nomc and numz=" + zone; Statement stmt = null; ResultSet rs = null; Connection conn = null; int res = 0 ; try { conn = BDConnexion.getConnexion(); stmt = conn.createStatement(); rs = stmt.executeQuery(requete); if(rs.next()) { res =rs.getInt(1); } else{ throw new BDException("Problème dans l'interrogation, impossible de déterminer le prix. Hey c'est pas gratuit"); } } catch (SQLException e) { throw new BDException("Problème dans l'interrogation des places (Code Oracle : "+e.getErrorCode()+")"); } finally { BDConnexion.FermerTout(conn, stmt, rs); } return res; }
2
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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { javax.swing.UIManager.LookAndFeelInfo[] installedLookAndFeels=javax.swing.UIManager.getInstalledLookAndFeels(); for (int idx=0; idx<installedLookAndFeels.length; idx++) if ("Nimbus".equals(installedLookAndFeels[idx].getName())) { javax.swing.UIManager.setLookAndFeel(installedLookAndFeels[idx].getClassName()); break; } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Anagrams.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Anagrams.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Anagrams.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Anagrams.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ SwingUtilities.invokeLater(new Runnable() { public void run() { new Anagrams().setVisible(true); } }); }
6
public BufferedImage toImage() { BufferedImage output = new BufferedImage(this.width, this.height, BufferedImage.TYPE_3BYTE_BGR); WritableRaster raster = output.getRaster(); DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer(); byte[] pixels = buffer.getData(); int index = 0; for(int y=0;y<this.height;y++) { for(int x=0;x<this.width;x++) { int v = (short)(this.get(y, x) & 0xFFFF); byte bv = (byte)((v > 0xFF) ? 0xFF : v); pixels[index] = bv; pixels[index+1] = bv; pixels[index+2] = bv; index += 3; } } return output; }
3
private static void displayStatistics(BufferedReader reader, VideoStore videoStore) { try { System.out.println("Please enter the start of a date range (YYYY-MM-DD):"); Date beginDate = Date.valueOf(reader.readLine()); System.out.println("Please enter the end of a date range (YYYY-MM-DD)"); Date endDate = Date.valueOf(reader.readLine()); System.out.println("Please enter the max number of items you would like to see in each category:"); int amount = readInt(reader, 1, -1); System.out.println(); System.out.println("*** Most Popular Videos ***"); LinkedList<Video> popularVideos = videoStore.getPopularVideos(beginDate, endDate, amount); int i = 1; for (Video video : popularVideos) { System.out.println( i++ + ". " + video.getIsbn() + " - " + video.getTitle() + " (" + video.getFormat() +")"); } System.out.println(); System.out.println("*** Most Popular Directors ***"); LinkedList<String> popularDirectors = videoStore.getPopularDirectors(beginDate, endDate, amount); i = 1; for (String director : popularDirectors) { System.out.println(i++ + ". " + director); } System.out.println(); System.out.println("*** Most Popular Performers ***"); LinkedList<String> popularPerformers = videoStore.getPopularPerformers(beginDate, endDate, amount); i = 1; for (String performer : popularPerformers) { System.out.println(i++ + ". " + performer); } System.out.println(); } catch (Exception e) { e.printStackTrace(); } }
4
protected void save() { // System.out.println("show the file picker"); JFileChooser filePicker = new JFileChooser(); // filePicker.setFileHidingEnabled(false); // filePicker.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); boolean exportData = false; File f = null; do { int returnValue = filePicker.showSaveDialog(parent); if (returnValue == filePicker.APPROVE_OPTION) { f = filePicker.getSelectedFile(); String split[] = f.getName().split("\\."); String newname = ""; if (split.length == 1) { // System.out.println("no extension, so put one"); newname = split[0] + ".csv"; } else if(!split[1].equals("csv") ) { // System.out.println("not csv, so put it"); newname = split[0] + ".csv"; } else newname = f.getName(); newname = f.getParentFile() + System.getProperty("file.separator") + newname; System.out.println("new name: " + newname); //make a new file f = new File(newname); if (f.exists()) { // System.out.println("the file exists, ask them if they want to overwrite it"); int overwrite = JOptionPane.showConfirmDialog(null,"The file exists, overwrite?","File Exists", JOptionPane.YES_NO_OPTION); System.out.println("overwrite: " + overwrite); if(overwrite == 0)//overwrite the file, 0 = yes, 1 = no { exportData = true; } else //don't overwrite the file { exportData = false; } } else { exportData = true; } } //don't save the file at all else { break; } } while(exportData == false); if (exportData) { try { FileWriter writer = new FileWriter(f); BufferedWriter bufferedWriter = new BufferedWriter(writer); PrintWriter out = new PrintWriter(bufferedWriter); //loop through the tree Csv combine = new Csv(); for(int i=0;i<data.size();i++) { String s = combine.combine(data.get(i)); // System.out.println("write this: " + s); out.println(s); } out.close(); bufferedWriter.close(); writer.close(); } catch (Exception fe) { System.out.println("something happened, " + fe); JOptionPane.showMessageDialog(parent, "Can't write to\n" + fe, "Export data error!", JOptionPane.ERROR_MESSAGE ); } }//end write the file }//end save
9
public void testNegated() { Weeks test = Weeks.weeks(12); assertEquals(-12, test.negated().getWeeks()); assertEquals(12, test.getWeeks()); try { Weeks.MIN_VALUE.negated(); fail(); } catch (ArithmeticException ex) { // expected } }
1
@Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = getNoQuestMsg(); QuestState st = player.getQuestState(qn); if (st == null) return htmltext; switch (st.getState()) { case Quest.STATE_CREATED: if (player.getLevel() < 76) { player.sendMessage("Low lvl, canceling subclass quest."); st.exitQuest(true); } else if (player.getClassIndex() != 0) { player.sendMessage("Not a base class, canceling subclass quest."); st.exitQuest(true); } else { st.setState(STATE_STARTED); htmltext = "<html><body>Subclass quest started.</body></html>"; } break; case Quest.STATE_STARTED: st.giveItems(SUBCLASS_MARK, 1); st.exitQuest(false); htmltext = "<html><body>Subclass quest completed.</body></html>"; break; case Quest.STATE_COMPLETED: htmltext = getAlreadyCompletedMsg(); break; } return htmltext; }
6
final void ZA(int i, float f, float f_15_, float f_16_, float f_17_, float f_18_) { anInt7912++; boolean bool = (anInt8172 ^ 0xffffffff) != (i ^ 0xffffffff); if (bool || f != ((NativeToolkit) this).aFloat8174 || f_15_ != ((NativeToolkit) this).aFloat8186) { anInt8172 = i; ((NativeToolkit) this).aFloat8174 = f; ((NativeToolkit) this).aFloat8186 = f_15_; if (bool) { ((NativeToolkit) this).aFloat8087 = (float) (anInt8172 & 0xff00) / 65280.0F; ((NativeToolkit) this).aFloat8180 = (float) (0xff0000 & anInt8172) / 1.671168E7F; ((NativeToolkit) this).aFloat8168 = (float) (0xff & anInt8172) / 255.0F; method3928(0); } ((NativeToolkit) this).aNativeInterface7924.setSunColour (((NativeToolkit) this).aFloat8180, ((NativeToolkit) this).aFloat8087, ((NativeToolkit) this).aFloat8168, f, f_15_); method3842(true); } if (aFloatArray8142[0] != f_16_ || aFloatArray8142[1] != f_17_ || aFloatArray8142[2] != f_18_) { aFloatArray8142[2] = f_18_; aFloatArray8142[1] = f_17_; aFloatArray8142[0] = f_16_; aFloatArray8140[2] = -f_18_; aFloatArray8140[0] = -f_16_; aFloatArray8140[1] = -f_17_; float f_19_ = (float) (1.0 / Math.sqrt((double) (f_17_ * f_17_ + f_16_ * f_16_ + f_18_ * f_18_))); ((NativeToolkit) this).aFloatArray8170[1] = f_19_ * f_17_; ((NativeToolkit) this).aFloatArray8170[2] = f_19_ * f_18_; ((NativeToolkit) this).aFloatArray8170[0] = f_16_ * f_19_; ((NativeToolkit) this).aFloatArray8102[1] = -((NativeToolkit) this).aFloatArray8170[1]; ((NativeToolkit) this).aFloatArray8102[2] = -((NativeToolkit) this).aFloatArray8170[2]; ((NativeToolkit) this).aFloatArray8102[0] = -((NativeToolkit) this).aFloatArray8170[0]; ((NativeToolkit) this).aNativeInterface7924.setSunDirection (((NativeToolkit) this).aFloatArray8170[0], ((NativeToolkit) this).aFloatArray8170[1], ((NativeToolkit) this).aFloatArray8170[2]); method3892(0); ((NativeToolkit) this).anInt8133 = (int) (f_16_ * 256.0F / f_17_); ((NativeToolkit) this).anInt8114 = (int) (256.0F * f_18_ / f_17_); } method3884((byte) 101); }
7
@Override public void onEnable() { try { Metrics metrics = new Metrics(this); this.getLogger().log(Level.INFO, "Enabling Metrics..."); metrics.start(); } catch (IOException ex) { this.getLogger().log(Level.SEVERE, "Error enabling metrics!", ex); } this.getLogger().log(Level.INFO, "Enabling listeners..."); this.listener = new ListenerManager(this); this.getLogger().log(Level.INFO, "Enabling command handler..."); this.chandle = new CommandHandler(this, "&b", "&7"); this.getLogger().log(Level.INFO, "Evaluating update checks..."); boolean check = this.cloader.getBoolean(ConfigValues.UPDATE_CHECK); boolean dl = this.cloader.getBoolean(ConfigValues.UPDATE_DOWNLOAD); this.update = new UpdateHandler(this, Choice.getChoice(check, dl), this.ID, this.getFile().getName()); }
1
void registerDeleteBooking(Booking b) { if (!newBooking.contains(b) && !modifiedBooking.contains(b) && !deleteBooking.contains(b)) { deleteBooking.add(b); } }
3
public static void main(String[] args) { String userInput = ""; // input from the user String quitCode = "q"; // code for quitting program Scanner scanner = new Scanner(System.in); // scanner for user input ParkerPaulTime time; // time object for display while (!userInput.equalsIgnoreCase(quitCode)) { System.out.print("Enter time in the form hh:mm (\"q\" to quit): "); userInput = scanner.next(); if(!userInput.equalsIgnoreCase(quitCode)) { time = new ParkerPaulTime(userInput); time.print(); } } }
2
public static char[][] build_block(String plain, int row,int period, int direction) { String plain_u=plain.toUpperCase(); if(row==-1) { row=plain_u.length()/period; } if(plain_u.length()%period!=0) { row++; } char[][] result=new char[row][period]; if(direction==1)//1 for vertical, 0 for horizontal { int cur_row=0; int cur_col=0; for(int i=0;i<plain_u.length();i++) { result[cur_row][cur_col]=plain_u.charAt(i); if(cur_row == row-1) { cur_row=0; cur_col++; } else { cur_row++; } } } else { int cur_row=0; int cur_col=0; for(int i=0;i<plain_u.length();i++) { result[cur_row][cur_col]=plain_u.charAt(i); if(cur_col == period-1) { cur_row++; cur_col=0; } else { cur_col++; } } } return result; }
7
@Override public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; if (!this.dead) { // Updates the x value of the pipe if (this.x1 < -151) { this.x1 = 930; this.score++; this.pipeA = new Pipes(this.x1,this.PIPEPATH); } if (this.x1 < -151) { this.score++; this.x1 = 930; this.pipeA = new Pipes(this.x1,this.PIPEPATH); } this.x1 -= 4; this.x2 -= 4; // draws the pipe this.pipeA.draw(g2, this.x1); this.pipeB.draw(g2, this.x2); // bird this.bird.draw(g2); // Checks if dead if(Math.abs(Main.FRAMEWIDTH/2-(this.x1-50))<50){ this.checkDead(this.pipeA); } if(Math.abs(Main.FRAMEWIDTH/2-(this.x2-50))<50){ this.checkDead(this.pipeB); } } else { //death Screen ImageRendering.drawImage(g2, "Graphics/gameOver.png", 400, 450, 0); } }
5
public Iterable<Integer> adj(int v) { validateVertex(v); return adj[v]; }
0
@Override public void setTitle(String title) { super.setTitle(title); if (isVisible()) { WindowMenuProvider.update(); } }
1
public void untap(){ for(Creature c : p1.getCritters()) c.setTapped(false); }
1
public static int countWaysOfChange(int[] S, int n) { if (n < 0) { return 0; } if (n == 0) { return 1; } int m = S.length; int[][] counts = new int[m + 1][n + 1]; for (int j = 0; j <= n; j++) { counts[0][j] = 0; } for (int i = 0; i <= m; i++) { counts[i][0] = 1; } for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { int count = 0; count += counts[i - 1][j]; if (j - S[i - 1] >= 0) { count += counts[i][j - S[i - 1]]; } counts[i][j] = count; } } return counts[m][n]; }
7
public void setFalse(TFalse node) { if(this._false_ != null) { this._false_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); } this._false_ = node; }
3