method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
c06b6f58-0ec6-4de1-a67a-f66e81113c38
4
@Override protected void run() { long startTime = System.currentTimeMillis(); long elapsedTime = 1; ClonAlg clonAlg = (ClonAlg) algorithms.get("ClonAlg"); int sameCounter = 0; clonAlg.run(); runBestIndividual = clonAlg.getBestIndividual(); System.out.println(); boolean reset = false; w...
acb4b8b9-dc5a-4b27-89e3-654f4c788ee2
2
@Override public void collideWith(Element e) { if (isActive() && e instanceof PlayerCTF) ((PlayerCTF) e).dropFlagOnAdjacentPosition(getGrid().getElementPosition(this)); super.collideWith(e); }
a1ae7bd1-8bbc-48dc-ac86-adb457f799f2
7
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final Physical target=getAnyTarget(mob,commands,givenTarget,Wearable.FILTER_UNWORNONLY); if(target==null) return false; if(target==mob) { mob.tell(L("@x1 doesn't look dead yet.",target.nam...
3793a6ee-195c-4c05-9346-82a472be3d6c
9
public void actionPerformed(ActionEvent e) { if ("hit".equals(e.getActionCommand())) { this.game.hit(this.hp, 1); resetScore(); } else if ("stay".equals(e.getActionCommand())) { stayStuff(); } else if ("reset".equals(e.getActionCommand())) { resetGame(); } else if ("bet +10".equals(e.getActionComman...
be2ccac5-3feb-402c-91ed-1d039eebe5d0
2
@Override public void initialize(Vertex start) { this.queue = new Queue(); for (int i = 0; i < edges.getSize(); i++) { edges.get(i).setVisited(false); } for (int i = 0; i < vertices.getSize(); i++) { vertices.get(i).setColor(VertexColor.WHITE); ver...
dd39e8e6-7fe9-4f9e-9051-52d49a6ca4e2
5
public static void maxHeapify(int[] a, int i, int heapSize) { int left = left(i); int right = right(i); int largest = i; if (left <= heapSize && a[left] > a[i]) { largest = left; } if (right <= heapSize && a[right] > a[largest]) { largest = right; } if (largest != i) { swap(a, i, largest); ...
74b80721-8441-418c-8fd4-38f2946b1085
2
public static void main(String[] args) { List<String> maleTeam = new LinkedList<>(); maleTeam.add("John"); maleTeam.add("Tom"); maleTeam.add("Sam"); maleTeam.add("Vijay"); maleTeam.add("Anthony"); System.out.println("Male Team:" + maleTeam); List<String> femaleTeam = new LinkedList<>(); femaleTeam.add...
f4e1a321-8a32-4ac4-8908-c1f72476216d
5
public Missile(Player player, Start start, int dir, int heigth, int width, GameScreen gameScreen, List<BasicZombie> basicZombieList, Boss boss) { this.player = player; this.dir = dir; this.heigth = heigth; this.width = width; this.gameScreen = gameScreen; this.start = start; this.basicZombieList = basi...
f8199165-8200-4cd3-bac4-b832455c2a1c
1
private boolean onkoNopeusToisestaPois(Pelihahmo h){ double toisenSuunta = normalisoi(hahmojenValinenKulma(h)); double nopeus = normalisoi(nopeudenSuunta(h)); return nopeus < normalisoi(toisenSuunta - Math.PI/2) && nopeus > normalisoi(toisenSuunta + Math.PI/2); }
78874f5e-5b76-4f57-82f5-67fa4b4e2ac9
3
@EventHandler public void createSignEvent(SignChangeEvent event) { if (event.isCancelled()) return; Player player = event.getPlayer(); Block block = event.getBlock(); if (event.getLine(0).equalsIgnoreCase("[Teleporter]")) { if (!player.hasPermission("TeleportManager.sign.create")) { player.sendMessage(C...
b9a6b210-37c5-4983-b87a-efd026cd5293
4
public static byte[] decodeFromFile(String filename) throws java.io.IOException { byte[] decodedData = null; Base64.InputStream bis = null; try { // Set up some useful variables java.io.File file = new java.io.File(filename); byte[] buffer = null; int length = 0; int numBytes = 0; // Check ...
bce540a6-2cbb-42b8-bda8-bc3b867c3589
1
public String addUser() { try { User user = new User(); user.setId(getId()); user.setName(getName()); user.setSurname(getSurname()); userService.addUser(user); return SUCCESS; } catch (DataAccessException e) { e.printSta...
513cacde-8744-4649-8261-d0b3175e1d06
4
public static void main(String[] args) { if (args.length != 1) { System.err.println("usage: java Registrar [integer]"); System.exit(1); } int n = Integer.parseInt(args[0]); Registrar server = new Registrar(n); Utils.out(server.pid, String.format("Registrar started; n = %d.",n)); ServerSocket se...
f31ba759-d197-4159-96ad-5bcfd33f7693
0
protected void setDecomposition(int[] decomposition) { tempDecomposition = decomposition; }
5199962f-1c9a-4cec-b1d6-88c9ae13bf8c
7
public static void actWhenMassiveAttackIsPending(Unit unit) { // If unit is surrounded by other units (doesn't attack alone) // if (isPartOfClusterOfMinXUnits(unit)) { // If there is attack target defined, go for it. if (StrategyManager.isSomethingToAttackDefined() && !MapExploration.getEnemyBuildingsDisc...
60b871d0-a460-4ea0-b2cd-af664a56a8b1
9
public void giveIntervalReward(Player p, int breaks) { if (intervalRewards == null || intervalRewards.isEmpty()) { return; } for (Reward r : intervalRewards.values()) { if (breaks % r.getBlocksNeeded() == 0) { if (r.getCommands() == null || r.getCommands().isEmpty()) { return; } ...
3dd5e251-9863-4759-8aa3-969b323e0414
3
public void mouseClicked(MouseEvent event) { GrammarTable gt = (GrammarTable) event.getSource(); Point at = event.getPoint(); int row = gt.rowAtPoint(at); if (row == -1) return; if (row == gt.getGrammarModel().getRowCount() - 1) return; Production p = gt.getGrammarModel().getProduction(row); ...
6e2efec7-e3fc-4f8e-869a-314efaa6a8a5
5
public static void matrixsum(int x[][]) { int sumr = 0, sumc[], sumd1 = 0, sumd2 = 0; sumc = new int[x[0].length]; for (int i = 0; i < x.length; i++) { sumr = 0; System.out.print("\n "); for (int j = 0; j < x[i].length; j++) { System.out.print(x[i][j] + " "); sumc[j] = sumc[j] + x[i][j]; ...
1a2997e9-6a3f-4a00-86ef-5b26a4b13a50
6
public void printConfusionMatrix() { // print header System.out.println("Confusion Matrix:\n"); System.out.format("%20s", ""); for (String classifier : testInstances.classifiers()) { System.out.format("%20s | ", classifier); } System.out.println("\n"); // get set of classifiers Set<String> classifier...
5020a745-1788-487c-807f-03f0b1a57160
8
private static void findHelp(BoggleBoard board, LexiconInterface lex, int min, int r, int c, AutoPlayerBoardFirst ap, String word, ArrayList<BoardCell> cellList){ cellList.add(new BoardCell (r, c)); if(lex.containsPrefix(word)){ if(lex.contains(word) && word.length() >= min && !ap.myWords.contains(word)){ ...
f97e56e1-b19b-4589-992c-9db4f9cd3a67
9
private void addPart(int gridX, int gridY, int dir, int amount) { Random random = new Random(); amount += 2; if (gridY < cloudAtlas.length && gridX < cloudAtlas[0].length - 1 && gridX > -1 && gridY > -1) { //System.out.println("dir: " + dir + " adding cloud: " + gridX + " " + gridY)...
2ffd754f-570c-408f-a282-25616d9e85e0
0
public String getNombre() { return nombre; }
e04b3de5-dbd5-47f1-9895-1ca793ddc4f4
2
static final public NamesValues namesValuesOf(Map map){ if (map == null){ return new NamesValues(new String[0],new Object[0]); } Object[] keys = map.keySet().toArray(); String[] names = new String[keys.length]; Object[] vals = new Object[keys.length]; for (int i = 0 ; i < vals.length; i++){ Object k...
19f324b1-7d1a-4596-91c2-1fe7d6245f26
0
@Test public void testWritePriceForQuantity() throws Exception { BigDecimal bd1 = BigDecimal.valueOf(150.00); product.writePriceForQuantity(7, bd1); assertTrue(product.getPrices().get(7).equals(bd1)); }
38abb8d9-eb7e-4436-90b3-066c88f00026
4
private Object unwrapValue(Object value) { if (value == null) return null; if (value instanceof Wrapper) { return ((Wrapper) value).getHandle(); } else if (value instanceof List) { throw new IllegalArgumentException("Can only insert a Wra...
9546fa3b-a731-456b-a9ed-f91caf88dfb7
5
private void addPlanets(Point3 startPoint, Point3 parallSize, int count ){ Random rand = new Random(); int maxLoopEntries = 10000; //чтоб бесконечно не крутился while(count > 0 && maxLoopEntries>0){ maxLoopEntries--; Point3 randPoint = new Point3( ra...
0456657a-c80a-4e50-8750-f973014a326c
1
public void addKey(int keyEvent, Key key) { if (keys.containsKey(keyEvent)) { keys.get(keyEvent).add(key); } else { ArrayList<Key> newKeyList = new ArrayList<Key>(); newKeyList.add(key); keys.put(keyEvent, newKeyList); } }
bee7474e-aa22-4152-a881-da4780380c81
2
public double[] columnStandardErrors(){ double[] standardErrors = new double[this.numberOfRows]; for(int i=0; i<this.numberOfColumns; i++){ double[] hold = new double[this.numberOfRows]; for(int j=0; j<this.numberOfRows; j++){ hold[i] = this.ma...
2884e8c1-428e-4af0-b6be-53e82947f810
3
public ParkingSpot searchBySpotNumber(String number) { ParkingSpot spot = null; for(TreeSet<ParkingSpot> t: garage.values()) for(ParkingSpot p: t) if(p.getParkingNumber().equalsIgnoreCase(number)) spot = p; return spot; }
1db3bd7d-28a2-4234-8e78-ebaa96d3db69
4
public void editTask(HabitItem task) { boolean flag=false; int i=0; while(i<this.items.size() && flag!=true) { if(this.items.get(i).getId().equals(task.getId())) { flag=true; } else { i++; } } if(flag) { this.items.set(i, task); } }
c2a3292e-8b21-435c-b9d1-5bcb1c892e92
5
public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) { buf.setLength(0); buf.append('\n'); if ((access & Opcodes.ACC_DEPRECATED) != 0) { buf.append(tab).append("// DEPRECATED\n"); } buf.append(tab).append("// access flags 0x")...
fc99771d-5f0d-4038-af7f-dce6d3bedaa0
7
public static boolean hasNonVowel(String text) { int c = 0; for(int i = 0; i < text.length(); i++) { if(text.charAt(i) == 'a' || text.charAt(i) == 'e' || text.charAt(i) == 'i' || text.charAt(i) == 'o' || text.charAt(i) == 'u') c++; } if(c > 1) return true; else return false; }
1ceabc3f-a292-49d0-9007-cc5e9d6701ff
9
public TimerunsDataset(String textPath, int step, int count) throws IOException, ParserConfigurationException, SAXException, AnnotationException, XPathExpressionException{ int currIdx = 0; String fullBody= loadBody(textPath); for (int i=0; i<count; i++){ //advance of <step> more words for (int j=0; j<step; ...
f08441bd-d30e-42cb-a752-c4f4ac85fd10
2
public void addLocation(String p_Type, int p_X, int p_Y) throws Exception { String add = "add_" + p_Type + "(" + appendPos(p_X, p_Y) + ",A,B)."; SolveInfo info = m_Engine.solve(add); while(info.isSuccess()) { String x = info.getVarValue("A").toString(...
6cecf8b9-99e4-41c4-864b-4b4b346715af
0
private void modificarDatos(){ idLabel.setText(Integer.toString(cliente.getIdCliente())); nombre.setText(cliente.getNombre()); apellidos.setText(cliente.getApellidos()); apodo.setText(cliente.getApodo()); especial.setSelected(cliente.isEspecial()); }
d4439a20-3e11-4cb1-8503-2d9483f58125
2
public boolean buscar(T dato){ boolean resultado = false; Nodo<T> q = p; while(q != null){ if(q.getValor().equals(dato)){ resultado = true; } q = q.getLiga(); } return resultado; }
5a42fb58-e0cd-4302-b3a2-142265190cd7
2
public int compareTo(Vehicle v) { if (v.getPosition() > this.getPosition()) { return 1; } else if (v.getPosition() < this.getPosition() ) { return -1; } else { return 0; } }
ac39e236-2f42-4f55-8515-1e04b2fcc9ea
7
public void setOptions(String[] options) throws Exception { String tmpStr; String[] tmpOptions; setChecksTurnedOff(Utils.getFlag("no-checks", options)); tmpStr = Utils.getOption('C', options); if (tmpStr.length() != 0) setC(Double.parseDouble(tmpStr)); else setC(1.0); tmpS...
838beae0-e289-40af-86c8-9c2a82573917
3
protected static String convertToWikiIndent(String wikiText) { String[] linesArr = wikiText.split("\\n"); for (int i = 0; i < linesArr.length; i++) { if (linesArr[i].trim().isEmpty() == false) { char firstChar = linesArr[i].trim().charAt(0); if (Character.isD...
bef9f6f8-ed11-4001-ad4d-dc262bb2cd50
8
public static void pokemonWasSelected(int pokeIndex, Item item) { if(item.effect1==Item.Effect.POKEBALL) { usePokeBall(item); } else if(item.effect1==Item.Effect.ROD) { useRod(item); } else if(item.effect1==Item.Effect.REPEL) { useRepel(item); } else if (item.effect1 != Item.Effect.TM && i...
39060d87-be40-4ad6-aecc-b8fd3f80ef65
2
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(type.toString() + "[" + value + "]"); if (!constraints.isEmpty()) { sb.append("{"); for (Constraint def : constraints) sb.append(def); sb.append("}"); } return sb.toString(); }
273c580e-3f09-43fb-be70-49bf9358efa7
3
public void updateMembersList(){ listModelMembers.removeAllElements(); for (String i:admin){ listModelMembers.addElement(i+" (Admin)"); } for (String i:members){ listModelMembers.addElement(i); } for (ExternalUser i:externalUsers){ listModelMembers.addElement(i.getName()+" (External)"); } }
1d2d1376-5954-4dba-ad12-2ff2860d6513
8
public static double betacf(double a, double b, double x) { double MAXIT = 100; double EPS = 3e-7; double FPMIN = 1e-30; int m, m2; double aa, c, d, del, h, qab, qam, qap; qab = a+b; qap = a+1; ...
d5e5f892-1c9e-4452-916e-debdf63e652c
3
@Override public void actionPerformed(GuiButton button) { if(button.id == 0) { GameStatistics.lives--; MapGenerator gen = new MapGeneratorSimple(); Remote2D.guiList.pop(); Remote2D.guiList.push(new GuiLoadMap(gen, 40, 40, 1337)); } else if(button.id == 1) { while(!(Remote2D.guiList.peek() insta...
1e90b5d6-ce71-4ca7-bcd8-0a4b1dafca7e
7
public static void main(String[] args) throws IOException { readConfigFile(); File file = new File(CONFIG.getEntryFolder()); for (File currentFolder : file.listFiles()) { for (String currentProject : CONFIG.getProjectsToCheck()) { if (currentFolder.getAbsolutePath().e...
ccd3f796-b01d-476f-827f-2666906480a6
8
protected void genDoorName(MOB mob, Exit E, int showNumber, int showFlag) throws IOException { if((showFlag>0)&&(showFlag!=showNumber)) return; if(E instanceof Item) mob.tell(L("@x1. Exit Direction (or 'null'): '@x2'.",""+showNumber,E.doorName())); else mob.tell(L("@x1. Door Name: '@x2'.",""+showNumbe...
0ef95df5-d88c-460a-a5e6-78b93165bd74
5
private int isDPI(String mnemonic) { if(mnemonic.length()!=3 && mnemonic.length()!=5 && mnemonic.length()!=6) { return -1; } String dpiMnemonics[] = {"and","eor","sub","rsb","add","adc","sbc","rsc","tst","teq","cmp","cmn","orr","mov","bic","mvn"}; System.out.print...
b13e640e-36bc-4abf-b90e-4cf9509898c0
3
static public float atan2_fast(float y, float x) { // From: http://dspguru.com/comp.dsp/tricks/alg/fxdatan2.htm float abs_y = y < 0 ? -y : y; float angle; if (x >= 0) angle = 0.7853981633974483f - 0.7853981633974483f * (x - abs_y) / (x + abs_y); else angle = 2.356194490192345f - 0.7853981633974483f * (x...
57b4f639-959e-4a09-97a1-9a1ac979d7ae
5
public void visit_switch(final Instruction inst) { final Switch sw = (Switch) inst.operand(); final int[] values = sw.values(); final Label[] targets = sw.targets(); if (values.length == 0) { if (longBranch) { addOpcode(Opcode.opc_pop); // Pop switch "index" off stack addOpcode(Opcode.opc_goto_w); ...
9e73757b-0683-4030-80de-64d7357583d1
2
public void destroy(Long id) throws NonexistentEntityException { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); Ausencia ausencia; try { ausencia = em.getReference(Ausencia.class, id); a...
b6a160cf-3ea8-4c5c-a7aa-4f2f5d949b48
1
public Door(Transform transform, Material material, Vector3f openPosition) { this.transform = transform; this.openPos = openPosition; this.closedPos = transform.getPosition(); this.material = material; opening = false; closing = false; open = false; startTime = 0; openTime = 0; closeTime = 0; ...
2ffdbbc4-2680-4721-8aa5-146179d470aa
0
public Builder against(final Object value) { this.value = value; return this; }
23553cc7-c6cf-4383-aff7-c29f97bfde62
6
private void recursivePrint(int i, Node parentNode, int parentPosition, int depthLeft, int depthRight) { int newLeftPosition = 2 * i + 1; Pair left = null; Node nodeLeft = null; int parentLeftPosition = parentPosition; if (newLeftPosition < nodes.length) { left = nod...
dd621972-9eab-4888-a44e-076c4484a317
8
private boolean handlePlaceBlocked(Player player, Block block, Material type) { if (WorldRegionsPlugin.getInstanceConfig().ENABLE_BLOCKED_PLACE && WGCommon.willFlagApply(player, WorldRegionsFlags.BLOCKED_PLACE)) { // Disabled? if (WGCommon.areRegionsDisabled(player.getWorld())) return true; // Bypass? ...
779dc689-b07c-4e84-8a5e-de1079e787d0
9
@Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case "Lopeta": System.exit(0); break; case "Kirjaudu ulos": ikkuna.kirjaaUlos(); break; case "Uusi käyttäjätunnus/oppilas...
c4b976c2-9eaa-41f3-8db2-a94ee9ee9f02
8
public Tile getTile (int x, int y) { if (x < 0 || x >= width || y < 0 || y >= height) return Tile.voidTile; if (tiles[x + y * width] == Tile.col_grass) return Tile.grass; if (tiles[x + y * width] == Tile.col_floor) return Tile.floor; if (tiles[x + y * width] == Tile.col_wall_1) return Tile.wall_1; if (tiles[x...
9d8e70c7-8356-4e08-9f5e-a58cbf123ff2
7
@Override public Descriptor compile(SymbolTable symbolTable) { Descriptor d = null; if (subject instanceof IdentNode) { d = symbolTable.descriptorFor(((IdentNode) subject).getIdentName()); } if (d instanceof IntConstDescriptor) { write("PUSHI, " + ((IntConstDescriptor) d).value()); } else if (subject...
bbeb48b1-1d8f-41eb-8e18-32820e50ebd9
9
private void process(Kernel kernel, int[] in, int[] out, int width, int height, boolean alpha, boolean wrap) { float[] matrix = kernel.getKernelData( null ); int cols = kernel.getWidth(); int cols2 = cols/2; for (int y = 0; y < height; y++) { int index = y; int ioffset = y*width; for (int x = 0; x < w...
497c4b01-b259-4f59-823b-be3509918250
8
public static void craftRunesOnAltar(Client c, int requiredlvl, int exp, int item, int x2, int x3, int x4) { int essamount = 0; if(!hasRequiredLevel(c, 20, requiredlvl, "runecrafting", "craft this runes")) { return; } if (!c.getItems().playerHasItem(1436)) { c.sendMessage("You need some rune essence to cr...
c5d002c1-7c25-44e6-9844-6f01b82599cd
5
public <T> Provider<T> scope(final Key<T> key, final Provider<T> unscoped) { // Memoize call to unscoped.get() under key. return new Provider<T>() { public T get() { ConcurrentMap<Key<T>, Future<T>> futures = futures(); Future<T> f = futures.get(key); ...
c96ead3a-0979-4438-8959-9e5713d44aa3
5
static private int jjMoveStringLiteralDfa1_0(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(0, active0); return 1; } switch(curChar) { case 97: return jjMoveStringLiteralDfa2_0(active0, 0x20000L); case 10...
a957f518-ac96-4417-8235-519340b2dfa1
7
public static Node nextInorder(Node node) { if (node == null) return null; Node current = node.getRight(); // If current node has right subtree then the next inorder node is // leftmost node in right subtree if (current != null) { while (current.getLeft() != null) current = current.getLeft(); r...
33a8531a-0288-4b9f-b070-f557c5d9ac4d
2
private void removecurrentChartPanel(){ if(this.currentChartPanel != null){ try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { TesterMainGUIMode.this.getContentPane().remove(TesterMainGUIMode.this.currentChartPanel); TesterMainGUIMode.this.getContentPane().r...
4ea09d07-b2d8-4029-b0b9-d4a2d41532f7
4
public static void save(String filename) { File file = new File(filename); String suffix = filename.substring(filename.lastIndexOf('.') + 1); // png files if (suffix.toLowerCase().equals("png")) { try { ImageIO.write(onscreenImage, suffix, file); } catch (IOExcep...
42a338cc-47e5-4241-9360-74ee1eb532b0
6
public static int nextValidInt(Scanner s, int lo, int hi){ Integer input = null; do{ if (s.hasNextInt()){ input = (Integer) s.nextInt(); } else{ // Case: there is no integer in the next input System.out.println("Please input a number."); s.next(); // this prevents build up of empty lines when ...
353bb86a-a407-499f-8321-261863630db7
9
@Override public int compareTo(BussinessMessage o) { if ((getFieldName() == null) && (o.getFieldName() == null)) { return getMessage().compareTo(o.getMessage()); } else if ((getFieldName() == null) && (o.getFieldName() != null)) { return 1; } else if ((getFieldName() ...
dc3964a2-4217-4b00-89f3-9dd0720fc8ec
2
public void UpdateIndicesOnDelete(Persistent obj) throws IllegalArgumentException, IllegalAccessException { String globalName = obj.GetIndexGlobalName(); NodeReference node = connection.createNodeReference(globalName); Field[] fields = obj.getClass().getFields(); for (int i =0; i< fi...
5a413050-55a4-4bb1-ba42-74150346ef09
7
public static boolean hasDivisibilityProperties(String x) { boolean d234by2, d345by3, d456by5, d567by7, d678by11, d789by13, d8910by17; d234by2 = Long.parseLong(x.substring(1, 4)) % 2 == 0; d345by3 = Long.parseLong(x.substring(2, 5)) % 3 == 0; d456by5 = Long.parseLong(x.su...
ba28032f-671c-4e6c-8ff2-70104277ad37
6
public Fee(JSONObject json) throws JSONException { if (json.has("Amount")) { this.setAmount(json.getString("Amount")); } if (json.has("CurrencyCode")) { this.setCurrencyCode(json.getString("CurrencyCode")); } if (json.has("IncludedInEstTotalInd")) { this.setIncludedInEstTotalInd(json.getString("Inclu...
d1304d0d-68c2-4a85-bf0a-aaf922d02746
8
protected void waitForBridgeView(int expected_size, long timeout, long interval, JChannel ... channels) { long deadline=System.currentTimeMillis() + timeout; while(System.currentTimeMillis() < deadline) { boolean views_correct=true; for(JChannel ch: channels) { R...
75d07b2c-5830-440c-8420-a5440c00e400
4
public static void main(String[] args) { ExecutorService exec = Executors.newCachedThreadPool(); ArrayList<Future<String>> results = new ArrayList<Future<String>>(); for (int i = 0; i < 10; i++) /* * <T> Future<T> submit(Callable<T> task) Submits a value-returning * task for execution and returns a ...
f73862c6-c3be-4bf1-a83f-d98d97041791
1
private void allFalse() { for(boolean bool : keyStates) bool = false; }
fb8944a7-615a-4d82-88ac-3e6b164ba8fd
1
@Override public List<ValidateException> validate(String parameter) { final int maxPatronymicLength = 30; List<ValidateException> validateExceptionList = new LinkedList<>(); if (!ValidateUtils.stringMaxLengthValidation(parameter, maxPatronymicLength)) { String exMsg = "entered q...
ee01b23e-3c8b-4bb8-b84f-16c4c4b4f570
2
@DataProvider(name = DATA_PROVIDER) public Object[][] parameterIntTestProvider() { if (USE_REMOTE_BROWSERS) { return new Object[][] { { new DriverGenerator.RemoteFirefox() }, { new DriverGenerator.RemoteChrome() } }; } else { if(USE_STORED_PROFILE_FOR_FIREFOX){ return new Obje...
2deea150-d85d-4bd4-bfb0-8b54f49533ac
6
@Override public void hook(Game game) { String[] statusb = game.getPlayer().toStatus().split("\n"); StringBuilder sb = new StringBuilder(); int cur = 0; for (String statusb1 : statusb) { if (statusb1.contains("\r")) { sb.append(statusb1).append("\n"); ...
ffaa0eba-e61e-4ee5-8689-7166eae50d24
8
public int candy(int[] ratings) { if (ratings == null || ratings.length == 0) throw new IllegalArgumentException("Invalid args"); // Arrays.sort(ratings); // sort int n = ratings.length; int num[] = new int[n]; int sum = 0; for (int i = 0; i < n; i++) num[i] = 1; int k = 1; for (int i = 1; i < n...
58954772-6f36-4560-ae21-f325b6031b27
3
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Kokus other = (Kokus) obj; if (this.nbkoku != other.nbkoku) { return false; } ...
888adab2-0b9b-4af8-b93e-b56aae449a69
8
private long updateRewrite(Master master, File f, Location accessLoc, int rewriteCount) { MasterMeta fm = null; if (master.map.containsKey(f.getId())) { fm = master.map.get(f.getId()); } else { fm = new MasterMeta(f); master.map.put(f.getId(), fm); } int cCount = master.clusters.s...
6ad04a83-7758-4287-a236-2a3f41d29f03
5
private void findLastUsage_BFS() { // TODO Auto-generated method stub List<Unit> first_node = graph.getHeads(); if(first_node.size()>1){ return; } queue.add(first_node.get(0)); units_already_seen.add(first_node.get(0)); while(!queue.isEmpty()){ Unit u = queue.remove(); List<Local> vr = sll....
f215ae75-eadb-4437-8444-f883e1727b3b
7
private boolean testHypothesis() { if (hypothesis == Hypothesis.LESS_THAN && testStatistic < criticalRegion) { return true; } else if (hypothesis == Hypothesis.GREATER_THAN && testStatistic > criticalRegion) { return true; } ...
5b68df51-6ab7-4b61-a3b7-74277d1f2f40
8
private static String getShortMachineID() throws Exception { String MachineID = null; String localIP=null; String timestamp=null; try{ Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()){ NetworkInterface current = interfaces.nex...
5bdc787b-09cf-470f-86c1-8c1658c767cf
1
void objectParsed(Object what) { if (logger.isDebugEnabled()) { logger.debug("objectParsed()"); } inParams.addElement(what); }
e377f983-0328-459c-a173-94973aef4f93
1
private GameObject GetRootObject() { if(m_root == null) m_root = new GameObject(); return m_root; }
4006d99c-3ce1-4fda-840b-7d6c9263e51a
1
public static double getDouble() throws BadInput { double num; try { String str = getString(); num = Double.parseDouble(str); } catch(NumberFormatException e) { throw new BadInput(); } return num; }
96db2762-32cb-4623-98c7-7254bf017526
3
public void restoreBackedUpTiles(){ System.out.println("restoring backed up tiles: " + backUpNum); //backUpGoBack(); if(backUpMaps.size() > 0){ int[][][] vecArray = backUpMaps.get(backUpNum); int[][][] temp = new int[vecArray.length][vecArray[0].length][vecArray[0][0].length]; for(int k = 0; k < vecArray...
88aa1c5a-75c1-4ac1-bf3b-bb76ffcad9d5
5
private void insertUserRoles(String email, Role role, Connection conn) throws SQLException { PreparedStatement st = null; String q; try { switch (role) { case administrator: { q = "INSERT INTO user_roles SET email = ?, roles = ?"; ...
f1d92dc2-5a89-43d3-a15b-abc8b7e0e4eb
5
@Override public void draw(Graphics g) { if (acceptingUserInput() && !captured && closeEnough()) { //illustrate basics g.setColor(Color.LIGHT_GRAY); Point pt = getClosestPt(); g.drawLine(getMouseLoc().x, getMouseLoc().y, pt.x, pt.y); } if (acceptingUserInput() && captured) { //illustrate ch...
bee5723a-62c6-482a-b868-339046efd312
0
public Ellipse2D getShape() { return new Ellipse2D.Double(x, y, XSIZE, YSIZE); }
7e8cd150-3c5c-414c-9ee6-db64011e824d
8
private DoubleDate handleUntimedTask(String[] words, int indexOfDate1, int indexOfDate2, int indexOfFrom, int indexOfTo) { DoubleDate result = null; boolean noTime = false; boolean isNext = false; if (indexOfDate1 != words.length - 1 && indexOfDate1 > -1) { String...
e5ddd73e-e342-4ba5-ab7c-49d3d833fd41
5
@Override public void update(Observable model, Object msg) { ObserverMessage message = (ObserverMessage) msg; if (msg instanceof ObserverMessage) { if (message.getMessage()==ObserverMessage.NEW_LOG_MESSAGE) { String logmessage = ((AutoDJModel) model).getLogtext(); if (!logmessage.endsWith("\n")) logmess...
8da70a6c-ef95-44fc-8546-2e95dee8bb82
1
public void connect(String host, int major, int minor, String key) { this.host = host; this.major = major; this.minor = minor; this.key = key; try { socket = new Socket(host, 43594); input = socket.getInputStream(); output = socket.getOutputStream(); ByteBuffer buffer = ByteBuffer.al...
4b12b7bd-20d7-4edf-98a5-a62932f4b2c4
9
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Train train = (Train) o; if (id != train.id) return false; if (totalSeats != train.totalSeats) return false; if (departure != null ? !d...
bdf87a02-f7a0-4165-8a42-4ac18a0388f3
4
void setLink() { final Shell dialog = new Shell(shell, SWT.APPLICATION_MODAL | SWT.SHELL_TRIM); dialog.setLayout(new GridLayout(2, false)); dialog.setText(getResourceString("SetLink")); //$NON-NLS-1$ Label label = new Label(dialog, SWT.NONE); label.setText(getResourceString("URL")); //$NON-NLS-1$ final Text...
7eaaa90d-73ec-47a3-977f-efdb10e793f6
0
@Override public synchronized void setName(String name) { this.name = name; }
c25c2f4f-07e9-45c6-bea1-206efa972a88
3
private void handleDropItem(Message m, GameSession s) { Player p = s.getPlayer(); m.readInt(); int slot = m.readLEShortA() & 0xFFFF; m.readLEShort(); if(slot < 0 || slot >= 28 || p.getInventory().get(slot) == null) { return; } Item item = p.getInventory().get(slot); World.getSingleton().getGroundItem...
45b52482-3f2c-4657-b8dd-a8935d40fcc7
5
public void heapify(int indeksi){ int vasen = left(indeksi); int oikea = right(indeksi); int pienin; if(oikea <= heapsize){ if(keko[vasen].getPaino() < keko[oikea].getPaino()){ pienin = vasen; } else{ pienin = oikea; ...
6712906d-698c-4ff6-9bae-d9ad744536b4
7
public void updateCurrentPoints(PlayerCharacter girl) { double value = 0; String message = ""; if (challengeNumber == 1) { value = attributes.get(0).getAttributeValue(); } else if (challengeNumber == 2) { value = attributes.get(1).getAttributeValue(); } else if (challengeNumber == 3) { value = att...
83cadede-8922-497e-8982-98286f52ddb1
5
@EventHandler(priority = EventPriority.HIGH) public void onBlockDamage(BlockDamageEvent event) { if (event.isCancelled()) return; Block bl = event.getBlock(); Location loc = bl.getLocation(); if (bl.getType().equals(Material.ANVIL)) { if (plugin.anvils.containsKey(loc)) { ItemStack hand = event.get...
653c589b-64e7-4c63-b835-d29de9c97fee
5
private final long method714(int i) { long l = System.nanoTime(); long l2 = 0L; long l1 = -aLong3105 + l; aLong3105 = l; if (0xfffffffed5fa0e00L < l1 && ~l1 > 0xfffffffed5fa0dffL) { aLongArray3103[anInt3104] = l1; anInt3104 = (1 + anInt3104) % 10; ...
940a8f77-81dc-464b-b8ab-32d2fe71072c
1
private void setPopupMenu(JComponent component) { //Создаем контекстное меню final JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Отменить заявку"); popup.add(menuItem); //Добавляем слушателя на нажатие кнопки меню и на показ контекстного меню me...