method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
faec000d-f2be-49e5-8b21-fd44c6ae042f
5
public void mouseClicked(int button, int x, int y, int clickCount) { switch (GameplayState.currentState) { case PAUSED: case PLACE: case NORMAL: this.gui.mouseClicked(button, x, y, clickCount); break; case WIN: case LOSE: this.gameOverUI.mouseClicked(button, x, y, clickCount); break; } }
5ef5fc62-544a-45a8-99ee-f2326de1a01c
1
public Object next() { int pos = rand.nextInt(pool.size()); Iterator i = pool.iterator(); while (pos > 0) i.next(); return (String) i.next(); }
da1dd088-7789-40f8-b2d9-7ed43d81850a
3
public DialogCase open() { Shell dialog = createContent(); UI.centerShell(shell, dialog); dialog.open(); while (!dialog.isDisposed()) { if (!dialog.getDisplay().readAndDispatch()) dialog.getDisplay().sleep(); } if (!dialog.isDisposed()) { dialog.close(); } return dialogOutput[0]; }
6210df02-e6fc-4893-9bbb-ee6e21a7063a
5
public KorpaBean PotrosackaKorpa(KorisnikBean kb) throws Exception{ KorpaBean korpa = null; try{ stmt=con.createStatement(); String query1 = "select * from potrosackakorpa where korisnikID=(select KorisnikId from korisnik where korisnickoIme = '"+kb.getKorisnickoIme()+"' ) A...
af4a37a5-e935-453f-87b1-c857484d8dde
1
public void testWithStartInstant_RI2() { Interval test = new Interval(TEST_TIME1, TEST_TIME2); try { test.withStart(new Instant(TEST_TIME2 + 1)); fail(); } catch (IllegalArgumentException ex) {} }
b287e30f-ee99-4c94-b303-fec7ad7d7d54
3
public static int maxProfit(int[] prices) { int profit=0; if(prices.length <= 0) return profit; for(int i=0;i<prices.length-1;i++){ if(prices[i+1]-prices[i] >0) profit+=prices[i+1]-prices[i]; } return profit; }
b5a35bbc-d8e0-4d83-82b6-8c420332d271
4
@Override public void union(Vector vector, VectorVectorMapper callback) { int size = Math.max(size(), vector.size()); for(int i=0; i<size; i++) { float v1 = get(i); float v2 = vector.get(i); if (v1 != 0 || v2!= 0) { if (!callback.map(i, v1, v2)) { ...
6bec025e-6aa9-4ee7-8b4c-f607eec5e746
5
public void addCalendar(boolean weekView, Date date) { JPanel container = new JPanel(); FlowLayout panelLayout = new FlowLayout(); panelLayout.setHgap(0); panelLayout.setVgap(0); container.setLayout(panelLayout); scrollPane = new JScrollPane(container); if (weekView == true) { int width = 100; ...
007f1b82-b98a-4871-be6b-5e534fee39f9
4
public static boolean insertlistcheck (Connection conTst ) throws SQLException { boolean chk = true; boolean doCreate = false; try { Statement s = conTst.createStatement(); s.execute("update SYSTEMINSERT set ENTRY_DATE = CURRENT_TIMESTAMP, INSERT_ITEM = 'TEST ENTRY' where 1=3");...
5508194d-ad7b-4d41-a97c-b74cd41adf43
5
public Disparo doDisparar(TipoDisparo tipo, Posicion posicion){ Disparo disparo = null; switch(tipo){ case CONVENCIONAL: disparo = new Convencional(this, posicion); disparo.setCosto(200); this.disparar((Convencional) disparo); break; case MINA_SIMPLE: disparo = new MinaRetardada(this, posi...
045b4234-9dbd-48bb-9119-583389626465
9
private void updateState(boolean sevenedOut) { if (isNumberEstablished()) { if (dice.getTotal() == 7 || dice.getTotal() == number) number = 0; } else { if ((dice.getTotal() >= 4 && dice.getTotal() <= 6) || (dice.getTotal() >= 8 && dice.getTotal() <= 10)) number = dice.getTotal(); } RollComple...
cc565c53-85e4-49e2-bf07-65b73482e876
9
protected boolean isSubTypeOf(final Value value, final Value expected) { Type expectedType = ((BasicValue) expected).getType(); Type type = ((BasicValue) value).getType(); switch (expectedType.getSort()) { case Type.INT: case Type.FLOAT: case Type.LONG: case Type.DOUBLE: return type.equals(expectedType...
c0b2a381-b4c1-4c3a-a6e5-bbfb09ceb404
5
@Override public String toString() { StringBuilder string = new StringBuilder(game.name) .append(" - (") .append(game.getTick()) .append(":") .append(String.format("%.3f", (double) game.getFrames() / game.getTick())) .append("):...
769d073d-6495-402e-9ce9-bad799cfb25d
4
public void print(){ for(int k=1;k<=cols;k++){ System.out.print(vnames[k]+"\t"); } System.out.print("\n"); for(int k=1;k<=cols;k++){ System.out.print(vunits[k]+"\t"); } System.out.print("\n"); for(int i=0;i<rows;i++){ for(int j=0;j<cols;j++){ System.out.print(vls[i][j]+"\t"); ...
0b3b0f93-0889-4a2c-8a38-6cd792c3140b
8
public void writeCONTROL_REG(int /* reg8 */control) { waveform = (control >> 4) & 0x0f; ring_mod = control & 0x04; sync = control & 0x02; int /* reg8 */test_next = control & 0x08; if (ANTTI_LANKILA_PATCH) { /* * SounDemoN found out that test bit can be used to control the * noise register. Hear t...
4d88a3f5-603d-402e-ab66-66c10d52d26a
8
public void setGoalGradMerged() { // set high values for (int row = 0; row < Board.getNbRows(); row++) { // for each col for (int col = 0; col < Board.getNbCols(); col++) { goalGradMerged[row][col] = -1; } } int value; ...
877ce014-6c01-48b2-b1c2-a4cadc37c52c
5
public static void main(String args[]) { int x; for (x = 0; x < 6; x++) { if(x == 1) System.out.println("x is one"); else if (x == 2) System.out.println(" x is two"); else if (x == 3) System.out.println(" x is t...
23e159aa-e757-4426-b46d-7b7559ffcabc
5
protected static void search(ProcessSearchRentacars processSearchRentalcars) { StringBuffer stringBuffer = new StringBuffer(TravelSDK.INSTANCE.getSettingsResult().getWsUrl()); stringBuffer.append("?prgm=rentacar.search"); TravelSDK.appendStandartServiceParameters(stringBuffer); stringBuffer.append("&limit=").ap...
e8b4d922-adbe-4694-917d-42d74d8e4f93
9
private void initA() { A = new HashSet<Edge>(); vertex = new HashSet<Integer>(); // copy edges: ArrayList<Edge> ce = new ArrayList<Edge>(edges); int cost = ce.get(0).getweight(); Edge anedge = ce.get(0); // 1. find a least cost edge and insert to A as first Edge for (Edge E : ce) { if (E.getweight() ...
b6e09705-4ad6-442d-9360-acd5568afb9d
1
public void setMasterVolume(float masterVolume) { this.masterVolume = masterVolume; adjustVolume = true; if(background != null) background.adjustVolume(masterVolume); }
340b3292-e5f8-4872-a1d8-db8440b65357
5
protected void moveCar(int[] nextCoordinates) throws GameEndException{ if(countMoves > 10000/waitingDuration){ throw new GameEndException("Car " + name + " has " + getPoints() + " points"); } if(nextCoordinates[0] != -1){ this.x = nextCoordinates[0]; this.y = nextCoordinates[1]; Field newField = ...
1cddf1e0-9513-4d52-a27c-0b0a955ef566
6
void deviceAdded (Device dev, DefaultTreeModel model) throws IOException { HubNode h = getHubOf ("add", dev); if (h == null) { System.err.println ("what hub has " + dev); return; } else if (h != this) { h.deviceAdded (dev, model); return; } synchronized (children) { for (int i...
eda27ae9-8e5e-484d-b1b5-16bb85b2fcbc
6
public static JButton getAttackButton() { if (attackButton == null) { attackButton = new JButton("Attack"); attackButton.setEnabled(false); attackButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (GameData.COLLECT_ROUND == true) { gameLabel.setTe...
c2637356-085d-49c1-9afc-2412212d7a17
7
public int compareToNumbers(double n1, double n2, String name1, String name2, boolean descending) { int order = (descending ? -1 : 1); // Both are NaN => compare strings (always in alphabetical order) if (Double.isNaN(n1) && Double.isNaN(n2)) { return name1.compareTo(name2); } // One of them is NaN? (when sor...
3e5b8882-a0ce-4157-8923-7053125f7c20
6
public void push(String stack, E element) { synchronized(lock) { if(STACK1.equals(stack)) { array[tail1++] = element; if(tail1 >= array.length/3-1) { resize(); } } else if (STACK2.equals(stack)) { array[tail2--] = element; if(tail2 <= tail3+1) { resize(); } } else if (STACK3...
296abf54-418a-46b0-970a-ec6c4db19785
1
private Scene createPreloaderScene() { loading = new Loading(); try { loading.buildComponents(); } catch (IOException ex) { } return loading.getScene(); }
7e4a9551-231b-43c5-828a-c2be8d221312
9
public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) { mv.visitFieldInsn(opcode, owner, name, desc); if (constructor) { char c = desc.charAt(0); boolean longOrDouble = c == 'J' || c == 'D'; switch (opcode) { case GETSTATIC: pushValue(OTHER); ...
3062b748-93a0-4091-ad79-bb70c024a8a1
7
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
f1340508-300b-40cb-b83a-2fd8e52f32df
9
private void cppPrintMethodSignature(Method m, boolean isImplementation, boolean isStatic) throws ClassNotFoundException { out.print("\t" + (isStatic && !isImplementation ? "static " : "")); cppPrintType(m.getReturnType(), false); if (isImplementation) out.print(classNameWithUnderscores + "::"); out....
3c030de6-87e5-4f1b-bf70-5aaa2fb3e180
3
private static int fastSq(int base, int power) { if (power == 1) { return base; } else if (power == 0) { return 1; } else if (power % 2 == 0) { return (int) Math.pow(fastSq(base, power / 2), 2); } else { return (int) (Math.pow(fastSq(base, power / 2), 2) * base); } }
29023051-1567-46b1-97cc-8dcd0f4cfcbd
1
public String getStringWithDefault(String entry, String defaultEntry) { String result = getString(entry); if (result == null) { result = getString(defaultEntry); } return result; }
d5459cda-035a-41d9-b820-9662e75d203c
8
public GameOptions() { setResizable(false); setBounds(100, 100, 267, 221); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(null); final JToggleButton tglbtnDefaultMaze = ne...
348ac1e0-63f9-42ab-84a7-a788c5dd29e7
5
public static void ReadFromFile(String fileName){ BufferedReader br = null; try{ br = new BufferedReader(new FileReader(fileName)); String line = null; while((line = br.readLine()) != null){ HashMap<Integer, ArrayList<Double>> geneEntry = new HashMap<I...
c00fd46b-4d88-4624-9ce7-bd2051479570
7
private void getOldMods(){ Patch_Controller.delete(new File(Strings.TEMPORARY_DATA_LOCATION_B)); UnZip.unZipIt(Strings.MODDEDZIP_LOCATION, Strings.TEMPORARY_DATA_LOCATION_B); ArrayList<Integer> rows = new ArrayList<Integer>(); ArrayList<Integer> rows1 = new ArrayList<Integer>(); try { ArrayList<String[]> ...
79a8aefd-e1fd-4350-a6da-cf2d2d226689
4
public String toString() { String s; s = "Vertices:\n"; for (int i=0; i < current; i++) { s += " " + i + ": " + locations[i].getName() + "\n"; } s+="\n"; s += "Edges:\n"; for (int i=0; i < current; i++) { for (int j=0; j < i; j++) { if (adjacent[i][j]) { s+=" ...
d80ecab6-e207-4e11-93f3-8ffa66ae6b49
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 fe...
031ce74f-dd6c-4b36-947f-d98411e1adfc
3
public static int getBillTotalCost(int billId) { int total = 0; String query = "SELECT ifNull(sum(`cost` * `quantity`),0) + `consultationCost` as `total` " + "FROM `bill` " + "LEFT JOIN `billItem` on `bill`.`billId` = `billItem`.`billId` " + "LEFT JOIN `m...
a34af2fa-edd1-44c4-9545-bacafb324e57
5
public void move(boolean isLeft) { if (this.getLeft() <= 0 && moveInt == 1) { this.setMoveInt(0); x = 1; } else if (this.getRight() >= 500 && moveInt == 2) { this.setMoveInt(0); x = 499 - width; } if (isLeft) { x -= 5; }...
b3f21a4f-ab6e-4020-bd9e-a6a0a0563c3e
2
public void testPropertyAddNoWrapHour() { TimeOfDay test = new TimeOfDay(10, 20, 30, 40); TimeOfDay 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, 2...
5037330d-6564-477f-af1a-ef0f97aeb807
4
public ArrayList<Patch> getTargetsInRange(int r){ ArrayList <Patch> ans = new ArrayList(); ArrayList <Patch> temp = new ArrayList(); ans.addAll(getPatch().getNeighbors4()); while (r > 0){ for (int i = 0; i<ans.size();i++){ if (ans.get(i).getTurtle()==null||(an...
4229b5c6-623c-4b04-ba3a-ce2f4fcd40f1
0
public FenPrincipale() { initComponents(); this.nomAnimal = "Aucun animal"; this.positions = new ArrayList(); this.positionsAff = new ArrayList(); nbrPointsAff = sliderNbrPoints.getValue()+1; nbrPointsAffiche = Integer.toString(nbrPointsAff); cho...
b4a3fe58-ec21-472b-a231-58e87a52e4f5
5
public int getDegree(final City city) { int index = getIndex(city); if (index < 0) { return -1; } int degree = 0; for (int[] edge : edges) { for (int x = 0; x < edge.length; x++) { if (x == index && edge[x] != 0) { degre...
f3f267bc-36d4-4393-b2d1-b1b7b4f80d51
2
public void writeVariable(CycVariable cycVariable) throws IOException { if (trace == API_TRACE_DETAILED) { Log.current.println("writeVariable = " + cycVariable.toString()); } final String name = cycVariable.toString(); if (cycVariable.isHLVariable()) { write(CFASL_COMPLE...
83a7b5e3-7bdf-43df-ae72-e96df6ed238b
0
public Hospital getHospitalidHospital() { return hospitalidHospital; }
a23df4fc-77ed-4561-ab76-a5345515120b
5
@Override public void setMemoryAllocation(int[] memory) { DefaultTableModel mdlMemory = new DefaultTableModel(); if (memory != null && memory.length > 0) { for(int i = 0; i < memory.length; i++) { if (memory[i] > -1) { //If value is -1 then leave it blank mdlMemory.addColumn(i, new Object[]{memory[i]})...
7b21d067-b580-4e58-b514-5649496ba8e3
0
private ReflectUtils() { }
c4579b0f-09a0-4032-83c6-f8a4da5483c1
7
public static void MWF() throws IOException{ int timeblock = 5; BufferedReader r = new BufferedReader (new InputStreamReader(System.in)); while (timeblock > 0){ System.out.println("What would you like to do right now?"); if (timeblock >= 3) { System.out.println("1. Go to class (not likely)"); ...
40872751-3a00-4445-bb42-45a7714dfa0a
9
public void loadFromObject() { try { if (cls==null) return; for (int i=0; i<fields.size(); i++) { String fieldname = (String)fields.get(i); String fieldtype = (String)fieldtypes.get(fieldname); //System.out.println("<field "+fieldname+" "+fieldvalue); if (fieldtype.equals("key") || fieldtype.equals(...
7ce8155b-d7c0-4d84-ade9-34282201880d
7
private void txtPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPasswordActionPerformed String username,stringPass=""; char[] pass; String passHash=""; username=this.txtUsername.getText(); pass=this.txtPassword.getPassword(); for(int...
2928b6aa-317d-4fed-a2bc-ec437855f8c5
9
int insertKeyRehash(char 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 u...
67313954-a69b-4c2f-8da9-7bcb91b49886
0
private void jButton0MouseMouseClicked(MouseEvent event) { this.dispose(); }
655f6e8a-4402-4381-a70d-0bf5e2493f8e
6
public void choixDuGeneral(Set<Joueur> hjoueur, Set<General> hgeneral){ Scanner sc = new Scanner(System.in); String nomgeneral = new String(); for(Joueur j : hjoueur){ boolean isCorrect = false; // On vérifie que le choix du général est bien possible (pas déjà pr...
3132db0a-ec9a-45bf-8ca5-2e7844f35ec7
8
private void splitImage() { int vertical = ytrans[0].length / 8; int horizontal = ytrans.length / 8; for(int y = 0; y < vertical; y++) { for(int x = 0; x < horizontal; x++) { int xoff = (x * 8); int yoff = (y * 8); double[][] Y = new double[8][8]; double[][] Cb = new double[8][8]; ...
8bc5e666-1e6b-4228-b469-0b3ef5944ff6
8
public static short parse_serial_parameter(final String cur_serial_data, boolean highlight, byte show_device_flags) { if (show_device_flags == SHOW_DEVICE_NONE) return ANALYZER_SUCCESS; String title = null; String content = null; String date = null; String time = null; String number = null; String se...
0fc04877-adc3-4717-9f38-012ab961a17b
4
public boolean doLogin(String username, String password){ PreparedStatement preparedStatement; ResultSet resultSet; String dbPassword = null; PasswordService passwordService = new DefaultPasswordService(); Connection connection = DatabaseConnection.connectDB(); // be cons...
ca7fbe53-5a7e-482c-bf41-9f6137679957
8
public boolean stem() { int v_1; int v_2; int v_3; int v_4; // (, line 64 // do, line 66 v_1 = cursor; lab0: do { // call mark_regions, line 66 ...
0e686bd7-df86-4783-a5cf-82961fd7225e
2
private static TypedObject parseObject(LinkedList<Character> json) { TypedObject ret = new TypedObject(null); char c = json.removeFirst(); if (c == '}') // Check for empty object return ret; json.addFirst(c); do { json.removeFirst(); // Read quote String key = parseString(json); json.remove...
6f9aea48-8fad-487f-8a44-aa773200e824
4
public void convertPointsToShape(){ if(allData.size()!=0) return; try{ for(int i=0; i<allPoints.size(); i++){ SeShape shape = new SeShape(); ArrayList<SDEPoint> points = allPoints.get(i); //convert to array of SDEPoint SDEPoint pts[] = new SDEPoint[points.size()]; for(int j=0; j<pts.leng...
2fa5cb3a-e7ce-43eb-96ed-bf8d1d3a8983
2
public static Object fromByteArray(byte[] array){ try{ ByteArrayInputStream bis = new ByteArrayInputStream(array); ObjectInput in = null; in = new ObjectInputStream(bis); Object o = in.readObject(); try{ bis.close(); in.close(); }catch(Exception e){System.out.println("A Memory Leak Has Happ...
bcda7cd1-e850-4716-afc2-a806810b1f1a
6
public ListNode mergeTwoLists(ListNode l1, ListNode l2) { if(l1 == null) return l2; else if(l2 == null){ return l1; } ListNode head = new ListNode(-1); ListNode index = head; while(l1 != null && l2 != null){ if(l1.val > l2.val){ ...
8f7677e9-b296-4883-8f10-83c31fb9219f
3
private void getEndElement(String name) throws MiniXMLException { MiniXMLToken oMiniXMLToken; boolean bEnd = false; // String attrName, attrValue; MiniXMLEndElement element = new MiniXMLEndElement( automaton.getStateInt(), name); automaton.endElement(name); // System.out.print("</" + name); do { oM...
73d8efc2-c846-48dd-a7e2-1347b2c17963
2
public Final fingFinalByValues(List<String> values){ for(String value : values){ Final finalElement = findFinalByValue(value); if(finalElement != null) return finalElement; } return null; }
50c78377-f4b1-47be-81a2-f4c307220d46
3
private void timerActie(){ if(baanTeller < baanPad.size()){ volgendeStapAfgelegdeBaan(); if(baanTeller == baanPad.size()){ try{ onCompleteFunc.call(); //moet gecalld worden op de voorlaatste stap van de animatie } catch(Exception e){ ...
3e4e9b08-47e6-49da-9042-81fc3e647416
7
public void testBuildInitialization() { String[][][] results; Instances inst; int i; int n; int m; results = new String[2][m_Instances.numInstances()][m_NumNeighbors]; // two runs of determining neighbors for (i = 0; i < 2; i++) { try { m_NearestNeighbourSearch.se...
0b1b69fc-2731-48a1-86e6-139a1f5b5b27
9
private void doQueryRound(int n, int range) { Future<RPCMessage> futureReply; int i=0; int rangeCounter=1; Iterator<Contact> it = shortList.iterator(); Contact c; while (it.hasNext() && rangeCounter <= range && i < n) { c = it.next(); //if c is unprobed and it is not the local node then que...
a6a3a9a8-c549-4c99-a204-54f0c28bc19f
6
public void layout(Graph g, Set notMoving) { graph = g; ArrayList vertices = getMovableVertices(graph, notMoving); if (graph==null || vertices.size() == 0) return; /* After checking to see if the graph has movable vertices, sort the vertices * degree in the graph, and then insert them in a VertexChain ...
5e987455-1581-4b08-8810-2e8eb5d2170b
8
* @param id 選択レコードのID */ private void setTblData(boolean selectedQuery, String selectedId) { // ソート解除 for (int i=0; i<recTable.getColumnCount(); i++) { recSorter.setSortingStatus(i, TableSorter.NOT_SORTED); } DefaultTableModel dataModel = (DefaultTableModel)recSorter.getTableModel(); dataModel.set...
1595435a-6e87-4c1f-af8d-45c821f8ddea
5
public static Path findDoorToDoorPath(Door start, Door end) { double[][] adjacency; if (start.equals(end)) { Path result = new Path(start.getCentralPoint(), end.getCentralPoint()); result.add(start.getCentralPoint()); return result; } try { adjacency = SimulationEngine.getInstance().getWorld() ...
eada36fd-312b-477c-a571-442a1e99a131
0
public void setVue(VueAbstraite vue) { this.vue = vue; }
fc16ad63-49c3-4620-a65d-08be50da749f
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...
d5fd38f1-2787-43f8-9d98-bf62e9e86e02
4
public void executeCommand(final String... inputs) throws IOException { final ArrayList<String> commands = new ArrayList<String>(); commands.add("c:/windows/system32/cmd.exe"); commands.add("/c"); for (String x : inputs) { commands.add(x);...
ec66b43f-97c1-46b9-8323-7c6d04b052d8
8
private static boolean allSameFormat(List<String> input, ArrayList<SECTION_ALIGN> order) { int n = 0; if (order == null) { order = getAlignOrder(input.get(0)); ++n; } // now check that remainder follow this order for (; n < input.size(); ++n) { String line = input.get(n); int formatNum = 0; for...
ebb47273-1437-42df-bc80-425c5f0acd1c
2
@Override protected void shutdownOutput () throws IOException { if ( !this.closed && this.fd.valid() ) { NativeUnixSocket.shutdown(this.fd, SHUT_WR); } }
f8295215-6cf1-482a-aaa6-8f3fc53b95b6
8
public void generateNet (int length, int width) { ArrayList<Node> firstLayer = new ArrayList<Node>(); ArrayList<Node> secondLayer = new ArrayList<Node>(); // populate the first layer for (int i = 0; i < width; i++) { InputNode firstNode = new InputNode(getNextId());...
6fbbe95b-2cde-4291-8050-3f679e25ea1d
9
public void actionPerformed(ActionEvent e){ if(e.getSource().equals(timer)){ model.updatePositions(); view.update(); timeCounter += (int)timer.getDelay(); if(record){ try { skrivfil(); } catch (IOException e1) {} } } if(e.getSource().equals(recordButton)){ if(!record){record=true; } el...
12b40a5e-9fa0-452c-bb53-36e73f7fe238
6
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); request.setCharacterEncoding("UTF-8"); User loggedIn = (User) session.getAttribute("loggedIn"); String na...
6f921a08-de80-4f84-b1ec-bca106ebe342
5
@Override public Date decodeFromString(String value) throws Exception { if (value.contains("y")) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 0); ...
e9a8586a-f8c3-4e1c-b52b-9a2577f4042d
9
static boolean seq_valid(int[] seq) { int j; boolean positive = false; boolean pred_not = false; boolean operand = false; for(j=0;j<SEQ_MAX;++j) { switch ((seq)[j]) { case CODE_NONE : break; case CODE_OR : if (!operand || !positive) re...
e0ac1fb3-aeb0-4fc3-ab31-e3ae7d5b5593
1
private static byte[] readPasswordFromHex(String hexPassword) { byte[] passwordBytes = new byte[hexPassword.length() / 2]; for (int i = 0; i < passwordBytes.length; i++) { passwordBytes[i] = (byte) Integer.parseInt(hexPassword.substring(2 * i, 2 * i + 2), 16); } return passwo...
f8b2998d-00c8-414a-b53b-75eb4399d305
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 Roles)) { return false; } Roles other = (Roles) object; if ((this.rolidRol == null && other.rolidRol != null) |...
9f0ac1b3-6bb7-474e-9101-0a9fc42b895a
5
@Test public void testDuplicateAnalyzerMethods() throws IOException, TesseractException { // HACK: this will be impossible to maintain. Need a better way to identify and // test methods that should fail (possibly reflection) ImageAnalyzerFactory factory = TestContext.getImageAnaylzerF...
753056d5-7b61-466c-8b77-8607db6c117b
7
public boolean validargrado(String Grado) { boolean correcto = false; String[] rrecorregrado = Grado.split("-"); // for (int i = 0; i < rrecorregrado.length; i++) {} try { if (esnumero(rrecorregrado[0]) && esnumero(rrecorregrado[1]) && Integer.parseInt(rrecorregrado[0]) <= ...
4723b569-f4d6-44ca-941a-fc3037c638c1
2
@Override public boolean equals(Object r) { return r != null && r instanceof Reponse && getId() == ((Reponse)r).getId(); }
413cffed-44eb-4b8e-9205-e28cce209fdc
2
private void playSong(){ if(songStatus == SONG_STOPPED){ Song selectedSong = playerLibrary.getSongByIndex(titlesList.getSelectedIndex()); myPlayer = new MP3Player(selectedSong); new Thread(myPlayer).start(); songStatus = SONG_PLAYING; songInfoField.set...
4c62661a-9b3c-42de-bbe6-2a65f7c4e787
6
public String addRoute(List<String> stationsForNewRoute, String routeName) throws IOException { String message = ""; log.debug("Start method \"addRoute\""); if (stationsForNewRoute.size() <= 1) { message = "Маршрут должен содержать больше одной станции"; return message; ...
23436c55-1548-45cd-a7e5-ba3229469dc5
3
public static void main(String[] args) { // TODO Auto-generated method stub String Driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String connectStr = "jdbc:odbc:test"; try { Class.forName(Driver); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { Co...
2f914e21-d0ed-446e-930f-c10158c7fbc7
2
public boolean removeID(String ID) { boolean OK = false; OK = IDList.remove(ID); //If false, then ID not found! IDList.remove(ID); System.out.print(IDList); if( OK ) { int gradeHistIndex = Integer.parseInt( ID.substring(0,1) ); gradesHist.set(gradeHistIndex, new Integer(( (Integer)gradesHist.get(grad...
b65e4aaa-c5ce-4919-b8f3-d127aa8fc00d
8
private void jButton9MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton9MouseReleased // TODO add your handling code here: //System.out.println(this.CommandBox.getSelectedIndex()); switch ( this.CommandBox.getSelectedIndex() ) { case 0: comm...
95fb8abf-4945-46e5-b433-b188169bdafb
9
public static void evaluate_queue(String type) { System.out.println("Evaluating " + type + " queue +++++++++++++++++++"); int total_ops = 25000; int[] n_threads_arr = {2, 3, 4, 5, 6}; for (int t = 0; t < n_threads_arr.length; t++) { int n_threads = n_threads_arr[t]; System.out.println("For " + n_threads +...
9d82e4ef-79af-43a4-9390-3b34f3945e90
6
public boolean validFile() throws NullPointerException { String regex = "(<notestore)(.*)(nextId=\")(\\d+)(\">)(.*)(<\\/notestore>)"; Pattern p = Pattern.compile(regex, Pattern.DOTALL); Matcher m = p.matcher(data); if(m.find()) { regex = "(<note>)(.*?)(<\\/note>)"; p = Pattern.compile(regex, Pattern.DO...
b5d53908-3ae5-4ff0-933f-6cec5857bcfb
6
private final void method740(AbstractToolkit var_ha, Class72 class72_60_) { Model class124 = Class300.createModel(0, Class260.aClass45_3309, anInt1224); if (class124 != null) { var_ha.getDimensions(anIntArray1226); var_ha.setDimensions(0, 0, anInt1220, anInt1220); var_ha.drawQuad(0, 0, anInt1220, ...
da662fb8-3b5c-4589-a7a2-59505655847b
1
public void mouseDragged(MouseEvent e) { if(e.isControlDown()) { markerRect.draw(); markerRect.setWidth(-(mouseStartX-e.getX())); markerRect.setHeight(-(mouseStartY-e.getY())); repaint(); } /* else if(markerRect.isSelectedDrag()) ...
363375ce-d951-4e52-9d04-5419d4412ebd
1
private boolean jj_3_15() { if (jj_3R_33()) return true; return false; }
42f8b8c6-f453-4327-863f-31ce0c3ae3b7
0
@Override public void draw() { glColor3d(255, 204, 0); Rectangle bounds = getAbsoluteRect(); glBegin(GL_QUADS); glVertex3i(bounds.x + width, bounds.y, 0); glVertex3i(bounds.x + width, bounds.y + height, 0); glVertex3i(bounds.x, bounds.y + height, 0); glVertex3i(bounds.x, bounds.y, 0); glEnd(); }
0a233e79-ad23-43f1-a292-20196654e633
2
private Chunk generate(Point p) { Chunk c = new Chunk((new Random()).nextInt(Chunk.NUM_BIOMES-1), 0, p); if (p.x == 0 && p.y == 0) { ArrayList<Villager> population = new ArrayList<Villager>(); population.add(new Villager()); population.add(new Villager()); population.add(new Villager()); populatio...
b4819a86-a547-4483-9eca-668b7a49b11e
8
@Override /** * Issues actions to units *@param gs the game state *@param time_limit how much time is given for this turn (msec) */ public void getAction(GameState gs, int time_limit) { turn_start = System.currentTimeMillis(); turn_limit = time_limit; state = gs; current_turn++; if (!init) { ...
a5c92b15-3986-4509-8d40-cc3aba903bad
4
private void runTree(RBNode root) { if (root != nil) { if (root.getColor() == Color.BLACK) { treeStr.add(root.getKey() + " [style=filled,color=black,fontcolor=white];"); } else { treeStr.add(root.getKey() + " [style=filled,color=red];"); } ...
d91ec965-abdb-4c68-9600-5150da7747c8
6
public static Visualization Fusion(Visualization visu1, Visualization visu2) throws IncompatibleIndexAxisException { Visualization visualization = new Visualization(); for(Resource resource : visu1.getResources()) visualization.addResource(resource); for(Resource resource : visu2.get...
96e4210a-2c85-4045-94fb-bdc07e58cb0f
9
public List<String> getWords(){ List<String> res = new ArrayList<String>(); for (int x = 0; x < points.length; x++) { for (int y = 0; y < points.length;y++) { Point[][] points = getPointArray(x, y); Point[] word = new Point[WORD_LENGTH]; Boole...
bff69eb0-6dfe-4e0b-974f-82276d95c4d4
2
public void testDefaultSecurity() { if (OLD_JDK) { return; } try { Policy.setPolicy(RESTRICT); System.setSecurityManager(new SecurityManager()); DateTimeZone.setDefault(PARIS); fail(); } catch (SecurityException ex) { ...