method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
275c03fe-220b-4bfc-8560-df29060df776
1
public Node popNode() { if (--sp < mk) { mk = marks.remove(marks.size()-1); } return nodes.remove(nodes.size()-1); }
17f2ee16-45c2-4391-80d0-7ffecc79f091
7
@Test public void testAvoidance() { Random r = new Random(260379); /* First create some data */ ArrayList<Integer> workArr = new ArrayList<Integer>(); TreeMap<Integer, Integer> countToId = new TreeMap<Integer, Integer>(new Comparator<Integer>() { public int compare(Inte...
831c560b-f608-496d-a53c-94daa57948fe
8
@Override public void onKeyPressed(char key, int keyCode, boolean coded) { // Doesn't react to coded keys if (coded) return; // If backspace was pressed, removes the last character if (key == KeyEvent.VK_BACK_SPACE && this.input.length() >= 1) this.input = this.input.substring(0, this.input.length()-...
2a2c0a73-7611-43c7-b2d6-9dbaac3b3229
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } QName other = (QName) obj; if (localName == null) { if (other.localName != null) { retu...
cea976a8-3864-440a-97e6-d8fe972d3da1
3
private void listLastTransactions(CommandSender sender, int amount) { if (TransactionManager.getInstance().getTransactions().isEmpty()) { sender.sendMessage(EdgeCore.errorColor + "No transactions found!"); return; } for (int i = TransactionManager.getInstance().amountOfTransactions() -1; i < TransactionM...
13b9716e-580b-4c0b-bdb0-a35981805074
1
public TripTimeLabelComponent (Trip trip) { super (new FlowLayout (FlowLayout.LEADING)); JPanel labelPanel = new JPanel (new GridLayout (2,1)); River r = trip.getRiver(); String riverName; if (r == null) { riverName = "<?>"; } else { riverName = r.getRiverName(); } addLabelWithBorder (labe...
ea7880ec-2055-4d5d-8b50-a3068ef754dc
1
public Production getLambdaProductionForFinalState(Automaton automaton, State state) { /** Check if state is a final state. */ if (!automaton.isFinalState(state)) { System.err.println(state + " IS NOT A FINAL STATE"); return null; } String llhs = (String) MAP.get(state); String lrhs = LAMBDA; Produ...
50c26092-ef1f-4ffc-a976-dd3c415180b6
2
private void instantiate(int size) { try { DBConnection con; for (int i = 0; i < size; i++) { con = new DBConnection(); con.connect(driver, url, db, usr, pw); free.add(con); } } catch (Exception e) { e.print...
f98ec3fd-7689-43cc-8392-cbbe0bcb5fff
4
public void initialiseWithInfected(int numI) { if ((numI < N) && (numI > 0)) { states[0].setStateValue(N-numI); for (int i = 1; i < states.length; i++) { if (states[i].getStateName().equals("I")) { states[i].setStateValue(numI); ...
1045ef22-1845-485e-9839-6df7c3b22002
8
@Override protected void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.clearRect(0, 0, this.getWidth(), this.getHeight()); g2.scale(scale, scale); g2.translate(translateX, translateY); world.paint(g2); int count = 0; ...
5252157c-dce3-4553-b00a-714878c4d438
5
private static boolean dragBetween(WidgetChild start, WidgetChild end) { if (start == null || end == null || !start.visible() || !end.visible()) return false; if (!hoverChild(start)) return false; Mouse.drag(end.getNextViewportPoint()); return true; }
f25dfa73-47e3-44e3-86ad-c01983c07b87
1
@Test public void WhenUnionBothHavingLevels_ExpectChange() throws UnknownHostException { int level = localhost_.getHostPath().length(); RoutingTable table = new RoutingTable(); table.setLocalhost(localhost_); Host host = new PGridHost("127.0.0.1", 3333); table.ad...
bd430ee0-d091-4709-aa79-fb15a155b5b3
1
public boolean reserve(long id) { if(enemyID == NO_ENEMY) { enemyID = id; return true; } else { return false; } }
bbc020f7-ed59-4475-985f-c1e148a8b3fa
6
@Test public void testIterativeSearch() throws Exception { PersistenceManager pm = new PersistenceManager(driver, database, login, password); // drop all tables pm.dropTable(Object.class); // create 42 simpleobjects final int testCount = 42; for (int x = 0; x < testCount; x++) { SimpleObject so = ne...
7d30ef47-285d-4612-b82e-09b038373e77
8
public static void adjustModuleCMakeLists(File moduleDirName, String fileName, boolean fileWasCreated, IOutput output) { output.writeLine(" Registering file in module specific CMakeLists"); File cmakelistsFile = new File(moduleDirName, Constants.CMAKELISTS_FILENAME); if (!cmakelistsFile.e...
0c8b3c67-dd93-4cfa-8946-5a82e1fc2658
6
public static URL convertToURL(String path) { if(path==null || path.isEmpty()){ return null; } URL url = null; try { url = new URL(path); } catch (MalformedURLException e) { url = Thread.currentThread().getContextClassLoader().getResource( path); if (url == null) { File file = new File(pa...
059a18c8-254c-442c-9e46-4a00b927f575
9
private void upload(File source) throws Exception { if (source.isDirectory()) { String[] list = source.list(); for (int index = 0; index < list.length; index++) { File newSource = new File(source, list[index]); upload(newSource); } if (count.containsKey("Directory")) { count.put("Directory...
779df4eb-afb3-42a3-b9b9-5255a8137ff0
3
public static String[] getFileContents(String fileName) { final ArrayList<String> lines = new ArrayList<String>(); String line = ""; try { final BufferedReader reader = Files.newBufferedReader(Paths.get(fileName), Charset.forName("US-ASCII")); while (true) { line = reader.readLine(); if (line...
7b79db23-f7bd-4a90-a66e-0934a9db71fe
5
@Override public void execute(Player player, String[] args) { if(args.length == 1) { Player other = player.getServer().getPlayer(args[0]); if(other != null) { player.setPos(other.getX(), other.getY(), other.getZ()); } else { player.sendMessage(args[1] + " is not online."); } } else if(arg...
0f65cc12-983e-422b-a43e-65f937931e55
9
protected Value getSimpleDefaultValue(String t) { if (t.equals("java.lang.String")) return StringConstant.v(""); if (t.equals("char")) return DIntConstant.v(0, CharType.v()); if (t.equals("byte")) return DIntConstant.v(0, ByteType.v()); if (t.equals("short")) return DIntConstant.v(0, ShortType.v());...
90aee75a-c54e-4d34-8f65-d229c70bca96
7
public static int HSBtoRGB(float hue, float saturation, float brightness) { int r = 0, g = 0, b = 0; if (saturation == 0) { r = g = b = (int) (brightness * 255.0f + 0.5f); } else { float h = (hue - (float)Math.floor(hue)) * 6.0f; float f = h - (float)java.lang...
28201e3d-cdaa-4466-8df4-1e340e35b07a
9
public boolean prob(double x) { if (x >= 1) { return true; } if (x <= 0) { return false; } double eps = 0.000000001; double a = 0, b = 1; do { boolean pb = prob(); double center = (a + b) / 2; if (Math.abs(x - center) < eps) { return pb; } if...
ee8b84ef-4738-48d3-a843-ade6012885f5
4
protected void appendDescriptor(final int type, final String desc) { if (type == CLASS_SIGNATURE || type == FIELD_SIGNATURE || type == METHOD_SIGNATURE) { if (desc != null) { buf.append("// signature ").append(desc).append('\n'); } } else { buf.append(desc); } }
2dc2139f-aed3-482d-b4f2-12c5e4c794fe
5
public Collection<LineUp> getLineUps(Groop grp) throws SQLException { Collection<LineUp> lineups = new LinkedList<LineUp>(); // Get a statement and run the query String sql = "SELECT LineUp.LineUpNumber, ArtistNumber FROM LineUp,LineUpDetails WHERE LineUp.GroopNumber = ? AND LineUp.LineUpNumber = ...
f13ded13-fe21-4981-a5ed-79e4c4206da3
2
private String getResponse() { String result; try { result = _in.readLine(); } catch (IOException e) { throw new UIError(); // re-throw UIError } if (result == null) { throw new UIError(); // input closed } return result; }
0d13f07e-d862-48e6-8266-94167a4e814d
9
public void doStuff() { if (!hsa.done) { hsa.doAlg(); int step = hsa.step; switch (step) { case 1: l.setText("step 1: divided in intervals"); break; case 2: l.setText("step 2: found interval with odd intersection property"); break; case 3: l.setText("step 3: constructed trapeze")...
9ad31dc5-f81f-4cc3-b5ba-89e5a639d17b
5
public Knapsack executeOnce(Knapsack knapsack) { int neighbours = generateRandomNumberOfNeighbours(); Knapsack best = null; for (int i=0; i<neighbours; i++) { Knapsack candidate = generateNeighbour(knapsack); if (best == null) { best = candidate; } else if (candidate.compareWith(best) > 0) {...
0bce1a04-6590-4a1e-9f1f-ccaf1cdffca0
6
public void method354(Background background, int i, int j) { j += anInt1442; i += anInt1443; int k = j + i * DrawingArea.width; int l = 0; int i1 = myHeight; int j1 = myWidth; int k1 = DrawingArea.width - j1; int l1 = 0; if(i < DrawingArea.topY) { int i2 = DrawingArea.topY - i; i1 -= i2; i...
65b222a2-e630-422d-b27f-03701bb493da
5
public static boolean visible(WidgetChild... wc) { if (wc == null || wc.length == 0) return false; for (WidgetChild c : wc) { if (c == null || !c.visible()) return false; } return true; }
4a402649-6271-4a95-9841-00699259d404
7
@Override protected String readLineInternal() throws IOException { if (skippingDone == false) { skippingDone = true; do { final String s = readLine(); if (s == null) { return null; } Matcher m = endifPattern.matcher(s); if (m.find()) { return null; } m = elsePattern.matche...
30ebd30d-eacb-472f-8645-460d239a3281
1
public static List<String> readTextFile(Path file) { if (!FileUtil.control(file)) { IllegalArgumentException iae = new IllegalArgumentException("The filepath is null or points to an invalid location!"); Main.handleUnhandableProblem(iae); } return FileReader.readFile(file...
54076626-fb0c-4d30-a76e-7646eea4a156
8
protected void drawMapTiles(final Graphics g, final int zoom, Rectangle viewportBounds) { int size = getTileFactory().getTileSize(zoom); Dimension mapSize = getTileFactory().getMapSize(zoom); // calculate the "visible" viewport area in tiles int numWide = viewportBounds.width / size + 2; int numHigh = viewp...
db7dbee9-c2f7-4867-b505-5e3c95110b9d
6
public static void main(String args[]) { //<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://download.oracle.com/javase/tutorial/uiswing/loo...
bee29ef4-349e-4117-9e83-2c2634cc5fd1
2
public static boolean zmq_proxy (SocketBase frontend_, SocketBase backend_, SocketBase control_) { if (frontend_ == null || backend_ == null) { ZError.errno (ZError.EFAULT); throw new IllegalArgumentException(); } return Proxy.proxy ( frontend_, ...
30a2b3ee-35dc-4586-9770-67501391c382
1
@Override public int getSlotSpacingX() { return isNotPlayerInventory() ? 32 : 18; }
92efdd57-3e2f-4e08-86fd-4474cd2a10a6
9
public static void reallyDeleteObject(PaintBox box) { Rectangle redrawBounds = null; if (box instanceof FTLRoom) { FTLRoom r = (FTLRoom) box; Point oldLow = null; Point oldHigh = null; if (Main.ship != null) { oldLow = Main.ship.findLowBounds(); oldHigh = Main.ship.findHighBounds(); oldLow....
e8d25583-274e-428c-ae4a-5bd6b3c47e30
7
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
0fbfdd2d-e524-4675-a8c6-710fcad2ba23
0
public void draw(Graphics g){ Color c = g.getColor(); g.setColor(Color.DARK_GRAY); g.fillRect(x,y,w,h); g.setColor(c); }
66121632-73f0-489c-a2af-8fe605fd89ff
2
public int minHeight(int[] height,int sta,int end){ int min =0Xffff; int index =sta; for(int i= sta; i<=end ;i++){ if(min > height[i]){ min = height[i]; index = i; } } return index; }
f66f3c1e-91ff-49ab-a706-7eac6f229fa0
3
public void init() { int a, b, c, d, e, f, g, h; a = b = c = d = e = f = g = h = 0x9e3779b9; for (int i = 0; i < 4; i++) { a ^= b << 11; d += a; b += c; b ^= c >>> 2; e += b; c += d; c ^= d << 8; f += c; d += e; d ^= e >>> 16; g += d; e += f; e ^= f << 10; h += e; f +=...
8054107a-2890-40e7-9ebb-18f62e8de4b3
7
@Test public void testNull() { StaticIntervalTree<Double, Interval<Double>> tree = new StaticIntervalTree<Double, Interval<Double>>(); try { tree.buildTree(null); Assert.fail(); } catch (NullPointerException e) { } try { tree.fetchContainingIntervals(new ArrayList<Interval<Doubl...
e30ab844-565b-4eda-8e29-7e23bc036bea
8
public ArrayList<Pair<File,Tag>> load(File file) throws FileNotFoundException,IOException { ArrayList<Pair<File,Tag>> pairs = new ArrayList<Pair<File,Tag>>(); FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); String strLine; if (br.readLine().equals("#EXTM3U")) { while...
6590723c-6c93-44ad-a4b5-fde079d2b04a
2
public static void addBoilerFuel(Fluid fluid, int heatValuePerBucket) { ModContainer mod = Loader.instance().activeModContainer(); String modName = mod != null ? mod.getName() : "An Unknown Mod"; if (fluid == null) { FMLLog.log("Railcraft", Level.WARN, String.format("An error occured...
543e1d85-b8ef-45c4-b371-1cdae2e1cf9a
7
@Override public boolean execute(WorldChannels plugin, CommandSender sender, Command command, String label, String[] args) { final Map<Flag, String> info = new EnumMap<Flag, String>(Flag.class); info.put(Flag.TAG, WorldChannels.TAG); if(!(sender instanceof Player)) { ...
d43c9458-f5a4-45c2-97f0-b55d19b207ba
2
public int compare(Object arg1, Object arg2) { if (!map.containsKey(arg1) || !map.containsKey(arg2)) { return 0; } Comparable value1 = (Comparable) map.get(arg1); Comparable value2 = (Comparable) map.get(arg2); return -value1.compareTo(value2); // Note: We use a minus because we want decreasing order (high val...
ad6d46e0-9d8c-48d1-b17f-1dd2fbbb4cb2
1
public boolean _setHp(int hp) { if(hp > -1) { this.hp = hp; // Set HP to the provided value. return true; // Return true, HP updated. } else { return false; // Couldn't update HP (probably invalid HP value). } }
b7385ef4-2d01-4efe-a84c-b469fe0229c5
2
public T set(T newValue, int index) { if(index < 0 || index > size()) throw new ArrayIndexOutOfBoundsException(); T old = item[index]; item[index] = newValue; return old; }
9922ed4a-f659-4721-b515-cee78f7bdd00
5
private Dockable getDockableInDrag(DropTargetDragEvent dtde) { if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) { try { if (dtde.isDataFlavorSupported(DockableTransferable.DATA_FLAVOR)) { Dockable dockable = (Dockable) dtde.getTransferable().getTransferData(DockableTransferable.DATA_FLAVOR); Doc...
484c4f32-4b29-45c5-96ab-e8447c8981fa
5
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Funcionario other = (Funcionario) obj; if (this.IdFuncionario != other.IdFuncionario && (this.IdFuncionar...
73b67e88-2af0-4b8d-b4f1-78fa193b66c5
3
public Iterable<WeightedEdge> edges() { List<WeightedEdge> edges = new LinkedList<WeightedEdge>(); for (int v = 0; v < V(); v++) for (WeightedEdge e : adj[v]) if (e.other(v) > v) edges.add(e); return edges; }
3a55bb83-de1a-4b69-86e9-70aa25e4df9a
1
public ArrayList<Double> getSeparateLengths() { ArrayList<Double> lengths = new ArrayList<Double>(); for (Edge edge : edges) lengths.add(edge.getLength()); return lengths; }
768ad829-5320-42a9-9d0b-30b3ac1177cb
4
public ScaledResolution(GameSettings var1, int var2, int var3) { this.scaledWidth = var2; this.scaledHeight = var3; this.scaleFactor = 1; int var4 = var1.guiScale; if(var4 == 0) { var4 = 1000; } while(this.scaleFactor < var4 && this.scaledWidth / (this.scaleFactor + 1...
d44bc5bf-201f-45af-8f54-3b685b47ebce
0
public void setLocation_id(String location_id) { this.location_id = location_id; setDirty(); }
066b4e7d-7630-43e1-bc67-91cad1f79bd8
7
double playGame(Player black, Player white) { System.out.println(black + " vs " + white); long[] elapsedTime = new long[2]; State board = new State(); while (!board.gameOver()) { int move; long before = System.nanoTime(); if (board.getColorToPlay() == 'X') { move = black.move(board); elapsedTim...
02c4438b-c0d3-4e5e-9115-f69d8fe86424
9
public boolean isLargerThan(Domino other, int suit) { // Shortcut edge case if (other == null) { return true; } if (isSuit(suit) && !other.isSuit(suit)) { // The other domino doesn't match the given suit return true; } // Determine which side of the other domino we match if (isSuit(other.little...
d98f967e-dfa4-4c97-b264-d26f647a9550
0
public void driver() { System.out.println("bmw bus drive"); }
1854aaff-5154-4260-aba0-06e260cf0c55
8
private static String escapeJSON(String text) { StringBuilder builder = new StringBuilder(); builder.append('"'); for (int index = 0; index < text.length(); index++) { char chr = text.charAt(index); switch (chr) { case '"': case '\\': ...
0a3e686a-b6dc-4ded-861a-5b86dcffaa3c
4
@Override public String getColumnName(int col) { switch (col) { case 0: return Localization.getInstance().get("wordColumnName"); case 1: return Localization.getInstance().get("definitionColumnName"); case 2: return Localization.getInstance().get("categoryColumnName"); case 3: return Localization.getInstance(...
48dce37d-ae34-4dd8-b1fd-9b48dd36fa7a
2
public void savePatient(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException{ log.debug("PatientManager savePatient method called..."); Map<String, String> validationMap=new HashMap<String, String>(); Map<String, String> resultsMap; String action=req.getParameter("action");...
62485725-ad78-40a3-849f-2dac55f1d727
5
public Macro(File macro, RecordModel model) { BufferedReader br = null; this.model = model; try { br = new BufferedReader(new FileReader(macro)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { ...
dd094f20-9e6b-479f-8588-5199da0d4c08
8
public final void testBoundaryPlacement() { int gridSize = q8cb.getSize(); // Bottom left hand corner. q8cb.clearTheBoard(); assertTrue(q8cb.placePiece(0, 0)); assertTrue(q8cb.getBoard()[0][0] == PositionStatus.OCCUPIED); for (int j = 1; j < gridSize; j++) { assertTrue(q8cb.getBoard()[0][j] == Positio...
43360fc5-00a0-418f-8827-98ca178a276d
0
@Override public void newAttribute(String key, Object value, boolean isReadOnly, AttributeTableModel model) { model.keys.add(key); model.values.add(value); model.readOnly.add(new Boolean(isReadOnly)); Node node = doc.tree.getEditingNode(); node.setAttribute(key, value, isReadOnly); // undo Comp...
38f69cb6-7494-47fb-877d-935e1c368461
7
public void validateMove(Team movingTeam, int fromX, int fromY, int toX, int toY) throws IllegalMoveException { // Check that inputs make sense at all validateCoordsOnBoard(fromX, fromY); validateDestination(toX, toY); if (Team.NEUTRAL.equals(movingTeam)) { throw new IllegalArgumentException...
64c85831-cf01-4a1e-97ce-126395ad31ad
0
public AutomatonSizeSlider(AutomatonPane view, AutomatonDrawer drawer) { super(AUTOMATON_SIZE_MIN, AUTOMATON_SIZE_MAX, AUTOMATON_SIZE_INIT); this.view = view; this.drawer = drawer; this.addChangeListener(new SliderListener()); setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(...
6217054b-edf6-4862-be8f-4c172cd9a0df
0
public String getCode() { return code; }
af52b134-3c89-4af2-b8ec-16e907a05510
3
protected Function(Dictionary d) { Vector dom = (Vector) d.getObject("Domain"); domain = new float[dom.size()]; for (int i = 0; i < dom.size(); i++) { domain[i] = ((Number) dom.elementAt(i)).floatValue(); } Vector r = (Vector) d.getObject("Range"); if (r != nu...
2eacf2dc-1017-4230-9a56-d000252d4928
4
@Override public int read(char[] cbuf, int off, int len) throws IOException { if (len == 0) { return 0; } int c = read(); if (c == -1) { return -1; } int result = 0; do { cbuf[result + off] = (char) c; result++; c = read(); } while (c != -1 && result < len); return result; }
f12d197c-0df5-414d-80d1-ee56046c168a
1
public void printIdentificationNumberStr(String enteredIdentificationNumber, boolean lineSeparator) { if (lineSeparator) { System.out.printf("Identification number: %s\n", enteredIdentificationNumber); } else { System.out.printf("Identification number: %s", enteredIdentificationN...
ed3ed844-b4d8-495b-91a3-9b6beda20037
4
private void process() { if (intervals.size() < 2) { throw new IndexOutOfBoundsException("Processing requires at least two intervals"); } // addressing to the first non-fictitious interval double y_min = intervals.get(1).getY(); MatterInterval inl; for (int i...
bccb6430-219d-4a6c-bd3d-7f213fb387d1
2
public Set<T> concat(Set<T> s) { Set<T> res=this; if(s==null) { return res; } else { if(s.next==null) { return res.append(s.a);} else//s.next!=null { return res.append(s.a).concat(s.next);} } }
d516f57e-e79e-4187-ab07-f4171eac502b
4
@Override public boolean onCommand(CommandSender commandSender, Command cmd, String lbl, String[] args) { if(commandSender instanceof Player) { Player pl = (Player) commandSender; if(cmd.getName().equalsIgnoreCase("challenge")) { if(args[0].equalsIgnoreCase("ironarmor...
abb42874-b94a-4950-9bd3-d6281732e3ba
3
private void removeHost(Host host) { HostPanel hp = hostsMap.remove(host.getName()); if (hp != null) { ClientConnectionManager.getInstance().removeClientChangedListener( hp); if ((hostList.size() > 1) && (hostList.indexOf(hp) == (hostList.size() - 1))) { GridBagConstraints newLastConstraints = ...
751072a5-4364-416d-b29f-c02476477dc5
5
public static double regularisedBetaFunction(double z, double w, double x) { if (x < 0.0D || x > 1.0D) throw new IllegalArgumentException("Argument x, " + x + ", must be lie between 0 and 1 (inclusive)"); double ibeta = 0.0D; if (x == 0.0D) { ibeta = 0.0D; } else { if (x == 1.0D) { ibeta = 1.0D; } ...
9ef85d59-0345-492c-8e08-d562e6bc39fe
1
public void deleteProperty(String section, String var) { if (map.containsKey(section + '.' + var)) map.remove(section + '.' + var); }
1147f6ac-5790-4baa-9b81-7fbd2bdee1a4
5
public String toString() { if (Double.isNaN(im) || Double.isInfinite(im)) { return re + " + " + "i" + im; } if (im == 0) { return re + ""; } if (re == 0) { return im + "i"; } if (im < 0) { return re + " - " + (-im) +...
a45e097c-944e-40c2-ba7a-6e32459c13ea
1
private static void dumpImageToSheet(SegmentedImage image, Workbook wb){ Sheet s = wb.createSheet(); generateHeader(s); for(int rownum = 1; rownum <= image.numCells(); rownum++){ fillData(s, rownum, image.getCell(rownum-1)); } }
d8f3032a-5040-43e1-9354-75877580d9e3
5
public boolean hasCycle(ListNode head) { if (head == null || head.next == null) return false; ListNode oneStep = head; ListNode twoStep = head.next; while (twoStep != null) { if (oneStep == twoStep) return true; twoStep = twoStep.next; if (twoStep == null) break; oneStep = oneStep....
359e2426-0839-4c3b-a75c-dff0cd67ca05
4
@Test public void testBasicMethodSmall() { final float[] weights = initWeights(18); ChiVertex<Integer, Float> vert = new ChiVertex<Integer, Float>(0, new VertexDegree(0, weights.length)) { public Float getOutEdgeValue(int i) { return weights[i]; } ...
c57048c1-f1a9-49b8-970b-e20b583c1a24
5
public void handleCollisions(CollisionHandler... handlers) { for (int i = 0; i < size(); i++) { for (int j = 0; j < size(); j++) { if (i != j) { Sprite s1 = get(i); Sprite s2 = get(j); if (s1.intersects(s2)) { Collision c = new Collision(s1, s2); Loader.addEventToAll(n...
0d9d7f32-3d83-487c-9d3b-98080395d0ed
6
public void initialize() { if(Configuration.hasParameter("DistributionModel/Line/FromX") && Configuration.hasParameter("DistributionModel/Line/FromY") && Configuration.hasParameter("DistributionModel/Line/ToX") && Configuration.hasParameter("DistributionModel/Line/ToY")) { try { previousPositionX ...
662282d9-c9ff-40d1-ac0b-8ec547b135df
0
public DialogWindowView(String title) { dialog = new JDialog((JFrame) null, title); dialog.setResizable(false); dialog.setSize(200, 100); dialog.setLocation(MainWindowView.WIDTH/2, MainWindowView.HEIGHT/2 - dialog.getHeight()/2); init(); addActionListeners(); }
6b8dad5c-3c93-4323-be0a-fe9e7a673c4e
6
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { BigDecimal percentage = null; List<String> fouten = new ArrayList<>(); try { percentage = new BigDecimal(request.getParameter("percentage")); if (percentage.compareTo(BigDecimal.ZERO) <=...
ff377770-6a93-4d03-8326-dc5b6521c815
6
public String catchInfo(String url) { this.url = url; String html = null; try { getMethod = new GetMethod(url); int statusCode = httpclient.executeMethod(getMethod); System.out.println("StatusCode:" + statusCode + ">>>>URL:" + url); if ((statusCode == HttpStatus.SC_MOVED_TEMPORARILY) || (sta...
ae97f135-5a9c-4188-a15d-56ce2c58fc24
4
protected List<Actor> actors() { if (!(model instanceof Factional)) { return new ArrayList<Actor>(model.actors); } // If we're interacting with a Factional model, // only neutral actors and actors from the current // team should have a chance to act: List<Actor> ret = new ArrayList<Actor>(); int curren...
49c852ad-477a-47a2-afb8-dd8c7bdd0394
1
@Override public Object getPreviousValue() { int n = getNumber().intValue(); if (n == 1) { return n; } return n-1; }
1cd68c88-2d0e-4e2c-b578-cf1442b38af3
1
public Class<?> getColumnClass(int col) { return getValueAt(0, col).getClass(); }
d25774fb-2469-4560-bf13-302e763934ce
5
protected GeneralPath renderSimpleGlyph (GlyfSimple g) { // the current contour int curContour = 0; // the render state RenderState rs = new RenderState (); rs.gp = new GeneralPath (); for (int i = 0; i < g.getNumPoints (); i++) { PointRec rec = new PointRec...
65d425e0-1c9f-4681-abe0-f06dc5141941
1
public void push(IntegerNode newNode) { if (this.top == null){ this.top = newNode; } else { IntegerNode nextInLine = this.top; this.top = newNode; this.top.setNextTop(nextInLine); } count++; }
4ed615f1-9131-45b4-8ef3-88d710db9f97
7
public void paint(Graphics g) { double dx = this.getWidth() / (double) a.getWorld().getWidth(); double dy = this.getHeight() / (double) a.getWorld().getHeight(); dx = Math.min(dx, dy); dy = Math.min(dx, dy); for (int x = 0; x < a.getWorld().getWidth(); x++) { for (int y = 0; y < a.getWorld().getHeight();...
d00c3e7b-d32a-41f1-8928-83a44c5db705
0
private JPanel placeTextFields(){ final int ROWS = 2; final int COLUMNS = 2; GridLayout layout = new GridLayout(ROWS, COLUMNS); layout.setHgap(10); layout.setVgap(10); JPanel panel = new JPanel(layout); oldValue = new JTextField("Old value"); oldValue.setE...
65f4bf1e-fe03-4cdd-b370-7881420a2456
4
@Override public void run() { final GameObject obelisk = ctx.objects.select().id(OBELISK).nearest().poll(); if (obelisk.valid() && IMovement.Euclidean(obelisk, ctx.players.local()) < 5) { renewPoints(); } else { if (!locationAttribute.isInObeliskArea(ctx)) { if (doSmall()) { ctx.sleep(666); } ...
2b669862-4a63-48d1-b7b9-88a705b1b552
9
public boolean buttonDown(Controller controller, int code) { switch(code){ case XBox360Pad.BUTTON_A: MyInput.setKey(Input.JUMP, true); break; case XBox360Pad.BUTTON_X: if(!menu) MyInput.setKey(Input.INTERACT, true); break; case XBox360Pad.BUTTON_RB: MyInput.setKey(Input.ATTACK, true); break; case ...
2c2c4f23-3ee9-4d53-bd2e-ed7d9bc05924
0
public void setPreNote(String preNote) { this.preNote = preNote; }
dcd36b41-cd94-468f-b6ad-8ad4bb21947b
2
public boolean available(int num) { boolean availablity = false; try { if(!seat[num])//= if seat is false, then condition will be true availablity = true; } catch(ArrayIndexOutOfBoundsException ex) { System.out.println("Error:" + ex); availablity = false; } return availablity; }
4c15a24c-1bdc-40ac-90c3-9b165ac3a07e
7
@EventHandler public void GhastJump(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getZombieConfig().getDouble("Ghast.Jump.DodgeCh...
0153b094-9901-473e-bb9b-43f966181ad0
9
@Override public String process(HttpServletRequest request) throws MissingRequiredParameter { ResultSet resultSet = null; String ciudad = request.getParameter("ciudad"); JSONArray result = new JSONArray(); //String result; try { // Get Connection and Statement connection = dataSource.getConnect...
6a073368-003b-4fb8-aab5-ff0a55456787
8
private String readline(InputStream is) { StringBuilder rtn = new StringBuilder(); int temp; do { try { temp = is.read(); } catch (Exception e) { return null; } if (temp == -1) { String str = rtn.toSt...
a96c5e18-f882-4249-8c5a-6c328bd36f66
0
public double getValue() { return value; }
04b3d502-47ef-4e1e-af78-f31852f66e2a
4
public void closeConnection(){ if (stmt!=null) { try { stmt.close(); } catch (Exception ignore) {} } if (conn!=null) { try { conn.close(); } catch (Exception ignore) {} } }
21762369-e7ed-43ba-9f7f-0dafbc1e611a
3
@Test public void testSearchAndUpdateCollection() { gcPrintUsed(); int repeats = 1000; // five seconds. HugeArrayBuilder<MutableTypes> mtb = new HugeArrayBuilder<MutableTypes>() { }; HugeArrayList<MutableTypes> mts = mtb.create(); mts.setSize(length); for (MutableTypes mt : mts) { mt...