method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
51f4d040-53b7-4eb6-bf30-2f9aa5501657
6
public static void stringExperiment(PrintWriter pen, SortedList<String> slist) { VerboseSortedList<String> strings = new VerboseSortedList<String>(slist, pen, "strings"); // Add a bunch of strings heading(pen, "Adding first"); String[] first = new String[] { "twas", "brillig", "an...
47cab92a-68ef-4866-a529-db76780658b1
7
public void writeTermsToFile(String strNumber, Hashtable<String, Double> oTermVsTFIDF) throws IOException { String strKey = null; Double maxValue = Double.MIN_VALUE; String strTerms = ""; int len = oTermVsTFIDF.size() < 5 ? oTermVsTFIDF.size() : 5; for (int i = 0; i < len; ++i) { for (Map.Entry<Strin...
7361af99-feed-4c3a-b96e-28e650839431
7
private static String stringForJSON(String input) { if (input == null || input.isEmpty()) return ""; final int len = input.length(); final StringBuilder result = new StringBuilder(len + len / 4); final StringCharacterIterator iterator = new StringCharacterIterator(input); char c...
c86d6ccc-83e9-4d1c-b7b2-469591e172f7
5
public void update(long currentTime) { if (isFinished || target == null) { return; } if (!isStarted) { startTracking(currentTime); return; } int dt = (int)(currentTime - lastTime); lastTime += dt; Point nextLocation; ...
c5d672d2-0855-4d17-a637-cb13a4047eca
5
private void jMenuItem1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem1MousePressed try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); JFrame mainFra...
e8256627-a1e9-4f83-9b72-1789cf562e59
8
public Object makeDefaultValue(Class type) { if (type == int.class) return new Integer(0); else if (type == boolean.class) return Boolean.FALSE; else if (type == double.class) return new Double(0); else if (type == S...
7e913e96-09d1-4cb8-8395-49a3dd445e15
5
public synchronized Connection getConnection() throws ConnectionException{ Connection connection; for ( int i = 0; i < POOL_SIZE; i++ ){ if ( pooledConnections[i] == null ){ connection = createConnection(); PooledSqlConnection pooledConnection = new PooledSqlC...
ab9963d8-727e-4851-ac0e-770d73befad0
6
@Override public void run() { if(elCliente.entrada==null){ System.out.println("El Stream esta null"); return; } System.out.println("Iniciando el Thread el Input"); System.out.println("Esperando mensajes..."); try{ Object in=elCliente.entrada.readObject(); do{ String mensaje=(String)in; //...
af0344e9-4cad-4e4a-8cda-38e72395b280
0
private ServerConnectionType(String type) { this.type = type; }
8b079a8d-fd38-4fb0-abb9-4f213d5c80dc
2
public Counter nextTurn(Counter lastPlaced, Board b) { Counter next = Counter.EMPTY; if (lastPlaced == Counter.BLACK) { next = Counter.WHITE; } else if (lastPlaced == Counter.WHITE) { next = Counter.BLACK; } return next; }
d491d349-da9c-4114-89bc-bfb51cf79a2f
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...
6fb67563-ebad-46a5-8ab1-6168d6a30199
8
public static int searchInt(int[] arr,int low,int high,int x){ if(low>high) return -1; int mid = (low+high)/2; if(x==arr[mid]) return mid; if(arr[mid]>=arr[low]&&arr[mid]>=arr[high]){ if(x>=arr[low]&&x<arr[mid]) return searchInt(arr,low,mid-1,x);//could replace this with binarySearch else return searchInt...
ace6952a-a44f-4f7b-ae25-08193210fd47
7
public void updateUnicodeString( String s ) { if( s.equals( toString() ) ) { return; } // 0 cch 2 Count of characters in string (NOT the number of bytes) // 2 grbit 1 Option flags // make sure to get formatting runs if present byte[] strbytes = null; try { ...
7958e05c-5afc-4730-a1bb-9c1d407da5ad
1
private static void buildCode(String[] st, Node x, String s) { if (!x.isLeaf()) { buildCode(st, x.left, s + '0'); buildCode(st, x.right, s + '1'); } else { st[x.ch] = s; } }
d414dba3-d478-475a-8add-ba3d0a067ab4
0
public void testCorrectColorList() { Combination<Colors> combination = DefaultValues.DEFAULTATTEMPTCOMBINATION1; List<Colors> list = combination.getColorsList(); assertEquals(list.get(0), Colors.R); assertEquals(list.get(1), Colors.O); assertEquals(list.get(2), Colors.Y); assertEquals(list.get(3), Color...
a80d692b-4db9-4430-89c5-b1da16eae3ac
7
private JList createJList(Object[] data){ JList list = new JList(data) { private static final long serialVersionUID = 1L; // Subclass JList to workaround bug 4832765, which can cause the // scroll pane to not let the user easily scroll up to the beginning // of the list. An alternative would be to s...
d572ee45-9226-467b-88d1-fb4cee7a42e8
7
public int calculateDay(int day) { if (day == 1) return 0; if (day == 2) return 1; if (day == 3) return 2; if (day == 4) return 3; if (day == 5) return 4; if (day == 6) return 5; return day != 7 ? 7 : 6; }
d611b812-bc9c-48b3-b57f-a8240b1b0b3a
8
public boolean compareNames(String... names) { if (names.length != 2) return false; NameComparison nameUtil = NameComparison.get(); String[] firsts = get("firstName"), lasts = get("lastName"), boths = get("name"); if (firsts.length == 0 || lasts.length == 0) { for (String both : boths) { if (nameUtil....
503d4603-8b55-4f73-9c1b-58d294840711
2
@SuppressWarnings("unchecked") public static TreeMap<String, float[]> restoreTM1D(String findFromFile) { TreeMap<String, float[]> dataSet = null; try { FileInputStream filein = new FileInputStream(findFromFile); ObjectInputStream objin = new ObjectInputStream(filein); try { dataSet = (TreeMap<String, ...
d8da8fb3-4cbe-47f5-8dd3-468ae76e98f0
7
private void drawHands(){ for (int i = 0; i < playerHand.size(); i ++){ boolean isSelected = false; Card c = playerHand.getCard(i); for (Integer iS: selections) if (iS == i) isSelected = true; if (isSelected){ // any selected card will be signified by lowering the alpha Image a = cardImag...
50f41df4-ee7e-4e6c-9c75-5564b613970f
0
public void setCategories(String newCategories) { categories = newCategories.split(","); }
17c0981a-7bfd-4e3f-86e8-0dc6626ec75b
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Vector2f vector2f = (Vector2f) o; if (Float.compare(vector2f.x, x) != 0) return false; if (Float.compare(vector2f.y, y) != 0) return false; ...
d788e3dc-420f-4ee1-9fa4-8e1f843d3e74
0
public double getMarkerHeight() { return markerRect.getHeightCoordinates(); }
379313b9-331c-42a7-9e29-f32c71ed0ec7
9
public static int awtKeyToLWJGL(KeyEvent e) { int key_code = e.getKeyCode(); int position = e.getKeyLocation(); /* Code taken from LWJGL, specifically org.lwjgl.opengl.KeyboardEventQueue */ switch (key_code) { case KeyEvent.VK_ALT: // fall through if (position == KeyEvent.KEY_LOCATION_RIGHT) retu...
2a0872ad-e5df-425b-8d77-e3590fc6a2b8
8
public void tick(){ if(alive){ if(listener.isPressed(40)){ if(y<750){ y = y + 8; } } if(listener.isPressed(38)){ if(y>0){ y = y - 8; } } if(listener.isPressed(32)){ if(delay<=20){ shots = shots.add(new laser(x+34,y+28)); delay = delay + 20; } } ...
aaaf3064-b62e-4a20-8276-918fd045a3e2
2
public BattleField(int width, int heigth) { hitCount = 0; if (width > 5) { this.width = width; } if (heigth > 5) { this.width = heigth; } ships = new HashSet<>(); initFields(); }
9b9211b5-1185-4c65-8719-b8839cd08d88
2
@Override public Data read(int index) { if (index > -1 && index < 16) { //Ensure valid index (0-15) return generalPurposeRegisters[index]; } return null; }
92a1e066-dd0d-4373-95a2-88a11e38fe7e
1
@Override public void removeOne(int intId, String strTabla) throws Exception { Statement oStatement; try { oStatement = (Statement) oConexionMySQL.createStatement(); String strSQL = "DELETE FROM " + strTabla + " WHERE id = " + intId; oStatement.executeUpdate(strSQ...
d0129731-01db-477c-9f81-b4c78f80a08a
1
public boolean getScrollableTracksViewportWidth() { if (adapt) return true; return getPreferredSize().width < getParent().getSize().width; }
11f1581d-dea5-4c78-8586-6ac7a2235e39
2
public void visitEnd() { if (state != CLASS_TYPE) { throw new IllegalStateException(); } state = END; if (sv != null) { sv.visitEnd(); } }
3b959a0f-0860-433d-8b11-b1a281edf9db
8
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) { prevRowIndex = currentRowIndex; prevColumnIndex = currentColumnIndex; currentRowIndex = rowIndex; currentColumnIndex = columnIndex; // logger.debug("prevRowIndex=" + prevRowIndex); ...
d7d7aeae-9687-4c24-8bfe-8826f0fedae6
8
public static Stella_Object accessMeasureSlotValue(Measure self, Symbol slotname, Stella_Object value, boolean setvalueP) { if (slotname == Utilities.SYM_UTILITIES_BASE_UNIT) { if (setvalueP) { self.baseUnit = ((StringWrapper)(value)).wrapperValue; } else { value = StringWrapper.wr...
4c4ca51c-734c-4ff4-b69a-a8bf23074dc6
8
public PathNode search(final Unit unit, Location start, final GoalDecider goalDecider, final CostDecider costDecider, final int maxTurns, final Unit carrier) { Location entry = findRealStart(unit, start, carrier); int initi...
dd9615cd-abe0-4b3e-8cb5-d6a0955e023c
0
public static String getDesc(int bookId) { return bookDesc[bookId-300]; }
342dade5-0a1f-4542-8303-f2b2e52d18b0
4
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PID other = (PID) obj; if (id != other.id) return false; return true; }
9cedcad7-523f-463d-bf75-8438dfa554d2
6
public static int dehexchar(char c) { if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'F') { return c - ('A' - 10); } if (c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; }
0206f312-b660-493b-98f8-b3a29ad4bcf4
5
public void itemStateChanged(ItemEvent arg0) { if (arg0.getSource().equals(playerBox) && arg0.getStateChange() == ItemEvent.SELECTED) { // config.setActivePlayer((Class)arg0.getItem()); selectedPlayer = (Class) arg0.getItem(); config.setPlayerClass((Class<Player>) playerBox.getSelectedItem()); if(selec...
12915a76-5655-4116-a823-83382388e216
3
private static void displayRateReview(BufferedReader reader, VideoStore videoStore) { try { System.out.println("Please enter the title of the video the review was for:"); String isbn = getISBNFromTitle(reader, videoStore, reader.readLine()); System.out.println("Please enter ...
948fdbd0-a4de-482c-8d39-88890fe0fa16
7
public void init() throws IOException { //create a vector to hold the lines of text read from the file buffer = new ArrayList<>(1000); modified = false; //no data has yet been modified or added //create various decimal formats DecimalFormats = new DecimalFormat[11]; DecimalFormats[0] = new D...
91327638-f0a8-4717-9beb-6a7c6b5a9cd4
7
public List<Airfield> getRecentAirfield() { try{ List<Airfield> airfields = DatabaseDataObjectUtilities.getAirfields(); List<Airfield> recentAirfieldList = new ArrayList<Airfield>(); if(instance == null) { return null; } ...
2c73ef38-ad60-4325-915e-4e2b44fa50d0
0
public CheckResultMessage check19(int day) { return checkReport.check19(day); }
87b5867f-a7af-4b59-a21c-12bdb1b101c5
1
private static void printListOldWay(String type) { System.out.println("Old Way " + type + ":"); for (User u : users) { System.out.println("\t" + u); } System.out.println(); }
ee42731e-75ad-4ef5-ac44-9b74f400087a
0
@BeforeTest public void setUp() throws Exception { driver = new FirefoxDriver(); baseUrl = "http://localhost:8888/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); }
844680aa-4f12-4922-93ab-ac150e765a9e
6
public void setWeights(int node) { for (int i = 0; i < result.length; i++) { if (adjMatrix[node][i] != 0 && visited[i] != 1 && (result[i] > (result[node] + adjMatrix[node][i]) || result[i] == -1)) result[i] = result[node] + adjMatrix[node][i]; } vi...
ea01f107-96f7-48fd-8b02-96c3ddc3394b
4
public void body() { int resourceID[] = new int[this.totalResource_]; double resourceCost[] = new double[this.totalResource_]; String resourceName[] = new String[this.totalResource_]; LinkedList resList; ResourceCharacteristics resChar; // waiting to get list of res...
a9fbd428-94b3-40c1-9f3b-480f0eb482dd
4
@Override public void run() { Random rnd = new Random(); try (ServerSocket server = new ServerSocket(port)) { System.out.println("server up and running on port " + port); ServerOutputHandler output = new ServerOutputHandler( allConnections, m, rnd.nextLong()); output.start(); while (true) { S...
78ad3d89-f8bd-48e8-98cd-3b58aa8e4d5d
2
public void setState(State _state) { if(getWidth() > 0 && getHeight() > 0) { getGui().setVisible(false); state = _state; getGui().setVisible(true); }else{ ClientHelper.log(LogType.GUI, "GuiManager: setState wurde vor setBounds aufgerufen"); ...
86ced496-a8f7-41fa-977e-a93edf187adf
6
public void processArgs(Option opt, ListIterator iter) throws ParseException { // loop until an option is found while (iter.hasNext()) { String str = (String) iter.next(); // found an Option, not an argument if (getOptions().hasOption(str) && str.startsWi...
e11715b8-f43f-4a54-8b15-79b2c7736a7b
7
@Override public void runClient(GameEntity entity, float delta) { if(EntityManager.interpolate && prevSnapshot != null && nextSnapshot != null) { float progress = acc/0.05f; Vector3 pos = nextSnapshot.v3_0; Vector3 vel = nextSnapshot.v3_1; Vector3 imp = nextSnapshot.v3_2; if(progress < 1f) { ...
0f0286b2-7cd2-496e-9912-dc1ea27c997d
4
private void addDependent(JSRTargetInfo result) { if (dependent == null || dependent == result) dependent = result; else if (dependent instanceof JSRTargetInfo) { Set newDeps = new HashSet(); newDeps.add(dependent); newDeps.add(result); } else if (dependent instanceof Collection) { ((Collec...
f292b836-d988-4221-a8fe-e249cff1197e
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...
41988be5-0bde-4b09-ac10-9f7974105fcf
8
@Override public void run() { try { BamWindow window = bamWindows.getWindow(); VariantCandidateEmitter emitter = new VariantCandidateEmitter(referenceFile, counters, window, options); List<VariantCandidate> variantCandidates = new ArrayList<VariantCandidate>(); ...
e9b7e9f1-5b72-4c22-b47c-eea45a0491a2
0
public int getValue() { return value; }
325df6c6-f577-4e70-aad3-d806c1ed89bf
5
public int getKeyCode(int game) { String name; switch(game){ case UP: name = "UP"; break; case DOWN: name = "DOWN"; break; case LEFT: name = "LEFT"; break; case RIGHT: name = "RIGHT"; break; case FIRE: name = "FIRE"; break; default: return game; } return Applicati...
859319aa-cf4b-46f8-ad77-cc1969c04ae4
3
@Test public void testRunStartServerSpotFaculty()throws Exception{ AccessControlServer server = new AccessControlServer(1932); server.start(); SpotStub spot = new SpotStub("101",1932); spot.start(); sleep(1000); String ans = ""; int x = 0; ...
374fe200-874c-404d-81d8-cc1fdf5c1452
0
public GridWorker(GridProcessingManager gpm, int id) { this.gpm = gpm; this.id = id; }
74a8668d-4e86-41a9-983f-33c56e081b7a
6
public String diff_toDelta(LinkedList<Diff> diffs) { StringBuilder text = new StringBuilder(); for (Diff aDiff : diffs) { switch (aDiff.operation) { case INSERT: try { text.append("+").append(URLEncoder.encode(aDiff.text, "UTF-8") .replac...
3a025884-2219-41f5-88b4-b8fbbc2a6586
9
private void drawLine(HomCoords2D homCoords1, HomCoords2D homCoords2, BufferedImage textureTop, BufferedImage textureBottom, Color colour) { // We note that we speak about points in the textured image as (x, y) where (0, 0) represents the middle of the image, // and the coordinates are scaled so that (+-1, +-1) are...
fc71c98d-ca9d-4a96-9fb8-b8fdd0a9ae18
0
public void setCountry(String country) { this.country = country; }
9a30a82c-5504-49fe-80fd-ecae44a1cd68
7
private void button_delete_selectedMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button_delete_selectedMousePressed if(hitbox_index_selected!=-1) { int i=0; for(Node hitboxes_node=current_frame.getFirstChild();hitboxes_node!=null;hitboxes_node=hitboxes_node.getNextSibling())//Hi...
bc34603d-9517-491f-b97c-6be29437340c
7
protected List<Getter> getters(Class<?> type) { List<Getter> result=new ArrayList<Getter>(); for(Class<?> c=type;c!=null;c=c.getSuperclass()) for(Field field : c.getDeclaredFields()) if((field.getModifiers()&Modifier.STATIC) != 0) { // We never serialize s...
704398db-a5c9-4e3d-a3f5-e682db4ca41f
6
private void doCalculation(double xf, double yf, int xi, int yi) { double a, b, aa, bb; float hue, huesat, new_gamma; double[] iter; a = 2 * (xf - 0.5) * zoom + xcen; b = 2 * (yf - 0.5) * zoom + ycen; aa = a; bb = b; iter = NewtonIterate(aa, bb, alg); if (mandelbrotAddition) { // get Color based...
8794c0a5-ffde-4e01-8a5d-a215202a3eb7
8
private void populate() { Random rand = Randomizer.getRandom(); field.clear(); for(int row = 0; row < field.getDepth(); row++) { for(int col = 0; col < field.getWidth(); col++) { if(rand.nextDouble() <= fox_creation_probability) { Location loca...
51d1e2a5-1edc-4722-8f1c-8204000df13d
5
private TagCompound saveObjective(Objective o) { TagCompound c = new TagCompound(o.getID()); c.setTag("name", new TagString("name", o.getName())); c.setTag("target", new TagString("target", o.getTarget())); c.setTag("type", new TagString("type", o.getType().getClass().getName())); c.setTag("iconid", new TagI...
51e7a507-ac54-42b9-9c67-98000d13c837
6
private List<Tuple> joinResults() { boolean continueReading = true; List<Tuple> result = new LinkedList<Tuple>(); while(continueReading) { try { String line = null; Tuple t2 = null; while( (line = input2.getNextString()) != null ){ if (line.indexOf("END") == 0) { continueReading = false...
71a20e22-b2be-46ac-963d-a9002e754693
9
public static boolean isValidClassName(String s) { if (s.length() < 1) return false; if (s.equals("package-info")) return true; if (surrogatesSupported) { int cp = s.codePointAt(0); if (!Character.isJavaIdentifierStart(cp)) return false; for (i...
c57cbd58-9499-4171-8765-d5719e4aa74b
7
public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); char[] v = new char[]{'A','U','E','O','I'}; char[] c = new char[]{'J','S','B','K','T','C','L','D','M','V','N','W','F','X','G','P','Y','H','Q','Z','R','S'}; ...
13ab1106-2c24-4130-ab33-91354b337426
1
public void visit_invokevirtual(final Instruction inst) { final MemberRef method = (MemberRef) inst.operand(); final Type type = method.nameAndType().type(); stackHeight -= type.stackHeight() + 1; if (stackHeight < minStackHeight) { minStackHeight = stackHeight; } stackHeight += type.returnType().stack...
8a6611bb-a98f-42cc-9769-f811de46afc0
9
public void drawSquares() { for (byte i = 0; i < board.length; i++) { for (byte y = 0; y < board[i].length; y++) { switch (board[i][y]) { case WALL: theG.setColor(Color.BLUE); theG.fillRect(y * SCALE, i * SCALE, SCALE, SCALE); break; ...
6a7a7a64-9d5e-4331-aab3-9e9a8917c6be
1
@Override public void mouseDragged(MouseEvent event) { Point where = mListener.convertToLocalCoordinates(new Point(event.getX(), event.getY())); mInterimBounds.setBounds(mBoundsToAdjust); mAdjuster.adjust(where.x - mSnapshot.x, where.y - mSnapshot.y, mBoundsToAdjust, mBoundsSnapshot); if (!mInterimBounds.equal...
0a90ba13-bd35-40f1-b04e-cc9e3639534b
0
@Override public String toString() { return StringUtil.concatenateStrings("Watcher: ", watchKey.toString()); }
0efe9ab4-6986-4a37-bac5-c86f28fd82ac
0
public Date getStart() { return start; }
99a6ecd2-ac73-498e-9d50-24625de80ff3
6
public void borrarElement(String dia, int hora, Element e) { int i; if (dia.equals("dilluns")) i = 0; else if (dia.equals("dimarts")) i = 1; else if (dia.equals("dimecres")) i = 2; else if (dia.equals("dijous")) i = 3; else if (dia.equals("divendres")) i = 4; els...
bc5fd7ce-8220-422d-9d99-157ea2caf052
1
public void renderAll(){ render(); for (GameObject child: children){ child.renderAll(); } }
de03ec3a-c9c8-4423-9029-bded6f4c4a14
5
public boolean actionPatrol(Actor actor, Target spot) { //I.say("Patrolling to: "+spot) ; if (actor.base() != null) { final IntelMap map = actor.base().intelMap ; map.liftFogAround(spot, actor.health.sightRange() * 1.207f) ; } // // If you're on sentry duty, check whether you need ...
6d9cc022-2061-4c97-bff3-bb9ea5255b68
3
public void useFuel(int amount) { if((amount <= fuelLevel) && (amount > 0) && !infinite) { fuelLevel -= amount; } }
2f2b8932-80e1-4067-9f22-a01434980c08
2
public void inorderPrint( )//LNR { if (left != null) { left.inorderPrint( ); } System.out.println(data); if (right != null) { right.inorderPrint( ); } }
d8626374-e9f4-494b-bfe5-18b8889d392f
2
public static AudioInputStream toAudioInputStream( double[] audioData, float sampleRate ) { int m = audioData.length; AudioFormat format = new AudioFormat(sampleRate, 16, 1, true, false); // build byte array byte[] byteArray = new byte[m * 2]; int val; for ( int i = 0; i < m; ++i ) { val = (int)(audioData[i]...
ac60fe9f-7947-4c65-903c-e6dc769c6525
8
public static void main(String[] args) { try { MainMenuUI mainMenu = new MainMenuUI(); boolean exit = false; while (!exit) { int option = mainMenu.firstMenu(); switch (option) { case 1: createInfo(); break; case 2: editInfo(); break; case 3: doLogin(); brea...
ed8db953-5f3f-4b06-a022-2061f185b141
1
private double getMatchFactor(int index){ double matchFactor = 0; int j = 1; for (int i = index; i < index+7; i++){ double velocityDiff = this.log.get(i).getVelocity() - this.pattern.get(j).getVelocity(); double logHeadingDelta = this.log.get(i).getHeadingRadians() - thi...
26f8a8cc-cc0f-4a08-b8b4-8f365ea0834b
8
private String buildMyUrl(String apilink, String link, int out, String nastavka) { StringBuffer urlBuilder = new StringBuffer(); urlBuilder.append(apilink); urlBuilder.append("format=").append(out==Constants.JSON_FORMAT? "json" : out==Constants.PLAIN_TEXT_FORMAT? "plaintext" : out==Constants.XML_FORMAT? "x...
a4e0c168-59dc-4ea2-827a-8f18930ca8f0
8
public void tick() { if (input.menu.clicked) game.setMenu(null); if (input.up.clicked) selected--; if (input.down.clicked) selected++; int len = player.inventory.items.size(); if (len == 0) selected = 0; if (selected < 0) selected += len; if (selected >= len) selected -= len; if (input.attack.clicked...
4e35d748-2f6f-4998-bd6a-cc8b414e4e4e
4
private void dropAlarm() { BufferedReader in; try { AlarmListViewHelper helper = (AlarmListViewHelper) dropAlarmComboBox.getSelectedItem(); if(helper == null) return; Alarm a = helper.getAlarm(); DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); in = new BufferedReader...
528e7b5d-0806-409f-ac49-095d0ca8e76b
7
public void actionPerformed(ActionEvent arg0) { if (((JButton) arg0.getSource()).getText().compareTo("start") == 0) { player.setReady(true); } else if (((JButton) arg0.getSource()).getText().compareTo("pause") == 0) { player.rest(); } else if (((JButton) arg0.getSource()).getText().compar...
80128e9e-a7a9-4fdc-9ed6-1772e916f63c
3
private boolean verifyAddress(String address){ char[] charAdd = address.toCharArray(); char[] invalid = new char[]{'(', ')', '{', '}', '$', ';', '@', ':', '#', '%', '<', '>', '§'}; for (int i=0; i<address.length(); i++) { for (char anInvalid : invalid) { if (charAdd[...
a3c9157a-2b4a-4aaf-8023-fb5b492bdb3e
7
@Override public Solution solve(Graph graph, long time, long duration) { // return newGreedy(graph, time, duration); int n = graph.getNodes(); Solution solution = new Solution(n); if (n == 2) { solution.path = new short[] {0, 1}; return solution; } ...
35786c46-0ee6-486a-8969-b1dcfcdc3acf
6
public static ListNode reverseKGroup(ListNode head, int k) { if (head==null||k<=1){ return head; } ListNode superHead = new ListNode(0); superHead.next=head; ListNode check = head; ListNode insert = superHead; int count = 1; ArrayList<ListNode>...
787accc0-cbfa-491d-af56-736da95396e2
3
public static Map<String, Object> getPrimaryKey(Object obj) throws Exception { Map<String, Object> attrs = new HashMap<String, Object>(); String pkName = null; for (Field field : obj.getClass().getDeclaredFields()) { Annotation[] annotations = field.getDeclaredAnnotations(); if (annotations.length > 0 ...
f9a12fec-76e2-4e3a-bf7e-c3918b39d0f4
7
public Modelo(Data data) throws IloException, FileNotFoundException { this.data = data; cplex = new IloCplex(); cplex.setOut(new PrintStream("./solution/" + data.filename + ".log")); //decision variable y (integer) y = new IloIntVar[data.nLinks]; for (int i = 0; i < data.nLinks; i++) { Link lin...
1e82f426-c473-4fea-abf9-682b0267482d
2
public void cargarProductos() { try { String sql = "SELECT * FROM productos"; Connection conn = Conexion.GetConnection(); PreparedStatement ps = conn.prepareStatement(sql); pro = ps.executeQuery(); while (pro.next()) { String[] row = ...
12204ac7-48df-4afd-a421-0155772cd2c7
7
public boolean stem() { int v_1; int v_2; // (, line 464 // (, line 465 // call more_than_one_syllable_word, line 465 if (!r_more_than_one_syllable_word()) { return false; ...
c46fd1ec-3d00-4438-8e0a-ab6d6fcbff15
7
@Override protected void doLoadTestData(StdConverter.Operation oper, File dir) throws Exception { /* First of all, read in all the data, bind to in-memory object(s), * and then (if read test), convert to the specific type converter * uses. */ byte[] readBuffer = new by...
a1dee203-abb9-449a-845a-1df792da9e1a
8
@Override public Object esegui() throws ExtraTokenException, OperazioneNonValidaException, ParentesiParsingException, OperandoMissingException, ParsingException, OperatoreMissingException { Token stampa; VarRepository variabili = VarRepository.getInstance(); ArrayList<Token> daStampareProvvisoria = (ArrayList<T...
f9413394-be18-4aaa-8395-a7be4de02bc5
2
public Object clone() { TicTacToeBoard deepClone = new TicTacToeBoard(); for (int row = 0; row < TicTacToeBoard.SIZE; row++) { for (int col = 0; col < TicTacToeBoard.SIZE; col++) { deepClone.square[row][col] = this.square[row][col]; } } deepClone.turn = this.turn; deepClone.numEmptySquares = this.nu...
a5cb703d-0a26-46e8-bb3e-f8af44cf84e5
9
public static void formatResults(ArrayList<Agent[]> generations, String file) { BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(file, false)); } catch (IOException ex) { ex.printStackTrace(); } int gens = generations.size(); // header for (int i = 0; i < gens; i++) {...
7ab9a3f8-8da1-46eb-adf3-02c2ebef2c7d
5
private Response sendLimitedRequest(String requestUrl, String requestBody) { //Lock to prevent multiple requests from executing at once rateLock.lock(); try { //Wait (if required) for the request time limit if(limiterEnabled) { try { if(requestQueueShort.size() == limitShort) req...
fde1083e-bd79-4a17-9aed-be682461dfd3
3
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed Transferable clipboardContent = getToolkit().getSystemClipboard().getContents(this); if ((clipboardContent != null) && (clipboardContent.isDataFlavorSupported(DataFlavor.stri...
8a66c1e9-678c-40c2-9c8d-168d2dce033a
3
@Override protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { DatabaseManager manager=DatabaseManager.getManager(); try { ServletResult.sendResult(response, manager.getRoomDao() .deleteById(Integer.parseInt(request.getParameter(ID)))==1 ? S...
bc6883f2-441f-488d-900e-29714de5ed61
5
private static int getCharWidth(char c) { int charWidth = 5; if(width5.indexOf(c) >= 0) { charWidth = 5; } if(width4.indexOf(c) >= 0) { charWidth = 4; } if(width3.indexOf(c) >= 0) { charWidth = 3; } if(width2.indexOf(c) >= 0) { charWidth = 2; } if(width1.indexOf(c) >= 0) { charWidth =...
030a360a-790e-4b54-9d8a-939142078316
1
@Test public void testPlayerCapturesOneFlagAndLastPlayerBoxedIn() throws InvalidActionException { final GameEnded gameEnded = new GameEnded(); game.addEventListener(new Listener() { @Override public void handleEvent(Event event) { if(event.getType() == EventType.END_GAME) gameEnded.setToTrue(...