method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
8950bae7-2a25-4a21-8d69-1008100a7dfe
6
@Override public void setData(List<Integer> data) { // System.out.println ("Setting display: " + this.id + " with data"); int[] elapsedTimeByteArray = new int[4]; int[] stopTimeByteArray = new int[4]; for (int i = 0; i < 4; i ++){ elapsedTimeByteArray[i]=data.get(i); //System.out.println((byte...
06f9ea6e-9f39-4005-9d36-e155dc52e138
1
protected void checkKey(K key) { if (key == null) throw new Error("Invalid key:null."); }
fd7cc9bb-fd42-48ac-9e3d-08de087af647
0
public Iterator<Item> iterator() { return new ListIterator<Item>(first); }
c121c21d-8550-492d-8bc3-337e4bf1ecc9
4
public static void main(String[] args) { int direction = (int) (Math.random() * 4); switch (direction) { case NORTH: System.out.println("travelling north"); break; case SOUTH: System.out.println("travelling south"); break; case EAST: System.out.println("travelling east"); break; case WEST:...
086580a4-afd4-4095-8164-85fe5c93f873
5
public static int[] insertionSort(int[] array) { if(array == null || array.length <= 1) { return array; } for(int i = 1; i < array.length; i++) { int temp = array[i]; int j = i; while(j > 0 && temp < array[j - 1]) { array[j] = array[j - 1]; j--; } array[j] = temp; } ret...
3adf0b3f-0810-4ed9-bcf1-3262bb7ad590
2
public int getFreeEntityId() { for (int i = 0; i < entities.length; i++) { if (entities[i] == null) return i; } return -1; }
0defef52-5378-4777-b5ab-e0665e49a6e7
3
private void parseSettings( Token token ) { if ( token.equals( "CLASS" ) ) { token = getNextToken(); if ( isNewLine( token ) ) { throwException( "Expected a class name, recieved new line." ); } setClass( toCamelCase( token ) ); // ch...
4ecd8a05-dabc-43b6-978f-a2399a19ef28
9
public GUI(ArrayList<ServerStatus> serverList, getStatus tStatus, Console tC){ status = tStatus; c = tC; this.setLayout(new BorderLayout()); this.setTitle("Diablo III - Server Status"); //menu Panel JPanel menuPanel = new JPanel(); menuPanel.setLayout(new GridLayout(5,1)); // Refresh button JBut...
6def7a54-1080-4a9b-9450-0786b1c06b16
2
public void removeOnetimeLocals() { cond = cond.removeOnetimeLocals(); if (type == FOR) { if (initInstr != null) initInstr.removeOnetimeLocals(); incrInstr.removeOnetimeLocals(); } super.removeOnetimeLocals(); }
a044252d-d5c5-4ee6-9675-e7e254d76520
4
public ViewPersonnelView(PayrollSystemModel model) { this.model = model; deleteBtn = new JButton(new ImageIcon( getClass().getResource("/images/buttons/delete.png"))); statusLbl = new JLabel("Status: No Data Found!"); statusLbl.setIcon(loadScaledImage("/images/notifs/warning.png",.08f)); selectCl...
80e71643-977d-4016-b3d3-9fc3a7b80925
0
public String getStartCity() { return startCity; }
b29fe1b5-25ba-4de2-9a92-5a428853508e
0
public void setId(Long id) { Id = id; }
8ee74b8a-2c31-4253-a8d1-16c96f6a504d
7
public <T> List<T> dumpResultSet(ResultSet rs, Class clazz) { // get the field mapping ArrayList<FieldMap> fieldMap = getFieldMap(rs, clazz); List<T> elements = new ArrayList<T>(); try { while (rs.next()) { Object newInstance = clazz.newInstance(); for (int i = 0; i < fieldMap.size(); i++) { i...
8df5b5cd-227c-4285-bb7f-e87d0d7a7985
2
@Test public void testNumDoors() { int count = 0; for (int i = 0; i < board.getCells().size(); i++) { if (board.getCells().get(i).isDoorway()) { count++; } } Assert.assertEquals(NUM_DOORS, count); }
42985146-c12c-4675-9f45-13c564c150c3
7
public void keyPressed(KeyEvent keyEvent) { Iterator<PComponent> it = components.iterator(); while (it.hasNext()) { PComponent comp = it.next(); if (shouldHandleKeys) { if (comp.shouldHandleKeys()) comp.keyPressed(keyEvent); } ...
c1700e14-9a14-4c05-9231-ea6e80599c52
5
public <V> Adapter.Getter<V> makeGetter(String methodName, Class<V> _class) { try { final Method method = version.getClass().getMethod(methodName); return new Adapter.Getter<V>() { public V call() { try{ lock.lock(); if (firstTime) { ((Recoverable...
5020e776-5f65-4727-a8d9-e4d27243ab2c
8
public static void main(String args[]) { Termio UserInput = new Termio(); // Termio IO Object boolean Done = false; // Main loop flag String Option = null; // Menu choice from user Event Evt = null; // Event object boolean Error = false; // Error flag SCSMonitor Monitor = null; // The envir...
670cf63a-e3c4-4039-8f6f-a43c44229b0b
7
protected String dumpArray(final Object value) { String result; if (value.getClass() == byte[].class) { result = Arrays.toString((byte[]) value); } else if (value.getClass() == short[].class) { result = Arrays.toString((short[]) value); } else if (...
70804428-c7d8-468a-a594-fcd235b413fa
0
public void setCategoryId(int categoryId) { this.categoryId = categoryId; }
622ccf18-6b62-44f0-9970-81c4aba8692a
8
public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { HttpSession session = req.getSession(true); String error = ""; Product product; int sku = 0; int price = 0; int category = 0; long owner = 0; try { // Checks if any attributes were blank ...
3a9df001-5c61-4cb8-bebf-1e7dfe533c08
4
public Snake(Point p, Rectangle field){ if(p.x < field.x || p.y < field.y || p.x >= (field.x + field.width) || p.y >= (field.y + field.height)) throw new IllegalArgumentException(); points = new ArrayList<Point>(); points.add(p); p = new Point(p.x - 1, p.y); points.add(p); p = new Point(p.x - 1, p.y); ...
5020fb00-61eb-4eb1-bd34-dabf9cd74bb9
2
public boolean removeImageButton(String name) { for (ImageButton button : screenObjects) { if (button.getText() == name) { screenObjects.remove(button); return true; } } return false; }
1125da67-acc7-439d-8900-aa0e1ab547be
5
public String getRightResult(long start_ts,long end_ts) { String tempResult=null; for (Map.Entry<String, String> entry : optimizedData.entrySet()) { String times = entry.getValue(); String[] timespan = times.split(","); Long firstTime = Long.parseLong(timespan[0]); Long secondTime = Long.parseLong(times...
f4b362fb-7759-4db4-8f56-df11b9971874
2
@Override public int hashCode() { int result; long temp; result = itemId; result = 31 * result + (name != null ? name.hashCode() : 0); temp = percent != +0.0d ? Double.doubleToLongBits(percent) : 0L; result = 31 * result + (int) (temp ^ (temp >>> 32)); return ...
22d95f61-ae0e-4ffe-9d50-39b8b4ed3d5b
4
@Override public List<Packet> onContact(int selfID, Sprite interactor, int interactorID, List<Integer> dirtySprites, List<Integer> spritesPendingRemoveal, ChatBroadcaster chater) { if (interactor instanceof AmmoPickup && isAlive()) { weaponsDataDirty = true; WeaponInfo wi = getWeapon...
1dd9fab7-82ed-425c-8ea4-39aab3638061
2
private Tree statementsPro(){ Tree statement = null, statements = null; if((statement = statementPro())!= null){ if((statements = statementsPro())!=null){ return new Statements(statement, statements); } return statement; } return null; }
d30ddfed-9714-4552-a531-39da9fa487b5
6
void printSprite() { //Get the current sprite path NodeList listOfMovesSprites = sprites_doc.getElementsByTagName("Move"); boolean sprite_found=false; for(int s=0; s<listOfMovesSprites.getLength() ; s++) { Node move_node = listOfMovesSprites.item(s); Element move_element = (El...
a2415e0a-1510-4a9e-8b7c-f8dbd418ba5b
6
private int valueIexpand(char[] charArray, int i) { if ('I' == charArray[i]) { if (charArray.length > i & ('V' == charArray[i + 1] | 'X' == charArray[i + 1] | 'L' == charArray[i + 1] | 'C' == charArray[i + 1] | 'D' == charArray[i + 1] | 'M' == charArray[i + 1])) { return -1; } else if (ch...
27a55a04-dda7-4b9e-a0c2-e493391ec0fa
5
public void collectStatistics() { String word; int numAccurances; int numAccurancesPerWord; double statistics; boolean accurance; DecimalFormat formatter = new DecimalFormat("##.00"); for (int j = 0; j < alphabet.length; j++) { numAccurances = 0; numAccurancesPerWord = 0; statistics = 0; fo...
2276004e-57dc-45cb-9911-55e68349ba04
6
private void recurseComments(JSONObject jobj, Properties more, HashMap<String, Properties> data) { try { Properties properties = pullComment(jobj, more); if (properties != null) { data.put(properties.getProperty("name"), properties); if (!jobj.getJSONObject("data").isNull("replies") && !(jobj.getJSONObj...
6c42e0c8-4775-4e72-a8ea-2bc2d7c964ef
1
public void pauseSimulation() { if (sim != null) sim.pause(); }
b1cece80-7b32-4f6c-8384-41af271a603f
4
public int gameTeamScore(int i) { if (i >= 2 || i < 0) throw new IllegalArgumentException(); int result = 0; if (i == 0) { result += players[0].getScore(); result += players[2].getScore(); } else if (i == 1) { result += players[1].getScore(); result += players[3].getScore(); } return result; ...
05788c4b-fad1-4985-a028-f769ef0b5fa5
7
private void saveStack() { int height = 0; for (int i = 0; i < stack.size(); i++) { final Expr expr = stack.get(i); if (Tree.USE_STACK) { // Save to a stack variable only if we'll create a new // variable there. if (!(expr instanceof StackExpr) || (((StackExpr) expr).index() != height)) { ...
375534aa-00ce-4e32-ba8a-f2ce4bb4c519
9
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); String username = request.getParameter("username"); String password = request.getParameter("password"); if (username == null || use...
ea166e04-a654-4f98-bb3d-eb39921b479d
0
public SimpleStringProperty phoneTypeProperty() { return phoneType; }
19967d68-704b-4aea-8670-128e8b5c6af6
1
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { accumulator.setLength(0); if (qName.equals("servlet")) temperature = attributes.getValue("id"); }
2699b097-51a6-458b-a104-4e862ab37a20
1
public void setMouseListener(MouseListener mouseListener){ if(this.mouseListener != null){ gamePanel.removeMouseListener(this.mouseListener); } this.mouseListener = mouseListener; gamePanel.addMouseListener(mouseListener); }
8a2c59e4-ba72-4884-96e0-2889307f58bb
9
public void update() { p.update(); for (Tile t : tiles) { t.update(); p.collide(t.boundingBox); } if (p.Position.x > WIDTH - (WIDTH / 8)) { p.Velocity.x *= -1; p.Position.x = WIDTH - (WIDTH / 8); xOffset+=32; for (Tile t : tiles) { t.Position.x -= 32; } } if (p.Position.x < WIDTH /...
17149fda-6d23-4544-b598-faf35b00c683
3
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed int numero = Integer.valueOf(campoNumero.getText()); for (int i = 0; i <= numero; i++) { textArea.append(" " + i); if(i % 25 == 0 && i != 0) ...
10caf844-820b-4eb1-ae09-a79d8eceda44
6
public boolean withdrawEvidence(Evidence evidence, String actionType) { boolean flag = false; Element evidenceE = (Element) document .selectSingleNode("//" + actionType + "[@id='" + evidence.getId() + "']"); if (evidenceE != null) { evidenceE.element("dialogState").setText(evidence.getDialogState()); //...
f828e156-75db-4aba-a7e2-96d85f1433a2
8
public void set(Scanner scan){ System.out.println("SELECT FIELD:\nName\t1" + "\nAddress\t2\nEmail\t3\nPhone\t4\nCity\t5" + "\nState\t6\nZip\t7"); int field = scan.nextInt(); String newVal = ""; System.out.println("you have to enter the same value 3 times."); while(1!=0){ System.out.println("E...
12aa24df-6bf3-48e2-bcd4-17cd1a43172a
7
@Test public void test() { try{ XmlIdRegister register = new XmlIdRegister("pre"); //Generate and register ID with default prefix Id id1 = register.generateId(); assertNotNull(id1); assertTrue(id1.toString().startsWith("pre")); try { register.registerId(id1); } catch (InvalidIdException ...
a780f111-eab2-4a28-b7f6-5c87f6c8985c
3
public void setFirstName(String firstName) throws Exception{ if (firstName.length() < MIN_INT_VALUE || firstName.toString() == null || firstName.length() > MAX_CHAR){ throw new IllegalArgumentException(NAME_ERR); } this.firstName = firstName; }
4d205aff-8888-4705-99b5-25b0b9bbe7af
3
public static void saveFixture(DB db, String name, FixtureResource resource) throws IOException { log.info("Saving [" + db.getName() + "." + db.getCollection(name) + "] to " + resource); int savedIndexes = 0; int savedDocuments = 0; PrintWriter output = new PrintWriter(resource.getWriter()); output.println(na...
e15cbb31-201b-4fb5-bd23-56794f578442
2
public static boolean isChestEmpty(Inventory i){ for(ItemStack is:i.getContents()){ if(is!=null){ return false; } } return true; }
7668ef7a-a921-4971-8c8c-9adc7059838c
8
public SimplifyResult simplify(AdditiveExpression expression) { Multimap<String, ASTElement> mapping = LinkedListMultimap.create(); for (ASTElement term : expression.getChildren()) { MathExpression expr = (MathExpression) term; mapping.put(expr.getSignature(), term); } boolean simplified = f...
bebc98e6-0828-4fb2-9230-d67efa9687e7
0
private Result(Level level, String message) { this.level = level; this.message = message; }
c39fe97d-6063-430c-8646-336d814ac2dc
2
public Auth_frame() { int selection = JOptionPane.showConfirmDialog( null , "Authentication Failed!" , "Input Error" , JOptionPane.OK_CANCEL_OPTION , JOptionPane.INFORMATION_MESSAGE); if (selection == JOptionPane.OK_OPTION) { new Login(); } else ...
1cd6f130-73e4-452c-99af-26aba4cbd450
8
public static Vector performSearch(Graph searchGraph, int nStartNodeID, int nGoalNodeID) { // create the open and closed lists Vector vOpenList = new Vector(); Vector vClosedList = new Vector(); // create the start node as an AstarNode Astar.AstarNode currNode = new Astar.AstarNode(); currNode.m_Node = ...
7a70c3e6-97e8-4984-b4f8-962290b48132
8
@Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String comando=e.getActionCommand(); if(comando.equals("explorar")){ principal.mostrarExploracion(); }else if(comando.equals("buscar")){ principal.mostrarBusqueda(); }else if(comando.equals("historial")){ pr...
10a451d9-35b2-4036-9a46-2bbe0b89ea60
8
public double evaluate(Individual ind) { IntegerIndividual iind = (IntegerIndividual) ind; Strategy es = strategies.get((Integer) iind.get(0)); int score = 0; for (int i = 0; i < maxEncounters; i++) { Strategy s = strategies.get(rnd.nextInt(strategies.size())); ...
93186365-8e5c-4070-980c-891d364ba7b0
8
public void update(String line, LineStatus status, Scanner fileScan) throws IOException { boolean isUrlObjectComplete = false; do { switch (status) { case BlankLine: { add("", BookmarkWorkbench.mainManifest); isUrlObjectComplete = true; } break; case Ti...
00ae5b93-7107-4b07-adb7-f381a83807ad
3
public void refresh() { zoeker.resetMap(accounts.getBusinessObjects()); combo.removeAllItems(); for(Project project : projects.getBusinessObjects()) { ((DefaultComboBoxModel<Project>) combo.getModel()).addElement(project); } Project[] result = new Project[projects.getBusinessO...
3a48a111-0b54-434d-8c91-1e5465fcb9d2
7
public synchronized void addRule(Rule newRule) throws TheoryException { if (newRule == null) throw new TheoryException(ErrorMessage.RULE_NULL_RULE); // throw exception if rule contains no head literals if (newRule.getHeadLiterals().size() == 0) throw new RuleException(ErrorMessage.RULE_NO_HEAD_LITERAL, new Ob...
bd876565-c77f-4af2-a02f-2b166835e812
8
public static double compute(double a) throws ArithmeticException { double MAXLOG = 7.09782712893383996732E2; double x, y, z, p, q; double P[] = { 2.46196981473530512524E-10, 5.64189564831068821977E-1, 7.46321056442269912687E0, 4.86371970985681366614E1, 1.96520832956077098242E2, 5.26445194995477358631E2, 9...
e4b12522-66b6-43a4-bf7c-f3c93bee1178
3
public void saveLaTeXTable(String fileName, List<List<String>> compact, List<List<String>> full) { if (!fileName.contains(".txt")) { fileName += ".txt"; } FileWriter writer = null; try { writer = new FileWriter(fileName); PrintWriter fout = new PrintWriter(writer); fout.println("%"); fout.println...
53d5f208-79e5-48f1-9d63-76c741dba1b4
8
private String formatMonome(int exponent, int coeficient) { if (coeficient == 0) { return ""; } if (exponent == 0) { if (exponent == this.getMaximumExponent()) return "" + coeficient; else return (coeficient > 0) ? "+" + coeficient : coeficien...
1b7f5e82-ef56-48fd-b143-4800fe9e9b71
1
private static void showScreen(final AbstractScreen screenToShow) { for (AbstractScreen screen : screenRef) { screen.setVisible(false); } screenToShow.reset(); screenToShow.loadFields(); screenToShow.setVisible(true); }
2d1d5b4c-29b0-4b2f-863e-7f3ab1c102bc
0
@Override public void characters(char ch[], int start, int length) throws SAXException { super.characters(ch, start, length); }
3160a04f-209c-44a6-90bc-013bf4005c93
7
@Override public int castingQuality(MOB mob, Physical target) { if((mob!=null)&&(target!=null)) { if((CMLib.flags().isSitting(target)||CMLib.flags().isSleeping(target))) return Ability.QUALITY_INDIFFERENT; if((target instanceof MOB)&&(((MOB)target).riding()!=null)) return Ability.QUALITY_INDIFFERENT...
78fc1114-72d8-44fd-94ac-5001eba0cefd
2
public StrongRenamer() { charsets = new String[idents.length][parts.length]; for (int i = 0; i < idents.length; i++) for (int j = 0; j < parts.length; j++) charsets[i][j] = "abcdefghijklmnopqrstuvwxyz"; }
6622d281-13bd-4f04-934d-e4ed6168b8c1
3
private List<String> getProperties() { List<String> properties = new ArrayList<String>(); for (Map.Entry<String, String> field: metadata.getEnvironment().entrySet()) { String fieldKey = field.getKey(); String fieldValue = field.getValue(); if (includeDeprecatedEntries...
89caed8f-b241-4d21-8268-7dce7966fe0e
0
public Vector2f(float x, float y) { this.x = x; this.y = y; }
e1a35fd2-1a9c-4cc3-8cc3-84c7cf291178
8
public void quick(int[] array, int left, int right) { if (left < right) { int i = left, j = right, x = array[left]; while (i < j) { while (i < j && array[j] >= x) j --; if (i < j) array[i++] = array[j]; while(i < j && array[i] < x) i ++; if (i < j) array[j--] = array[i]; } array[i] = x; ...
67a71b56-68c5-441a-8644-33aa6a859931
3
public String getNonPHr(int i){ String hr, min; try{ hr = Integer.toString(nonPeakHr[i].get(11)); if (hr.length()==1) hr = "0" + hr; min = Integer.toString(nonPeakHr[i].get(12)); if (min.length()==1) min = "0" + min; return hr + ":" + min; } catch(NullPointerException e){ } return null;...
43155bdd-7466-4abc-923b-ff3b56de7c1d
8
@Override public byte[] runBinaryMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) throws HTTPServerException { String filename=getFilename(httpReq,""); if(filename==null) filename="FileData"; final int x=filename.lastIndexOf('/'); if((x>=0)&&(x<filename.length()-1)) filename=filename.subst...
21cbdf82-5922-46b2-be1d-d70b619650da
5
protected HTTPResponse handleUriRes(HTTPRequest req) { Matcher m; String urn; String filenameHint; if( (m = rawPattern.matcher(req.path)).matches() ) { urn = urlDecodeString(m.group(1)); filenameHint = m.group(2); } else if( (m = n2rPattern.matcher(req.path)).matches() ) { urn = urlDecodeStri...
a0af1d92-3028-4a80-85ff-85bd4ff64a9b
4
private static long count(long n){ long twon = n*2; String N = Long.toBinaryString(n); String twoN = Long.toBinaryString(twon); if(N.length()<k) return 0; String smallest = findSmall(N); String largest = findLarge(twoN); if(Long.parseLong(smallest, 2) < n || Long.parseLong(largest, 2) > twon) return 0; ...
4e0c0ee7-1954-49db-9ecc-36eb478eb357
0
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + x; result = prime * result + y; return result; }
9a9f03a4-cf8a-4003-ad1f-17b3ab9258a4
3
@Override public Iterator<List<S>> iterator() { TreeNode<S> rootIntermediate = this; while (this.parent != null) { rootIntermediate = this.parent; } final ArrayDeque<TreeNode<S>> stack = new ArrayDeque<TreeNode<S>>(); stack.add(rootIntermediate); List<List<S>> paths = new ArrayList<>(); while (!st...
3b122358-355b-4d94-a2d8-770e4e1c025a
0
public InvalidPageNumberException(Exception ex, String name) { super(ex, name); }
aecba1cf-cf06-4819-81bf-f1d4bb76e326
5
private final Object[] loadScriptParameters(ByteBuffer class348_sub49, int i) { if (i != -1) return null; anInt691++; int i_33_ = class348_sub49.getUByte(); if (i_33_ == 0) return null; Object[] objects = new Object[i_33_]; for (int i_34_ = 0; i_34_ < i_33_; i_34_++) { int i_35_ = class348_sub49.ge...
a41fda80-7215-407f-9580-92a98a81f68e
5
public boolean delete(String zipPath, boolean delDirs) throws IOException { boolean failed = true; Path path = fileSystem.getPath(zipPath); if(!Files.exists(path) && !delDirs) { return false; } if(delDirs) { for(int i = path.getNameCount(); i > 0; i--) { Path p = path.subpath(0, i); try ...
3fbbc39f-d38c-4f8b-b18c-6f3ab96180ee
3
private JsonElement jNull() throws MalformedJsonException{ if(next()=='u' && next()=='l' && next()=='l'){ next(); return null; }else{ throw jsonError("invalid comment", true); } }
10de55aa-954c-42d7-8098-4e5d0af3b755
8
private void overlayFragment(final long pos, long otherOffset, long length, DeltaSource source, FragmentFactory factory) throws IOException, DeltaFormatException { // There is a top layer, find its intersecting common fragments CommonFragment topFragment = commonCursor.next(); if (pos > topFragment.oldOffs...
489b4645-9e92-4ba8-99f5-ce154d589132
7
public static int lengthOfPrimeSum(int[] primes, int n) { int currLength = 0, sum = 0, maxLength = 0; boolean foundSum = false; for (int i = 0; i < primes.length && primes[i] <= Math.sqrt(n); i++) { currLength = 0; foundSum = false; sum = 0; for (i...
a3c0f9ef-3b46-43da-987a-1a6efd551616
4
public static void loadLevel(String levelFile, GameState parentState, ArrayList<GameObject> gameObjectList) { try { BufferedReader in = new BufferedReader(new FileReader(levelFile)); String line = null; int y = 0; while ((line = in.readLine()) != null) { for (int i = 0; i < line.length(); i...
eccbbabd-db6f-4494-82de-d26831ad60fc
4
public boolean[] classify(int datapoint) { double hypothesis; boolean[] class_list = new boolean[classes]; int c, f, i; //System.out.println("Classifying:"); for (c = 0; c < classes; c++) { hypothesis = 0; //System.out.println(" "+data.classlist[c]+":"); for (f = 0; f < features; f++) { //Sy...
837d5cb4-41e7-4c14-9d10-903d68343252
5
private void sort_notes() { if (!notes.isEmpty()) { int min = notes.get(0); for (int i = 0; i < notes.size(); i++) { min = i; for (int j = i + 1; j < notes.size(); j++) { if (notes.get(j) < notes.get(min)) min = j; } if (min != i) { int temp = notes.get(i); notes.set(i, notes.get(...
4765d376-7f35-4122-b551-16427f6c768e
9
public int getHole(){ if(hole > -1){ return hole; } boolean[][] map = copyArray(imageMap); //first, paint the background to black paintBlack(map,0,0); //then, start counting int e = 0; int i = 0; int height = map.length; int width = map[0].length; for (int h = 0; h ...
9c368d6e-585f-473a-86b3-2204751230b3
4
public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); int width = 0, height = 0; if (wHint != SWT.DEFAULT) { width = wHint; } else { if (columns.length == 0) { for (int i = 0; i < itemsCount; i++) { Rectangle itemBounds = items [i].getBounds (false); width = Math.max (wid...
4e338b20-f14a-468a-97f6-79ed4b50f96a
6
public GClicker() throws Exception { super("gClicker"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocation(30, 30); model = new GClickerModel(); myAddress = InetAddress.getLocalHost(); ipAddress = new int[4]; for (int i = 0; i < 4; i++) ipAddress[i] = (0x000000FF & myAddress.getAddress()[i])...
d0a2817a-0bdc-4e96-89ed-c2564e200c43
1
public void setAvailablePieces(List<? extends Piece> availablePieces) { this.availablePieces = availablePieces; }
2937a044-efb5-42e5-af82-c37404b9014a
2
public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); HTTPTokener x = new HTTPTokener(string); String token; token = x.nextToken(); if (token.toUpperCase().startsWith("HTTP")) { // Response jo.p...
4ee2dd43-d221-4e3b-a3cd-d9327b42b7cb
0
public void setWord(Word newWord, int index){ words.set(index, newWord); }
99a1a6fa-9077-4fb1-a6c7-4394333727ec
7
@Override public Object getValueAt(int rowIndex, int columnIndex) { AnsatDTO ansat = ansatList.get(rowIndex); Object value = null; switch (columnIndex) { case 0: value = ansat.getmedArbId(); break; case 1: value = ansat.getfornavn(); break; case 2: value = ansat.getefternavn(); break; c...
e79d7482-2cce-4174-af9e-881bc532b85f
2
public int getLeftnumberByPID(Statement statement,String PID)//根据PID获取剩余车位数 { int result = -1; sql = "select leftnumber from Park where PID = '" + PID +"'"; try { ResultSet rs = statement.executeQuery(sql); while (rs.next()) { result = rs.getInt("leftnumber"); } } catch (SQLException e) {...
ee7f3f98-0f28-42fe-bcd8-264e9b5dfdae
4
public static boolean box_box(double ax0, double ay0, double ax1, double ay1, double bx0, double by0, double bx1, double by1){ double topA = FastMath.min(ay0, ay1); double botA = FastMath.max(ay0, ay1); double leftA = FastMath.min(ax0, ax1); double rightA = FastMath.max(ax0, ax1); double topB = FastMath.min(b...
c0462796-c2c9-4c04-adbd-7b0a3dddf1e8
0
public ListDataOut(){ listDataOut = new ArrayList<DataOut>(); }
6f2fa186-5ae0-4c90-8fa0-a0424fcf0723
2
public void drawSphere(float r, int scalex, int scaley) { BufferData data = RobotRace.VBOUtil.bufferHalfSphere(1F, scalex, scaley); if(r != 1F) gl.glScalef(r, r, r); RobotRace.VBOUtil.drawBufferedObject(data); gl.glScaled(1, -1, 1); RobotRace.VBOUtil.drawBufferedO...
28b808ea-25c0-46d6-9e38-4c1817067f10
3
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Familia other = (Familia) obj; if (!Objects.equals(this.idFamilia, other.idFamilia)) { return...
c9ababb5-637a-4744-afb3-682c49778f80
2
public static int adminSearch(Db db, LogAc logAc, String Username){ int i = 0; while (logAc.getAdmin(i) != null) { if (Username.equals(logAc.getAdmin(i).userName)) return i; i++; } return -1; }
07919169-db9a-42e3-b2dc-b1ac98a1510f
8
@Override public Map<String, Long> startExperiment(int amount, int maxRange, final int iterations, List<SortingAlgorithm> list) { System.out.printf("\n%s", "Starting experiment"); setPause(2); // parameters check if (amount == 0 || maxRa...
f33493b2-c937-4081-85cf-ac300921a305
7
private void initElements(String title, int size, Actor actor, boolean editable) { // labels lName = new JLabel("Name"); lForename = new JLabel("Vorname"); lFamilyname = new JLabel("Nachname"); lNationality = new JLabel("Nationalität"); lBirthday = new JLabel("Geburtstag"); lMovie = new JLabel("Filme"); l...
c3786131-625c-4e01-bdc1-2c3af8b4a20a
8
private void writeChunkToImage(RegionFile region, BufferedImage image, int chunkX, int chunkZ) { if (chunkZ == 0) System.out.print("."); DataInputStream chunkDataInputStream = region.getChunkDataInputStream(chunkX, chunkZ); if (chunkDataInputStream == null) return; try { Tag tag = Tag.readFrom...
ccb04c93-efe8-452b-a4c5-4626804b4fed
4
public void addResultToEvent(String eventIdentifier, Result newResult) { for(Event e: events){ if(e.getIdentifier().equals(eventIdentifier)) { //We check if the result is already there for(Result r: e.getResults()){ if(r.getIdentifier().equals...
0e7c7deb-bc87-4982-935e-53b0c4786aa5
0
@Test public void resolve() { print(squaresOfSum(1,100)-sumOfSquares(1,100)); }
db35f2ab-a6e4-43a5-8651-6d86bd52d3e1
6
@Override void processStatus(Status status) { if (_startDate == null) { _startDate = new Date(); } StringTokenizer tokenizer = new StringTokenizer(status.getText()); while (tokenizer.hasMoreElements()) { String word = tokenizer.nextToken(); if ((_onlyHashtags == false && _stopWords.contains(word)) ...
680ce739-471e-492f-b087-276462f9abbd
9
private void button13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button13ActionPerformed if (order2code2tf.getText().equals("1001")) { o2c2destf.setText("Chicken Nugget"); } if (order2code2tf.getText().equals("1002")) { o2c2...
0dd9b631-5853-414b-84b1-73ebd6d03bdd
9
protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = maxNextCharInd = 0; available = tokenBegin; } else if (tokenBegin < 0) bufpos = maxN...