method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
43c7ee3d-c92a-41b3-8475-4b52a562f311
5
private void addAndRemoveModels() { boolean changed=false; for (int i = 0; i < models.size(); i++) { if (models.get(i).getIsNoNeedMore()) { if (!models.get(i).getIsComplex()) explode(models.get(i).getCenter(), models.get(i).getMaxWidth() * 10, models.get...
93f64063-5fa9-4f63-99c2-0349d5dc04ff
4
public void removePlayer(Player p ){ if(blau.contains(p)){ blau.remove(p); } if(rot.contains(p)){ rot.remove(p); } if(grün.contains(p)){ grün.remove(p); } if(gelb.contains(p)){ gelb.remove(p); } }
ed854ed6-d8a3-4088-8e57-bb143d16f3df
8
public static double logLikelihoodScore(ICTClassifier<Double, CTDiscreteNode> model, int nodeIndex, Collection<ITrajectory<Double>> dataset, ILearningAlgorithm<Double, CTDiscreteNode> paramsLearningAlg, boolean dimensionPenalty) throws RuntimeException { if( dataset == null) throw new RuntimeException(...
edb26d4d-4b7b-4e07-91ca-35a06fa2c890
6
private void openSockets() { boolean requestSocketOpened = false; boolean echoSocketOpened = false; for (int i = 0; i <= SOCKET_OPEN_MAX_ATTEMPTS; i++) { try { requestSocket = new DatagramSocket(REQUEST_PORT); requestSocketOpened = true; break; } catch (IOException e) { U.sleep(150...
8cb3b9d7-e14b-4e1e-875d-5f4929266523
5
public static void narrclick() { // in case no card has been played yet if ((display[0] == 0 || display[0] == 13) && newhand[0] >= 1) { newhand[0]--; display[0] = 13; display[1]++; } // in case another card has been played else if (display[0] != 0 && newhand[0] >= 1) { newhand[0]--; display[1]+...
443b2e96-61fa-40cb-ac92-b333128e18bc
2
private String getTopType(int pos) throws BadBytecode { Frame frame = getFrame(pos); if (frame == null) return null; CtClass clazz = frame.peek().getCtClass(); return clazz != null ? Descriptor.toJvmName(clazz) : null; }
9a70caa1-da5c-46ad-875b-a51827ae1a86
8
public void mousePressed(MouseEvent e) { Mappable mappable=map.getMapObjectAt(e.getX(), e.getY()); setSelected(mappable); boolean ctrlDown=(e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) !=0; boolean altDown=(e.getModifiersEx() & InputEvent.ALT_DOWN_MASK) !=0; if(mappable!=null && SwingUtilities.isRigh...
8aaf3b0c-00c0-4d5b-a03a-c337bde666c2
6
Object unpack(Info vi, Buffer opb){ int acc=0; InfoResidue0 info=new InfoResidue0(); info.begin=opb.read(24); info.end=opb.read(24); info.grouping=opb.read(24)+1; info.partitions=opb.read(6)+1; info.groupbook=opb.read(8); for(int j=0; j<info.partitions; j++){ int cascade=opb.read(...
ddc92318-a397-4c42-bbcf-648153173649
6
private void knightBottomRightPossibleMove(Piece piece, Position position) { int x1 = position.getPositionX(); int y1 = position.getPositionY(); if((x1 >= 0 && y1 >= 1) && (x1 <= 5 && y1 < maxHeight)) { if(board.getChessBoardSquare(x1+2, y1-1).getPiece().getPieceType() != board.getBlankPiece().getPieceTy...
001537a6-e5cb-446d-97ab-6ad946e66867
3
public void SQLExceptionInterpreter(SQLException e) { if (gui.debug) { System.out.println(e.getErrorCode()); e.printStackTrace(); } switch (e.getErrorCode()) { case 2627: gui.setState("double PRIMARY KEY"); break; case 515: gui.setState("Null as PRIMARY KEY"); break; default: new ErrorD...
3f3483e7-5070-4f14-a6d0-f9b8619ae292
0
public String getPassword() { return password; }
0c9dc9d4-ead9-4e85-9224-ba7e9d5d6b6a
4
public boolean isDiagonal(){ boolean test = true; for(int i=0; i<this.numberOfRows; i++){ for(int j=0; j<this.numberOfColumns; j++){ if(i!=j && this.matrix[i][j]!=0.0D)test = false; } } return test; }
6709866b-a633-4e6e-9436-67d0ac20b89b
8
@Override public synchronized void redo() throws CannotRedoException { if (!canRedo()) return; AbstractDocument.DefaultDocumentEvent lastRedo = null; AbstractDocument.DefaultDocumentEvent nextRedo; UndoableEdit ue; while((ue = super.editToBeRedone()) != null) { if (!canRedo()) { break; } i...
a17e2d23-2d56-4528-95b5-43c1fb6c242b
3
private void vouch (String filename, String certname) throws IOException, GeneralSecurityException{ //create a read-only copy of the file File readOnlyCopy = new File(filename); readOnlyCopy.setWritable(false); String privkeyloc = null; //adapted from http://docs.oracle.com/javase/tutorial/displayCode.html...
5871f8c9-c308-4a40-946f-51360b648cd1
9
public List<IngredientRecipe> getPotentialIngredientList(State state, Domain domain, IngredientRecipe tlIngredient) { List<IngredientRecipe> ingredients = new ArrayList<IngredientRecipe>(); Collection<IngredientRecipe> allIngredients = this.allIngredients.values(); Set<String> necessaryTraits = tlIngredient.getNe...
201b9aa0-1d17-4c9f-871c-5297cb7032a8
1
@SuppressWarnings("unchecked") static <T> WatchEvent<T> cast(WatchEvent<?> event) { return (WatchEvent<T>)event; }
ffae52a7-0ee6-48ed-a9ab-77d30bc88cf3
9
public SimpleList<String> minaXMLStructure (){ try { String path = new File(".").getCanonicalPath(); FileInputStream file = new FileInputStream(new File(path + "/xml/papabuilding.xml")); DocumentBuilderFactory builderFactory = DocumentBuil...
329c4d63-2b5e-445c-930b-2087e20cddb8
5
private void fill(char[][] board, int i, int j) { int row = board.length; int col = board[0].length; if (i < 0 || i >= row || j < 0 || j >= col || board[i][j] != 'O') { return; } //add, the number make up by (curRow * col + curCol) queue.offer(i * col + j); ...
3be8b68b-e56c-42ed-b715-fad4bef073fa
8
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof RingPlot)) { return false; } RingPlot that = (RingPlot) obj; if (this.separatorsVisible != that.separatorsVisible) { return false; ...
584cc9f4-11f9-4d5f-b0cb-4f2412aa2517
7
@Override public void addScript(ScriptingEngine S) { if(scripts==null) scripts=new SVector<ScriptingEngine>(1); if(S==null) return; if(!scripts.contains(S)) { ScriptingEngine S2=null; for(int s=0;s<scripts.size();s++) { S2=scripts.get(s); if((S2!=null)&&(S2.getScript().equalsIgnoreCase(...
84be149b-36a3-44bd-8291-ba0d816741a0
2
public void repositionFlyUps() { // removeDeadFlyUps(); int basePosition = 15 + (!permanentFlyUp.equals("") ? 0 : 15); for(FlyUp fly:flyups) { fly.setDistanceAboveRobot(basePosition); basePosition += 15; } }
281a552d-cad5-4d2d-8f9a-7b81eff4d714
4
@Test public void testGet() { final double height = 10; final double width = 8; assertEquals("Side should be LEFT", Side.get(0, 2, width, height), Side.LEFT); assertEquals("Side should be LEFT", Side.get(0, 2.5, width, height), Side.LEFT); assertEquals("Side should be LEFT",...
377ee72f-1721-4219-a96c-bc574536040f
6
public static void writeElementStart( StringBuffer buf, int depth, boolean empty, String line_ending, String name, Map attributes ) throws IllegalArgumentException { if (isValidXMLElementName(name)) { indent(buf, depth); buf.append("<").append(name); if (attributes != null) { Iterator i...
b2b23a7d-cc13-4fb4-93dc-782bf9da274f
6
public boolean isFightCaveNpc(int i) { switch (npcs[i].npcType) { case 2627: case 2630: case 2631: case 2741: case 2743: case 2745: return true; } return false; }
7d97469c-b73b-489f-bedc-7ecd3db900fb
4
public void disableArena() { if (this.arenastate == ArenaState.STAT_READY || this.arenastate == ArenaState.STAT_STARTED) this.endGame(EndReason.END_REASON_ARENADISABLE); else if (this.arenastate == ArenaState.STAT_OPEN) { for (Player p : players) { this.removeplayer(p); p.sendMessage(ChatColor.RED...
9dd2e4a4-5803-4c9b-ad51-9508f7fb73fe
3
public synchronized void remove(long channelId, int clientId) { int i=0; for(TVChannel chann:channels){ if(chann.getChannelId()==channelId && chann.getClientId()==clientId){ channels.remove(i++); } } }
5ab7ad44-5ba5-4b94-b749-09fc9ee0265d
0
public void addItemtoRedo(ArrayList<UndoableItem> udi) { redoStack.push(udi); }
236434d3-aa15-42db-bf08-dcd99a0ddd16
1
private void setVerLength(int verLength) { if (verLength < 10) throw new IllegalArgumentException("The size of the grid has to be at least 10x10!"); this.verLength = verLength; }
6f8d92b8-9fea-4841-bc7a-51e94ce45e5c
7
public void run() { DataInputStream stream1 = new DataInputStream(this.file1); DataInputStream stream2 = new DataInputStream(this.file2); try { while (!suspending) { // Deserialize if its an already existing object and resume from there or simply go with the this reference String line1 = stream1.re...
869357e1-50e4-402b-96fc-2b0d244f1832
0
public Detalle(int idDetalle, Tpv tpv, Encargo encargo, Producto producto, String otro, double cantidad, double precio) { this.idDetalle = idDetalle; this.tpv = tpv; this.encargo = encargo; this.producto = producto; this.otro = otro; this.cantidad = cantidad; this...
2bddc10b-590d-4779-be16-4d5bc547965b
0
@Override public Server getServer() { return Plugin.getServer(); }
6f96cf62-b09c-4c72-88a0-53607306f2dc
4
private float computeFix(List<JstatItem> jstatItemList) { List<Float> fixList = new ArrayList<Float>(); for(JstatItem item : jstatItemList) { if(item.getOU() > fismb) fixList.add(item.getOU() - fismb); } if(fixList.isEmpty()) return 0; else { float sum = 0; for(Float f : fixList) sum ...
59887b96-478f-4ca4-871d-c074bf002514
3
private void sendEvent(String eventMessage) throws MMTConnectorException, IOException { String postMessage = EventParameterName + "=" + eventMessage; HttpURLConnection connection = (HttpURLConnection) this.getConnectorConfig().getServerURL().openConnection(); connection.setRequestMethod("POST");...
8c7d81a1-1466-426d-94ce-208b03450d00
0
@RequestMapping({"/", "index"}) public String index() { return "index"; }
98bb3081-4a66-445a-82d3-29059a026b8b
1
public AdjustMoneyEditor() { setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setTitle("Adjust Money Editor"); setBounds(100, 100, 343, 234); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); con...
66bb4d3f-0bd1-4a94-9d68-5c36d44c53b1
4
@SuppressWarnings({ "deprecation", "unused" }) public static boolean areItemsInDatabase(Player pl, ItemStack is, int qty) { if (is == null) return false; int playerID = getPlayerId(pl.getUniqueId()); WebInventoryMeta wim = new WebInventoryMeta(is); ResultSet rs = null; try { Connection conn = MineAucti...
ada5a486-11db-4ea5-ab21-33b1aa9a134f
2
private boolean jj_3_43() { if (jj_3R_62()) return true; if (jj_3R_56()) return true; return false; }
3f6e0c57-747c-4c9d-806d-69a8630190cd
1
public boolean jumpMayBeChanged() { return subBlock.jump != null || subBlock.jumpMayBeChanged(); }
a848227a-06d1-4161-881e-c619e61ab547
5
@Override public void deserialize(Buffer buf) { worldX = buf.readShort(); if (worldX < -255 || worldX > 255) throw new RuntimeException("Forbidden value on worldX = " + worldX + ", it doesn't respect the following condition : worldX < -255 || worldX > 255"); worldY = buf.readShor...
cb0934ca-d218-4859-9364-64dbaaabb0ab
4
private int getNextPiece(Peer p) { boolean[] peerBitfield = p.getBitfield(); boolean[] bitfield = tracker.getHost().getBitfield(); if(peerBitfield == null) return -1; for(int i = 0; i < bitfield.length; i++){ if(!bitfield[i] && peerBitfield[i]){ return i; } } return -1; }
7114aae5-8f30-4bdd-91e9-4f8f3f5caa59
3
public void run() { GroundItem spice = Util.getSpice(); int count = Inventory.getCount(spice.getId()); if (lootSpice()) { int time = 0; while (Inventory.getCount(spice.getId()) <= count && time <= 5000) { time += 50; Time.sleep(50); } } }
69e3598d-f134-4df3-87cd-e54619c14229
7
public KjStroke getReducedNoise(){ KjStroke result = new KjStroke(); if (pointList.size()<=2){ for(int i=0;i<pointList.size();i++){ result.addPoint(pointList.get(i)); } } else { result.addPoint(pointList.get(0)); for(int i=1;i<pointList.size()-1;i++){ ArrayList<Point> temp = new ArrayList<Poin...
b15dadc8-2010-41a5-aa86-4b33d5b8e31f
4
public Aresta retiraAresta(int v1, int v2) { int index; for (index = v1; this.prox[index] != 0; index = this.prox[index]) if (this.cab[this.prox[index]] == v2) break; int ind = this.prox[index]; if (this.cab[ind] == v2) { Aresta aresta = new Aresta(v1, v2, this.peso[ind]); this.cab[ind] = ...
06815fd6-ad08-4311-9621-2571d70c3083
2
@Override public int compareTo(Object obj) { String objString = null; String ourString = null; // if obj is not effectively one of us ... if (! this.getClass().isInstance(obj)) { throw new ClassCastException (); } // get the strings objString = ((StrungDocumentInfo)obj).getString(); ourString ...
0be54c32-953b-44db-a8c1-94ef7dbde7f5
2
private boolean hiddenField(String name) { boolean hidden = false; for (int i = 0; i < HIDDEN.length; i++) { if (HIDDEN[i].equals(name)) hidden = true; } return hidden; }
7e7356a6-6ebb-4851-86cf-f66d61d13a5b
5
private CvSeq findBiggestContour(IplImage imgThreshed) { CvSeq bigContour = null; CvSeq contours = new CvSeq(null); cvFindContours(imgThreshed, contourStorage, contours, Loader.sizeof(CvContour.class), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); float maxArea = SMALLEST_AREA; CvBox2D...
f1a1804b-765f-4504-8a3e-12c2c8ac5384
3
static Coordinates nextBackwardPosition(Coordinates position, Direction direction) { if (direction == NORTH) return new Coordinates(position.getX(), position.getY() - 1); if (direction == SOUTH) return new Coordinates(position.getX(), position.getY() + 1); if (direction =...
4682d414-c644-45d8-b8e1-b6370ef7bd7e
5
@Override public void extract() throws XMLStreamException, FileNotFoundException { FileInfo simc = this.bfis.get(Parser.Types.SIMC.toString()); this.factory = XMLInputFactory.newInstance(); this.readerRaw = factory.createXMLStreamReader(new BufferedInputStream(new FileInputStream(...
f77e337a-82ff-41c1-bed2-461ddab59298
2
boolean isLeapYear(int year) { if (year == 0) { throw new IllegalArgumentException("Illegal year: " + year); } return mod(year, 4) == (year > 0 ? 0 : 3); }
ab7cf02d-d227-4835-85b6-828bd97564f4
2
public World(int size) { this.size = size; w = new String[size+1][size+1]; for (int x = 0; x <= size; x++) { for (int y = 0; y <= size; y++) { w[x][y] = UNKNOWN; } } setVisited(1, 1); }
beb8d8cf-fe4e-42ef-88cf-6426ed6fbafd
0
@Test public void testCheckCellStatus() throws IOException { System.out.println("checkCellStatus"); int[] cell = new int[2]; cell[0] = 1; cell[1] = 1; Sense.condition cond = Sense.condFromString("FRIEND"); AntBrain ab = new AntBrain("cleverbrain1.brain"); ...
f4e4d2f0-d4a6-453e-8a60-6fc215a8dba4
9
public static void pollIO() { // Clear KeyPresses for(int i=0; i<keyPress.length; i++) keyPress[i] = false; // Update Keyboard Table while(Keyboard.next()) { if(Keyboard.getEventKeyState()) { keyDown[Keyboard.getEventKey()] = true; } else { keyDown[Keyboard.getEventKey()] = false; keyPress[...
1c365be7-2918-4995-8786-54373c4da647
1
private void LoadContent() { try { URL carImgUrl = this.getClass().getResource("/raceresources/resources/images/car2.png"); carImg = ImageIO.read(carImgUrl); carImgWidth = carImg.getWidth(); carImgHeight = carImg.getHeight(); URL carWonImgUrl = this.g...
a0be6691-ea51-4e78-ac63-acc6efa4440f
5
public static void run(TestOptions testOption){ if (testOption == TestOptions.ALL_TESTS){ for (TestOptions option : TestOptions.values()){ if (option != TestOptions.ALL_TESTS){ if (option != TestOptions.PCB442 && option != TestOptions.PR2392){ runTestingInstance(option); } } } } else...
86b8b88f-08df-475d-bac3-c5668b075e7d
6
public int restriccionTabu(double cambio, int indice1, int indice2) { String url = "jdbc:derby://localhost:1527/PDPIVP"; String selectdatos="SELECT * FROM EstructuraTabu"; double resultadotabu=0; double resultadofinal=0; int indice1_var=0; int indice2_var=0; int tabu=0; try{ Clas...
742525d7-71f5-489d-b424-a012d35617c6
6
public static void main(String[] args) { Estrutura ed = new Estrutura(100); Scanner scan = new Scanner(System.in); String cor; double altura; while (true) { menuPrincipal(); String res = scan.next(); switch (res){ ...
87e5ef01-881f-43eb-b52b-97be597d868f
7
public static void addFille(Personne pers, Fille fille) { List enfants; try { if (pers instanceof Pere) {//Un pere ajoute un fils //On recupere la liste des enfants du pere enfants = ((Pere) pers).getEnfants(); fille.setPere((Pere) pers); ...
248934aa-a97b-4754-b257-7d1582b7ea27
7
@Override public void select(int howMany, Population from, Population to) { double fitnessSum = 0.0; for (int i = 0; i < from.getPopulationSize(); i++) { fitnessSum += from.get(i).getFitnessValue(); } double[] fitnesses = new double[from.getPopulationSize()]; ...
b2a623be-ab46-4f26-abb1-df69852ef50a
4
private void handleMetaInput() { if (this.equalsHelper.state()) { this.tileSize += 5; if (this.tileSize > 100) { this.tileSize = 100; } } else if (this.minusHelper.state()) { this.tileSize -= 5; if (this.tileSize < 25) { this.tileSize = 25; } } }
c4243640-112c-4d14-91f9-365f4ecb4d3e
1
public void deleteLevel(int id) { try { PreparedStatement ps = con.prepareStatement( "DELETE FROM teacher WHERE id=?" ); ps.setInt( 1, id ); ps.executeUpdate(); ps.close(); } catch( SQLException e ) { e.printStackTrace(); } }
f0b4fa46-e8b5-4e23-b47e-66a6fffe5a72
6
public void sendRobotData() { HashMap<String, Player> players = new HashMap<String, Player>(registry.getPlayerManager().getPlayers()); try { for (String key : players.keySet()) { Player p = (Player) players.get(key); if (p != null && p.getRobot().getIsActivate...
683adec3-c141-4b5d-ab78-a7c47810ed37
5
@Override public void pressedBuyItem(ItemType itemType) { ItemData itemStats = Game.getItemData(itemType); if (HeroInfo.INSTANCE.isHeroAlive()) { if (money >= itemStats.buyCost && HeroInfo.INSTANCE.hasSpaceForItem(itemType) && GamePlayState.isHeroAliveAndCloseEnoughToMerchant()) { HeroInfo.INSTANCE.equipIte...
760a7fc5-954e-4a78-8d11-6b032693f83b
6
private final boolean inputNotCorrect(JFileChooser c) { if (tf_credName.getText().equals("") || tf_credID.getText().equals("") || tf_credIBAN.getText().equals("") || tf_credBIC.getText().equals("") || tf_execDate.getText().equals("")) { JOptionPane.showMessageDialog(c, texte.getString("D_MISSING_V...
aa7b737e-d4f3-4147-8cdc-14c837c0f4c3
5
private void add(int previous, int index, Node node) { Node[] children = node.getChildren(); // nodes following current node if(node.getChildren().length > 0 && node.hasSinglePath() && node.getChildren()[0].getKey() != TERMINATING_CHARACTER) { // If node has only one path, put the rest in tail array baseBuffer....
ffc05ace-307a-464c-9888-64371b43bef5
5
private void actionShowScores(int difficulty) { String msg = "<html>"; msg += "<font size=4>"; msg += "Best results - "; switch (difficulty) { case Grid.DIFFICULTY_EASY: msg += "easy"; break; case Grid.DIFFICULTY_MEDIUM: msg += "medium"; break; case Gr...
400c127e-5fd4-47f6-a022-201c737eb195
0
public User(String n) { name = n; }
dc95e03c-1f9d-45e0-aa83-ef18fb81373c
0
public void setMACKey(EncryptedDataType value) { this.macKey = value; }
4073f0bb-577b-4dd6-95b6-a5ee9a2a2241
5
public void run() { switch(serv) { case WORLDNAMES: setWorldNames(services.getAllWorldNames(lang)); System.out.println("worldnames: "+worldNames.size()); break; case MAPNAMES: setMapNames(services.getAllMapNames(lang)); System.out.println("mapnames: "+mapNames.size()); break; ...
c3f6fcef-ad16-41a3-9170-7f62d6f938ae
0
public static void dehoist(Node currentNode) { currentNode.getTree().getDocument().hoistStack.dehoist(); return; }
191b2bd9-f590-4769-a74e-79611e2c4b69
8
public boolean equals(Object obj) { if (obj == this) return true; if (obj == null) return false; if (obj.getClass() != this.getClass()) return false; Picture that = (Picture) obj; if (this.width() != that.width()) return false; if (this.height() != that.height()) return false; for (int x = ...
d2244000-fbe7-486d-9583-94b228b313f8
9
public static File getFile(Component parent, String title, boolean write) { JFileChooser fc = new JFileChooser(); fc.setDialogTitle(title); if (write) { fc.showSaveDialog(parent); } else { fc.showOpenDialog(parent); } File f = fc.getSelectedFile(); if (f == null || (!write && !f.exists()) || (f.exis...
5aa0f59e-62de-4dac-8d54-3bbe16bd0faf
0
public String getHostname() { return _hostname; }
40145560-5501-4165-94e8-bf9ac29995cb
7
protected boolean isMatchingStrategyList( List<StrategyT> aStrategyList1, List<StrategyT> aStrategyList2 ) { if ( ( aStrategyList1 != null ) && ( aStrategyList2 != null ) ) { if ( aStrategyList1.size() == aStrategyList2.size() ) { for ( int i=0; i < aStrategyList1.size(); i++ ) { if ( aStrategyL...
cf6ef804-2030-4659-93fe-6f96b3297c84
4
public ArrayList<Integer[]> selection2(ArrayList<Integer[]> population, int size) { if (size > population.size()) { return population; } ArrayList<Integer[]> parents = new ArrayList<>(); //int matchLength = grades.length / size; while (parents.size() < size) { ...
ec3545cf-3fba-4f80-aea8-0af5ae0f860e
1
public boolean equals(Auction auction){ if(this.id == auction.id){ return true; } else{ return false; } }
6bf8f069-c782-4a9a-850d-18950cc426f1
1
int truncatetable(String tableName) throws ClassNotFoundException, InstantiationException, SQLException, IllegalAccessException { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con = DriverManager.getConnection(url, dbUser, dbPass); Statement stm = con.createStatement(); ...
e0b174e0-507d-4c1b-95a3-8b079332fee6
3
public void flush() { if (myBitsToGo != BITS_PER_BYTE) { try{ write( (myBuffer << myBitsToGo) ); } catch (java.io.IOException ioe){ throw new RuntimeException("error writing bits on flush " + ioe); } myBuffer = 0; ...
92e336db-bf52-4420-92d3-587aae84f443
9
public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true){ int n = sc.nextInt(); if(n==0)break; C[] c = new C[n]; for(int i=0;i<n;i++)c[i]=new C(new Point(sc.nextDouble(), sc.nextDouble()), sc.nextDouble()); int m = sc.nextInt(); while(m--!=0){ Point u = new Poi...
bab97bd5-8335-497d-af10-702d5c34fbeb
5
private int travelTree(TreeNode node) { if(node == null) return 0; int left = travelTree(node.left); if(left == -1) return -1; int right = travelTree(node.right); if(right == -1) return -1; if(Math.abs(left - right) > 1) return -1; return left > right ? left + ...
1a6f6433-da8b-4139-bdc8-c3015d4f7f9c
3
@Override public void handleQuitRequestWith(QuitEvent event, QuitResponse response) { if (!UIUtilities.inModalState()) { mAllowQuitIfNoSignificantWindowsOpen = false; if (closeFrames(true)) { if (closeFrames(false)) { saveState(); response.performQuit(); return; } } mAllowQuitIfNoS...
501e23d2-3b5b-49e8-bb89-3d421c93a0c4
8
static LinkedList<Part> sort2(LinkedList<Part> unsorted) { if (unsorted.size() <= 1) return unsorted; int mid = unsorted.size()/2; int size = unsorted.size(); LinkedList<Part> sorted = new LinkedList<Part>(); LinkedList<Part> first = new LinkedList<Part>(); LinkedList<Part> second = new LinkedList<Part>...
7e780e84-80a8-402a-8de5-7ce1490078f2
9
public Message toMsgAlbe(String ocsfMsg) { Message msg = new Message(); StringTokenizer st = new StringTokenizer(ocsfMsg); msg.setRoomNumber(Integer.parseInt(st.nextToken())); Room r = s.getRoom(msg.getRoomNumber()); String id = st.nextToken(); msg.setWhat(Integer.parseInt((msg.getRoomNumber()==0 || msg.get...
292acbde-c082-486e-b471-41393c947efc
4
private void processWithClassName(ClassLoader classloader, String className, String prefix, TmpStatics tmpStatics) { Class clazz; String identification = null; try { clazz = classloader.loadClass(className); Field id = clazz.getField("ID"); identification = (S...
e5d3df86-dc50-43cf-8945-f224a30c5537
0
public static void init() { codes.put("HALT", "HaltCode"); codes.put("POP", "PopCode"); codes.put("FALSEBRANCH", "FalseBranchCode"); codes.put("GOTO", "GoToCode"); codes.put("STORE", "StoreCode"); codes.put("LOAD", "LoadCode"); codes.put("LIT", "LitCode"); ...
cdc7a5ec-9b3d-4d78-8257-e0c3510bc830
1
@Override public boolean isInternal(Position<T> p) throws InvalidPositionException { checkPosition(p); return (hasLeft(p) || hasRight(p)); }
740dd2b0-3623-4393-897d-40cc29cf0c50
7
public int calcHLine2(State m) { int line, column; int hLine = 0; for (line = 0; line < m.puzzle.getHeight(); line++) { for (column = 0; column < m.puzzle.getLength(); column++) { if ((column == (m.puzzle.getLength() - 1)) && (line < m.puzzle....
bfa681a7-8176-4dd6-a39a-1eafc2a4d34b
1
private void play() { String gameid = askForNewGame(); int attemptCount = sendAnAttempt(gameid, null); if (attemptCount == -1) { System.out.println("PERDU"); } else { System.out.println("J'ai gagné en " + attemptCount + "!"); } }
c10bb053-9263-4056-819f-4a40df63cb0d
9
public void reorderList(ListNode head) { // 1. get the middle node of the list (even / odd) and tail node // 2. divide the list into halves // 3. reverse the second half, merge two lists if (head == null) return; if (head.next == null) return; ListNode fast = head, slow = head; // temp head of merge...
288217f2-e379-4af2-9399-ddb646b2add5
1
public synchronized boolean hasMessage() { while(_buffers.size() > 0) { ByteBuffer bytes = _buffers.remove(0); CharBuffer chars = CharBuffer.allocate(bytes.remaining()); this._decoder.decode(bytes, chars, false); // false: more bytes may follow. Any unused bytes are kept in the decoder...
0ee105f8-4bb0-4698-9e16-2f11a37ef2e0
4
public void clearMap(GameAction gameAction) { for (int i=0; i<keyActions.length; i++) { if (keyActions[i] == gameAction) { keyActions[i] = null; } } for (int i=0; i<mouseActions.length; i++) { if (mouseActions[i] == gameAction) { ...
3b6503ff-45a9-4b97-9ac9-adf6d9eb4f58
7
public void setValue(BigDecimal aValue) { BigDecimal tempValue = aValue; // 12/15/2010 Scott Atwell if ( ( getMinimum() != null ) && ( tempValue.compareTo( getMinimum() ) < 0 ) ) if ( ( getMinimum() != null ) && ( tempValue != null ) && ( tempValue.compareTo( getMinimum() ) < 0 ) ) { tempValue = getMinim...
01836725-3677-4a2c-ab6a-d1b523741b8c
9
private int addConfigFields(JPanel p, String groupName) { GridBagConstraints c = new GridBagConstraints(); c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(1, 1, 1, 1); c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 1; for (final Field f : CraftConfig.class.getFields()) { ...
cb67a2c7-ce25-4e0b-a57a-cea62e9fed40
0
private double edgeY(int x, int y, double[][] smoothedGray) { return 1*smoothedGray[x-1][y-1] - 1*smoothedGray[x+1][y-1] + 2*smoothedGray[x-1][y] - 2*smoothedGray[x+1][y] + 1*smoothedGray[x-1][y+1] - 1*smoothedGray[x+1][y+1]; }
212d8287-26e7-4e4a-837f-a51b467a07e6
9
public void setImgPath_CommandBtn(Path img, Imagetype type) { switch (type) { case KEYFOCUS: this.imgComBtn_KFoc = handleImage(img, UIResNumbers.COMBTN_KFOC.getNum()); if (this.imgComBtn_KFoc == null) { this.imgComBtn_KFoc = UIDefaultImagePaths.COM...
2b1b3532-bfb4-4fb8-966c-bee9c6294585
5
@Override public boolean equals(Object object) { if (!(object instanceof UserGroup)) { return false; } UserGroup other = (UserGroup) object; if ((this.groupName == null && other.groupName != null) || (this.groupName != null && !this.groupName.equals(other.groupName))) { ...
09dc003c-7e79-417e-aaf0-4cbae381ac52
9
public void parseMethod(TypeDeclaration typeDecl, MethodDeclaration methodDecl, Method method) { Type[] types = method.getArgumentTypes(); int offset; if (Modifier.isStatic(methodDecl.getAccess())) { offset = 0; } else { // Reference to this is first argu...
52d00c96-2da5-4539-9ac9-70454aa67c67
3
public void checkParameters(String[] args) { if ((args.length == 1) && args[0].equalsIgnoreCase("-help")) { System.out.println("Parameters: \r\n (1) total number of entries [optional, defaulfs to 10,000]"); } if (args.length > 0) { documentCount = Integer.parseInt(args[0...
3f508b21-32bf-4ea7-9601-dc2ce5e2f9c5
6
public static void main(String args[]) throws SQLException { //Troca o LookAndFeel try { javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogg...
8f1098fa-e5d9-4a7c-bb92-95f1057f06ff
9
private void visitExpr(FormatDecl.BitField f, String name, int bit, int[] result) { Expr e = f.field; if ( matches(e, name) ) { for ( int cntr = 0; cntr < f.getWidth(); cntr++ ) result[cntr] = cntr + bit; } else if ( e.isBitRangeExpr() ) { FixedRangeEx...
89ef8dec-bac5-4c56-a198-483e0283eb3b
9
public final void updatePosition(int x, int y, boolean flag) { if (animationId != -1 && Sequence.sequenceCache[animationId].walkProperties == 1) { animationId = -1; } if (!flag) { int destX = x - walkQueueX[0]; int destY = y - walkQueueY[0]; if (destX >= -8 && destX <= 8 && destY >= -8 && destY <= 8) ...