method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
6bf2ca0a-5f1f-4fc4-baa0-82f04f17d6e9
9
public Path optimizePath(Path path, int[][] distances) { // int[][] distances = distanceHolder.distances; Node[] nodes = path.nodes; Path newPath = null; int skipped = 0; double bestDistance = 10000000; //path.distance; double newDistance = Integer.MAX_VALUE; double diff = 10000; // outerloop: do { ...
3259f8fb-5123-43e9-be2d-20bf836abf87
7
protected int getVersionIndex(String romId) { switch (romId) { case "B4WJ0": return 0; case "B4BJ0": return 1; case "B4WE0": return 2; case "B4WP0": return 3; case "B4BE0": return 4; case "B4BP0": return 5; case "B4WJ1": return 6; //case "B4BJ1": // return 7; ...
19461ee6-7db2-4c5a-97bb-06ba038d2646
2
private synchronized void pulse(){ for(int i = 0; i < peerList.size();i++){ Peer p = peerList.get(i); if(!checkPulse(p)){//if it has no pulse, it's dead disconnect(p); } } }
9462b359-6f6d-4f6c-aa1c-3021dc2014e5
5
public boolean checkcheck(Board b){ aiarr=b.getBoardArray(); for(int x=0;x<8;x++){ for(int y=0;y<8;y++){ if(aiarr[x][y].toString().charAt(0)==color && aiarr[x][y].toString().charAt(1)=='K' && isThreatened(new Point(x,y))){ System.out.println("CHECK"); //checkCheckmate(b,x,y); return true; ...
fa66dde9-14b4-4c2e-a309-84f68e17e180
5
private final String getChunk(String s, int slength, int marker) { StringBuilder chunk = new StringBuilder(); char c = s.charAt(marker); chunk.append(c); marker++; if (isDigit(c)) { while (marker < slength) { c = s.charAt(marker...
6684d5bb-2613-478a-b48b-be98dd293e0e
2
private void playSound(){ if (cSound.getModel().isSelected()) { if(status.getChangedServerList().size() > 0) alarm.play(); } }
fcd745eb-63f7-4649-9606-95aa9fc2906a
7
public static void main(String[] args) { if (args.length < 3) { System.out.println("Simple Web Crawler"); System.out.println("Usage:"); System.out.println("First argument: page URL e.g. http://example.com"); System.out.println("Second argument: number of pages to ...
43745c06-b4c3-402c-91d8-adc8aebf6c46
8
private boolean validateInput(Move theMove, Board board) { if (theMove == null || board == null) { throw new IllegalArgumentException("Move or Board were null"); } if (!(theMove instanceof ConnectFourMove)) { throw new IllegalArgumentException("Wrong move type"); } if (boardColumns != board.getColumn...
f606c5eb-e984-40d1-af49-36b682a9fd57
1
synchronized public void quitterVoie(Train train){ train.setVenteOuverte(false); if(train.listeVoyageurIsEmpty()){ listeTrainQuai.remove(train); System.out.println( train.getNomTrain() +" quitte gare"); } voiesDispo++; // Pour les trains en attente d'un qu...
497bf258-9552-4d1a-8eca-43278192b116
6
public static void main(String[] args) { WrapCheckedException wce = new WrapCheckedException(); for(int i = 0; i < 3; i++) { try { if(i < 3) { wce.throwRuntimeException(i); } else { throw new RuntimeException(); ...
a5bd990d-35b0-40d3-afea-48ea2a4950b5
5
public static String checkSum(String f) { try { MessageDigest md = MessageDigest.getInstance("MD5"); DigestInputStream ds = new DigestInputStream( new FileInputStream(f), md); byte[] b = new byte[512]; while (ds.read(b) != -1) ; String computed = ""; for(byte v : md.digest()) computed...
13e1d38d-7c5e-42bb-b1a3-e294344703f7
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof AttributeStorageLevel)) { return false; } AttributeStorageLevel other = (AttributeStorageLevel) object; if ((th...
a70b0a59-f14b-44ba-8425-98460d6b8a05
5
public void paint(Graphics g) { super.paint(g); if (ingame) { Graphics2D g2d = (Graphics2D)g; if (craft.isVisible()) g2d.drawImage(craft.getImage(), craft.getX(), craft.getY(), this); ArrayList ms = craft.getMissiles()...
3bf2cc7c-b704-470f-ac3e-3b8f244ef5da
1
public Double compute(User u) { Integer correct = u.get("correct"); Integer questions = u.get("questions"); if(questions == 0) return 1.0; else return correct / (double) questions; }
9bf5858e-eb24-4b73-b961-04bac1710ede
3
public boolean addNewSportsBooking(ArrayList<SportsBooking> sb1, Connection conn) throws SQLException { int rowsInserted = 0; try { String SQLString = "insert into sportsBooking values (?,?,?,to_timestamp(?),?)"; PreparedStatement statement = null; statement = conn.pr...
c6258dfb-3ff3-45ba-bec4-d8d4ff4152ef
4
public void eseguiSimulazioneDoppiaCPU() { /* Inizializzazione vettore. */ ArrayList<Double> tempiUscitaMedi = new ArrayList<Double>(); /* Cicla sui job. */ for (int i = passo ; i <= jobTotali ; i += passo) { /* Cicla sui run. */ for (int j = 1 ; j <= run ; j++...
ca57b441-f7eb-4719-b908-61fdc0241a46
9
@Override public void putAll( MultiMap< ? extends K, ? extends V > map ) { // Get iterator to map's entry set Iterator< ? extends Map.Entry< ? extends K, ? extends V > > it = null; try { it = map.entrySet().iterator(); } catch( Throwa...
1b732335-e4d0-4427-80f7-4dd6685db445
8
private ArrayList<NonDuplicateArrayList<String>> getKSubset(NonDuplicateArrayList<String> set, int k){ /* // recursive approach // ref: http://stackoverflow.com/questions/4504974/how-to-iteratively-generate-k-elements-subsets-from-a-set-of-size-n-in-java ArrayList<NonDuplicateArrayList<Integer>> subsets = new A...
1c44def6-c772-485d-b595-018500899394
8
@Override public void mutate(){ TspPopulation offspring = new TspPopulation(); for (int i = 0; i < population.getSize(); ++i){ double r; synchronized (rng){ r = rng.nextDouble(); } if (r < PROBABILITY){ TspIndividual mut...
c6427ee2-aaf1-4603-99f8-db38c40b700e
8
private void writeTag(ByteQueue queue, int tagNumber, boolean classTag, long length) { int classValue = classTag ? 8 : 0; if (length < 0 || length > 0x100000000l) throw new IllegalArgumentException("Invalid length: " + length); boolean extendedTag = tagNumber > 14; if (len...
3f2bbadc-2f57-49f9-aa70-a08b9f4615b1
5
private void actionInterested (String key, OutputStream out) throws IOException { Object o = _hash.get(key); if (o != null){ Fichier f = (Fichier)o; if (_estMisAssertion) System.out.println("On me demande mon fichier " + key); String reponse = "have " + key + " "; int i; boolean[] masque =...
f51f2134-d664-4a7f-b5e4-3a6caee29342
7
public void setValueAt(int numSample, int numChannel, Object value) { boolean channelAdded = false; boolean valueAdded = false; if (numSample < 0 || numChannel < 0) return; //Locate the channel while (numChannel >= channelsValues.size()){ //Add empty vectors until the desired channel channelsValues....
a1dc6cb7-e462-4865-bd3f-41feddad6d69
0
public ProxyDynamicSubject(Object obj) { this.obj = obj; }
ee3d5e9c-0ab4-43bb-b8ce-b35e687e5f0c
9
void showdetail() { int max =0; ArrayList<Integer[]> scorelist0 = new ArrayList<Integer[]>(); ArrayList<Integer[]> scorelist1 = new ArrayList<Integer[]>(); for (int i=0; i<size*size-1; i++) { if (grid[i].value>max) { max = grid[i].value; ...
47b5614e-8769-4a59-a40f-477ef7f3493a
2
public static int columnIndex(CSTable table, String name) { for (int i = 1; i <= table.getColumnCount(); i++) { if (table.getColumnName(i).equals(name)) { return i; } } return -1; }
025ce6d3-4ffa-4cdc-9484-b9eae9d95d3c
9
void run(){ Scanner sc = new Scanner(System.in); for(boolean h = true;;h=false){ n = sc.nextInt(); m = sc.nextInt(); if((n|m)==0)break; if(!h)System.out.println(); Map<String, Integer> ref = new HashMap<String, Integer>(); String[] s = new String[n]; for(int i=0;i<n;i++){ s[i] = sc.next(); ...
0830c515-4dcc-4b0f-af88-d944c71298fa
5
private void init(int numRowsOfPieces) { for (int i = 0; i < SIZE; i++) { //Adds red checkers. for (int j = 0; j < numRowsOfPieces; j++) if ((i + j) % 2 == 1) pieces.add(new RedChecker(i, j)); //Adds blue checkers for (int j = SIZE - numRowsOfPieces; j < SIZE; j++) if ((i + j) % 2 =...
80bf399e-eb2f-4de3-bedd-3a2bbf78e4cc
2
public boolean taskExists(Task task){ for (Task t : tasks){ if (t.equals(task)){ return true; } } return false; }
8b5f5a7d-dd8f-4f72-8bcb-2cdd2a629573
3
public void checkDeclaration(Set declareSet) { if (instr instanceof StoreInstruction && (((StoreInstruction) instr).getLValue() instanceof LocalStoreOperator)) { StoreInstruction storeOp = (StoreInstruction) instr; LocalInfo local = ((LocalStoreOperator) storeOp.getLValue()) .getLocalInfo(); if (dec...
ecc46575-ab36-48ad-b8ea-16dc6d1dfa29
3
public void sendMessage(Message m, String url) { try { IMessageReceivedHandler stub = (IMessageReceivedHandler) java.rmi.Naming.lookup("rmi://"+registry+":1099/"+url); stub.onMessageReceived(m); } catch (MalformedURLException e) { e.printStackTrace(); } catch (RemoteException e) { e.printStackTrace()...
c8f7a3a9-f035-48a7-9e44-f5ef554c5d4a
9
public static void setLongLE(final byte[] array, final int index, final long value, final int size) { switch (size) { case 0: return; case 1: Bytes.setInt1(array, index, (int)value); break; case 2: Bytes.setInt2LE(array, index, (int)value); break; case 3: Bytes.setInt3LE(array, index...
6a05fb9d-5a0d-4bd5-8f54-2a5ea28348c2
7
float getMeasurement(int[] countPlusIndices) { float value = Float.NaN; if (countPlusIndices == null) return value; int count = countPlusIndices[0]; if (count < 2) return value; for (int i = count; --i >= 0;) if (countPlusIndices[i + 1] < 0) { return value; } switch (count) { case 2: va...
9d5d4e39-b1b4-4f7e-ace6-704ceba5165d
4
private static double slowCos(final double x, final double result[]) { final double xs[] = new double[2]; final double ys[] = new double[2]; final double facts[] = new double[2]; final double as[] = new double[2]; split(x, xs); ys[0] = ys[1] = 0.0; for (int i = ...
c1e79ecc-8356-482a-9bd3-e875a598ac93
1
public static void main(String[] args) { EntityManagerFactory entityManagerFactory= Persistence.createEntityManagerFactory("introducaojpa_pu"); EntityManager entityManager = entityManagerFactory.createEntityManager(); Scanner scanner = new Scanner(System.in); Banda banda; for(int i = 0;i<2;i++ ){ b...
9ef67dfe-3d6b-4cf3-84fc-e1881224cba0
0
public void destroy() { removeAll(); removeNotify(); setIcon(null); renderer = null; }
a6894248-ffa8-4820-9309-7052dffe005d
6
public StringTemplate getAbandonEducationMessage(boolean checkStudent) { if (!(getLocation() instanceof WorkLocation)) return null; boolean teacher = getStudent() != null; boolean student = checkStudent && getTeacher() != null; if (!teacher && !student) return null; Building sch...
36049c90-fdef-40a8-a700-8aae6e7dc826
1
public final String encode(final K[] plain) { String crypt = ""; for (K symbol : plain) { crypt += this.symbols.get(symbol); } return crypt; }
9fbec80f-79f9-4b57-a0df-48a17e42b9d9
1
public void set(int symbol, int freq) { checkSymbolInRange(symbol); if (freq < 0) throw new IllegalArgumentException("Negative symbol frequency"); freqTable.set(symbol, freq); }
7fa70212-8c9d-4492-a35c-6738c9858cc0
2
public Object success(NullParamFn<? extends Object> fn) { return this.suc ? fn.fn() : null; }
c2ccee8f-3eee-4bd7-a712-294805e431d1
2
public void run() { while (true) { try { sleep(delay); } catch (InterruptedException e) { } objectPool.reapObjects(); } }
1b5a2e3f-bfe1-4bc8-a548-242884142006
9
private static void parseTraces(final JsonNode rootNode, final TraceRelationshipBuilder<Integer> builder) throws IOException { for (JsonNode traceNode : getField(rootNode, JsonTraceCodec.TRACES)) { final int traceId = getIntField(traceNode, JsonTraceCodec.TRACE_ID); final String name = getTextFiel...
1080e8ed-7097-456a-a7c1-bc2054750839
8
public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { retur...
f5f35f72-5633-4843-b666-5b444f676406
0
public static boolean getAutoConnect(){ return AutoConnect; }
03a1ba95-34fa-4efb-87e3-a781322690cf
7
private static boolean isOnlyDoubleByteKanji(String content) { byte[] bytes; try { bytes = content.getBytes("Shift_JIS"); } catch (UnsupportedEncodingException uee) { return false; } int length = bytes.length; if (length % 2 != 0) { return false; } for (int i = 0; i < l...
48a1fe2c-1b3a-4c5c-bd31-5e233049c838
2
@RequestMapping(value = {"/CuentaBancaria/{idCuentaBancaria}/MovimientosBancarios"}, method = RequestMethod.GET) public void readMovimientosPorCuenta(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse, @PathVariable("idCuentaBancaria") String idCuentaBancaria) { try { Object...
86156403-f75d-46d1-8491-a1c7603c7aef
0
public KeyboardListener() { keyMapper = new KeyMapper(); keyStates = new boolean[MAX_KEY]; }
7165326b-7bde-416b-842e-b845cfb76154
6
public static void main(String[] args) { // TODO Auto-generated method stub String sr_ip; int sr_port; if (args.length < 3) { System.out.println("Wrong arguments, Format: java examples/TestServer <ip of S_Registry> <port of S_Registry> <port of this Server>"); return; } sr_ip = args[0]; try { ...
52f6d065-f014-4a95-8304-532653dc0b16
4
public void run() { // Adjust sleeping time to avoid too small times double sampleInterval = DESIRED_INTERVAL; double execInterval = sampleInterval / mySpeed; if (execInterval < MINIMUM_INTERVAL) { execInterval = MINIMUM_INTERVAL; sampleInterval = MINIMUM_INTERVAL * mySpeed; } try { long t = 0...
50c06bcd-88d1-4e46-bfda-6c27f020e205
6
public boolean chocaElPardalet(float px, float py, float pw, float ph) { //System.out.println(py+" "+yEspacio); if(px>x+getW()){ System.out.println("estem a lesquerra"); } if(px+pw<x) System.out.println("estem a la dreta"); if(px+pw>x) System.out.println("Dreta: "+px+" "+pw+", "+x); if(py>yEspacio+yEs...
9d50387e-e112-4074-b065-5e8068cdf622
4
public static void reset() { step = 0; actors.clear(); populate(); if(CUSTOM_DEPTH>0 && CUSTOM_WIDTH>0 && CUSTOM_DEPTH <=100 && CUSTOM_WIDTH <=100) { field.setField(CUSTOM_DEPTH, CUSTOM_WIDTH); view.getSim().getView().changeView(CUSTOM_DEPTH,CUSTOM_WIDTH); ...
312ca556-215c-4678-b5fd-28f847d38629
5
public void convert(String input, String output, Formats inputFileformat, int lineCount) throws IOException { // we save the parameter in the class fields this.input = input; this.output = output; this.lineCount = lineCount; // we create an object fro writing the output file writer = new BufferedWrite...
dc016bde-a4a3-4bc1-b02d-1560cdd97148
5
public void loadLibrary() { try { BufferedReader br = new BufferedReader(new FileReader("./ivJava.ini")); String line = ""; while ((line = br.readLine()) != null) { if (line.length() > 0) { int index = line.indexOf("LoadLibrary="); if (index >= 0) { String Library = line.substring(index +...
de452f38-a713-46e1-b054-312baa006dd1
6
public static int[] lcp(int[] sa) { int n = sa.length; int[] rank = new int[n]; for (int i = 0; i < n; i++) rank[sa[i]] = i; int[] lcp = new int[n - 1]; for (int i = 0, h = 0; i < n; i++) { if (rank[i] < n - 1) { for (int j = sa[rank[i] + 1]; Math.max(i, j) + h < cad.length && cad[i + h] == ca...
16a7ade3-7355-4cc3-b079-b435b991eb08
0
private void initializeWithABC() { l.insert(c); l.insert(b); l.insert(a); }
59920104-a450-4b37-a29d-a18eb3d8d91d
9
public static void main(String[] args) { if (args.length != 1 || args[0].charAt(0) != '-') { usage(); return; } try { // Create the modeler/solver object IloCplex cplex = new IloCplex(); IloNumVar[][] var = new IloNumVar[1][]; IloRange[][] rng = new IloRange[1][]; // Evaluate command line ...
202ee728-5548-4ce5-a489-c8162f79b2b3
3
public void update() { time++; if (time >= 7400) time = 0; if (time > life) remove(); za -= 0.1; if (zz < 0) { zz = 0; za *= -0.55; xa *= 0.4; ya *= 0.4; } move(xx + xa, (yy + ya) + (zz + za)); }
db57b191-d94d-4888-b0e5-9957bcdc3121
9
private void postPlugin(final boolean isPing) throws IOException { // The plugin's description file containg all of the plugin data such as // name, version, author, etc final PluginDescriptionFile description = plugin.getDescription(); // Construct the post data final StringBuilder data = new StringBuilde...
622ab433-0507-422a-a02d-12472b47a03a
3
private String buildBar() { // Collecting information about the bar length int every = 100 / BAR_DEPTH; int bars = approx_progress / every; int subDepth = BAR_DEPTH / 2; // Creating the array of character corresponding to the percentage of // completion char a[] = new char[BAR_DEPTH]; if (bars > BAR_DE...
2de72012-fc19-454c-a93a-3e985413f6d9
3
private void jTextField9KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField9KeyPressed if (evt.getKeyCode() == 38) { jTextField7.grabFocus(); } else if (evt.getKeyCode() == 40) { jTextField8.grabFocus(); } else if (evt.getKeyCode() == 39) { jRadioButton1.grabFocus...
41e3a7e8-78a8-4c1f-b5d7-6f1bb23c0607
9
public final void interfaces() throws RecognitionException { try { // fontes/g/CanecaSemantico.g:216:2: ( ^( INTERFACE_ modificadorDeAcessoFeminino IDENTIFICADOR listaDeTiposGenericos listaDeInterfaces corpoDaInterface ) ) // fontes/g/CanecaSemantico.g:216:4: ^( INTERFACE_ modificadorDeA...
3a3786df-d5c5-4ef6-aa3c-33ee5a71cb51
4
private int checkRegEx(String result) { if(result == null || result.isEmpty()) return 0; result = result.toLowerCase(); String regEx1 = "[2-9][p-z][a-h][2-9][a-z]*[p-z][2-9][p-z][2-9][p-z]"; String regEx2 = "[2-9][p-z][p-z][a-h][2-9][a-z]*[p-z][2-9][2-9][2-9][p-z]"; if(result.mat...
59950f67-d14f-424e-9424-2250cc5f36d3
0
public String getName(){ return name; }
a2748b0e-976e-4fae-bccf-d38002128691
9
public void keyPressed(KeyEvent arg0) { int keyCode = arg0.getKeyCode(); if(keyCode == KeyEvent.VK_ENTER) { name = inputName.getText(); for(int i = 0; i < name.length(); i++) { if(name.charAt(i) == ' ' && i < name.length() - 1) { name = name.sub...
e204439c-1bbc-4565-b6ef-b31808104006
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
1a01199f-3f7f-44a4-9880-0efe73dd8559
0
private void connectLocal(DcServer server, DCStation station) { DummyChannel chA = new DummyChannel(), chB = new DummyChannel(); Connection c1 = new DummyConnection(chA.getInputStream(), chB.getOutputStream(), station); Connection c2 = new DummyConnection(chB.getInputStream(), chA.getOutputStream(), server); st...
64b2968a-0195-432b-8119-d4964cb08200
7
public static void conversationthread() throws Exception { while (worker1) { java.sql.Connection conn = DbController.dbconnect(); conv = DbController.getconversation(conn, m_loggedas); try { conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } ...
73d110c9-d3c7-4352-ba1b-1974fef98c7c
9
public int Execute(PolishProgram program) throws Exception { // execute the command. // returns -10 - standard running // returns label in goto - in case the command was goto // returns -1 - in case there is a runtime error int expressionVal = -1; switch (m_Type) { case Assignment: { expressio...
c2039078-5e74-4b7f-a800-f981fe7d1fef
5
public static World initWorld( ResourceContext rc ) throws IOException { final DemoBlocks blocks = DemoBlocks.load(rc); final GenericPhysicalNonTileInternals crateInternals = getCrateInternals(rc); final SubstanceContainerInternals fuelCanInternals = getFuelCanInternals(rc); int worldSizePower = 24; int...
5a8771fe-657e-4378-a547-9915bb087b30
1
@Override public Clock deepCopy() { VectorClock newClock = new VectorClock(); newClock.hostName = this.hostName; for (String key : this.clock.keySet()) { newClock.clock.put(key, this.clock.get(key)); } return newClock; }
b52f342c-bc56-4cb9-88e2-307fa20a9bc8
7
public static Stella_Object accessTruthValueSlotValue(TruthValue self, Symbol slotname, Stella_Object value, boolean setvalueP) { if (slotname == Logic.SYM_LOGIC_POLARITY) { if (setvalueP) { self.polarity = ((Keyword)(value)); } else { value = self.polarity; } } else ...
c9fb834e-2eca-491b-9e26-dad5edbd544c
3
public HomeScreen(Market m, User u) { setPreferredSize(new Dimension(1000, 650)); // set it to the same size as the container setLayout(null); // it will be a card in the main deck setBackground(Color.black); // From MainFrame market = m; user = u; // Set up the home label homeLabel = new JLabel("<html> <h1> ...
fd436f30-3045-4dff-a082-7763f72b458e
1
private static void hasRole() throws Exception { UserDAO ud = new UserDAO(); RoleDAO rd = new RoleDAO(); Role role = (Role) rd.findById(2); User user = (User) ud.findById(2); boolean itHasRole = ud.hasRole(role, user); if (itHasRole == true) { System.out.print...
4400d2cb-5812-46cf-a302-87700dfe1c98
6
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { try { commands.execute(cmd.getName(), args, sender, sender); } catch (CommandPermissionsException e) { sender.sendMessage(ChatColor.RED + "You don't have permission."); } catch (Mis...
add5a6f1-a916-4f34-873c-a73bad1de73d
0
@Override public Object filter(PropertyContainer container, Object value) { return value; }
3053a9bb-af40-43fc-8b11-15bb510d35c0
5
@Override public void handle(HttpExchange exchange) throws IOException { System.out.println("In rob player handler"); String responseMessage = ""; if(exchange.getRequestMethod().toLowerCase().equals("post")) { try { //TODO verify cookie method String unvalidatedCookie = exchange.getRequestHeade...
a7a3115e-e8be-4fd9-ac7f-29eea493f71c
3
public UIForm toUIForm(String heading) { if (null == heading) throw new IllegalArgumentException(); if (_menu.size() < 1) throw new IllegalStateException(); UIForm.Pair[] array = new UIForm.Pair[_menu.size()]; for (int i = 0; i < _menu.size(); i++) array[i] = _menu.get(i); return n...
1656fd78-26a7-415e-9736-e2d6a9a0f9b5
4
@Override public Map<UUID, String> call() throws Exception { Map<UUID, String> uuidStringMap = new HashMap<UUID, String>(); for (UUID uuid : uuids) { HttpURLConnection connection = (HttpURLConnection) new URL(PROFILE_URL + uuid.toString().replace("-", "")) .openConnecti...
4b355869-498b-4cc2-98f7-28a28bf13450
5
public static void main(String[] args) throws InvalidFormatException, IOException, ClassNotFoundException, InterruptedException { InputStream is = new FileInputStream( "en-pos-maxent.bin" ); setModel( new POSModel( is ) ); //use sockets? System.out.print("USE SOCKETS? "); boolean useSockets = scan.next...
8bf36192-64c6-4fa8-93b3-74daad6dde4f
3
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { fcSkin = new javax.swing.JFileChooser(); grbLogin = new javax.swing.JPanel(); lblUsername = new javax.swing.JLabel(); txtUsern...
5c029e19-1d5b-4d55-804c-d0df0bf9a680
1
public void addClassAnalyzer(ClassAnalyzer clazzAna) { if (innerAnalyzers == null) innerAnalyzers = new Vector(); innerAnalyzers.addElement(clazzAna); getParent().addClassAnalyzer(clazzAna); }
ea457ede-4621-4c49-abd4-31db087ed13e
2
@Override public void run() { while (true) { repaint(); try { Thread.sleep(10); } catch (InterruptedException e) { } frame++; } }
721920dc-eaaa-4004-b29e-9a494890dc43
1
@Override protected boolean doDelete(final String key) { boolean ok = client.delete(key); if (!ok) { CacheErrorHandler.handleError(new Exception("Memcached:删除缓存Key[" + key + "]对应的对象失败")); } return ok; }
7c00109e-c5a9-4a04-9d8b-e5f81eb243db
5
public void askActionType(List<String> actions) { System.out.println(this.texts.get("actionType")); String result = ""; for (int i = 0; i < actions.size(); i++) { result += "\t[" + (i + 1) + "]\t" + actions.get(i) + "\n"; } System.out.println(result); String rep = ""; int indexRep = -1; boolean e...
f11c5afc-3136-4de6-8a27-4a2b8a3f20cd
6
@Override public int processMessage(String msg) { System.out.println(msg); String[] action = msg.trim().split(":"); if(!action[0].equals(tabPlayer[currentPlayer].getId())) return -2; if (action[1].equals("MOVEB")) { if(moveB(tabPlayer[currentPlayer].getColor(), action[2], action[3])) return 0; els...
37b34f8c-0937-4e01-939d-4ced44f69340
6
public static boolean chooseSave() { JFileChooser cho = new JFileChooser(file); cho.setFileSelectionMode(JFileChooser.FILES_ONLY); FileFilter emu = new FileFilter(){{} @Override public boolean accept(File f) { if (f.isDirectory()) return true; String ext = getExtension(f); if (ext != null) { ...
03e4952e-63af-471f-956e-70621c7bfe05
4
public boolean isOptOut() { synchronized (optOutLock) { try { // Reload the metrics file configuration.load(getConfigFile()); } catch (IOException ex) { if (debug) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g...
50ebc905-2ce7-4cbb-b8bb-2c8f8c8652ac
0
public String getTrainNumber() { return this._trainNumber; }
d937ac99-4252-4914-a87e-c34989ea7dd0
5
@Override public Object solve() { int max = 0; for (int i = 0; i < 20; i++) { for (int j = 0; j < 20; j++) { for (Direction d : Direction.values()) { if (isAValidDirection(d, i, j)) { int val = calculateProduct(d, i, j); ...
aa03cddc-b98c-4183-85bf-715a84d7b824
3
public boolean isPrime(long num) { if (num%2 == 0) { return false; } for (int i = 3; i*i <= num; i+=2) { if (num % i == 0) { return false; } } return true; }
d68daf1d-9243-44d4-a296-a723720f3afc
1
public void pause() { for (ConnectionProcessor pipe : pipes) { pipe.pause(); } }
783301ba-a11f-4bf1-bd92-760b7b32fe6e
1
public static ArrayList<Excel> rotateX(int angle, ArrayList<Excel> toScale) { ArrayList<Excel> result = new ArrayList<Excel>(); double matrix[][] = { {1, 0,0,0}, {0, Math.cos(angle * Math.PI/180), Math.sin(angle* Math.PI/180), 0}, {0,(-Math.sin(angle* Math.PI/180)), Math.cos(angle* Math....
b44c0b0c-af1c-45b6-930d-96b059fd5cd8
2
public void broadcast(String broadcastMessage){ Iterator<DCBroadcastReceiver> it = dCBroadcasterSubscribers.iterator(); while(it.hasNext()) { DCBroadcastReceiver subscriber = it.next(); if (subscriber==null) { it.remove(); } else { subs...
d656914e-a52d-418d-8e1d-e740327d33b2
6
static void checkMethodSignature(final String signature) { // MethodTypeSignature: // FormalTypeParameters? ( TypeSignature* ) ( TypeSignature | V ) ( // ^ClassTypeSignature | ^TypeVariableSignature )* int pos = 0; if (getChar(signature, 0) == '<') { pos = checkFormalTypeParameters(signature, pos); } ...
545c7e66-d1f7-4dee-aee5-253962455046
1
public void addHability(Ability ability) { if(!this.abilitiesListed.contains(ability.getName())) { buttons[cur].setAbility(ability); buttons[cur].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectedAbility = ((AbilityButton)e.getSource()).getAbility(); own...
39b35edf-0a4d-48d8-b381-c7e79c7e7b8d
9
private void setOutputFormatNumeric() { if (m_Indices == null) { setOutputFormat(null); return; } FastVector newAtts; int newClassIndex; StringBuffer attributeName; Instances outputFormat; FastVector vals; // Compute new attributes newClassIndex = getInputFormat().clas...
751823a5-7e90-4c50-b005-d0a0d7b5a8f3
8
private Object genRandom(Class<?> clazz) { Object rand = null; if (clazz == Boolean.class) { rand = random.nextBoolean(); } else if (clazz == Integer.class) { rand = random.nextInt(); } else if (clazz == Long.class) { rand = random.nextLong(); } else if (clazz == Double.class) { rand = random.ne...
08bf5bff-c39f-4930-b1d0-697824ae03e3
7
static boolean isThereAStraight(Hand hand){ //first check for ace low straight if (hand.get(0).getValue() == 2 && hand.get(1).getValue() == 3 && hand.get(2).getValue() == 4 && hand.get(3).getValue() == 5 && hand.get(4).getValue() == 14) return true; for(int x = 0; x < hand.size()-1 ; x++) // look for...
4f110985-791b-4485-b3eb-6a9ff69061d7
3
MainWindow() { this.setLayout(new BorderLayout()); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(WINDOW_DEFAULT_WIDTH, WINDOW_DEFAULT_HEIGTH); this.setTitle(WINDOW_TITLE); this.setMinimumSize(new Dimension(WINDOW_MIN_WIDTH, WINDOW_MIN_HEIGTH)); fram...
4eefcf3c-da77-470d-ab86-3687b6cf6530
0
public String getCountry() { return super.getCountry(); }
42723639-56f0-4a0c-b663-2860e3eb18e9
7
public int check() { if (columns < 3 || rows < 3) { return 1; } else if (timesteps < 1) { return 2; } else if (constantK <= 0 || constantK > 1) { return 3; } else if (timesteps > 100) { return 4; } else if (rows * columns > 3600) { ...