method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
88dd2261-70ee-4a17-aba4-39a2728e2392
2
private void checkFlush() { for (int i = 0; i < 4; i++) { if (getNumberOfSuits(i) == 5) { myEvaluation[0] = 6; myEvaluation[1] = hand[0].getValue(); myEvaluation[2] = hand[4].getValue(); myEvaluation[3] = hand[0].getValue(); break; } } }
67b73f7c-cf37-49ed-aa52-4e39fa2d2d83
9
private static void quickSort(ArrayList<PERange> array, int start, int end) { int i = start; // index of left-to-right scan int k = end; // index of right-to-left scan if (end - start >= 1) { PERange pivot = array.get(start); while (k > i) { while (array.get(i).getBegin() <= pivot.getBegin() ...
5b654af2-0591-4792-80c2-733d14c98d53
4
public static int getGreatesProdDownRightDiagonal(int[][] arr, int maxDigits, int columns, int rows) { int prod = 0; for(int i = 0; i < (rows-(maxDigits - 1)); i++) { int tmp = 0; for(int j = 0; j < (columns-(maxDigits-1)); j++) { int tmpprod = 1; for(int k = 0; k < maxDigits; k++) { tmpprod = tm...
4a55ffa3-45ff-4f5a-9d31-0a5690092a89
3
public static void removeLibrary(Class<?> libraryClass) throws SoundSystemException { if (libraries == null || libraryClass == null) return; libraries.remove(libraryClass); }
6f592275-2e64-4f32-99fc-a6a32b984c6b
4
public static void main(String[] args) throws Exception { String filename = args[0].trim().equals("") ? "A.txt" : args[0]; Scanner inp = new Scanner(new java.io.File(filename)); System.out.println("Lecture de données :" + filename); init(inp); tour(); if...
b656a40e-ca0d-4a9e-aca8-f848e9757bd5
4
public void replaceTransition(Transition oldTrans, Transition newTrans) { if (!getTransitionClass().isInstance(newTrans)) { throw new IncompatibleTransitionException(); } if (oldTrans.equals(newTrans)) { return; } if (transitions.contains(newTrans)) { removeTransition(oldTrans); return; } if (...
0dffeafc-b4bf-409e-a564-f1d94fba1656
5
public void checkUp(Node node) { this.up = -1; // reset value to -1 // Prevent out of bounds (negative coordinates) if((node.getX()-1) >= 0) { if(checkWall(new Node( (node.getX()-1), (node.getY()) ))) { if(this.closedNodes.size()==0) this.up = 1; else { for(int i = 0; i < this.closedNodes.siz...
71e3e982-ff8d-4a3a-b660-7aea9077f840
9
private void initializeTextFields() { mNameHeading = new JTextField(); mNameHeading.setBounds(478, 22, 491, 14); panel.add(mNameHeading); mNameHeading.setEnabled(false); mNameHeading.setForeground(new Color(0, 0, 0)); mNameHeading.setText("NAME"); mNameHeading.setToolTipText(""); mNameHeading.setEdit...
1633b94d-82be-47f4-b269-6ad46c9babee
8
public static void drawObjects(Graphics g){ if (left) xs -= 1; else if (right) xs += 1; if (up) ys -= 1; else if (down) ys += 1; if (drag){ checkMouse(); } g.setColor(PlatformManager.floorColor); // draw dynamic objects for (Rectangle p : platforms) g.fillRect(p.x - xs, p.y - ys,...
f34d1e2f-6ca6-4975-9877-1418ce9f4aa1
6
@Override protected void decode( ChannelHandlerContext ctx, ByteBuf in, List<Object> out ) throws Exception { int byteSize = in.readableBytes(); if(byteSize == 0 || !ctx.channel().isOpen()) return; int id = Utils.readVarInt(in); int conState = ctx.channel().attr(Utils.connectionState).get(); switch(c...
2ef17e48-99a1-40e5-a0cb-14d1df0afcb1
6
public static void CDC_pairwise(CDCRelation p, boolean connected) { int count=0; //int[] c = new int[511]; //counters int i,j; //first we calculate all the valid CDC relations, stored in valid_rel[] List<CDCRelation> valid_rel = new ArrayList<CDCRelation>(); CDCRelation r = new CDCRelation(0); r.connect...
46e0bc3b-57fe-43d7-8fef-1c57d4a8f884
8
public static boolean export2FormatedJsonFiles(final String date, final String[] labels, final String[] labelsStat, final String text){ //Check if skip creating file if( labels.length == 0 && (text == null || text.trim().length() == 0) ){ return true; } final String checked ...
64354d61-77e0-43d4-bdb2-15457dc38b4d
9
public static long convertToLong(String addr) throws Exception { String[] octs = addr.split("\\."); if( octs.length != 4 ){ throw new Exception("Invalid address format."); } long octA = Long.parseLong(octs[0]); long octB = Long.parseLong(octs[1]); long octC ...
ea7a7d3c-2576-49ee-92b9-dc6a5cf4b4b4
6
public void expand() { computedIntervals++; Interval interval = q.poll(); double a = interval.a; double b = interval.b; double mid = (a + b) / 2; Interval interval1 = new Interval( a, mid, p, usedFormula ); Interval interval2 = new Interval( mid, b, p, usedFormula ); if ( (!interval1.sing...
4a9e722c-cb13-4533-bba4-3f1db7ed3b1e
8
public int getEnemiesLasersOnField(){ int enemyLaserCount = 0; for(Enemy enemy : munchkins){ if(enemy != null){ for(int i = 0; i < enemy.lasers.length; i++){ if(enemy.lasers[i] != null){ enemyLaserCount++; } } } } for(Enemy enemy : ufos){ if(enemy != null){ for(int i =...
5796c74d-5f1c-4f95-91a6-6da04c2204c4
4
public void limpiarBD() { Query personas = actualizador.verificarConexion().createQuery("Select persona from Persona persona"); List<Persona> idsPersona = personas.getResultList(); for (Persona persona : idsPersona) { actualizador.bajaDePersona(persona.getCi()); } Que...
54e6c22f-5269-4c23-8290-6f6a732c43a2
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ParkBoy other = (ParkBoy) obj; if (code == null) { if (other.code != null) return false; } else if (!code.equals(other.code)) return ...
fb7bacaf-e1b3-420f-a443-2270b3bae029
6
private int jjMoveStringLiteralDfa1_0(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(0, active0); return 1; } switch(curChar) { case 32: return jjMoveStringLiteralDfa2_0(active0, 0x40L); case 104: ...
8a923968-2446-4a14-948b-ec9e06178d56
8
public static void fillIslands() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { Index index = new Index(i, j); stack.push(index); String tempPath = ""; int tempWeight = 0; while (!stack.isEmpty()) { index = stack.pop(); if (islands[index.getRow()][index.getCol()] > 0) ...
e2ca8605-5e1a-4941-a22a-b3e9a24a028d
3
private void populateCyrillicComboBoxes() { DefaultComboBoxModel cyrillicCapitalLetterComboBoxModel = new DefaultComboBoxModel(); // Add the standard Cyrillic (Russian) characters to the combo for (int i = 0x0410; i < 0x042F; i++ ) { char a = (ch...
f80415a2-0618-4810-9681-218dd0b9adce
9
TranslationFinder(Elements subSectionTitles, Document document) { Elements transArray = document.getElementsByAttributeValueContaining("data-destinationLanguage", "אנגלית"); this.JSONTransArray = new JSONArray(); for (Element translation : transArray) { this.JSONTransArray.put(tran...
be412956-e254-45c2-8066-833393e3e99a
2
public float setBand(int band, float neweq) { float eq = 0.0f; if ((band>=0) && (band<BANDS)) { eq = settings[band]; settings[band] = limit(neweq); } return eq; }
32330c9c-95f5-41b4-800c-f721ac4b97bf
4
private void init() { JPanel content = new JPanel(); content.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); JPanel spacerPanel = new JPanel(); spacerPanel.setLayout(new GridLayout()); if (m_allowAdd) { JButton addButton = n...
2f3fa1cd-0321-41dc-8c8d-e84fd40c18b6
4
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Map other = (Map) obj; if (this.noOfRows != other.noOfRows) { return false; } ...
fd9d9b8e-191b-47f2-b901-1f65abccd88f
1
@Override public QuadTree getQuadTree(){ if (QT == null) { initDataStructure(); } return QT; }
ba4ca138-98cf-42af-9f05-f4f8296301e1
9
private void randomizeBackground(Background background) { int j = 256; for(int k = 0; k < anIntArray1190.length; k++) anIntArray1190[k] = 0; for(int l = 0; l < 5000; l++) { int i1 = (int)(Math.random() * 128D * (double)j); anIntArray1190[i1] = (int)(Math.random() * 256D); } for(int j1 = 0; j1 < 20; ...
8cf1fe36-d61d-406c-8b7c-e959c0bab6b3
7
protected static Ptg calcCount( Ptg[] operands ) { int count = 0; for( Ptg operand : operands ) { Ptg[] pref = operand.getComponents(); // optimized -- do it once!! -jm if( pref != null ) { // it is some sort of range for( Ptg aPref : pref ) { Object o = aPref.getValue(); if( o != null...
06bb829c-4ef1-4e19-80af-a31379f0432c
6
public void testFilteredDocIdSet() throws Exception { final int maxdoc=10; final DocIdSet innerSet = new DocIdSet() { @Override public DocIdSetIterator iterator() { return new DocIdSetIterator() { int docid = -1; @Override public int d...
7cc8212e-637e-4461-8073-8e156bc3e4ef
3
public static Homework_database read(int value) { Homework_database homeworkreturn = null; { try { RandomAccessFile raf = new RandomAccessFile(login_area.setURL.getUrl(), "rw"); raf.seek(raf.length()); raf.seek(538*value); Timetable_main_EDIT.delete = raf.read(); raf.seek(ra...
615324c6-be53-4f64-a3c6-95a8d6edb510
0
private static String getArrayTableName(String tableName, String field) { return tableName + "_" + field; }
f238b78d-310c-4136-a7e8-5902d7133eef
2
public void testPropertyPlusNoWrapHour() { LocalTime test = new LocalTime(10, 20, 30, 40); LocalTime copy = test.hourOfDay().addNoWrapToCopy(9); check(test, 10, 20, 30, 40); check(copy, 19, 20, 30, 40); copy = test.hourOfDay().addNoWrapToCopy(0); check(copy, 10, ...
a856e6fe-8c38-4a0e-81df-9f9508a7960f
9
@Override public <T extends Comparable<? super T>> int search(T[] array, T key) { if (array == null) throw new NullPointerException("argument array is null"); if (key == null) throw new NullPointerException("argument key is null"); // Make sure every element is not n...
b4561396-f86f-4020-b7fc-122cb421eeda
2
public void resize() { int image[] = new int[trimWidth * trimHeight]; for (int offY = 0; offY < height; offY++) { for (int offX = 0; offX < width; offX++) { image[(offY + offsetY) * trimWidth + (offX + offsetX)] = pixels[offY * width + offX]; } } pixels = image; width = trimWidth; height = trimHei...
eeedc69e-8198-4d05-85e4-aaebf664c0a3
4
public void save(String filename) { File file = new File(filename); String suffix = filename.substring(filename.lastIndexOf('.') + 1); // png files if (suffix.toLowerCase().equals("png")) { try { ImageIO.write(offscreenImage, suffix, file); } catch (IOException e...
eb6c2598-0a31-48a5-a309-1e16d12d41c6
2
@Override protected void process(List<RegistrationState> l) { for (RegistrationState ls : l) { if (ls.isSuccess) { this.cp.setVisible(false); JOptionPane.showMessageDialog(cp, "Username successfully registered", "Success", JOptionPane.INFORMATION_...
18d17490-20ab-4bc8-b896-8ce7ae304f1d
1
public SwingWorker() { final Runnable doFinished = new Runnable() { public void run() { finished(); } }; Runnable doConstruct = new Runnable() { public void run() { try { setValue(construct()); } catch (Exception e) { ...
30f91e82-db43-4b57-8e26-206a5e295d1e
1
public void setFloors(int value) { if (value <= 0) { throw new IllegalArgumentException( "Illegal number of floors, must be positive"); } else { floors = value; weight = calculateTotalWeight(); } }
13ff21e7-3434-4e7d-9fec-b31e422cf951
7
public void update(double delta) { frameCount++; if(frameCount >= program.framerate) { secondFlash = !secondFlash; frameCount = 0; } //Camera Zoom canvas.camera.zoom(Input.getMouseScroll() / 10.0); if(canvas.camera.getScale() < maxZoom) canvas.camera.setScale(maxZoom); if(canvas.camera.getSca...
b6dab465-1020-48fd-b400-fdbd6e529875
7
public static void main(String[] args) { // Exercício 03 Scanner entrada = new Scanner(System.in); // Esse é o Sacanner que captura dados do teclado. Para utilizá-lo é preciso importar a classe java.util.Scanner System.out.println("Digite um número: "); // Perguntamos um número...o programa vai ...
29963ada-a207-47a0-8cb0-1c99e160a6c4
6
public boolean canUpdate(long isbn, Book b, Statement st, ResultSet rs) throws SQLException { //Check if any authors will be left without a book. ArrayList<Author> leftAuth = getAuthors(isbn, st, rs); if(b.getAuthor() != null) leftAuth.removeAll(b.getAuthor()); //Test if any authors that are left out are onl...
cd2db2bd-f62b-4822-96c5-510fa94f0f4b
8
public boolean remove_special(String s,String p,String o,String s_type,String o_type) { String ret; deb_print("<remove_special>\n"); deb_print("Perform the QUERY\n"); ret = queryRDF( s.equals("*")?null:s ,p.equals("*")?null:p ,o.equals("*")?null:o ,s_type ,o_type); deb_print("KP-CORE MESSA...
1d9cd0ac-6b1c-42ed-a0c6-cc04e5566c93
9
public static LinkedList<File[]> recursiveConfigs(File folder, boolean rec) { LinkedList<File[]> files = new LinkedList<File[]>(); if(folder.exists() && folder.isDirectory()) { for(File f : folder.listFiles()){ if(f.isFile()){ if(f.getName().endsWith(".pc")) { files.add(new File[]{f}); } ...
91f1ef2d-eace-4c16-b21d-81a042321c0d
4
private static int[] getNeighbours(ImageData imageData, int mx, int my, int y, int x) { int x0 = x - 1; int y0 = y - 1; int x2 = x + 1; int y2 = y + 1; x0 = x0 < 0 ? 0 : x0; x2 = x2 > mx ? mx : x2; y0 = y0 < 0 ? 0 : y0; y2 = y2 > my ? my : y2; int[] pixels = new int[9]; pixels[0] = imageData.getPixe...
5ad478d9-df22-402e-826a-1ecf3e1ed9c9
6
public void simulate() throws IOException{ System.out.format("### %s ###\n",heuristic.type.toString()); boolean moreLinesToRead = true; if (debug_f) print_debug_header(); while (true) { commit(); issue(); ...
f4841117-bb0a-4c5a-b207-1b951df9266e
1
protected Color getNodeColor(TreeNode node) { return isSelected(node) ? selectedColor : deselectedColor; // Color color = super.getNodeColor(node); // return isSelected(node) ? color.darker() : color; }
c3f72b73-8a4b-4718-bb01-aee02f8f7332
3
@RequestMapping(value = "/sign_in") public String custVerification(Model m,HttpServletRequest request, HttpServletResponse response,HttpSession session) { String username = request.getParameter("custID"); System.out.println("Customer user name : "+username); String password = request.getParameter("password"); ...
164d82e8-9392-4274-8d67-fe752ef18d17
4
public boolean isSolid(float x, float y) { if (x < 0 || x / tileSize >= width || y < 0 || y / tileSize >= height) return false; return getTileSolid(tiles[(int) (x / tileSize) + (int) (y / tileSize) * width]); }
5f785a5f-9aff-429f-ad5c-a24c35bd4a03
6
boolean anyResultMatches(String transcriptId, Variant seqChange, ChangeEffects changeEffects, boolean useShort) { for (ChangeEffect chEff : changeEffects) { String resStr = chEff.toStringSimple(useShort); Transcript tr = chEff.getTranscript(); if (tr != null) { if ((transcriptId == null) || (transcriptI...
10226bc8-7026-4702-b1c9-49b969997c9f
2
public static void main (String args[]) { Map<String, String> map = new HashMap(); fillData(map); String[] strings = keysAsArray(map); for (String string : strings) { System.out.println(string); } System.out.println(""); List<String> list = keysAsLis...
cd2eb532-6794-43a1-a3f9-5a823f7fb273
2
public void render(Graphics2D g2d) { g2d.drawImage(image, (int) x, (int) y, null); if (x < 0) g2d.drawImage(image, (int) x + Game.WIDTH, (int) y, null); else if (x > 0) g2d.drawImage(image, (int) x - Game.WIDTH, (int) y, null); }
aca39430-5c63-4b20-bcaf-edc0e14e8021
5
@Override public void doAction(String value) { char choice = value.toUpperCase().charAt(0); do { switch (choice) { case 'M': return; case 'D': System.out.println("You are not carrying any logs"); ...
8197f5ae-7846-4fba-aa00-ec7cb4510548
0
public int run(){ sort(array); return 0; }
dcc01244-6021-4875-b4b7-db0e559e54ae
7
public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) { SpringLayout layout; try { layout = (SpringLayout)pa...
1f918780-a522-4a8b-834d-ba565e813180
7
public static void main(String[] args) { if(args.length >= 1) { try { int servers = Integer.parseInt(args[0]); String mIP = (args.length >= 2) ? args[1] : "239.23.12.11"; InetAddress address = InetAddress.getByName(mIP); int basePort = ...
8f24132c-7429-474b-9c88-0d912291fd86
4
public ArrayList<Integer> checkCollisions() { ArrayList<Integer> ints = new ArrayList<Integer>(); for (Rectangle r : getGame().getCollisionRecs()) { if (new Rectangle((int) (getBounds().x + 10 - getVeloX()), getBounds().y + 14, getBounds().width - 20, getBounds().height - 14).intersects(r)) ints.add(1);...
d5df3d8b-c677-4fc4-a657-95c175d9a3ca
3
public void setVar(PVar node) { if(this._var_ != null) { this._var_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); } ...
316fbdaa-624e-471e-bb90-9b2af2d4066d
6
public static long[] calculatePalette(long[] colors, int numBuckets) { ArrayList<Bucket> buckets = new ArrayList<>(); Bucket initialBucket = new Bucket(); for (long color : colors) initialBucket.add(color); buckets.add(initialBucket); while (buckets.size() < numBuckets) { int maxI = -1;...
7344b295-fb94-45d1-93fa-7da0720f127c
7
public void showCards() { playercards = GameData.CURRENT_PLAYER.getPlayerCards(); for (int i = 0; i < playercards.size(); i++) { if (i == 0) { cardone.setBounds(10, 10, 125, 195); cardone.setIcon(playercards.get(i).getCardIcon()); } else if (i == 1) { cardtwo.setBounds(135, 10, 125, 195); ...
344c54e6-4ac4-43a3-8466-d2c5a01cfc2d
2
public void testGetCars() { TimeServer ts = new TimeServerLinked(); VehicleAcceptor r = new VehicleAcceptorObj(); Vehicle c = VehicleFactory.newCar(ts, r); r.accept(c); Assert.assertTrue(r.getCars().size() == 1); Assert.assertTrue(c.equals(r.getCars().get(0))); for (int i=0;i<10;i++) { r.ac...
9f30a716-f97e-43e2-bbe0-9db8bef38d1a
8
public int getFileCount(int idx) throws Exception{ Connection conn = null; PreparedStatement pstmt = null; ResultSet rs =null; int result = 0; try{ conn = getConnection(); pstmt = conn.prepareStatement("select count(*) from board where idx=?"); pstmt.setInt(1, idx); rs = pstmt.executeQuery(); i...
93ac6a39-fa6c-4c57-bffd-3b8a26f6e60e
7
@Override public void unInvoke() { if(canBeUninvoked()) { if(affected instanceof MOB) { final MOB mob=(MOB)affected; final Room room = CMLib.map().getRoom(fromRoom); final int direction=this.direction; if((messedUp)||(direction<0)||(fromRoom==null)) { commonTell(mob,L("You've ruined...
076f0735-d575-4ed0-abd8-9dbc4797757a
9
public void doCommand(String messageData, String nick) { String[] str = messageData.split(" "); for (int i = 0; i < commands.size(); i++) { if (str[0].startsWith(commands.get(i).getName())) { if (commands.get(i).userNeedsToBeOp() && ServerMain.uh.isOp(nick)) { try { ServerMain.EVENT_BUS.post...
ccd1d1e0-8da1-47f8-8126-7d96a2808be0
7
protected double[][] calculateAssociationMatrix() { if( this.associationMatrix != null) return this.associationMatrix; if( this.clusterizedTrajectories == null) throw new RuntimeException("Error: impossible calculates the association matrix after the final calculation call"); NodeIndexing nodeIndexing...
bea8e98b-b34b-4fee-8a86-4313a819b4f2
9
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TransformedIterator<?, ?>)) { return false; } TransformedIterator<?, ?> that = (TransformedIterator<?, ?>) obj; return function.equals(that.fun...
dfcae319-e228-40f8-b019-ae42a0f0e5fe
5
private void updateGate(String A, String B, String C, String D, String E, String Y) throws InvalidPinException { if (this.isLow(A) && this.isLow(B) && this.isLow(C) && this.isLow(D) && this.isLow(E)) { this.setPin(Y, Pin.PinState.HIGH); } else { this.setPin(Y, Pin.PinState.LOW); } }
2909cc7e-f038-4b55-9646-4f69612e5b12
9
@Override public void onMouseMove(MouseMoveEvent event) { if (supportsTouchEvents) { return; } Widget sender = (Widget) event.getSource(); Element elem = sender.getElement(); // TODO optimize for the fact that elem is at (0,0) int x = event.getRelativeX(elem); int y = event.getRelati...
db69a816-9210-4ac7-a8d1-ac35d85dae2f
6
private static Location newLocation(Player player, Location loc, BorderData border, boolean notify) { if (Config.Debug()) { Config.LogWarn((notify ? "Border crossing" : "Check was run") + " in \"" + loc.getWorld().getName() + "\". Border " + border.toString()); Config.LogWarn("Player position X: " ...
07c2ffba-2bb3-43a8-9d90-c03ec1ec5fb2
0
public void setTempo(int hora, int minuto, int segundo) { setHora(hora); setMinuto(minuto); setSegundo(segundo); }
85b4ac43-9743-4377-9b0f-b35f5867b2f0
8
public int getArticleCount(int area) throws Exception{ Connection conn = null; PreparedStatement pstmt = null; ResultSet rs =null; int result = 0; try{ conn = getConnection(); pstmt = conn.prepareStatement("select count(*) from travel where area=?"); pstmt.setInt(1, area); rs = pstmt.executeQuery(...
a37452c0-e1ed-4591-bd32-523f08f674ca
4
private void findUser(SessionRequestContent request) throws ServletLogicException { Criteria criteria = new Criteria(); criteria.addParam(DAO_ID_USER, request.getParameter(JSP_SELECT_ID)); User user = (User) request.getSessionAttribute(JSP_USER); if (user != null) { ClientTy...
ddbe44bd-b394-4f38-9e1a-7f6dc80c14ae
1
public void setStatus(SeanceStatus status) { if (status == null) { throw new IllegalArgumentException("Status shouldn't be NULL"); } this.status = status; }
231b31f6-0b41-4fa3-833e-f4833a9305f5
2
private String lireFichier(String chemin_ficher) throws FileNotFoundException, IOException { contenu_fichier = new StringBuilder() ; f = new File(chemin_ficher) ; if(!f.getName().endsWith(".plic")) throw new ArrayIndexOutOfBoundsException() ; BufferedReader b = new BufferedRe...
d2297ae2-31c3-424a-a284-77f59853c966
0
public RaiseTilter() { requires(Robot.tilter); }
6a24e9f7-3e65-47ae-813a-5a1774259dd4
9
private void checkScoutValidity(StrategyBoard gameBoard, PlayerColor currentTurn, PieceType movePiece, Location moveFromLocation, Location moveToLocation) throws StrategyException { final int distance = moveFromLocation.distanceTo(moveToLocation); if (gameBoard.getPieceAt(moveToLocation) != null && distance...
21a2e7cc-27e7-40cc-857e-4ff629800917
7
private void calculateLineHeight() { lineHeight = maxAscent = 0; // Each token style. for (int i=0; i<syntaxScheme.getStyleCount(); i++) { Style ss = syntaxScheme.getStyle(i); if (ss!=null && ss.font!=null) { FontMetrics fm = getFontMetrics(ss.font); int height = fm.getHeight(); if (height>lin...
25136f51-66a8-4556-adfd-68d4fb1a212f
7
public static void main(String[] args) throws Exception { BufferedWriter writer = new BufferedWriter(new FileWriter(new File( "c:\\temp\\SimulatedSpuriousCorrelationsAllGaussian.txt"))); writer.write("category\tabundant1\tlow1\tlow2\tresampledAbundnat1\tresampledLow1\tresampledLow2\tresampledRatio1\tresample...
4a6d51a9-4244-4e24-9a76-ef6e00b76157
5
public void buffmsg(Message msg) { String name = msg.string().intern(); synchronized (buffs) { if (name == "clear") { buffs.clear(); } else if (name == "set") { int id = msg.int32(); Indir<Resource> res = sess.getres(msg.uint16()); ...
7230899d-40a9-4913-b04d-7212c05a0756
2
public void run() { if (player!=null) { try { player.play(); } catch (JavaLayerException ex) { System.err.println("Problem playing audio: "+ex); } } }
9d6b3e04-d5a0-4947-b293-fa00b6d52643
7
protected void addOutsidersAndTimers(Faction F, Vector<Faction.FactionChangeEvent> outSiders, Vector<Faction.FactionChangeEvent> timers) { Faction.FactionChangeEvent[] CEs=null; CEs=F.getChangeEvents("ADDOUTSIDER"); if(CEs!=null) { for (final FactionChangeEvent ce : CEs) outSiders.addElement(ce); } ...
8ccae75d-a5cd-4616-952d-363edc31a46a
8
@Override public void caseAMethodCallExp(AMethodCallExp node) { for(int i=0;i<indent;i++) System.out.print(" "); indent++; System.out.print("(Call [ "); System.out.print(node.getIdentifier()); System.out.println(" ]"); inAMethodCallExp(node); if(node.getHexp() != n...
f050b6bd-cbcf-47d4-a344-e5504b357251
4
private void nextGeneration() { boolean someSelected = false; for (int i = 0; i < generators.size(); i++) if (generators.get(i).isSelected()) { gaPop.setIndividualFitness(i, 1); generators.get(i).deselect(); someSelected = true; } if (someSelected) { if (!goBackButton.isEnabled()) goBack...
18b94faf-70a1-441a-b645-431dc4414c3a
4
public static SampleSet generateSamples(final int length) { SampleSet set = new SampleSet(); // int size = 1 << length; boolean[] data = new boolean[length]; // for (int i = 0; i < size; i++) { Sample s = new Sample(1, length, 1, 1); // ...
3bf850aa-aef5-42f7-9c61-7d2156cccbba
0
@Override public void restoreCurrentToDefault() {cur = new Color(def.getRGB());}
835dd408-aa42-451a-8d0a-991512fae53b
3
public MainFrame() { super("Hello World"); setLayout(new BorderLayout()); lista = new ArrayList<FormEvent>(); btn = new JButton("Click me"); textPanel = new TextPanel(); formPanel = new FormPanel(); toolbar = new Toolbar(); dbl = new DatabaseLayer(); toolbar.setArrayList(lista); toolbar.se...
b7764097-b002-4d49-ba33-9316b72b5a3e
6
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
69abf99a-5f64-4600-b9a3-49071e5e28ff
8
public void update() { removeAll(); HighSeas highSeas = getMyPlayer().getHighSeas(); if (highSeas != null) { for (Unit unit : highSeas.getUnitList()) { boolean belongs; if (destination instanceof Europe) { ...
273116c5-70c2-46b1-b781-b6f9282fceaf
4
public boolean Salvar(Venda obj) { try { if (obj.getId() == 0) { PreparedStatement comando = bd.getConexao().prepareStatement("insert into vendas(funcionario,cliente,pagamento,data_venda,total,status) values(?,?,?,?,?,?)"); comando.setInt(1, obj.getAtendente().getId()...
d7a1ad4e-7215-483f-8dcf-b840a374ced2
4
private Move getMinMove(StateTree tree) throws Exception { if (tree.isLeaf()) { return new Move( tree.getMove(), tree.getScore()); } Move minMove = null; for (StateTree successor : tree.getSuccessors()) { Move move = this.getMaxMove(successor); if (minMove == null || move.getScore() < min...
e1b6da8f-23ba-4fa4-93eb-167cac4cb4bd
6
@EventHandler public void PigZombiePoison(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getPigZombieConfig().getDouble("PigZombie...
4d7bc130-6e2f-4b71-abfe-46e159bafb3a
1
private double f(double b) { double PrB=1, p=probLessThan(b); for (int i = 0; i < futureBowls; i++) { PrB*=p; } double PrA=1-PrB; double ExA=exptGreaterThan(b); double ExB=exptLessThan(b); double Ex2=PrA*ExA+PrB*ExB; return Ex2; }
e53c1a5d-7ce8-4972-9cf1-42531d8523f3
4
static String getPlatformFont() { if(SWT.getPlatform() == "win32") { return "Arial"; } else if (SWT.getPlatform() == "motif") { return "Helvetica"; } else if (SWT.getPlatform() == "gtk") { return "Baekmuk Batang"; } else if (SWT.getPlatform() == "carbon") { return "Arial"; } else { // photon, etc ... ...
d993df01-91ce-43ef-8525-3b7fc5284a5b
9
int insertKeyRehash(short val, int index, int hash, byte state) { // compute the double hash final int length = _set.length; int probe = 1 + (hash % (length - 2)); final int loopIndex = index; int firstRemoved = -1; /** * Look ...
ffcdecff-e17c-47e2-b730-e430be89f4e2
9
public void updateLabels(){ //sets all the new labels depending on the board configuration int value; int index = 0; switch (gameMode) { //set labels differently depending on the game mode case "normal" : for (int r = 0; r < 4; r++) //labels will be counted left to right, up to down for (int c = 0; c ...
84f738f7-e677-4aac-a7dd-bc41349482ca
5
@Override public String execute() throws Exception { try { session = ActionContext.getContext().getSession(); User u1 = (User) session.get("User"); if (existpass.isEmpty()) { addActionError("Please Enter existing password"); return "error";...
17946827-e891-43ee-b7a7-a5e48ab2dce3
5
public String toQString() { StringBuffer str = new StringBuffer(); for (int i = 0; i < FIELD_NAME.length; ++i) { if (get(FIELD_NAME[i]) == null || get(FIELD_NAME[i]).equals("")) continue; if (i != 0) str.append("&"); try { str.append(FIELD_NAME[i] + "=" + URLEncoder.encode(get(FIELD_NAM...
57b57e68-6881-47ea-ac81-0ae30c924ba3
9
public static CitationRecord read(InputStream is) throws IOException { CitationRecord rec=new CitationRecord(); String file=LabnoteUtil.readStreamToString(is); String[] lines=file.split("\\r\\n"); LinkedList<String> nlines=new LinkedList<String>(); for(String s:lines) nlines.add(s); while(!nlines...
3b6a5176-c8e1-42fd-af8d-e568bebe2d97
0
public ClusterNode getParent() { return this.parent; }
0864c631-29c8-4874-9ff4-0cf1f5a3e9c4
5
public static Document readResourceDocument(Class<?> c, String name) { Document doc = null; InputStream is = null; try { is = c.getResourceAsStream(name); DocumentBuilder db = XMLUtils.newDocumentBuilder(false); doc = db.parse(is); } catch (SAXExc...
5aab1659-131c-40d2-9286-7a7699956f43
4
private static int loadTexture(String fileName) { String[] splitArray = fileName.split("\\."); @SuppressWarnings("unused") String ext = splitArray[splitArray.length - 1]; try { BufferedImage image = ImageIO.read(new File("./res/textures/" + fileName)); boo...
0c3b9705-9397-454f-a71e-304cea98f5c1
7
public List<String> getValidationErrors() { List<String> errors = new ArrayList<String>(); if (customerId == null || customerId.length() == 0) errors.add("Customer ID is required"); if (username == null || username.length() == 0) errors.add("Customer username is required"); ...