method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
5eb09eb9-ef22-4cf3-bffa-a8ad67c95875
4
@Override public Iterator<NPuzzleMove> getMoves() { List<NPuzzleMove> moves = new ArrayList<NPuzzleMove>(); if (exists( openX + 1, openY )) { moves.add( new NPuzzleMove( openX + 1, openY ) ); } if (exists( openX - 1, openY )) { moves.add( new NPuzzleMove( openX - 1, openY ) ); } if (exists( o...
bc42b673-7a0f-4ed3-9df3-a673ca467f10
4
public static void main(String[] args) throws Exception { String fileName = "vectors.txt"; // Global.initializeDataBaseSimulator(fileName); ArrayList<DataPoint> points = new ArrayList<DataPoint>(); ArrayList<Association> left = new ArrayList<Association>(); ArrayList<Association> associations = new ArrayList<...
b7dd9080-740c-470c-8bba-f50975779395
9
public void scrollCellToView(JTable table, int rowIndex, int vColIndex) { if (!(table.getParent() instanceof JViewport)) { return; } JViewport viewport = (JViewport) table.getParent(); Rectangle rect = table.getCellRect(rowIndex, vColIndex, true); Rectangle viewRect =...
b2db4e21-6f23-4aef-bd13-f49b1c05ac5d
4
public Ui(){ bg = new GreenfootImage (1000, 230); cache = new GreenfootImage [6]; cache[0] = new GreenfootImage ("UI/general.png"); cache[1] = new GreenfootImage ("UI/buildTower.png"); cache[2] = new GreenfootImage ("UI/sendMobs.png"); cache[3] = new GreenfootImage ("UI/s...
870533ec-18df-4f46-812e-ccafb135a09e
2
public static boolean CheckPlayers(int noplayers) { if ((noplayers >= 2) && (noplayers <= 8)) return true; else return false; }
e12d3fb0-769e-48c0-98b1-f36cc0ead3f7
3
public void render(Graphics2D g){ Graphics2D g2d = (Graphics2D)finalBoard.getGraphics(); g2d.drawImage(gameBoard, 0, 0, null); for (int row = 0; row < ROWS; row++) { for (int col = 0; col < COLS; col++) { Tile current = board[row][col]; if(current == null) continue; current.render(g2d); } }...
953f7f9b-f42a-47f5-86ed-a7347ede2bb2
5
public Msg recvpipe(Pipe[] pipe_) { // Deallocate old content of the message. Msg msg_; // Round-robin over the pipes to get the next message. while (active > 0) { // Try to fetch new message. If we've already read part of the message // subsequent part shou...
fc6decb7-6da2-433f-aa35-baf3e3a0bee7
2
public static Value changePlayer(Value player) { Value state = empty; switch(player) { case x: {state = o; break;} case o: {state = x; break;} } return state; }
2a32406d-b40d-4d72-b9f2-f018c80a4129
8
public void eventPosted(TimeflecksEvent t) { if (t.equals(TimeflecksEvent.GENERAL_REFRESH)) { GlobalLogger.getLogger().logp(Level.INFO, "MainWindow", "eventPosted", "MainWindow responding to general refresh event."); this.refresh(); } else if (t.equals(TimeflecksEvent.EVERYTHING_NEEDS_REFRESH)...
60d99c2a-871f-421b-9236-2385bd48e6dd
2
private double getFreeSpaceInOutsideVehicleAcceptor(VehicleAcceptor va) { try { //if va is null, return 0 if (va == null) { return 0; } List<Vehicle> cars = va.getCars(); //the va has cars, return the last backPos return cars.get(cars.size()).get...
3ec24ed3-76f6-4afc-81b8-7ebe54e0f927
9
public static void step(Page page, int step) { StyledDocument doc = page.getStyledDocument(); AbstractDocument.BranchElement section = (AbstractDocument.BranchElement) doc.getDefaultRootElement(); if (step < 0 && isSmallest(section)) return; Enumeration enum1 = section.children(); AbstractDocument.Branc...
200e7b76-80bd-4a58-86e8-43695c4ede94
6
public void enableBillTypes() { if (isFirstBill){ isFirstBill=false; reset(); ack(); d.readToPort(); try {Thread.sleep(900L);} catch (InterruptedException e) {e.printStackTrace();} d.writeToPort("02030C34FFFFFF000000B5C1"); ...
6afe1f7a-deea-4f6e-bed3-8d10730e4e71
1
public float getU() { if(animation != null) { return animation.getU(); } return tex.getU(); }
65e117dc-39f4-45f0-84dc-aeb287e342b6
7
private void moveNewZipFiles(String zipPath) { File[] list = listFilesOrError(new File(zipPath)); for (final File dFile : list) { if (dFile.isDirectory() && this.pluginExists(dFile.getName())) { // Current dir final File oFile = new File(this.plugin.getDataFol...
f38847c8-7cd0-492e-a23e-dc0860761311
2
public void setDAO(String daoLine) { if (daoLine.equals("Mock")) { dao = new MockDAO(); } else if (daoLine.equals("MySQL")) { dao = new MySQLDAO(); } }
12619145-b9e7-4dee-8844-b73d8c0fc900
4
public int get(final int index) { final int i0 = index >>> 22; int[][] map1; if (i0 != 0) { if (map == null) return NOT_FOUND; map1 = map[i0]; if (map1 == null) return NOT_FOUND; } else map1 = map10; int[] map2 = map1[(index >>> 11) & 0x7ff]; if (map2 == null) return NOT_FOUND; ...
1a570b8b-d27e-49a1-80b3-fc7a2b72b118
1
public void stop() { if (!stop) { stop = true; } }
8696f1d5-2f8c-4cee-bae4-e8561d643802
8
public void transferKE(float amount) { if (iAtom <= 0) return; float k0 = getKin(); if (k0 < ZERO) return; synchronized (forceCalculator) { for (int i = 0; i < iAtom; i++) { if (!atom[i].isMovable()) continue; k0 = EV_CONVERTER * atom[i].mass * (atom[i].vx * atom[i].vx + atom[i].vy * atom[...
b11b5eb1-b8ee-4a78-99f4-9408e1ac1433
3
public static long transfer( InputStream in, OutputStream out, long maxReadLength, int bufferSize ) throws IllegalArgumentException, IOException { byte[] buffer = new byte[ bufferSize ]; int len; long totalLength = 0; long bytesLeft = maxReadLength; // Math.max( maxReadLength, bufferSize )...
8d8dea99-8be4-4bcb-be64-9ca37715efb6
7
public void paintComponent(Graphics g){ super.paintComponent(g); BoardObject[][] tiles = board.getBoardTiles(); if (tiles == null) return; // before board is made ... // draws stuff //Draw each tile on the board. for(int y=0; y<Board.SIZE; y++){ for(int x=0; x<Board.SIZE; x++){ if(tiles[y][x] != nu...
489aca43-ad91-48bc-9126-bf1ae8d2d264
2
protected void attemptToGrowFruit() { System.out.println(getName() + " is attempting to grow some fruit."); // for each unit of growth that does not contain a fruit for(int i = getFruits().size(); i < getSize(); i++) { if(Math.random() < 0.01) { getFruits().add(getFruit()); ...
ab61e115-ca09-4074-834c-f626fa37d783
6
private static String encrypt(final int key, final String text) { String encryptedText = ""; logger.log(Level.INFO, "Plain text: {0}", text); for (int level = 0; level < key; level++) { for (int n = 0; n < text.length() / (2 * key - 2) + 1; n++) { if (level != 0 && le...
11861163-0392-468b-a86c-1bfec81051a3
6
@Override public void mousePressed(MouseEvent e) { if (calculated) { return; } Tile targetTile = getTileAt(e.getX(), e.getY()); int button = e.getButton(); if (targetTile != null) { targetTile.handleClick(button); if (targetTile.getState()....
ec8d4b4e-6ad7-46a4-b74b-d4a1317f319a
6
public final void levelDone() { if (!inGameState("InGame") || inGameState("LevelDone") || inGameState("LifeLost") || inGameState("GameOver") ) return; // System.err.println( // "Warning: levelDone() called from other state than InGame." ); //} clearKey(key_continuegame); removeGameState("StartLevel"); r...
e1f2e3cf-806b-4883-8ab3-938a2808d854
5
public void initializeBoard() { gameArray = new PlayableSquare[60]; for (int i = 0; i < 60; i++) { gameArray[i] = new PlayableSquare(Integer.toString(i)); } redHomeArray = new PlayableSquare[6]; greenHomeArray = new PlayableSquare[6]; blueHomeArray = new PlayableSquare[6]; ...
b17c0f7d-9da4-4f72-b6c3-c5b2411c036f
0
public SetUndoAmountAction () { super("Set Undo Amount", null); //this.environment = environment; }
e8dd209d-6ee1-4416-af6f-df7b561cfef4
9
private List<Mapper> estimateMappers() { List<Mapper> newMapperList = new ArrayList<Mapper>(); if(isSplitSizeChanged || isMapperConfChanged) { MapperEstimator mapperEstimator = new MapperEstimator(finishedConf, newConf); //split size is changed if(isSplitSizeChanged) { //List<Long> splits...
91fe4007-957d-401a-b761-35db250800b8
0
@Override public void onReceived(long delta, long bytes) { }
57db888b-e2d8-4151-9d44-fe0d401d54d5
4
public static String doRecognition(int[] positions){ String bestMatchString = null; float bestMatchPercentage = 0; for(Gesture item : gestureList){ float variance = 0; for(int i=0; i<4; i++){ variance += (float) Math.abs( item.getPosition(i) - positions[i]/(SignalProcessor.getMaxSignalValue()*0.01) ); ...
56493e03-8268-4cbf-a9f4-6496ea6db24c
0
public BlockListener(LogOre plugin) { this.plugin = plugin; }
023feadc-e3b9-439a-8d21-f8d59733d667
9
@Override public void run() { // TODO Auto-generated method stub Random rand = new Random(50); Random ano_rand = new Random(20); int rand_num; int wiget_send = 0; int money_send = 0; while (true) { // get a random number between 0-2 rand_num = rand.nextInt(proc_num); // for send the marker ...
3e726240-c7df-466e-92bf-7b30ee74e2d7
8
@EventHandler public void onWeatherChange(WeatherChangeEvent event) { notifyAboutUpdate(); Random r = new Random(); Boolean voteInProgress = false; //Check if the world is enabled if (getFileConfig().getStringList("Worlds").contains(event.getWorld().getName())) { ...
2093390b-6d1b-4d6e-ad0c-89b8a0731892
9
void applyForce() { //PhBody.applyForceToCenter(new Vec2(0,-3)); setForcesFromBodiesAffect(); if (BackJoint == null) return; //parent.text(f.length(),100,100); float CurrentJointLength = BackJoint.getLength(); LWormPart wp = (LWormPart) BackJoint.getBodyB().getUserDa...
2526dc5b-f757-4beb-b12d-03fcdc56f06e
2
public int sizeEffective() { int count = 0; for (String gene : this) if (geneSets.hasValue(gene)) count++; return count; }
9622b480-a58c-4364-bc26-5a6f6dbe46f2
7
boolean validateMove(movePair movepr, Pair pr) { Point src = movepr.src; Point target = movepr.target; boolean rightposition = false; if (Math.abs(target.x-src.x)==Math.abs(pr.p) && Math.abs(target.y-src.y)==Math.abs(pr.q)) { rightposition = true; } if (Math.abs(target.x-src.x)...
30e93598-6c7b-427e-a199-c1e1a2ee6b5c
9
public boolean combineLocal() { StructuredBlock firstInstr = (catchBlock instanceof SequentialBlock) ? catchBlock .getSubBlocks()[0] : catchBlock; if (firstInstr instanceof SpecialBlock && ((SpecialBlock) firstInstr).type == SpecialBlock.POP && ((SpecialBlock) firstInstr).count == 1) { /* The except...
caa1ffb6-a8a7-4c4f-833a-2b85c7a90280
1
public void draw1(Graphics g, ImageObserver observer) { if (image1 != null) g.drawImage(image1, x, y, width, heigth, observer); }
336901d4-0b7f-46ea-8f81-2a6adc7f5e94
7
public void writePairedNodeInformation( String filepath ) throws Exception { BufferedWriter writer = new BufferedWriter(new FileWriter(new File(filepath))); writer.write("nodeA\tnodeB\tparentA\tparentB\tnodeLevel\tsameParents\tleastCommonDistnace\talignmentDistance\talignmentDistanceMinusPredictedDistance\tnumS...
1af7f4fe-b35d-4cea-9706-0b41996639e9
7
private Element parseBranch() throws ParserException, XMLStreamException { String condition = getAttribute("condition"); startElement("branch"); Labelled left = null, right = null; while (look().isStartElement()) { String name = getNameOfStartElement(); if (name.equals("left")) { if (left != null) { ...
3088ef43-e171-418d-807d-fd3fd7d6a847
3
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String id=request.getParamet...
cac03689-0c1c-4efb-83de-82c8df42be42
1
public void doDelimitedMultiLine() { try { final String data = ConsoleMenu.getString("Data ", DelimitedMultiLine.getDefaultDataFile()); DelimitedMultiLine.call(data); } catch (final Exception e) { e.printStackTrace(); } }
2136d770-cd97-4c7e-8a39-1d088bc652e7
7
public boolean isAABBInMaterial(AxisAlignedBB var1, Material var2) { int var3 = MathHelper.floor_double(var1.minX); int var4 = MathHelper.floor_double(var1.maxX + 1.0D); int var5 = MathHelper.floor_double(var1.minY); int var6 = MathHelper.floor_double(var1.maxY + 1.0D); int var7 ...
f07d3edd-27b2-4a86-93f0-0713914330c8
5
public static void main(String args[]) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); int testCases = 0; while (T > 0) { T--; int N = sc.nextInt(); testCases++; int lowJumps = 0; int highJumps = 0; int ...
c2b5b295-1b54-4a4b-8e45-88b169774d20
6
@Override public void removeEdgesBetween(N from, N to) { if(containsNode(from) && containsNode(to)) { for(Edge<N> edge : edgesFrom(from)) { if(edge.to.equals(to)) { nodes.get(from).remove(edge); } } for(Edge<N> edge : edgesFrom(to)) { if(edge.to.equals(from)) { nodes.get(to).remove(...
2a70df44-5c85-4be2-a125-149f06593336
4
public void updateGroup(Group group, List<Group_schedule> list) { try { PreparedStatement ps; if(group.getId()>0) { ps = con.prepareStatement( "UPDATE groups SET name=?, level=?, capacity=?," + " stud_age=?, teacher=? WHERE id=?" ); ps.setInt( 6, group.getId() ); }else{ ...
e55fb53b-9bdc-4552-8a22-fa8bbba799ae
2
public String createListInfo(String exceptName) { String temp = "<SESSION_ACCEPT>"; for (ClientInfo node : client_list) { if (node.name.equals(exceptName)) continue; temp += "<PEER>"; temp += "<PEER_NAME>" + node.name + "</PEER_NAME>"; temp += "<IP>" + node.ip + "</IP>"; temp += "<PORT>" + node.p...
6fe45ea5-5d6d-45f2-bc4b-0ac03cd102d3
5
public synchronized void downloadLatestVersion () { FileOutputStream fos = null; try { if (remoteVersion == null) { this.updateCheck(); } plugin.getLogger().info("Downloading latest version..."); ReadableByte...
aeaafdf6-8448-4d29-a0a1-2a6daf41b6b2
0
public static void DamonMarksReport() { System.out.println("Damon's final exam mark is: " + DamonStats.Final); System.out.println("Damon's midterm exam mark is: " + DamonStats.Midterm); System.out.println("Damon's final mark for the term is: " + (DamonStats.Final* 0.75 + DamonStats.Midterm * 0.25)); }
42ea83ca-5048-4087-809a-c5f57c9da4b1
4
private static List<Shape> buscarSubparce(List<Shape> shapes, String subparce){ List<Shape> shapeList = new ArrayList<Shape>(); for(Shape shape : shapes) if (shape != null && shape instanceof ShapeSubparce) if (((ShapeSubparce) shape).getSubparce().equals(subparce)) shapeList.add(shape); return sha...
ca725df5-af5e-42a6-b8ba-b00f0921a91e
1
@Override public ArrayList<String> load() throws IOException { ArrayList<String> words = new ArrayList<String>(); InputStreamReader isr = new InputStreamReader(is); BufferedReader reader = new BufferedReader(isr); String line = reader.readLine(); while (line != null) { words.add(line); line = reader.re...
68b9d060-0995-4b00-bb42-085cdd46c876
2
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < fieldNames.length; i++) sb.append(fieldNames[i] + "\t" + types[i] + (multipleValues[i] ? "\tmultiple" : "") + "\n"); return sb.toString(); }
a59be1e8-8985-4059-98a1-f11a48256ed0
1
public boolean isAncestorToDescendent(final GraphNode v, final GraphNode w) { return (preOrderIndex(v) <= preOrderIndex(w)) && (postOrderIndex(w) <= postOrderIndex(v)); }
2feaf90a-4a27-494e-b4c2-d61596d49819
5
public static void testFileIO(){ // File I/O contained in java.io package (imported) FileInputStream infile=null; FileOutputStream outfile=null; File inf=new File("input.txt"); File outf = new File("output.txt"); try{ infile = new FileInputStream(inf); outfile = new FileOutputStream(outf); ...
7d277391-b23c-48df-83f6-c1b3b852d0a2
3
public ArrayList<String> getFailure(){ ArrayList<String> fail = new ArrayList<String>(); if(failures.contains(Signal)){ fail.add(Signal); } if(failures.contains(Break)){ fail.add(Break); } if(failures.contains(Engine)){ fail.add(Engine)...
d8fe6c32-ba5e-49af-a574-03b7cca4d7f3
9
public boolean canPlaceRoom(int roomX, int roomY, int roomWidth, int roomHeight) { if (roomX < 1 || roomY < 1 || roomX + roomWidth > sizeX - 2 || roomY + roomHeight > sizeY - 2) { return false; } for (int x = roomX; x < roomX + roomWidth; x++) { for (int y = roomY; y <...
d41c21d1-b715-46d9-ad18-b31825f5b9fa
0
@Test public void itShouldSerialize() throws Exception { MultiLineString multiLineString = new MultiLineString(); multiLineString.add(Arrays.asList(new LngLatAlt(100, 0), new LngLatAlt(101, 1))); multiLineString.add(Arrays.asList(new LngLatAlt(102, 2), new LngLatAlt(103, 3))); Assert.assertEquals("{\"coordinat...
188b4634-7eb5-43c3-9797-e6c632918719
5
private void writeSheet(XSSFSheet sheet, List list) throws IOException { int size = list.size(); int colno = 6; if (size < 2) { return; } // for (int i = 0; i < size; i++) { for (int j = 0; j < 4; j++) { sheet.createRow(i * 4 + j); } } ExcelUtils.copyEdge(wb, sheet, size); for (int i = 0...
3c37f1e7-e268-4120-9e56-42e94c5d0524
9
@Override public void run() { if (Main.DEBUG) { System.out.println("SpeakThread Started"); } Audio audio = Audio.getInstance(); while (isRunning) { try { Main.putIntoSpeakLatch.await();//wait for items to be put ...
31b45c5a-1329-4677-ab9c-0aa69296e979
3
private void loadConfig(){ File liftFolder = new File(getDataFolder().getPath() + "/elevators/"); File signFile = new File(getDataFolder().getPath() + "/signs.yml"); if(!liftFolder.exists() || !signFile.exists()){ try{ liftFolder.mkdirs(); signFile.createNewFile(); }catch(IOException e){ e...
2effa604-f5ed-4931-bd69-6f4c34f2d2fe
4
public static String toString(JSONObject jo) throws JSONException { StringBuffer sb = new StringBuffer(); sb.append(escape(jo.getString("name"))); sb.append("="); sb.append(escape(jo.getString("value"))); if (jo.has("expires")) { sb.append(";expires="); s...
7e9377b8-cdc3-42fe-a4cd-8e6ab26a6b7e
8
private Predicate[] getSearchPredicates(Root<Passenger> root) { CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); List<Predicate> predicatesList = new ArrayList<Predicate>(); String name = this.example.getName(); if (name != null && !"".equals(name)) { predic...
ba77025e-6592-426f-b12a-bbc3eeef452d
7
private void createTextField() { textField = new TextField(getString()); textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2); textField.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) { if (t.getCod...
4c53a161-5717-4604-a878-6e5d3c221dff
3
@Override public void keyTyped(KeyEvent e) { int s = e.getKeyChar()-48; if(s<=0 || s>9) { System.out.println("input is not 1-9"); } else { Button b = (Button) e.getComponent(); String right = b.getLabel().trim(); int right2 = Integer.parseInt(right); if(right2 == s) { b.setLabel(String.valueO...
31d183da-987e-4be3-8e05-5ac2c35eb165
2
public static void createConfig() { File dir = new File(System.getProperty("user.dir") + "/config"); // Create save directory if(dir.mkdir()) { try { saveConfig(); } catch(Exception e) { System.err.println("Config file failed to be created"); e.fillInStackTrace(); } System.out.print...
f1669b8b-35cc-4486-9db2-47b8dd777758
1
public static void clearCache(){ for(String id : cacheClips.keySet()){ stop(id); cacheClips.get(id).close(); } cacheClips.clear(); System.out.println("[SoundManger] Clearing cache."); }
71f3f2d1-d993-4786-aa6b-2444477cae33
9
public String minWindow(String s, String t) { Map<Character, Integer> map = new HashMap<Character, Integer>(); for (char c : s.toCharArray()) { map.put(c, 0); } for (char c : t.toCharArray()) { if (map.containsKey(c)) { map.put(c, map.get(c) + 1); } else { return ""; } } int sta...
1d7e8ca1-2481-4a9a-8360-7ec23769da3a
8
private void lstCommandeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstCommandeMouseClicked // TODO add your handling code here: article.removeAllElements(); articleLoiseau.removeAllElements(); int indice = 0; for (Commande c : lesCommandes) { if (l...
ab736658-1826-4fdf-b37c-9d96fad4e222
9
public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // -------- // Handle email sending // ------- // If a valid email address is provided if (req.getParameter("email") != null && req...
9f2c563c-a02a-4c6b-acec-6f5fa98ba3e1
0
public void setConcurrent(){ this.concurrent = true; }
b068dad7-b6f4-4147-a4a8-791ca08bcb94
4
@Override public void actionPerformed(ActionEvent e) { boolean global = tb.getSelected(); boolean state = this.selected; boolean result = false; if (!global) { tb.setSelected(); this.setSelected(true); result = true; } else { if (state) { this.setSelected(false); tb.setSelected()...
d04e4db5-f39c-4162-9c2b-dc0c338c5a41
4
@Override public float millisecondsPlayed() { switch( channelType ) { case SoundSystemConfig.TYPE_NORMAL: if( clip == null ) return -1; return clip.getMicrosecondPosition() / 1000f; case SoundSystemConfig.TYPE_STREAMING:...
ef4c80b6-50ad-4c08-b175-a2fb09a255ba
8
@Override public Void visitIndent(IndentToken token) { assertExpected(token); // If we're dealing with a comment, just smile and wave if (tokens.peek().getType() == TokenType.COMMENT) { setExpected(TokenType.COMMENT); return null; } /...
8fad66c4-8c6b-46c8-9747-08241d5a95e9
7
@Override public void solve() { double A = 0, B = 0, C = 0, D = 0; updateRightWeights(); updateLeftWeights(); for (Term t : leftTerms) { if (t instanceof XTerm) { A += ((XTerm) t).coefficient; } else if (t instanceof Constant) { C += t.weight; } } for (Term t : rightTerms) { if (t inst...
0f34d6ab-5c5a-456b-bfc9-e1b0fb8ed2e7
7
public void setEditValue(int n, EditInfo ei) { if (n == 0) { inductance = ei.value; } if (n == 1) { ratio = ei.value; } if (n == 2 && ei.value > 0 && ei.value < 1) { couplingCoef = ei.value; } if (n == 3) { if (ei.ch...
3dac74b2-36e7-406c-92c3-1cba7fc93dde
5
public void dmgUpdate(int i, int j, int k, int l) { Obstacle[][] obs = level.getObstacles(); int dmg = 0; if ((y+height)/Obstacle.getHeight()>=0){ // Could be out of the map while (l<height){ int tmpK = k; int tmpJ = j; while(tmpK<width && i>=0){ dmg += obs[i][tmpJ].getDmg(); // if (obs[i]...
914c68a1-1d97-4c1d-8166-0537e4b01f87
5
public boolean checkMethodInvocation( Method method ) { if( method == null ) return false; // result not specified // Method must be public if( ! Modifier.isPublic(method.getModifiers()) ) return false; return method.getName().equals("doAnything") || method.getName().equals("doSomething"...
241b56ad-b5a2-49d2-bb73-862eaf0814e6
6
public Matrix subtract(Matrix a) { if (a == null) { return null; } if ((!this.isJagged && !a.isJagged) && this.sameOrder(a)) { double[][] new_elements = new double[this.rowCount][this.columnCount]; for (int row = 0; row < this.rowCount; row++) { ...
7b0db98a-41c5-40d0-892c-038210112f94
7
public Path obtainRevisionContent(long timestamp) { // Check first if the specific revision is a binary revision. If it is, we're done. Path specificRevision = getRevisionInfo(timestamp); if(!FileOp.isPlainText(specificRevision)) { logger.debug("Revision for file " + file.toString() + " (" + timestamp + ") ...
0b9a397a-0f0f-4e7b-9b31-dcf6786306e9
7
public void playerLeaveWorld(World world, Player player){ List<Player> playersInWorld = world.getPlayers(); if (playersInWorld.size() < 1 && !plugin.doNotUnload.contains(world.getName())){ Bukkit.getServer().unloadWorld(world, true); String worldName = world.getName(); for (String worldN : plugin.mainWorld...
3546ea94-e1d1-4fbe-a822-269cfce4fa2b
1
protected void updateBall() { ball.move(); ball.bounceOffWalls(isEndless); ball.bounceOffPaddle(paddle1, player1); ball.scorePoint(player1, player2, isEndless); if (!isEndless) { ball.bounceOffPaddle(paddle2, player2); } ball.teleport(isTeleport, telep...
718d9910-a4cc-4f15-ae09-9c4bd8425c61
2
private void zoomtoRouteArea() { final double fromNodeX = fromNode.getxCoord(); final double fromNodeY = fromNode.getyCoord(); final double toNodeX = toNode.getxCoord(); final double toNodeY = toNode.getyCoord(); final double xDistance = Math.max(fromNodeX, toNodeX) - Math.min(fromNodeX, toNodeX); fi...
c630edf6-6978-4396-92d5-0cd880938cd3
6
private Map<SecondLevelId, Object> getValue() { while(true) { if (firstVal == null && !firstCursor.hasNext()) { return null; } if (firstVal == null) { firstVal = firstCursor.next(); secondCursor = iterable.iterator(); ...
6f9c4587-8f86-4a8d-bc8d-2d10876fd397
8
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost,msg); if(!(affected instanceof MOB)) return; final MOB mob=(MOB)affected; if((msg.amISource(mob)) &&(msg.tool()!=this) &&(!CMath.bset(msg.sourceMajor(),CMMsg.MASK_CHANNEL)) &&((CMath.bset(msg.sour...
6fc02202-fb89-4a13-b14a-a79144fdf78b
4
public static <T extends Comparable<? super T>> int bestPivotStrategy(ArrayList<T> list, int start, int end){ int middle = (end + start)/2; if(list.get(middle).compareTo(list.get(start)) < 0){ normalSwap(list, start, middle); } if(list.get(end).compareTo(list.get(start)) < 0){ normalSwap(list, start, end...
7f79edc3-8466-44ee-8e6d-e9db6b70fdb5
6
public static String downloadToString(String url) { URL website = null; try { website = new URL(url); } catch (MalformedURLException e) { System.out.println("Couldn't connect to "+url); return null; } URLConnection connection = null; try { connection = website.openConnection(); } catch (IOExc...
ccb29beb-37c2-475d-9b66-18e1813d6000
6
public boolean isIdentity(){ boolean test = true; if(this.numberOfRows==this.numberOfColumns){ for(int i=0; i<this.numberOfRows; i++){ if(this.matrix[i][i]!=1.0D)test = false; for(int j=i+1; j<this.numberOfColumns; j++){ if(this.matri...
75707500-805e-49ff-b4ff-b66632c5afc3
7
private void barInput(int time){ //draw a moving bar watch out for out of boundary int length=8; for(int bar=0; bar<time/20; bar++){ int intercept=20*bar; for(int i=intercept;i<time;i++){ for(int j=0;j<length;j++){ if(i+j-intercept<column && i+j-intercept>=0){ output.get(i).add(new int[]...
2b3e9d9f-3988-4988-92b8-584f99a28a81
9
public static Row copyRow(Sheet sheet, Row sourceRow, int destination) { Row newRow = sheet.createRow(destination); // get the last row from the headings int lastCol = sheet.getRow(0).getLastCellNum(); for (int currentCol = 0; currentCol <= lastCol; currentCol++) { Cell newCe...
476685ef-2daa-4543-a93c-fc1562a0b10c
9
@SuppressWarnings("unused") @Test public void testGlyphIterator() { //Create a few regions with text lines, words and glyphs Page page = new Page(); PageLayout pageLayout = page.getLayout(); TextRegion r1 = (TextRegion)pageLayout.createRegion(RegionType.TextRegion); TextLine t11 = r1.createTextLine(); Wor...
0137e048-d105-4789-bafe-53e824354106
9
public void run() { try { boolean running = true; while (running) { try { String line = null; while ((line = _breader.readLine()) != null) { try { _bot.handleLine(line); ...
4731f152-ba98-4fc9-b2d8-0525da36f695
8
public static boolean isLeftButton(MouseEvent e, Boolean ctrlDown, Boolean shiftDown, Boolean altDown) { return (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0 && (e.getModifiersEx() & MouseEvent.BUTTON2_DOWN_MASK) == 0 && (e.getModifiersEx() & MouseEvent.BUTTON3_DOW...
cf5a0aee-f76c-42ce-8352-bdc0dbf81e5b
1
private void initContent() { setBounds(100, 100, 400, 300); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); tabbedPane = new JTabbedPane(JTabbedPa...
efa83fa6-ba58-47bd-97b8-5fa25e60972f
9
public void GoRight(WumpusPolje[][] wumpusWorld) { WumpusPolje oce = tmpPolje; tmpPolje = wumpusWorld[tmpPolje.m_x][tmpPolje.m_y + 1]; obiskanaPolja.add(tmpPolje); tmpPolje.m_oce = oce; this.m_points += WumpusRating.action; WumpusHelper.Print(WumpusSteps.PremikNaPolje(tmpPolje.m_x, tmpPolje.m_y)); /...
ec11e122-913c-4053-bdf2-cc633662ec56
5
static final char method462(byte i, int i_20_) { anInt5216++; int i_21_ = 0xff & i; if ((i_21_ ^ 0xffffffff) == -1) throw new IllegalArgumentException("Non cp1252 character 0x" + Integer.toString(i_21_, 16) + " provided"); if ((i_21_ ^ 0xffffffff) <= -129 && i_21_ < 160) { int i_22...
f2133e05-4288-4e23-995d-fa42e6a2dd26
1
protected static int toUShort(final byte b1, final byte b2) { int x = (short) (Instruction.toUByte(b1) << 8) | Instruction.toUByte(b2); if (x < 0) { x += 0x10000; } return x; }
d21e04d0-f6a5-41ca-8d0b-281f79e1a3df
6
public int trap(int[] A) { // Start typing your Java solution below // DO NOT write main() function int max = 0; int n = A.length; for (int i = 0; i < n; i++) { if (A[i] > A[max]) max = i; } int tmpH = 0; int res = 0; for (int i = 0; i < max; i++) { if (tmpH > A[i]) res += (tmpH - A[i]);...
587e41f2-de03-41b5-9abf-4fd972ed58a8
3
public static void main(String args[]) throws FileNotFoundException { Scanner in = new Scanner(System.in); System.out.println(">Enter your new file name:"); String fileName = in.nextLine() + ".txt"; boolean exist = false; String[] files = FileLister.getFilesArrayString(); for (int i = 0; i < files.length...
80c4dc98-d3d0-4ed4-9ff5-28ed7cc8c156
5
double getKth(int[] a, int[] b, int k) { int m = a.length; int n = b.length; if (n == 0) return a[k - 1]; if (m == 0) return b[k - 1]; if (k == 1) return Math.min(a[0], b[0]); // divide k into two parts int p1 = Math.min(k / 2, m); int p2 = Math.min(k - p1, n); if (a[p1 - 1] < b[p2 - 1]) ...
7edb61e2-ed60-4f87-9d03-90717413bfd5
6
@Override public void keyTyped(KeyEvent e) { JTextField f = (JTextField) e.getSource(); // Only accept numbers and decimals in the average mark JTextField if ( (!Character.isDigit( e.getKeyChar() )) && (e.getKeyChar() != '.') ) { e.consume(); // Set and display a helpful toolt...
f26519d7-59c1-425e-98a3-e633fa4221e0
7
public int trap(int[] height) { int water = 0; if (height.length < 3) { return water; } // find max height and its position int maxHeight = 0; int maxHeightPos = 0; for (int i = 0; i < height.length; i++) { if (height[i] > maxHeight) { maxHeight = height[i]; maxHeightPos = i; } } ...