text
stringlengths
14
410k
label
int32
0
9
public String getInterfaceMethodrefName(int index) { InterfaceMethodrefInfo minfo = (InterfaceMethodrefInfo)getItem(index); if (minfo == null) return null; else { NameAndTypeInfo n = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex); ...
2
public Tile returnBestCityScoresMod(int settlerR, int settlerC, int capitalR, int capitalC, double distBias, int maxDist) { evalBefore(); int[][] cityScores = new int[rows][cols]; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { int dist = (int)Math.sqrt(Math.pow(r-settlerR,2) + Math...
8
private void verifierAuthentification() { if (loginTF.getText().equals("") && pwdTF.getText().equals("")) errorMessageLabel.setText("Les champs login et password sont vides."); else if (loginTF.getText().equals("")) errorMessageLabel.setText("Le champs login est vide."); ...
9
private static void preRenderChunk( short[][] sectionBlockIds, byte[][] sectionBlockData, boolean[] usedSections, byte[] biomeIds, BlockMap blockMap, BiomeMap biomes, int cx, int cz, int[] colors, short[] heights) { /** * Color of 16 air blocks stacked */ fina...
8
public synchronized static Logger getLogger() { if(logger == null) { try { logger = Logger.getLogger("RedpinLogger"); FileHandler fh = new FileHandler(Configuration.LogFile); if(Configuration.LogFormat == LoggerFormat.PLAIN) { fh.setFormatter(new SimpleFormatter()); } else if(Configura...
5
public String getType() { return type; }
0
static final int method1908(int i, int i_1_, int i_2_, boolean bool, int i_3_, int i_4_, int i_5_) { i_2_ &= 0x3; anInt3216++; if (bool != true) aClass21_3217 = null; if ((i_5_ & 0x1 ^ 0xffffffff) == -2) { int i_6_ = i_4_; i_4_ = i_3_; i_3_ = i_6_; } if ((i_2_ ^ 0xffffffff) == -1) ret...
5
public synchronized boolean removeIRCEventListener(IRCEventListener l) { if (l == null) return false; int index = -1; for (int i = 0; i < listeners.length; i++) if (listeners[i].equals(l)) { index = i; break; } if (index...
6
private Vector2 adjust(float minx, float maxx, float miny, float maxy, Vector2 v){ if(v.x > maxx - viewportWidth * zoom / 2) v.x = maxx - viewportWidth * zoom / 2; if(v.x < minx + viewportWidth * zoom / 2) v.x = minx + viewportWidth * zoom / 2; if(v.y > maxy - viewportHeight * zoom / 2) v.y = maxy - viewportHeigh...
4
private static void write(Path path) throws IOException, InterruptedException { int value; int width; int height; byte rgba[] = new byte[4]; int bitmap[]; PixelGrabber pg; BufferedImage img = null; try { img = ImageIO.read(image.toFile()); ...
5
public int[] sensedCell(int[] pos, int dir, Sense.senseDir sD) { int[] sensedCellPos = new int[2]; switch (sD) { case HERE: sensedCellPos = pos; break; case AHEAD: sensedCellPos = adjacentCell(dir); break; ...
4
public void tick() { time++; if (time >= lifeTime) { remove(); return; } xx += xa; yy += ya; zz += za; if (zz < 0) { zz = 0; za *= -0.5; xa *= 0.6; ya *= 0.6; } za -= 0.15; int ox = x; int oy = y; int nx = (int) xx; int ny = (int) yy; int expectedx = nx - x; int expectedy...
3
public int[] merge(int[] L1, int[] L2) { int[] L = new int[L1.length + L2.length]; int i = 0; while ((L1.length != 0) && (L2.length != 0)) { if (L1[0] < L2[0]) { L[i++] = L1[0]; L1 = eliminar(L1); if (L1.length == 0) { while (L2.length != 0) { L[i++] = L2[0]; L2 = eliminar(L2); ...
7
public Car build() { if (builtOn != null) { throw new IllegalStateException("can't call build more than once"); } builtOn = new Date(); delegate.setBuiltOn(builtOn); return delegate; }
1
* @return Returns whether the given column in the line with the given * index lies within a tab character. */ public boolean column_in_tab(int line, int col) { int ind = 0; StringBuilder l = code.getsb(line); int i; for (i = 0; i < col && ind < l.length(); ind++) { if (l.charAt(ind...
4
*@param nivel * @return des **/ public long cobrarMiembros(beansMiembro miembro, int nivel){ long a = 0, desc = 0, des = 0; if(nivel <= 10){ if(condicionarPago(miembro.getListaInterna(), nivel) == true){ for(beansMiembro miembroInterno : miembro.getListaInterna()){ desc += devolverPorcentaje(miembroI...
3
@Override public void caseADeclLeiaDefinicaoComando(ADeclLeiaDefinicaoComando node) { inADeclLeiaDefinicaoComando(node); if(node.getLeia() != null) { node.getLeia().apply(this); } if(node.getLPar() != null) { node.getLPar().apply(this); ...
6
public void applyMove(Operators2048 op) { boolean moved = false; switch (op) { case UP: moved = moveUp(); break; case DOWN: moved = moveDown(); break; case RIGHT: moved = moveRight(); break; case LEFT: moved = moveLeft(); break; } if (moved) { addTile(); } }
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AtLine atLine = (AtLine) o; if (clazz != null ? !clazz.equals(atLine.clazz) : atLine.clazz != null) return false; if (method != null ? !method.equals(atLine.method) : atLine.me...
9
@SuppressWarnings("unchecked") public void load(String courseraUrl) throws IOException { // Coursera has a limit of 1000 courses per query, but over 1500 // classes at the time of this writing. We will use categories as // additional argument to split the whole thing into multiple requests. universities.clear(...
5
public static ArrayList<TestReaction> findTestReactionByTestId(ArrayList<TestReaction> testReactions, int id) { ArrayList<TestReaction> outputReactions = new ArrayList<TestReaction>(); for(TestReaction tr:testReactions) { if(tr.test==id) { outputReactions.add(tr); } } return outputReactions; }
2
private void writeOriginsQuartiles(String originsQuartilesFilename, Map<Byte, SpikeClassStats> stats, SpikeClassStats single33, SpikeClassStats single66, SpikeClassStats single100, byte maxHop) throws IOException { // create folders if needed if (originsQuartilesFilename.lastIndexOf("/") != -1) { File ...
7
public Image scale(Image img) { // Offset the image by one pixel so there's a border around it. // This lets us avoid having to check that A-I are in range of the image before samping them sourceGraphics.drawImage(img, 1, 1, null); int line = width + 2; for (int y = 0; y < height; y++) { // Two lines o...
8
public static Command inputEventToCommand(InputEvent e) { if (e==null) {return NO_COMMAND;} if (e instanceof KeyEvent) { switch (((KeyEvent)e).getKeyChar()) { case 'w': return MOVE_UP; case 'a': return MOVE_LEFT; case 's': return MOVE_DOWN; case 'd': return MOVE_RIGHT; case '=': return D...
9
public void extract(LauncherAPI api, int min, int max) { System.out.println("Extracting '" + getFileName() + "'..."); if (type == Type.NATIVE || type == Type.ADDITIONNAL) { File dest = this.dest; boolean recursive = true; ...
5
static String toHex4ByteString(int i) { String hex = Integer.toHexString(i); if (hex.length() == 1) return "0000000" + hex; if (hex.length() == 2) return "000000" + hex; if (hex.length() == 3) return "00000" + hex; if (hex.length() == 4) return "0000" + hex; if (hex.length() == 5) return "000...
7
private String parseSettingsPath(String settingsPath) { if (settingsPath.matches("^~.*")) { settingsPath = settingsPath.replace("~", ""); String home = System.getProperty("user.home"); settingsPath = home + settingsPath; } return settingsPath; }
1
public void calculateCycleLength(){ boolean notFound = true; int currentState; int threshhold = 10; while(notFound){ for(int i=0;i<threshhold;i++){ update(); } currentState = getState(); for(int i=0;i<threshhold;i++){ update...
4
public boolean renderBlockFenceGate(BlockFenceGate par1BlockFenceGate, int par2, int par3, int par4) { boolean flag = true; int i = blockAccess.getBlockMetadata(par2, par3, par4); boolean flag1 = BlockFenceGate.isFenceGateOpen(i); int j = BlockDirectional.getDirection(i); if...
9
public boolean existeRelacion( String nombreClaseA, String nombreClaseB, int tipoRelacion ){ for ( int i=0 ; i<listaFigura.size() ; i++ ) { if ( listaFigura.get(i) instanceof RelacionGrafica ){ RelacionGrafica r = (RelacionGrafica)listaFigura.get(i); ...
5
public void visitLdcInsn(final Object cst) { buf.setLength(0); buf.append(tab2).append("LDC "); if (cst instanceof String) { appendString(buf, (String) cst); } else if (cst instanceof Type) { buf.append(((Type) cst).getDescriptor()).append(".class"); } else { buf.append(cst); } buf.append('\n'); ...
3
boolean isDynamicTypePersistenceModeDifferent(SystemObjectTypeProperties property, DynamicObjectType.PersistenceMode persistenceMode) { // Liste der erweiterten Typen (SuperTypen) final List<SystemObjectType> superTypes = new ArrayList<SystemObjectType>(); superTypes.addAll(createSuperTypes(property.getExtendedPi...
7
public boolean similar(Object other) { if (!(other instanceof JSONArray)) { return false; } int len = this.length(); if (len != ((JSONArray)other).length()) { return false; } for (int i = 0; i < len; i += 1) { Object valueThis = this.ge...
8
static String getFingerPrint(HASH hash, byte[] data){ try{ hash.init(); hash.update(data, 0, data.length); byte[] foo=hash.digest(); StringBuffer sb=new StringBuffer(); int bar; for(int i=0; i<foo.length;i++){ bar=foo[i]&0xff; sb.append(chars[(bar>>>4)&0xf]); ...
3
public final void method43(AbstractToolkit var_ha, int i) { if (i != -14218) aBoolean10019 = false; anInt10016++; Object object = null; r var_r; if (aR10036 == null && aBoolean10003) { Class2 class2 = method2417(i + 14218, var_ha, 262144, true); var_r = class2 != null ? ((Class2) class2).aR118 : nul...
5
public Move chooseMove(State s) { // remember who we are so we can correctly evaluate states me = s.whoseTurn(); // The rest of this function looks a lot like evalMove, except // that it doesn't just track the minimaxvalue, but also the // best move itself. // get a list of possible moves MyList moves = s.find...
3
@Override public Column parse() { if(!this.prepared) { this.prepared = true; StringBuilder sB = new StringBuilder(); sB.append(this.name); String type = this.t.getTextual(); if(this.t == DataType.RAW) { sB.append(type.replace("%1", this.data)); }else if(null != this.length) { ...
7
@SuppressWarnings("deprecation") @EventHandler public void onTeamChatKick(PlayerKickEvent event){ if(functions.isPlayerInTC(event.getPlayer())){ if(config.getBoolean("tc.general.kick-offline-players")){ TeamChat2.remove(event.getPlayer().getName()); for(Player p : Bukkit.getServer().getOnlinePlayers()){...
4
void searchFiu(String ID) { //read text file String line = ""; //traverses the whole file line by line try { BufferedReader reader = new BufferedReader( new FileReader("FiuDB.txt")); while((line = reader.read...
5
private void displayCompResults(List<SplitMapperCompJvmCost> cMapperJvmCostList, List<SplitReducerCompJvmCost> cReducerJvmCostList, String mapperFile, String reducerFile, String jobName) throws IOException { File mFile = new File(mapperFile); File rFile = new File(reducerFile); if(!mFile.getParentFile().ex...
4
@Override public void executeMsg(Environmental host, CMMsg msg) { if(affected instanceof MOB) { final MOB M = (MOB)affected; if((msg.target()==M) &&((msg.targetMinor()==CMMsg.TYP_LOOK)||(msg.targetMinor()==CMMsg.TYP_EXAMINE)) &&(CMLib.flags().canBeSeenBy(M,msg.source()))) { final String s=CMLib...
8
@Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub if(e.getKeyCode() == KeyEvent.VK_ENTER) { String message = txtBox.getText(); String showMessageForMe = "me: " + message + "\n"; message = message.replace("<", "&lt;"); message = message.replace(">", "&gt;"); String me...
2
@RequestMapping(value = "/saveProject", method = RequestMethod.POST) public String saveProject(@ModelAttribute("project") Project project, BindingResult result) { System.out.println("project id:" + project.getProjectId() + "name" + project.getName()); if (project.getProjectId() == null) { ...
1
public Socket findServer(){ String IP = getIP(); String[] nodes = IP.split ("\\D"); String newIP = ""; for (int i = 0 ; i < nodes.length - 1 ; i++) { newIP = newIP.concat (nodes [i] + "."); } //Declares an array used for searching for a server Socket[] sktarr = new Soc...
3
public int getSourceLinesSize() { return sourceLines.size(); }
0
public void interact(ThePlayer p) { for (Item k : getKeys(p)) { Key K = (Key) k; if (K.getName().equals(keyName)) { System.out.println("Thou use-ith thine key to open ye door."); p.moveTo(getLocation()); return; ...
2
protected static boolean getBoolean(String key, JSONObject json) throws JSONException { String str = json.getString(key); if(null == str || "".equals(str)||"null".equals(str)){ return false; } return Boolean.valueOf(str); }
3
private void init() { Scanner reader = null; try { reader = new Scanner(new File(Constants.IMAGE_LIST_PATH)); } catch (FileNotFoundException e) { e.printStackTrace(); } while(reader.hasNext()){ String row = reader.nextLine(); if(row.isEmpty()) { //Ignore empty rows. continue; } Strin...
4
public static void act(Unit unit) { MapPoint goTo = null; MapPoint unitPlace = getNearestInfantryPreferablyOutsideBunker(unit); if (unitPlace != null) { goTo = unitPlace; } // If there's someone to protect, go there if (goTo != null) { double distance = goTo.distanceTo(unit); // If distance is bi...
5
@Override public boolean equals(Object o) { if(this == o) return true; if(o == null) return false; if(getClass() == o.getClass()) { Controlsystem s = (Controlsystem) o; return (inQueue.equals(s.inQueue) && outQueue.equals(s.outQueue) && ...
5
public void HuffmanBlockEncoder(BufferedOutputStream outStream, int zigzag[], int prec, int DCcode, int ACcode) { int temp, temp2, nbits, k, r, i; NumOfDCTables = 2; NumOfACTables = 2; // The DC portion temp = temp2 = zigzag[0] - prec; if(temp < 0) { temp = -temp; temp2--; } nbits = 0; while...
9
protected void wrapBuffer() throws IOException { // Handle chunking int size=size(); if (_chunking && size()>0) { prewrite(__CRLF,0,__CRLF.length); while (size>0) { int d=size%16; if (d<=9) ...
7
public boolean daysAreChecked() { return (chckbxLun.isSelected() || chckbxMar.isSelected() || chckbxMie.isSelected() || chckbxJue.isSelected() || chckbxVie .isSelected()); }
4
@Override public void run() { try (DatagramSocket socket = new DatagramSocket(Constants.SYSTEM_PORT)) { byte[] buf = new byte[512]; DatagramPacket packet = new DatagramPacket(buf, buf.length); // infinite listening for (;;) { socket.receive(...
8
public User findUserByLogin(String login){ User user = new User(); String requete = "select * from User where Login=?"; try { PreparedStatement ps = MyConnection.getInstance().prepareStatement(requete); ps.setString(1, login); ResultSet resultat = ps.executeQuery(); ...
2
@Test public void testInfixToPostfix1() throws DAIllegalArgumentException, DAIndexOutOfBoundsException, ShouldNotBeHereException, BadNextValueException, UnmatchingParenthesisException { try { QueueInterface<String> postFix = calc.infixToPostfix(infix); String result = "24+"; assertEquals(result, calc...
5
static int CacheCorrespondenciaDirecta(int i) { int Etiqueta = Integer.parseInt(Integer.toBinaryString(0x1000 | i).substring(1).substring(0, 3)); int Palabra = Integer.parseInt(Integer.toBinaryString(0x1000 | i).substring(1).substring(9, 12), 2); int Linea = Integer.parseInt(Integer.toBinaryStr...
7
private void networkStartup() { String load = "n"; while (!(load.equals("y") || load.equals("n"))) { System.out.print(" Load network (y/n) : "); try { load = bufReader.readLine(); load = load.toLowerCase(); } ...
5
@Override public void actionPerformed(ActionEvent e) { Reference.lastActionMinute = new DateTime().getMinuteOfDay(); if (e.getSource() == overviewButton) { Reference.overPanel = new OverPanel(); ...
8
private static int hexToInt(char ch) { if ('a' <= ch && ch <= 'f') { return ch - 'a' + 10; } if ('A' <= ch && ch <= 'F') { return ch - 'A' + 10; } if ('0' <= ch && ch <= '9') { return ch - '0'; } throw new IllegalArgumentException(String.valueOf(ch)); }
6
public void setSuperstrateRefractiveIndex(double index){ if(this.calcEffectiveDone)this.clearData(); this.superstrateRI = index; super.superstrateRefractiveIndex = index; this.setSuperstrateRI = true; if(this.setMeasurementsGrating && this.setGratingPitch && super.setWavelength)t...
4
public UpdateChecker() { }
0
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; BigFraction that = (BigFraction) o; if (denominator != null ? !denominator.equals(that.denominator) : that.denominator != null) return false; i...
7
private static void parseStyles(Map<String, String> styles, String inlinedStyles) { String[] keyValues = inlinedStyles.split(","); for (String keyValue : keyValues) { String[] kv = keyValue.split(":"); if (kv.length > 1) { styles.put(kv[0].trim(), kv[1].trim()); ...
2
public ArrayList<MatchScheduling> schedule(ArrayList<Team> teams) throws SQLException { ArrayList<MatchScheduling> matches = new ArrayList(); int i = 1; while (getGroup(i, teams) != null) { ArrayList<Team> group = getGroup(i, teams); ArrayList<Team> group2 =...
3
public static void print(ListNode root){ ListNode step = root; while(step != null){ System.out.print( +step.val); step = step.next; } System.out.println(); }
1
Page readPageData(RandomAccessFile raf) throws IOException { PageId pid; Page newPage = null; String pageClassName = raf.readUTF(); String idClassName = raf.readUTF(); try { Class<?> idClass = Class.forName(idClassName); Class<?> pageClass = Class.forNam...
9
public boolean scrollTo(int line, int offset) { // visibleLines == 0 before the component is realized // we can't do any proper scrolling then, so we have // this hack... if(visibleLines == 0) { setFirstLine(Math.max(0,line - electricScroll)); return true; } int newFirstLine = firstLine; int new...
7
@Override public Object getValueAt(int rowIndex, int columnIndex) { ArrayList<Event> eventsPerHall = schedulesMap.get(columnNames[columnIndex]); if (eventsPerHall != null) { for (int i = 0; i <= this.daysInMonth; i++) { if(rowIndex == i){ for (Event event : eventsPerHall) { Date eventStartDate = ...
6
public String nextToken() throws JSONException { char c; char q; StringBuilder sb = new StringBuilder(); do { c = next(); } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; for (; ; ) { c = next(); ...
9
public static Double calculate(Component c1, Component oper, Component c2, MathGame game) { NumberCard card1 = null; NumberCard card2 = null; OperationCard operation = null; try { card1 = (NumberCard) c1; card2 = (NumberCard) c2; operation = (OperationCard) oper; } catch(Exception e) { System.out....
5
public void listen() { try { while (!this.open) { Thread.sleep(SLEEPTIME); } while (this.open) { String text = this.client.receive().toString(); enteredText.insert(text + "\n", enteredText.getText().length()); enteredText.setCaretPosition(entered...
3
public synchronized void drop (DropTargetDropEvent dropTargetDropEvent) { try { Transferable tr = dropTargetDropEvent.getTransferable(); if (tr.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) { dropTargetDropEvent.acceptDrop (DnD...
6
public final void method78(int i, boolean bool, Component component, int i_11_) throws Exception { if (anInt5158 == 0) { if (i < 8000 || (i ^ 0xffffffff) < -48001) throw new IllegalArgumentException(); anInt5157 = !bool ? 1 : 2; if (i_11_ != 27929) aDirectSound5162 = null; anInt5161 =...
7
public boolean hasEmbeddedMovie() { if (isEmpty() || getTapePointer() <= 0) return false; if (numberOfAtoms > 0) { if (atom[0].rQ == null || atom[0].rQ.isEmpty()) return false; } if (obstacles != null && !obstacles.isEmpty()) { RectangularObstacle o = obstacles.get(0); if (o.rxryQ == null || o.r...
9
public PublishedSwarmDetails getSwarmDetails( final long swarmid ) { return (new SQLStatementProcessor<PublishedSwarmDetails>( "SELECT * FROM swarm_extras WHERE swarmid = ?" ){ PublishedSwarmDetails process(PreparedStatement s) throws SQLException { s.setLong(1, swarmid); ResultSet rs = s.executeQuery(); ...
2
private static void getSongLibrary(ArrayList<Song> songs, ArrayList<String> dates, ArrayList<String> names, ArrayList<String> artists) { TimeCalculator calc= new TimeCalculator(); for(int i=(names.size()-1); i>=0; i--){ boolean contains=false; for(Song song: songs){ if (song.getTitle().toLowerCase() ...
7
public static Bank narrow (org.omg.CORBA.Object obj) { if (obj == null) return null; else if (obj instanceof Bank) return (Bank)obj; else if (!obj._is_a (id ())) throw new org.omg.CORBA.BAD_PARAM (); else { org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable...
3
private short try_open_comport() { // the next line is for Raspberry Pi and gets us into the while loop and was suggested here was suggested http://www.raspberrypi.org/phpBB3/viewtopic.php?f=81&t=32186 System.setProperty("gnu.io.rxtx.SerialPorts", COM_PORT_NAME); Enumeration portEnum = CommPortIdentifier...
4
boolean alreadyInFile(String name) { File file = new File("Users.txt"); Scanner scanner; try { scanner = new Scanner(file); while (scanner.hasNextLine()) { String lineFromFile = scanner.nextLine(); if(lineFromFile.contains(name)) { JOptionPane.showMessageDialog(null, "Username has already ...
3
public boolean accept(File f) { if (f != null) { if (f.isDirectory()) { return true; } String extension = getExtension(f); if (extension != null && filters.get(getExtension(f)) != null) { return true; }; } ...
4
public Encoder correspondingEncoder() { // return this; return xmlcodec; }
0
public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int a, b, c, max; System.out.print("整数aを入力 >"); a = scan.nextInt(); System.out.print("整数bを入力 >"); b = scan.nextInt(); System.out.print("整数cを入力 >"); c = scan.nextInt(); if(a > b &&...
6
private Direction getDirection() { if (id.length() == 1) return Direction.None; else if (id.substring(id.length()-1).equals("0")) return Direction.NW; else if (id.substring(id.length()-1).equals("1")) return Direction.NE; else if (id.substring(id.length()-1).equals("2")) ...
4
public void addCells(Object[] cells) { if (cells != null) { Collection<Object> remove = null; if (singleSelection) { remove = this.cells; cells = new Object[] { getFirstSelectableCell(cells) }; } List<Object> tmp = new ArrayList<Object>(cells.length); for (int i = 0; i < cells.length; ...
5
public ArrayList<Move> getPossibleMoves() { ArrayList<Move> possibleMoves = new ArrayList<Move>(); for(int i = -1; i <= 1; i += 2) { for(int j = -1; j <= 1; j += 2) { boolean openSpace = true; int count = 1; while(openSpace) { Location currentLoc = new Location(getLoc().getRow(...
7
public void testValueCollectionRemoveAllTCollection() { int[] keys = {1138, 42, 86, 99, 101, 727, 117}; long[] vals = new long[keys.length]; TIntLongMap map = new TIntLongHashMap(); for ( int i = 0; i < keys.length; i++ ) { vals[i] = keys[i] * 2; map.put( keys[i]...
7
public final SymbolraetselASTParser.sym_return sym() throws RecognitionException { SymbolraetselASTParser.sym_return retval = new SymbolraetselASTParser.sym_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token SYMBOL2=null; CommonTree SYMBOL2_tree=null; ...
8
public void addFreq(String word) { mFreq++; if (Character.isUpperCase(word.charAt(0))) mCapitalFreq++; }
1
public ArrayList<ArrayList<Integer>> fourSum(int[] num, int target) { ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>(); int size = num.length; ValueIndexPair[] twoSums = new ValueIndexPair[(size - 1) * size / 2]; int twoSumsSize = 0; for (int i = 0; i...
7
public void genNewIndividual(int parent) { Genome child; Genome tmp; Genome tmp2; RNG die = RNG.getInstance(); a1 = die.nextInt(individual.size()); a2 = die.nextInt(individual.size()); a3 = die.nextInt(individual.size()); a4 = parent; /* child = a1 + Xover(a2 - a3) */ child = individual.ge...
9
public BoundedGrid(int rows, int cols) { if (rows <= 0) throw new IllegalArgumentException("rows <= 0"); if (cols <= 0) throw new IllegalArgumentException("cols <= 0"); occupantArray = new Object[rows][cols]; }
2
public Simulator() { for (int i=0; i<6; i++) { if (i<2) { employees[i]=new TastebudStylist(500); } else if (i<4) { employees[i]=new Moover(200); } else if (i<6) { employees[i]=new Shaker(100); } } week=0; }
4
@Override protected boolean handleEvent(Event evt) { if(evt.isMouseEventNoWheel()) { if(dragActive) { if(evt.isMouseDragEnd()) { if(listener != null) { listener.dragStopped(this, evt); } ...
7
public static void main(String[] args) { int sum = 0; HashSet<Integer> prods = new HashSet<Integer>(); for(int i = 2; i < 10_000; i++) { for(int j = i+1; j < 10_000; j++) { int k = i*j; if( isPan(i, j, k) ) { boolean added = prods.add(k); System.out.printf("%6d%6d%6d", i, j, i*j); if...
5
public boolean hasReturnTypeMethod(String name, Class<?> returnType, Class<?>... argTypes) { Preconditions.hasText(name); Preconditions.notNull(returnType); try { return null != returnTypeMethod(name, returnType, argTypes); } catch (Exception e) { return false; } }
3
public void drawCell(mxICanvas canvas, Object cell) { mxCellState state = graph.getView().getState(cell); if (state != null && isCellDisplayable(state.getCell()) && (!(canvas instanceof mxGraphics2DCanvas) || hitClip( (mxGraphics2DCanvas) canvas, state))) { graph.drawState(canvas, state...
8
public boolean isWorldLoaded(String world) { if (world.equalsIgnoreCase(loadedWorld)) { return true; } else { return false; } }
1
private void findFromPoint(Point p, List<Point> curPath) { curPath.add(p); if(isFinalPoint(p)){ //recursive stop point pathes.add(curPath); return; } if(MAZE.isRoad(p.X + 1, p.Y)){ findFromPoint(new Point(p.X + 1, p.Y), new ArrayList<Point>(curPath)); } if(MAZE.isRoad(p.X, p.Y + 1)){ findFromPoi...
4
public ArrayList<ArrayList<Integer>> permute(int[] num) { ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>(); int n = num.length; if (n == 0){ return result; } if (n == 1){ ArrayList<Integer> t = new ArrayList<Integer>(); ...
7