method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
80e1f36c-cc5c-4f3e-baf0-6cbf173a2fac
6
*/ public void abandonColony(Colony colony) { if (!requireOurTurn()) return; Player player = freeColClient.getMyPlayer(); // Sanity check if (colony == null || !player.owns(colony) || colony.getUnitCount() > 0) { throw new IllegalStateException("Abandon bogus...
b9f05ea8-bdf1-4ea6-9982-6a5a3024bfb5
3
public HashSet<String> loadProductNameWords(String productName, HashSet<String> words) { // HashSet<String> words = new HashSet<String>(); String[] wordArray = productName.split(" "); for (String word : wordArray) { if (isNumeric(word) || word.equals(" ")) { continue; } words.add(word.trim()); }...
05b74bc5-9e21-4263-9cdd-4b5c86d2f4a3
4
private List<ReducerEstimatedJvmCost> estimateReducersMemory(List<Reducer> eReducers, InitialJvmCapacity gcCap) { int fReducerNum = finishedConf.getMapred_reduce_tasks(); if(fReducerNum == 0) return null; List<ReducerEstimatedJvmCost> reducersJvmCostList = new ArrayList<ReducerEstimatedJvmCost>(); Re...
54c2266d-fa23-40e8-97da-880308a01b14
4
public synchronized HijackCanvas getCanvas() { if (canvas != null) { return canvas; } if (loader == null || loader.getApplet() == null || !(loader.getApplet().getComponentAt(100, 100) instanceof HijackCanvas)) { return null; } return (HijackCanvas) loader.getApplet().getComponentAt(100, 100); }
b46748ab-158b-43db-a6b1-26a7d3a191ce
8
public <ObjectType> ObjectType bindAll( final ObjectType object ) { Class cl = object.getClass(); for ( final Method method : cl.getMethods() ) { Listener annotation = method.getAnnotation( Listener.class ); if ( annotation != null ) { if ( m...
77697609-8936-418d-a3b8-dc09339f8035
5
public Fibonacci union(Fibonacci H1, Fibonacci H2) { Fibonacci H = new Fibonacci(); //tarkistetaan, ettei kummankaan keon minimi ole null if ((H1 != null) && (H2 != null)) { //tehdään alustavasti H1:n minimistä H:n minimi H.min = H1.m...
09013999-d756-4864-b867-eedb9ba5b08e
3
public boolean intersect(int[] start, int[] off) { int len = this.start.length; boolean isIntersect = true; for (int i = 0; i < len; i++) { if ((this.start[i] >= start[i] + off[i] || this.start[i] + this.chunkStep[i] <= start[i])) { isIntersect = false; } } return isIntersect; }
0a5b3e6d-fe04-4c05-9b07-018b05d3878a
5
@Override public Point getTarget(GameState state) { float[][] candidates = new float[3][5]; Point target = null; int i = 0; for(TargetingStrategy strategy : strategies) { target = strategy.getTarget(state); if(target != null) { candidates[target.x][target.y] += weights[i]; } ++i; } float...
c1a44057-b67b-4835-a6cf-72cbb2dcc68e
5
private String statusSimple() { int activeHosts = 0; for (Host host : hosts.values()) if (host.isRunning()) activeHosts++; int numServices = 0; for (Map<String, Service> map : services.values()) numServices += map.size(); int forwardingConnections = 0; for (Connection connection : connection...
f6c31930-ee3a-42b3-884f-582bb5a88fa7
7
private int[] sevenSeg(double[] signalFFT, double Fs){ double areaTotal = ArithmanticUtil.sum(signalFFT) / Fs; double segmentSize = areaTotal / 7; double[] area = new double[7]; int[] interval = new int[8]; interval[0] = 0; for(int i = 1; i < interval.length; i++) interval[i] = signalFFT.length; do...
8b8f80d6-9dba-42f4-b4c3-ab203b261285
3
private void doUpdateJH(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String jhId = StringUtil.toString(request.getParameter("jhId")); if(!StringUtil.isEmpty(jhId)) { ObjectMapper mapper = new ObjectMapper(); Map result = new Ha...
41fa3a00-08ac-4953-ad78-a4067ab6a8e1
5
public final void doVote(final String player) { // Check Player exists! OfflinePlayer thePlayer = Bukkit.getOfflinePlayer(player); if (!thePlayer.hasPlayedBefore()) { log.info(String.format(plugin.getMessages().getString("player.never.played"), player)); return; }...
4b0d489a-9164-4ddd-9ea3-5be8f17fbd4f
4
public FieldName(final GObject gObj, ArrayList<String> fieldNames, String type, GridPane gp, int row, HistoryManager hm) { gp.add(new Label(LabelGrabber.getLabel("field.name.text") + ":"), 0, row); textField = new FieldNameTextField(); this.fieldNames = fieldNames; this.historyManager = ...
ab9cfdb4-fa8f-4e0d-ad15-3dc855783a30
3
@Test public void test2() { xmlReader.setContentHandler(new DefaultHandler() { private String currentQName; private int number; private int requiredNumber = 2; @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { currentQ...
cae80ed1-4675-4d07-9404-bd87670dfced
4
public SystemXMLParser(String fileName) { File schemaFile; Schema schema; Source xmlFile = new StreamSource(new File(fileName)); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); schemaFile = new File("bin/schema.xsd"); try { schema = schemaFactory.newSchema(...
9e647867-7c10-4e2f-88cb-eaae8039d94c
7
public void setChangable(boolean b) { changable = b; if (b) { questionBody.getHtmlPane().removeLinkMonitor(); if (!isChangable()) { if (choices != null) { for (AbstractButton x : choices) x.addMouseListener(popupMouseListener); } } } else { questionBody.getHtmlPane().addLinkMonito...
26079eba-a3f2-475b-bfdf-44c479368938
9
public static boolean isBlockSeparator(String s) { if (s.startsWith("--") && s.endsWith("--")) { return true; } if (s.startsWith("==") && s.endsWith("==")) { return true; } if (s.startsWith("..") && s.endsWith("..") && s.equals("...") == false) { return true; } if (s.startsWith("__") && s.endsWit...
cc0cfe45-ed6e-4607-90a9-febef92b9c8a
4
private Class classFor(final String name) { if (name == null) throw new NullPointerException("missing required 'type' filter config parameter"); Class cl = null; try { return Class.forName(name); } catch (ClassNotFoundException e) { } try { return ...
f2715d04-cc3f-43ec-95af-5635844545ed
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; WithNotAnnotatedField that = (WithNotAnnotatedField) o; if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) return fals...
3fe999fc-456a-47ce-b238-dc350a9f29f9
5
public static void main(String [] args) { Primes primeGetter = new Primes(); int maxSummands = 0; int j = 1; // for every prime p ... for (long p = primeGetter.getNth(j); p<=MAX_PRIME_VALUE; p = primeGetter.getNth(++j)) { // ... start testing summations at each smaller primes p2 ... int k = 1; for...
b6dd4dab-9ca6-41ac-a0f7-2ada5481d7b6
7
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { // Conditionally select and set the character encoding to be used if (this.ignore || request.getCharacterEncoding() == null) { ...
16298aa0-60ed-4724-b768-58cd7bfd7909
9
@Override public void run() { try { prepare(); } catch (FileNotFoundException e) { logger.fatal(e.getMessage()); return; } catch (InterruptedException e) { return; } String line; ...
ddd48d35-d74d-4ec9-9899-430fbdcb7f6a
1
public void setVisible(boolean visible) { if(window == null) { initialize(); } this.visible = visible; }
ff3fb5ed-86fc-4e4b-bca0-a510aef4d87b
0
public LngLatAlt getCoordinates() { return coordinates; }
58e7e4d2-ea15-4a3d-a88e-a4061e91bb6a
7
private void transformToRegularForm(String option) throws ConfigurationException, ConsoleException, UnrecognizedCommandException, NullValueException { if (!isTheoryModified) return; Command transform = commands.getCommand(Transform.COMMAND_NAME); String opt = "".equals(option.trim()) ? "" : transform.getOptio...
22f9cee8-7863-47ce-86b4-d8ec9b9d2cd4
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...
6532b554-7365-4258-b2b9-784e0d3fedf5
4
public List<Evidence> getEvidenceList(String fileName, String actionType, String teamType) { List<Evidence> evidenceList = new ArrayList<Evidence>(); Element evidenceE; Evidence evidence; ClaimDao claimDao = new ClaimDao(fileName); Claim claim = null; List<Claim> claimAndSubclaimList = claimDao.getClaimAndS...
8b8d2528-e639-41a6-8436-9e328cd84540
0
private void setNameGameWorld(String name) { nameGameWorld = name.substring(name.lastIndexOf(".") + 1, name.indexOf("Loc")); }
541add33-1612-4fef-bcc8-434ecec55471
5
public int immuneCounter(Type primary, Type secondary) { int counter = 0; if (immuneTypes == null || immuneTypes.length ==0) { return 0; } for (int i = 0; i < immuneTypes.length; i++) { if (immuneTypes[i].equalsTo(primary.showType()) || immuneTypes[i].equ...
b72219ac-d246-4cce-80f9-fbd30234e1ed
9
private void unfoldNonRecursiveTails() { // a la mohri nederhof determinization: // every time a nonrecursive tail is used, make a copy for the specific used position. // this can be done before addReduceTransitions Relation<Item, Item> edges = new Relation<Item, Item>(); for (Item i : allItems()) { for...
3e7d340e-a084-4f61-82d3-00d1040e0264
9
protected int transform(JavaMethod javaMethod, List tokens, int i) { if (!javaMethod.getName().equals("initializeClassAttributes")) { return i; } javaMethod.methodBody.remove(i, i+5/*12*/); if (((JavaToken)tokens.get(i)).value.equals("friends")) { int end = javaMethod.methodBody.findClosingCallEnd(i...
434b36a8-7c40-4508-b62d-87a9815a1735
9
private void updateButton(MouseEvent event) { int index = getUI().tabForCoordinate(CloseableTabbedPane.this, event.getX(), event.getY()); if (index != -1 && index != getSelectedIndex()) { if (visibleIndex == index) { return; } setButtonVisible(index, true); if (visibleIndex != index && visi...
8af03a84-5a4f-4246-8b5a-6240820c8bd0
0
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
0e1820fd-c9e7-4aa6-8459-590f48d6f9e5
7
public void computeStabilities(String s) { try { BufferedReader bufferedreader = new BufferedReader(new FileReader(s)); for (int i = 0; i < 10000; i++) { bufferedreader.readLine(); } for (int j = 0; j < 0x3d0900; j++) { String s1 = bufferedreader.readLine(); if (s1 == null) { break; ...
6db7ddcc-9259-43d9-a5e0-4364f3c7cab6
9
private String loadRivers() { if (details) System.out.println("Loading rivers."); File imageFile = new File("output/"+Name+"/overviews/rivers_overview.png"); if (imageFile.exists()) { try { BufferedImage tempImage = ImageIO.read(imageFile); if (tempImage.getWidth() == chunksX * MyzoGEN.DIMENSION_X &...
ef82b0c7-ae33-4f8d-8054-1af132de0e01
2
public String toString() { String res = "[Polygon"; for(int i=0; i<corners.length && i<4; i++) res += " " + corners[i].toString(); return res+"]\n"; }
dba76199-1c60-40ca-b8dc-eead82bf3d04
7
public int action(ArrayList<RObj> objs, int actionBy) { Player plr = (Player) objs.get(0); needIntersect = !needIntersect; if (panel.isEnabled()) { if (plr.getInv() == null) { intersect = true; fireThrough = true; riftIntersect = true; panel.setEnabled(false); panel.setOpaque(false); pl...
935d1a7d-654a-46f4-aa3c-68fe5bb1e586
6
public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); switch (key) { case KeyEvent.VK_UP: action.thrust = 0; break; case KeyEvent.VK_LEFT: action.turn = 0; break; case KeyEvent.VK_RIGHT: ...
0a019a2d-7220-4984-9db6-5b75b8d85559
5
@Override public boolean equals(Object other){ if(other == null){ return false; } else if (this == other) { return true; } else if (!(other instanceof RecipeIngredient)) { return false; } //Numbers in prefix and suffix might be sql doubles...
1bb1411b-797b-4f66-ad8b-f5efddd57193
1
public Iterable<Key> keys() { Queue<Key> queue = new Queue<Key>(); for (Node x = first; x != null; x = x.next) queue.enqueue(x.key); return queue; }
26818d5e-b815-40b3-9152-3ea75ade8cb7
0
@GET @Path("events/{id}/participants") @Produces({MediaType.APPLICATION_JSON }) public List<Participant> getEventParticipants(@PathParam("id")int idEvent){ System.out.println("Return the partcipants list of the event selected by the id"); return JpaTest.eventService.getParticipants(idEvent); }
7fedeae1-2df4-4f06-8b19-af0c18346362
7
public void testInverted() { m_Filter = getFilter("1,2,3,4,5,6"); ((TimeSeriesDelta)m_Filter).setInvertSelection(true); Instances result = useFilter(); // Number of attributes shouldn't change assertEquals(m_Instances.numAttributes(), result.numAttributes()); assertEquals(m_Instances.numInstance...
47a38a9c-390c-4d2e-a554-765b21162e67
6
public void run(){ AudioInputStream stream = null; for (int i = (int) (Math.random() * songs1.size()); i < songs1.size(); i++){ try { // open the audio input stream stream = AudioSystem.getAudioInputStream(songs1.get(i)); format = stream.getFormat(); //...
22d3d21e-9c27-41d8-8efc-3d2d4676300d
4
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final TAdjstkPK other = (TAdjstkPK) obj; if (!Objects.equals(this.transNo, other.transNo)) { return...
d4996924-e9f0-4a1c-8518-9af37ffde3bd
3
@Override public void conversion() { switch (type) { case RZ: codageRZ(); break; case NRZ: codageNRZ(); break; case NRZT: codageNRZT(); break; } }
ff71a7ff-56da-4ed1-a737-11f2947730d0
0
public void setAction(TicketQueryAction value) { this._action = value; }
4c2a66f5-41ee-4846-b2b7-658f1b58efc4
2
public double rawAllResponsesVariance(){ if(!this.dataPreprocessed)this.preprocessData(); if(!this.variancesCalculated)this.meansAndVariances(); return this.rawAllResponsesVariance; }
90a80ee9-6dc2-44a7-808b-ed05569463a8
0
public String getRecommendation() { return recommendation; }
0a9ff227-f2c0-4bed-81a9-6be65a24f68c
8
public float addWeight(int numberSum, int numberDirection) { switch (numberDirection) { case 1: if (numberSum >= 4) return 15; else return (float) 15 / (4 - 1) * numberSum - (float) 15 / (4 - 1); case 2: if (numberSum >= 7) return 15; else return (float) 15 / (7 - 1) * numberSum - (flo...
b4b60707-f937-4c03-bb78-64077ca3252a
3
@Test public void testCadastrarProduto(){ Produto p5 = new Produto(5,"Smartphone Samsung Galaxy Ace Preto, Desbloqueado Vivo, GSM, Android, C‚mera de 5MP, Tela Touchscreen 3.5\", 3G, Wi-Fi, Bluetooth e Cart„o de MemÛria 2GB",3, 499.00f); try { facade.cadastrarProduto(p5); Assert.assertEquals(facade.listarPro...
6cdf58e3-3eb9-4bc0-8210-208b5c5c5735
2
public AffichageUserGui() { initComponents(); setSize(700, 500); setMinimumSize(new Dimension(600, 0)); setMaximumSize(new Dimension(800, Integer.MAX_VALUE)); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(dim.width/2-this.getSize().width/2,...
ec1d71f0-f46e-41b6-8720-da6b493e0648
7
@Override public void addAllMapLast(Map<? extends K, ? extends Collection<? extends V>> map) { for (Map.Entry<? extends K, ? extends Collection<? extends V>> en : map.entrySet()) { addAllLast(en.getKey(), en.getValue()); } }
fa31659d-2f75-4a6c-b8ce-883d5cc39730
2
public void steppedOn(Level level, int xt, int yt, Entity entity) { if (random.nextInt(60) != 0) return; if (level.getData(xt, yt) < 5) return; level.setTile(xt, yt, Tile.dirt, 0); }
2734948d-472c-49e8-8f3b-c148cd454a99
6
public static Stella_Class getIdenticalClass(String classname, String stringifiedsource) { { Surrogate surrogate = Surrogate.lookupSurrogate(classname); Stella_Object oldvalue = ((surrogate != null) ? surrogate.surrogateValue : ((Stella_Object)(null))); if (oldvalue != null) { if (Surrogate.sub...
ef3e46ef-065c-4b12-943c-a8682a4867bc
9
@Override public String toString() { final ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); PrintStream out; try { out = new PrintStream(bos, false, IOUtils.UTF_8); } catch (UnsupportedEncodingException bogus) { throw new RuntimeException(bogus); } out.println(" ...
c7ae8feb-02f3-4c24-abea-6cae979a2510
1
@Override public void update(double delta) { if(linked.getRemoved()) { getEntity().remove(); } }
f2f39df7-dfc6-48e3-bb92-c93ca1e08722
3
public static SensitivityEnumeration fromString(String v) { if (v != null) { for (SensitivityEnumeration c : SensitivityEnumeration.values()) { if (v.equalsIgnoreCase(c.toString())) { return c; } } } throw new IllegalArgumentException(v); }
8a7797cc-0c86-4289-adef-f7e0dbcf2923
3
@Override public ICacheable put(Object key, ICacheable value) { if (key == null || value == null) { throw new NullPointerException("key == null || value == null"); } ICacheable previous = null; synchronized (this) { mPutCount++; mCurrSize += safeSizeOf(key, valu...
bd9b8a8b-9aba-4078-8bce-be2f36861937
3
public void setResourceParameter(int resourceID, double cost) { Resource res = new Resource(); res.resourceId = resourceID; res.costPerSec = cost; res.resourceName = GridSim.getEntityName(resourceID); // add into a list if moving to a new grid resource resList_.add(r...
85836e6f-7d32-4f85-a6ed-4b06f399fc0d
0
public LSystemEnvironment(LSystemInputPane input) { super(null); this.input = input; input.addLSystemInputListener(new LSystemInputListener() { public void lSystemChanged(LSystemInputEvent event) { setDirty(); } }); }
11221e47-b955-43a8-8b20-eb29c6e74346
5
private void askForItemToUse() { UseItemDialog dialog = new UseItemDialog("Choose item to use", 500, 500, objectTron.getActivePlayerInfo().getInventoryItems()); int answer = dialog.show(); if (answer == JOptionPane.OK_OPTION) { int chosenItemIndex = dialog.getChosenItemIndex(); ElementInfo chosenItem = obj...
68d1c717-8fdd-4121-a2ce-a812779a5055
1
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/mensaje.jsp"); EntradaBean oEntradaBean = new EntradaBean(); EntradaParam oEntradaPar...
1f44b490-d467-45a8-9c4a-14197f3cc0dd
9
public synchronized void createTables() throws BoardInitException, SQLException { ResultSet res; String commonSql = null; // Check if common stuff has already been created tableChkStmt.setString(1, "index_counters"); res = tableChkStmt.executeQuery(); try { i...
fdedeb98-3563-4323-a9a1-4b63924de955
5
public Tile getBlockAt(int x, int y) { if (!this.tiles.isEmpty()) { for (int i = 0; i < this.tiles.size(); i++) { if (this.tiles.get(i) != null) { Tile tile = this.tiles.get(i); if (tile.getX() / 48 == x && tile.getY() / 48 == y) return tile; } } } return null; }
74dddbac-06b3-4f5c-8185-c729607ecd76
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ConstructorInfo other = (ConstructorInfo) obj; if (beanClass == null) { if (other.beanClass != null) return false; } else if (!beanClass...
858607b3-869f-483b-99b4-784a30fb9d6b
5
public void drawFields(Graphics2D g) { // WILL EVENTUALLY CHANGE THESE CONSTANT NUMBERS for(int i = 0; i < this.getBoardSize(); i++) { if(i < 7) this.fields.get(i).draw(g, field_size, Color.WHITE); else if(i < 16) this.fields.get(i).dra...
0b57b4d1-7439-4b62-8c6b-73ed3376d51a
3
@Test public void testParseArguments() { Arguments args = new Arguments(); args.setArgument("var1", "Teest1 test2 test3 blah blah blahtest3 blah blah " + "blahtest3 blah blah blahtest3 blah blah " + "blahtest...
2614eb0c-aacf-4814-aba0-6c672012c6c3
3
private String getSelectedButtonName(ButtonGroup bg) { String returnString = ""; boolean isFound = false; Enumeration<AbstractButton> blockButtons = bg.getElements(); while(blockButtons.hasMoreElements() && !isFound) { JToggleButton button ...
3ae6949d-e62f-48b8-bbf4-15b21162d235
7
final void method3677(Canvas canvas) { try { aCanvas7575 = null; anInt7621++; aLong7636 = 0L; if (canvas == null || canvas == aCanvas7626) { aCanvas7575 = aCanvas7626; aLong7636 = aLong7553; } else if (aHashtable7577.containsKey(canvas)) { Long var_long = (Long) aHashtable7577.get(canvas...
50365cf9-1353-448c-b097-e0995d380b1f
2
public static void setDescriptor ( Device dev, byte descriptorClass, byte descriptorType, byte id, int index, byte buf [] ) throws IOException { if (index > 0xffff || buf.length > 0xffff) throw new IllegalArgumentException (); ControlMessage msg = new ControlMessage (); msg.setRequestType ((byte...
b7c89cd7-ede5-4446-af63-400e46e621b2
4
private void parseContributorList(String key) { // Init if (!contributors.containsKey(key)) { contributors.put(key, new ArrayList<String>()); } List<String> list = contributors.get(key); if (config.has(key) && config.get(key).isJsonArray()) { for(JsonElement el: config.get(key).getAsJsonArray()) {...
f6ddf61d-6c0b-483a-9f7e-26aab9ec0091
2
public String numberize(int number) { if (number >= 100) return "" + number; else if (number >= 10) return "0" + number; else return "00" + number; }
ac512ba4-6dba-4c7b-9641-d9d04099d6ad
4
@Override public void render(GameContainer gc, StateBasedGame arg1, Graphics g) throws SlickException { backgroundImage.draw(0, 0); for(Bird bird : birds) { bird.render(gc, g); } for(Obstacle o : obstacles) { o.render(gc, g); } controlledBird.render(gc, g); HashMap<Integer, Boolean> enab...
d932bf46-387b-4fcb-b1b0-a3b2f609ddd4
1
@Override public void startUp(final GameTime gameTime) { // Call the start up methods of any children that previously existed on // the logicalQueue for (ILogical gameComponent : logicalQueue) { gameComponent.startUp(gameTime); } // Also call the start up methods of any children that were queued to be /...
1f8c14c4-220c-498d-a5f8-d8a53be2b646
6
public void paintComponent(Graphics g) { super.paintComponent(g); if ( (OSI == null) || OSI.getWidth() != getWidth() || OSI.getHeight() != getHeight() ) { OSI = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); needsRedraw = true; } if (needsRedraw) { ...
5592b60e-034f-4e4b-b2d7-4d6e1d3f4146
1
Key[] resize(Key[] a, int n) { Key[] b = (Key[]) new Comparable[n]; System.arraycopy(a, 0, b, 0, (a.length < b.length) ? a.length : b.length); return b; }
75d5cc5a-276c-4597-87a7-3fc7b77b35df
5
private String Trans2Syn(String s) { Stack<Character> ts = new Stack<Character>(); for (int i = 0; i < s.length(); ++i) { if (Character.isDigit(s.charAt(i))) { if (ts.size() == 0 || !ts.peek().equals('i')) { ts.push('i'); } } else { ts.push(s.charAt(i)); } } String tmp = "...
5a0b0d0a-520f-4350-b48a-9f5d4515de8d
8
@EventHandler public void handleBlockBreaks(BlockBreakEvent event) { Player player = event.getPlayer(); User user = EdgeCoreAPI.userAPI().getUser(player.getName()); if (user != null) { Cuboid cuboid = Cuboid.getCuboid(player.getLocation()); if (cuboid == null) { if (!WorldManager.get...
800a36d9-5077-4b56-b276-0bf55aaf57fe
9
public static void decrypt(File inputFile, File outputFile) throws IOException { BufferedImage img = ImageIO.read(inputFile); int p1,p2; /** * Step 1: do the stuff */ p1 = img.getRGB(0, 0); p2 = img.getRGB(1, 0); int[] bitsPerChannel = new int[3]; getChannelEncoding(new byte[] { (byte)((p1 >...
8393f434-61f9-4ea8-8cf8-747433354e27
6
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { try { this.commandsManager.execute(command.getName(), args, sender, sender); } catch (CommandPermissionsException e) { sender.sendMessage(ChatColor.RED + "You don't have p...
31f455db-5806-44cb-ac0f-fa106db2e06c
2
public static void main(String[] args) { Digraph G = null; try { G = new Digraph(new In(args[0])); System.out.println(args[0] + "\n" + G); } catch (Exception e) { System.out.println(e); System.exit(1); } System.out.println("Vertex: Component"); StronglyConnectedComponents scc = new Stro...
ad164a56-269c-4d44-ab1d-fcaef53946cf
0
protected boolean isFinished() { return false; }
6a72c167-35d3-4678-a284-1d955316b773
7
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null || obj.getClass() != this.getClass()) { return false; } Admin admin = (Admin) obj; if (admin.getLogin() == login || (login.equals(admin.getLogin())) && admin.getPassword() == password || (password.equals(...
6b1bb3b0-8980-4a93-8c49-ead9911de58e
4
@Test public void depthest02vsdepthest21() { for(int i = 0; i < BIG_INT; i++) { int numPlayers = 2; //assume/require > 1, < 7 Player[] playerList = new Player[numPlayers]; ArrayList<Color> factionList = Faction.allFactions(); playerList[0] = new Player(chooseFaction(factionList), new DepthEstA...
3a857142-ddbe-4980-acc4-973263a16ce4
7
public boolean hasPreviouslyJudged(Judge j, Pair pairToCheck, List<Round> rounds) { for (Round r : rounds) { for (Pair currPair : r.getPairs()) { if (currPair.getAffTeam() == pairToCheck.getAffTeam() || currPair.getAffTeam() == pairToCheck.getNegTeam() || currPair.getNegTeam() == pairToCheck.get...
793b78c1-f05b-4366-840c-3bd29b637f31
4
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Product other = (Product) obj; if (!Objects.equals(this.name, other.name)) { return false; ...
529c2c4e-c401-4018-940b-d682c371bb26
4
public void setActive(boolean active){ if(this.active == false && active == true){ this.status = Status.JOINABLE; } if(this.active == true && active == false){ File fichier_language = new File(OneInTheChamber.instance.getDataFolder() + File.separator + "Language.yml"); FileConfiguration Language = YamlCo...
ab4cdb41-9f41-4e19-a957-02d6d6397994
3
@Override public void update(Object obj) { if(obj.equals("Revived") || obj.equals("Alive")){ recordRevive(); } else if(obj.equals("Dead")){ recordKill(); } }
6c08aa9f-04cc-4979-a586-f956e75b41aa
6
@Override public void run() { File file = new File(tmpFileDestination); if(file.exists()) { File[] files = file.listFiles(); for(int i=0;i<files.length;i++) files[i].delete(); MyLog.logINFO("tmpFile has been cleared..."); } File fil...
c7549b63-89ca-478f-aa1a-58a96e31bf1c
6
public static BasicUser lookUp(String username, char[] password){ BasicUser ret = null; try { Connection conn = DriverManager.getConnection("jdbc:mysql://174.102.54.43/communityhub", "commhubuser", "foobar"); String query = "SELECT password,role FROM user WHERE username='" + username + "';"; S...
00d0fefd-44b1-4527-9fdc-ca88a45674d2
9
protected static FastVector merge(Sequence seq1, Sequence seq2, boolean oneElements, boolean mergeElements) { FastVector mergeResult = new FastVector(); //merge 1-sequences if (oneElements) { Element element1 = (Element) seq1.getElements().firstElement(); Element element2 = (Element) seq2.getEl...
cb4aa3a9-d077-4061-8a76-1ce46b33f109
5
public ArrayList<ArrayList<String>> partition(String s) { ArrayList<ArrayList<String>> rows = new ArrayList<ArrayList<String>>(); ArrayList<String> row = new ArrayList<String>(); int len = s.length(); if (len == 0 || len == 1){ row.add(s); rows.add(row); } Set<String> dict = getPalindromes(s); // ...
988087af-0d16-4fa5-b0ac-43f789c2ba12
4
private void constructAboutPopup() { aboutPane = new JEditorPane("text/html", ABOUT_CONTENTS); aboutPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (EventType.ACTIVATED.equals(e.getEventType())) ...
ff3e43d5-8e5c-4209-89f7-e6cae8ba773e
7
public void checkDragging(int c, int d) { if(Greenfoot.mousePressed(this) && !isGrabbed){ // grab the object isGrabbed = true; wasGrabbed = true; contGoneX = this.getX(); contGoneY = this.getY(); // the rest of this block...
214c2935-48e7-4478-a9f5-e120763cb785
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...
a924d3d6-6a98-401f-b002-a65025a3f912
8
private String mobList(List<MOB> mobList, MOB oldMob, String oldValue) { final StringBuffer list=new StringBuffer(""); if(oldMob==null) oldMob=RoomData.getMOBFromCatalog(oldValue); for (final MOB M2 : mobList) { list.append("<OPTION VALUE=\""+RoomData.getMOBCode(mobList, M2)+"\" "); if((oldMob!=null)&...
e882911c-c822-45a9-b628-ebe262c42798
5
@Override public boolean equals( Object oth ) { if( !(oth instanceof TraceNode) ) return false; TraceNode tn = (TraceNode)oth; return division == tn.division && equalsOrBothNull(material, tn.material) && splitPoint == tn.splitPoint && equalsOrBothNull(subNodeA, tn.subNodeA) && equalsOrBothNull(s...
70c7a570-ac0e-4b38-a32b-55f4d7ce418f
3
public void WGSafeQuit(String sender) { for(Game game : new HashSet<Game>(games.values())) { if(saveGame(game)) { sendMessage(sender, "Game " + game.id + " saved."); } else { sendMessage(sender, MSG_SAVEERROR); } } ...
4afd5d9f-89b5-4155-9651-0eb21934b0da
7
private void calcNormalizedDirection(Point result, int x1, int y1, int x2, int y2) { // Hajo: calculate normalized vector components int dxn = (x1 == x2) ? 0 : (x1 < x2) ? 1 : -1; int dyn = (y1 == y2) ? 0 : (y1 < y2) ? 1 : -1; if(dxn != 0 &&...
d3b41072-7e03-459c-8da4-7d50ab13ad61
2
public HashMap<String, String> constructHashMap(){ int num=255; HashMap<String,String> binaryDecimal = new HashMap<String, String>(); binaryDecimal.put("00000000","0"); StringBuilder remainders ; while(num!=0){ remainders = new StringBuilder(); int temp = ...