text
stringlengths
14
410k
label
int32
0
9
@Override public void postUpdate() { if(!underTrap){ xPos = 12*Math.cos((direction-90.0)/180*Math.PI); yPos = 12*Math.sin((direction-90.0)/180*Math.PI); if(onBattle && canon.getId()==2){ listElements.addElement(new Bullet(x-xPos,y-yPos, direction)); } if(onBattle && canon.getId()==6){ listElemen...
6
public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[54]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 28; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { i...
9
public Dungeon(Point location) { this.location = location; active = false; random = new Random(); max_floors = random.nextInt(10) + 5;//max 15 min 5 size = 100; floor = 0; floors = new ArrayList<DungeonFloor>(); for (int c = 0; c < max_floors; c++) { ...
1
public static void rejectFriendRequest(int senderID, int receiverID) { try { String statement = new String("UPDATE " + DBTable + " SET isRejected = true " + "WHERE uid1 = ? and uid2 = ? and isConfirmed = false and isRejected = false"); PreparedStatement stmt = DBConnection.con.prepareStatement(statement); ...
1
private void gameSetup() { // BUILD THE BOARD mother.setBounds(0, 0, WIDTH, HEIGHT-30); GridLayout gl = new GridLayout(11, 11); board = new JPanel(gl); board.setBounds(0, 0, WIDTH, HEIGHT-30); // Add all spaces to the board int topPos = 20; int leftPos = 19; int rightPos = 31; int botPos = 9; ...
7
public String print() { String output = "Empty Shape"; if( PointList != null ) { output = "Shape - " + PointList.size() + "Points"; for( Point n: PointList ) { output = output + n.print(); } } return output; }
2
private String queryResultsToXMLStringInternal(CycObject query, CycObject mt, InferenceParameters queryProperties, CycList xmlSpec) throws UnknownHostException, IOException, CycApiException { String xmlSpecString = (xmlSpec == null) ? ":default" : xmlSpec.stringApiValue(); ...
1
public static void moveUpText(OutlinerCellRendererImpl textArea, JoeTree tree, OutlineLayoutManager layout) { Node currentNode = textArea.node; // Get Prev Node Node prevNode = tree.getPrevNode(currentNode); if (prevNode == null) { return; } // Record the EditingNode and CursorPosition tree.setEdit...
2
public void shiftRight(boolean isJump){ reDrawIndex += 5; if(reDrawIndex > files.size()-1){ reDrawIndex = reDrawIndex - files.size(); } if(isJump){ listPosition += 5; if(listPosition > files.size()-1){ listPosition = listPosition - files.size(); } } }
3
public void draw(Graphics g){ if(pDir == 0){ if(HUD.inventory[0].getItemNum() != 0) g.drawImage(HUD.inventory[0].getPicDown(), playerRect.x+15-HUD.inventory[0].width-1, playerRect.y+15-2, null); g.drawImage(monkDown, playerRect.x, playerRect.y, null); } if(pDir == 1){ if(HUD.inventory[0].getItemNu...
8
protected void updateModelForces(float deltaTime) { boolean wasIntersection = true; for (int n = 0; wasIntersection & n <= 5; n++) { n++; wasIntersection = false; for (int i = 0; i < models.size() - 1; i++) for (int j = i + 1; j < models.size(); j++) {...
6
public void hit(ArrayList<Tank> tanks){ for(Tank tank:tanks){ if(tank.inside(this) && tank.getId()!=id && tank.isAlive() ){ this.setAlive(false); } } }
4
public void mutate(double lineProb, Random rand) { for (ArrayList<WorkUnit> personWorkList : personWorkLists) { if (rand.nextDouble() < lineProb) { int indexA = rand.nextInt(projectSize); int indexB = rand.nextInt(projectSize); if (indexA == indexB) { if (indexB == projectSize - 1) index...
4
public String whichBinary(String type) { for (int i = 0; i < Expression.binaryTypes.length; i++) { if (type.equals (Expression.binaryTypes[i])) { if(type.equals("plus")||type.equals("minus")||type.equals("times") ||type.equals("divided by")) { return "operator"; } else if(type.eq...
8
protected Nodo reducirArbol(int dato) { if(super.raiz.getOpt1() != null) { if(super.raiz.getOpt1().getDato() == dato) return super.raiz.getOpt1(); } if(super.raiz.getOpt2() != null) { if(super.raiz.getOpt2().getDato() == dato) ...
8
public void handleInput() { if((InputHandler.isPressed(InputHandler.W)) && (currentOption > 0)) { currentOption--; } else if((InputHandler.isPressed(InputHandler.S)) && currentOption < options.length - 1) { currentOption++; } else if(InputHandler.isPressed(InputHandler.SPACE)) { select(); } }
5
public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { System.out.println("Please enter 3 numbers"); int first = sc.nextInt(); int second = sc.nextInt(); int third = sc.nextInt(); if (first == 0 && second == 0 && third == 0) { break; } if ((first + s...
5
public void setupContent() { /* * Other stuff Being created here */ JPanel empty = new JPanel(); empty.setBorder(new EmptyBorder(0, 0, 20, 0)); empty.setOpaque(false); JPanel info = new JPanel(); info.add(statusLabel); info.setBorder(new EmptyBorder(0, 0, 10, 0)); info.setOpaque(false); JLabe...
3
@Override public String getMessageFromTest() { if (isCorrectSoFar) { return SUCCESS_STRING; } else { final String errorString = expectedProgramBehaviorCopy.getErrorString(); if ("".equals(errorString)) { throw new IllegalStateException("message fro...
2
public String getSourceFile() { SourceFileAttribute sf = (SourceFileAttribute)getAttribute(SourceFileAttribute.tag); if (sf == null) return null; else return sf.getFileName(); }
1
public static byte[] getBytes(Object o) { if (o instanceof String) { return ((String)o).getBytes(); } else if (o instanceof byte[]) { return (byte[])o; } else if (o instanceof Serializable) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ...
7
private void updateStates() { State aux; for (State m : successors) { aux = states.get(m.puzzle.getKey()); if (aux != null) { if (aux.opened) { if (m.getStartDistance() < aux.getStartDistance()) { openedStates.remove(aux...
5
public ListNode reverseBetween2(ListNode head, int m, int n) { // Note: The Solution object is instantiated only once and is reused by each test case. if ( m == n || n == 1){ return head; } ListNode tmpHead = new ListNode(0); tmpHead.next = head; ListNode tmp ...
5
public void patientPersonalInfo(PatientInfo patient, JTextField[] tfPatient, JTextPane tp, JTextPane[] patientTP) { StringBuffer info = new StringBuffer(); if (tp == null && patientTP == null) { tfPatient[2].setText(patient.getBdate().toString()); tfPatient[3].setText(patient.ge...
9
public int LCAutil(Node node,int a,int b){ if(node == null){ System.out.println("root is coming as null"); return -1; } if( (node.value >= a && node.value <= b ) ){ if( findNodes(node, a) && findNodes(node, b) ){ return node.value; } else{ return -1; } } ...
7
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { FullHttpResponse response; String requestUri; if (msg instanceof HttpRequest) { HttpRequest req = (HttpRequest) msg; boolean keepAlive = isKeepAlive(req); ...
5
private static boolean reachableFromSource(Vertex from, HashMap<Vertex, Vertex> predecessors) { HashSet<Vertex> visited = new HashSet<Vertex>(); Vertex source = new Vertex(0, 0); Vertex aVertex = new Vertex(from.posX, from.posY); Vertex me; boolean exit = false; while(predecessors.get(aVertex...
5
@Override public void onEnable() { Mc_IrcBotCommands irccommands = new Mc_IrcBotCommands(this); Mc_PlayerCommands playercommands = new Mc_PlayerCommands(this); getCommand("ircbot").setExecutor(irccommands); getCommand("irc").setExecutor(playercommands); IrcPlayerLi...
4
public void gameAssists() { Collections.shuffle(assists); for (int i = 0; i < 20; i++) { Collections.shuffle(assists); if(assists.get(0) == team.get(0).name) { astC++; } if(assists.get(0) == team.get(1).name) { astPF++; } if(assists.get(0) == team.get(2).name) { astSF++; } if(a...
6
private static List<String> tokenize(String bencodedString) throws DecoderException { List<String> tokenList = new ArrayList<String>(); Matcher m = DECODE_PATTERN.matcher(bencodedString); while(m.find()) { String extractedToken = bencodedString.substring(m.start(), m.end()); if(extractedToken.equals(Bencodi...
7
public void movePlayer(String direction){ if (direction.equals("up")){ if (canMove(direction)){ location = location - size; } } else if (direction.equals("down")){ if (canMove(direction)){ location = location + size; } }else if (direction.equals("left")){ if (canMove(direction)){ ...
8
public static boolean isWhiteSpaceChar( char tc ) { if( tc == '\u0009' || tc == '\r' || tc == '\n' || tc == '\u000b' || tc == '\u000c' || tc == '\u0000' || tc == '\u00a0' || tc == ' ' ) { return true; } else { return false; } }
8
public static int[] plusOne(int[] digits) { int[] res = new int[digits.length + 1]; boolean isin = false; for (int i = digits.length - 1; i >= 0; i--) { int t = 0; if (i == digits.length - 1 || isin) t = digits[i] + 1; else t = digits[i]; res[i + 1] = t % 10; ...
5
private Level findCorrespondingLevel(String levelName, SortedSet<Level> levels) throws CorrespondingLevelNotExistsException { if (null == levelName || "".equals(levelName)) { throw new CorrespondingLevelNotExistsException(); } for ...
4
public static void startupPropagate() { { Object old$Module$000 = Stella.$MODULE$.get(); Object old$Context$000 = Stella.$CONTEXT$.get(); try { Native.setSpecial(Stella.$MODULE$, Stella.getStellaModule("/LOGIC", Stella.$STARTUP_TIME_PHASE$ > 1)); Native.setSpecial(Stella.$CONTEXT$, ((Mo...
7
public static void readFile(String filePath) throws Exception { instructionString = new ArrayList<String>(); try { BufferedReader inputf = new BufferedReader(new FileReader(filePath)); String tmp = null; while ((tmp = inputf.readLine()) != null) { tmp = tmp.trim(); instructionString.add(tmp); ...
2
public Room getReleaseRoom(Law laws, Area myArea, MOB criminal, LegalWarrant W) { Room room=null; if((criminal.isMonster())&&(criminal.getStartRoom()!=null)) room=criminal.getStartRoom(); else { if((laws.releaseRooms().size()==0)||(laws.releaseRooms().get(0).equals("@"))) return myArea.getMetroMap()....
8
public static boolean readBoolean(String label) { String line = null; boolean finished = false; boolean ret = false; BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); try { while(!finished) { System.out.print(label+" [j/n]: "); line = stdin.readLine().toLowerCase(); ...
6
public static byte[] base64decode(String s) { int delta = s.endsWith("==") ? 2 : s.endsWith("=") ? 1 : 0; byte[] buffer = new byte[s.length() * 3 / 4 - delta]; int mask = 0xFF; int index = 0; for (int i = 0; i < s.length(); i += 4) { int c0 = toInt[s.charAt(i)]; ...
5
private void physicsInvaders() { Invader invader; invader = invaders[0][0]; if (invader.getX() < 5) { invaderSpeedX = invaderSpeedX * -1; invaderLimit = true; } invader = invaders[COLUMNS - 1][ROWS - 1]; if (invader.getX() + invader.getTexture().getW() > Window.getW() - 5) { invaderSpeedX = invader...
7
public void removeDeadFlyUps() { List<FlyUp> toDelete = new ArrayList<FlyUp>(); for(FlyUp fly:flyups) { if(fly.timeSinceCreation() >= 3300) toDelete.add(fly); } for(FlyUp fly:toDelete) { flyups.remove(fly); } }
3
public void checkGuess(char guess) { if (word.contains(Character.toString(guess))) { for (int i = 0; i < length; i++) { char temp = word.charAt(i); if (temp == guess) { placeholder.set(i, guess); } } } else { wrongLetters.add(guess); } }
3
public void setCsaFechaHora(Date csaFechaHora) { this.csaFechaHora = csaFechaHora; }
0
public String addBinaryII(String a, String b) { StringBuilder sb = new StringBuilder(); int i = a.length() - 1, j = b.length() - 1; int l = 0; while (i >= 0 && j >= 0) { int numa = Character.getNumericValue(a.charAt(i)); int numb = Character.getNumericValue(b.charAt(j)); int sum = numa + numb + l; l...
8
@Override public boolean queueBuffer( byte[] buffer ) { // Stream buffers can only be queued for streaming sources: if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING, "Buffers may only be queued for streaming sources." ) ) return false; ...
5
public static Stella_Object accessInputFileStreamSlotValue(InputFileStream self, Symbol slotname, Stella_Object value, boolean setvalueP) { if (slotname == Stella.SYM_STELLA_FILENAME) { if (setvalueP) { self.filename = ((StringWrapper)(value)).wrapperValue; } else { value = StringW...
6
public Forecasts getForecast() { try { crs = qb.selectFrom("forecast").where("msg_type", "=", "forecast").executeQuery(); while(crs.next()){ String date = crs.getString("day"); String temperature = crs.getString("temperature"); String weatherDescription = crs.getString("summary"); forecasts.for...
3
@Override public String getPropertyValues() { String var; if(Math.abs(variance) < EPS) var = ""; else var = " (var=" +variance +")"; if(min != UNDEFINED) { if(max != UNDEFINED) { if(min == max) { return min +getUnit() +var; } else { return "[" +min +", " +max +"]" +getUnit() +var; ...
5
private void setControlsEnabled(Boolean enabled) { mainWindowView.getNumberOfPointsTextField().setEnabled(enabled); mainWindowView.getIntegrationMethodsComboBox().setEnabled(enabled); mainWindowView.getAngleComboBox().setEnabled(enabled); mainWindowView.getxMaxTextField().setEnabled(enab...
0
public String getPassword() { return password; }
0
private void createCurrCity(SessionRequestContent request) { City currCity = (City) request.getSessionAttribute(JSP_CURRENT_CITY); if (currCity == null) { currCity = new City(); currCity.setCountry(new Country()); currCity.setDescription(new Description()); } ...
1
public void push(PriorityItem o) { LinkedList.Node p = (LinkedList.Node)l.getFirstNode(); if(p == null) { l.add(o); return; } while(((PriorityItem)p.value).compareTo(o) < 0 && p.next != null) { p = p.next; } l.addAfter(o, p); }
3
public static int[] getArr(int n){ int [] array = new int[n]; Random random = new Random(); System.out.println("*******************unsort array NO:"+n+"************"); for(int i =0; i < n;i++){ array[i] = random.nextInt(100); System.out.print(array[i]+" "); } System.out.println(); return array; }
1
public boolean isJoinable(String channel) { this.channel = channel; if (ChannelsConfig.getChannels().getBoolean("channels." + channel + ".joinable") == true) { return true; } else { return false; } }
1
public int getBufferDmg() { int dmgFromBuffers = 0; for (GameAction action: getBuffers()) { dmgFromBuffers += action.getExtraDmg(); } extraDmg = dmgFromBuffers; return dmgFromBuffers; }
1
@Test public void dequeueReturnsObjectsInCorrectOrder() { int[] expected = new int[100]; for (int i = 0; i < expected.length; i++) { expected[i] = i; q.enqueue(i); } int[] actual = new int[100]; for (int i = 0; i < actual.length; i++) { act...
2
public void setCueMovto(String cueMovto) { this.cueMovto = cueMovto; }
0
private void txt_num_fileFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt_num_fileFocusLost System.out.println("a dejado de ser focuseado\n"); if (txt_num_file.getText().length() > 0) { try { boolean existe; existe = TicketDAO....
3
public void sendData(String data) { if(connected) { try { if(sock.isClosed()) disconnectFromURL(); else if(!sock.isConnected()) disconnectFromURL(); else { final byte[] bytes=Telnet.peruseInput(data); if(bytes!=null) { out.write(bytes); if((bytes.lengt...
8
public void testChain1() { TreeNode key = new TreeNode("leaf"); TreeNode tree = mkChain(new TreeNode[]{ key }); setTree(tree); Question1 originalTree = ((Question2)answer).tree; try { Map result = synchronizeTree(((Question2)answer).convertTree()); if (res...
9
public String toGetSourceString(OgnlContext context, Object target) { if (target == null) throw new UnsupportedCompilationException("Current target is null, can't compile."); try { Object value = getValueBody(context, target); if...
9
public <T extends Component> Collection<T> getAllComponentsOfType( Class<T> componentType) { synchronized (componentStores) { HashMap<UUID, ? extends Component> store = componentStores .get(componentType); if (store == null) { return new L...
2
public String convert(String s, int nRows) { int len = s.length(); if ((nRows==1)||(len<nRows)) return s; int block = nRows*2-2; int nBlock = (len+block-len%block)/block; int[][] location = new int[nRows][nBlock*(nRows-1)]; // reseting the location...
9
public void execute () { Double cyclops = null; try { CycAccess cycAccess = new CycAccess(); System.out.println("Loading benchmarks.lisp"); String script = "(load \"" + benchmarkFilePath + "\")"; cycAccess.converseVoid(script); script = "(bench...
1
@Override public void input(float delta) { float movAmt = speed * delta; if (Input.getKey(forwardKey)) move(getTransform().getRot().getForward(), movAmt); if (Input.getKey(backKey)) move(getTransform().getRot().getForward(), -movAmt); if (Input.getKey(leftKey)) move(getTransform().getRot().getLeft(),...
6
private void selectRandomNumber() { phr1 = ""; phr2 = ""; int tmp = getRand(nrPhr1_9000); if (tmp != -1) { phr1 += nrPhr1_9000[tmp]; phr1 += conPhr1[2]; phr2 += nrPhr2_9000[tmp]; phr2 += conPhr2[2]; } tmp = getRand(nrPhr1_900); if (tmp != -1) { phr1 += nrPhr1_900[tmp]; phr1 += co...
8
public void setCliente(Cliente cliente) { this.cliente = cliente; }
0
public Game(int unit) { this.unit.value = unit; Dimension spielgrenzeSize = new Dimension(FIELD_DIMENSION.width, FIELD_DIMENSION.height); Spielgrenze spielgrenze = new Spielgrenze( new Rectangle(new Point(0, 0), spielgrenzeSize), this.unit); schlange = new SchlangenKopf( n...
1
public ReferenceList createReferenceList() { return new ReferenceList(); }
0
public int createShader(String filename, int shaderType) throws Exception { int shader = 0; try { shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType); if (shader == 0) return 0; ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename)); ARBShaderObjects.glCompileShaderA...
3
private void drawLoopLine() { parent.noStroke(); parent.fill(0); parent.rect(controlButtons.get(0).getX() + 40, controlButtons.get(2).getY() + 80, 320, 5); /* ArrayList<Integer> tempTimes = loop.getTimes(); for(LoopNode node : graphedInputs){ float distance = 320.0f * ((float) note / (float)loop.getE...
1
public static int attemptGetEntryFieldByNumberInput(List<Integer> fieldList, String input) { int intInput; try { intInput = Integer.valueOf(input); } catch (NumberFormatException e) { return -1; } if (intInput > -1 && intInput < fieldList.size()) return intInput; return -1; }
3
private void moveMonth(int numberToMove) { if (DEBUG) log("Beginning moveMonth(int numberToMove) method"); if (DEBUG) log("1. Clone today"); if (DEBUG) log(" Current date: " + date(currentCalendar)); Calendar temp = (Calendar)currentCalendar.clone(); if (DEBUG) log("2. Add " + number...
8
public void Update(GameTime gameTime) { mMenu.Update(); if (!mMenu.IsMenuItemSelected()) { mMenu.SelectMenuItem(new Vector2(mInput.GetMouseX(), GameProperties.WindowHeight() - mInput.GetMouseY())); if (mInput.IsMouseHit(0)) { switch(mMenu.GetSelected()) { case 0: { UnLoad(...
8
@Override public void update(final int delta) { if (!entitiesToAdd.isEmpty()) { entities.addAll(entitiesToAdd); entitiesToAdd.clear(); } List<Entity> deadEntites = null; for (Entity e : entities) { e.update(delta); if (!e.isAlive()) { if (deadEntites == null) deadEntites = new ArrayList...
5
private void firstLogin() { boolean flag = true; String tip = "请输入账号"; while(flag) { String input = JOptionPane.showInputDialog(null, tip, "", WIDTH); if(input==null) { if(user_name==null) continue; else break; } ...
5
protected void doTestCycAccess9(CycAccess cycAccess) { long startMilliseconds = System.currentTimeMillis(); try { CycConstant brazil = cycAccess.getKnownConstantByGuid(BRAZIL_GUID_STRING); CycConstant country = cycAccess.getKnownConstantByGuid(COUNTRY_GUID_STRING); CycConstant worldGeographyM...
2
void actionDeleteCurrent() { Form form = (Form) tabPanel.getSelectedComponent(); boolean delete = MessageDialog.confirmQuestion("Odstranění serveru", "Potvrďte odstranění serveru " + form.getTitle() + ".", this); if (delete) { int serverId = tabPanel.getSelec...
1
public boolean nextMatch(int userID){ this.scoreList = this.runningMatch.getScoreList(); this.finishedMatches.add(this.runningMatch); if(upcomingMatches.peek() != null){ this.runningMatch = upcomingMatches.poll(); this.runningMatch.setLeftUser(alstLeftUser.toArray(new Integer[0])); this.runningMatch.set...
1
public ArrayList<UndoableItem> redoFunction() { ArrayList<UndoableItem> toReturn = new ArrayList<>(); if (redoStack.isEmpty()) { return null; } else { ArrayList<UndoableItem> cur = (ArrayList<UndoableItem>) this.redoStack.pop(); this.undoStack.push(cur); ...
5
@Test public void test1() throws PersistitException { System.out.print("test1 "); final Exchange ex = _persistit.getExchange("persistit", "TransactionTest1", true); ex.removeAll(); final Transaction txn = ex.getTransaction(); txn.begin(); try { for (int...
9
@Override public boolean urunSil(int urunID) { /* HbmIslemler hbm = new HbmIslemler(); * */ try { /* return hbm.sil(urunID, Urun.class); * */ Urun urun = urunBul(urunID); if(urun != null){ if(urunler.remove(u...
3
public static boolean analysisVMXM(AnalysisOutput o, List<AnalysisOutput> candidates) throws MorphException { int idxXVerb = VerbUtil.endsWithXVerb(o.getStem()); if(idxXVerb==-1) return false; o.setXverb(o.getStem().substring(idxXVerb)); String eogan = o.getStem().substring(0,idxXVerb); ...
9
@Override public List<TransMode> load(Criteria criteria, GenericLoadQuery loadGeneric, Connection conn) throws DaoQueryException { int pageSize = 10; List paramList = new ArrayList<>(); StringBuilder sb = new StringBuilder(WHERE); String queryStr = new QueryMapper() { @O...
2
public static void printFormulaInfo() { System.out.println("*********************************\nVariable Information"); //print out the variables for(int i = 1; i < variables.size(); i++) { Variable v = variables.get(i); System.out.println(v.getName() + "\tAssignment:" + (v.getAssignment()==Variable.U...
7
public static int[] find(int[] arr, int windowSize, boolean print) { if(arr==null || arr.length==0) { return new int[]{}; } int[] result = new int[arr.length]; int idx = 0; MyQueueWithMaxMin<Integer> queue = new MyQueueWithMaxMin<Integer>(arr.length); int i=0; queue.offer(arr[i++]); if(i<arr.leng...
6
private static String verifyUrlPagination(String url,ArrayList<String> exclusionKeyWords) { if (!url.toLowerCase().startsWith("http")) { return null; } try { new URL(url); } catch (MalformedURLException e) { Logger.getLogger(Crawler.class).debug("Exception :"+e.getMessage() + " Description :"+ e.to...
4
public void run(){ int data; while(true){ data = buffer.consume(); } }
1
protected String getNestedUsage(String[] args, int level, Method method, T player) throws CommandException { StringBuilder command = new StringBuilder(); command.append("/"); for (int i = 0; i <= level; ++i) { command.append(args[i] + " "); } Map<Strin...
5
public Tela() { initComponents(); //JFileChooser configure txt jFileChooser1.setAcceptAllFileFilterUsed(false); FileFilter filter = new FileNameExtensionFilter("TXT File","txt"); jFileChooser1.setFileFilter(filter); jFileChooser1.setControlButtonsAreShown(false)...
3
public int[][] generateMatrix(int n) { int[][] matrix = new int[n][n]; int[] layerTotal = new int[n/2 + 1]; layerTotal[0] = 0; // layer length outside current index for (int i = 0; i < n; i++) { int v = Math.min(i, n - i - 1); if (i > 0 && i < n/2 + 1) { ...
7
public Number multiplyNumbers(Number a, Number b) throws NumberClassNotFoundException { Number product = null; if (a instanceof Double && b instanceof Double) { product = new Double(roundDouble(a.doubleValue() * b.doubleValue())); } else if (a instanceof Integer && b instanceof In...
8
private void processCNumber(AnalyzeContext context){ if(nStart == -1 && nEnd == -1){//初始状态 if(CharacterUtil.CHAR_CHINESE == context.getCurrentCharType() && ChnNumberChars.contains(context.getCurrentChar())){ //记录数词的起始、结束位置 nStart = context.getCursor(); nEnd = context.getCursor(); } }else{//正在...
9
public static String longestTwoUniqueSubStr(String str){ List<String> chars = new ArrayList<String>(); String maxSubString = ""; String current = ""; int i=0; for(char c: str.toCharArray()){ chars.clear(); chars.add(c + ""); current = c + ""; for(int j = i+1; j <str.length(); j++){ if(char...
7
public static void cobrirLinhas(Coluna naoincluir, Solucao solucao){ for(Coluna col : solucao.getColunas()){ if(col.getNome()!= naoincluir.getNome()){ ArrayList<Integer> valores_cobertos_pela_coluna = col.getCobertura(); for(Integer linha : valores_cobertos_pela_colun...
4
public HTTPResponse handle(HTTPRequest req) { { Iterator<Plugin> it = plugins.iterator(); while ( it.hasNext() ) { Plugin thisPlugin = it.next(); if ( thisPlugin.handles(req) ) return thisPlugin.handle(req); } } String debugData = req.getMethod()+" "+req.getPath()+"<br>"; debugData ...
3
public void updatePos() { if(--time >= 0) { for (int i = 0; i < Map.getHeight(); i++) { for (int j = 0; j < Map.getWidth(); j++) { if (Utils.distance(j, i, px, py) == radius - time) Map.addAttack(new Attack(j, i, father)); }...
4
@SuppressWarnings("rawtypes") public List loadList(final List<Long> ids) { if (ids == null || ids.isEmpty()) return new ArrayList(0); // 因为要保持有序,所以按照id顺序创建对象 List<POJO> prjs = new ArrayList<POJO>(ids.size()) { private static final long serialVersionUID = 1L; ...
9
public void addClientEvent(int event){ for (Team team : playmode.getTeams()) { for (User user : team.getUser()) { ArrayList<Integer> events = userIDtoClientEvents.get(user.getID()); events.add(event); userIDtoClientEvents.put(user.getID(), events); } } }
2
public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { Object result; try { System.out.println("before method " + m.getName()); result = m.invoke(obj, args); result = interceptor.around(result); } catch (InvocationTargetExce...
2