method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
b67c75b9-d383-4d22-859c-406dcf8d56f0
3
public void prepare() { int maxSize = -1; for (Number number : numbers) { if (number.getSize() > maxSize) { maxSize = number.getSize(); } } for (Number number : numbers) { number.maxSize = maxSize; } }
734973f9-aa74-4228-8bb1-bf287ed125ed
8
public void performAction(String eventName, Object value) { gv = blackboard.getData(AbstractGraphRenderer.EVENT_KEY); //while resizing the vertex it shouldn't move it //resize // if (b == null || !b) { if (eventName == VertexEvent.EVENT_KEY) { VertexEvent vdd = blackboard.get...
7cd51059-fb40-408c-8545-f9c8a8f3e10a
4
@Override public void input(float delta) { float movAmt = speed * delta; if(Input.getKey(forwardKey)) move(getTransform().getRotation().getForward(), movAmt); if(Input.getKey(backKey)) move(getTransform().getRotation().getForward(), -movAmt); if(Input.getKey(leftKey)) move(getTransform().getRotation...
5be210b7-004f-4f03-8f56-dd9fe0709162
0
public Timer(int granularity) { this.granularity=granularity; }
17753fcc-15ee-4a8a-b9fb-049d5cf9a87d
4
public boolean inRange(int screenWidth,int screenHeight){ //жӵǷĻΧ if(this.x<screenWidth && this.y<screenHeight && this.x>0 && this.y>0 ){ return true; } else{ return false; } }
466600e7-d5a9-4b66-9bf2-a7eaafe202b4
1
public static Class getClass(Object obj) throws NoClassFoundException{ if(obj==null) throw new NoClassFoundException(); return obj.getClass(); }
3c1b49b6-67c6-47e4-a262-1198ab5a35f0
9
@SuppressWarnings("unchecked") public void run(){ /* * Input given to the map function is in the form of line by line. * Splits returned by the inputSplitter is fed to the record reader class. * RecordReader returns line by line data. */ FileRecordReader frr = new FileRecordReader(split); String te...
21ba58a9-3650-4f45-bc3c-99befcce5197
7
public MatchType determineMatch(BiFunction<T, T, Boolean> sameWhen, BiFunction<? super Exception, ? super Exception, Boolean> exceptionsSameWhen) { MatchType matchType; if (bothReturnedValues()) { matchType = valuesMatch(sameW...
55b7e4ff-4b7c-47ad-bfe5-effcf1b111fc
1
public static boolean isCglibProxyClassName(String className) { return (className != null && className.contains(CGLIB_CLASS_SEPARATOR)); }
15b9201c-5846-487a-8f6b-152864dbb26c
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://download.ora...
57593c22-3879-4733-836e-1b0cb4eaf33f
9
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (flavor.equals(DataFlavor.imageFlavor)) { return imageContent; } if (flavor.equals(DataFlavor.stringFlavor)) { return stringContent; } if (flavor.equals(min...
dc8868b8-7a96-4d72-b826-2e093d3fc234
1
@Test public void testLoad() { loader.load(testProgram); Data[] expected = testProgram; Data[] output = loader.getProgramCode(); for (int i = 0; i < testProgram.length; i++) { assertEquals(expected[i].toString(), output[i].toString()); } }
774601c1-488d-488a-8772-0bd8a45e24a0
7
public final FeatureVector next() throws IOException { final String line = reader.readLine(); if (line == null) { return null; } final StringTokenizer tokenizer = new StringTokenizer(line, " \t"); // If there is no label encoder, then just absorb this ...
3962ee58-3b46-440b-bee7-d74c8559c5cf
3
@Override public Pos WhereSet(Bord bord,Pos clickPos) { Pos retPos = new Pos(); //Y軸のループ 上から下へ for (int y = Common.Y_MIN_LEN; y < Common.Y_MAX_LEN; y++) { retPos.setY(y); // X軸のループ 左から右へ for (int x = Common.X_MIN_LEN; x < Common.X_MAX_LEN; x++) { retPos.setX(x); //置けるか判断して、置けるならその座標を返す。 if (...
42c9ec27-4dcf-4211-8980-ccb46a162e45
5
public static File getFolder() { if(folder == null) { String savedPath = getProperty("workFolder"); if(savedPath == null) { String appdata = System.getenv("APPDATA"); if(appdata != null) { folder = new File(appdata, ".blocky"); } else { fo...
210fc84f-f404-4041-a47c-69a58b5bc49e
5
public static void runfile(String filename) { StringBuilder sb = new StringBuilder(); File file = new File(filename); boolean flag = false; String res=null; try { FileInputStream fis=new FileInputStream(file); int c; while((c = fis.read())>=0) { if(c=='$') { res = run(sb.toString())....
4020d649-93f9-4dbe-8c84-a7671ee55565
0
public void setConnexion(Connection connexion) { this.connexion = connexion; }
e5a77e78-b3b4-403e-93a9-ac5d54fdf020
5
public void sendResponse() throws IOException { byte[] bytes = new byte[HTTPSettings.BUFFER_SIZE]; FileInputStream fis = null; String fileName = request.getUri(); try { File file = new File(HTTPSettings.DOC_ROOT, fileName); String contentType = null; Integer statusCode = 0; if(file.exists()...
4f801ffa-cfbd-467f-8458-c49084ab1864
3
protected Subscribers(final PluginManager pm, final String permission) { this.pm = pm; this.permission = permission; final Set<Permissible> permissibles = this.pm.getPermissionSubscriptions(this.permission); for (final Permissible permissible : permissibles) { ...
363b4b90-1f69-40f7-b8d2-d87028fbb63e
6
private final boolean method507(boolean bool) { if (bool != false) method511(-113); anInt986++; if (aClass348_Sub23_Sub1_1008 != null) { if (aClass348_Sub23_Sub2_1001.method2976(-1) && !(method519(126) > aClass348_Sub23_Sub2_1001.method2980((byte) 100))) return false; return true; } doubl...
c1a7e483-3ea6-4b70-9ec9-7f7927c1ed10
0
public void setAssignee(String assignee) { this.assignee = assignee; }
acb8d427-db6b-4441-8eba-204f3393452d
0
public ProgressDialog() { super(false, false, true, INITIAL_WIDTH, INITIAL_HEIGHT, MINIMUM_WIDTH, MINIMUM_HEIGHT); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { setCa...
693b2913-6570-419c-b565-6ac8a631f67b
3
public void uninit() { if ( sshSession != null ) { scpLog.logToConsole( "Closing SSH session...", LogCollector.INFO ); sshSession.close( false ); sshSession = null; } if ( sshConnection != null ) { scpLog.logToConsole( "Closing SSH connection...", LogCollector.INFO ); sshConnection.cancel(); ...
c8322596-7e4b-4f70-a9f1-17c928364cd7
2
@Override public void run() { Player player = Bukkit.getPlayer(playerName); if (player == null) { return; } player.setSleepingIgnored(false); BukkitTask task = plugin.getIgnoreSleepTasks().get(playerName); if (task != null) { task.cancel(); ...
1fbf17a3-d6dd-4438-93ec-e24d43f22fd2
5
public boolean dealerHits(Dealer dealer, Player player) { if (dealer == null || player == null) { return false; } int wins = 0; for (int i = 0; i < player.numberOfHands(); ++i) { if (wins(dealer.getActiveHand(), player.getActiveHand())) { ++wins; ...
4e6c2b75-9532-4647-b8f3-d28b8d0716ef
3
public void setHexp(PHexp node) { if(this._hexp_ != null) { this._hexp_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); }...
8bd41e9c-2452-4ed2-a653-59fd2e46bb83
1
public ReturnObject head() { ReturnObjectImpl output = new ReturnObjectImpl(); if (isEmpty()) { output.value = ErrorMessage.EMPTY_STRUCTURE; } else { output.value = array[0]; } return output; }
759fffec-e95f-4709-8c30-8b83dbc261ab
7
public void keyPressed(KeyEvent e) { chac.keyPressed(e); if(e.getKeyCode() == KeyEvent.VK_SHIFT) frozen = true; if(e.getKeyCode() == KeyEvent.VK_Q){ //If shift is held, switch universes if(frozen) { universe = 1 - universe; ...
2ecbbb74-ce7e-49a7-8b54-1d3d06570ab5
8
public Assassin() { super(); username="an assassin"; setDescription("He`s all dressed in black, and has eyes as cold as ice."); setDisplayText("An assassin stands here."); final Race R=CMClass.getRace("Human"); if(R!=null) { baseCharStats().setMyRace(R); R.startRacing(this,false); } baseCharSta...
dfdc7134-738e-47b3-866f-38e7d33c1b81
6
@EventHandler public void PigZombieRegeneration(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.getPigZombieConfig().getDouble("Pig...
f65590c1-9f5e-455c-8684-2961d8f0b002
3
@Override public void doAction(Player player, Grid grid) throws InvalidActionException { if (player.getRemainingTurns() <= 0) throw new InvalidActionException("The player has no turns left!"); Position currentPos = player.getPosition(); Position newPos = new Position(currentPos.getxCoordinate() + 1, curren...
2fd43339-47dd-46b2-b2ea-cdbbdc380252
0
public void someOtherMethod() {}
f32627ff-de48-4573-a8fd-c8a0fcee1bc4
3
public List<ValueType> getSortedList() { ListElement<ValueType> current = currentList.getHead(); while (current.getNext() != null) { ListElement<ValueType> help = currentList.getHead(); while (help.getNext() != null) { if (compareTool.firstBigger(help, help.getNex...
1460d2dc-6c83-4e77-a6da-dd49e3e262db
4
protected void rightRotate(TreeNode<K, D> nd) { TreeNode<K, D> nd2 = nd.left; if (isNil(nd2)) { return; // do nothing } //turn nd2's right subtree into nd's left subtree nd.left = nd2.right; if (!isNil(nd2.right)) { nd2.right.parent = nd; }...
d68372a6-03c6-46dd-a514-a4274fcdcd6b
8
private void scriptOpen(final String command) { String path = ""; String name; int i; int tabIndex = 0; String title; final int startIndex = command.indexOf("{"); final int endIndex = command.lastIndexOf("}"); if (startIndex == -1 || endIndex == -1 || startIndex == endIndex) { System.out.println("in...
7adbec82-2445-429c-b941-b15e64a20761
9
public void run() { while(true) { System.out.println("Running"); if(gui.connected) { System.out.println("Connected"); try { int o = Integer.parseInt((String)inFromServer.readObject()); switch(o){ case 3: { // Broadcast gui.update((String)inFromServer.readObject()); break; ...
0dd13b7b-4929-48f6-aa58-6ff02e29552e
2
* * @throws UnknownHostException if cyc server host not found on the network * @throws IOException if a data communication error occurs * @throws CycApiException if the api request results in a cyc server error */ public CycConstant getConstantByGuid(Guid guid) throws UnknownHostException, IOExc...
bc39dbe5-ad46-40b7-bca5-b74beaddca5e
7
void radb4(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { final float sqrt2 = 1.41421356237309514547462185873882845f; int i, ic; float ci2, ci3, ci4, cr2, cr3, cr4; float ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4, w...
59e705bf-0110-4c5b-816d-a73175771f81
6
public void display_result2infoTable(Vector array_result) { int index_found; Vector update_info_sp = new Vector(); search_list.removeAllElements(); //clear_table(dm_info_SP); int old_result_count = dm_info_SP.getRowCount(); for(int i = old_result_count - 1; i...
f4ee6297-c583-48ff-98d7-e3f23ef7170d
4
public String cmd(List<String> configs, List<List<String>> cfgParams, List<String> params) { if (null == this.handler) { throw new LackOfHandlerException(); } if (configs.size() != cfgParams.size()) { throw new LackOfParamsException(); } int index = 0; for (String cfg : configs) { Config config...
a30b9056-66ce-456f-8029-51dc02f73559
5
@Override public boolean equals(Object o) { if(o == null) return false; else if (o == this) return true; else if (o instanceof OfertaRecursos){ OfertaRecursos ofertaRecursos = (OfertaRecursos) o; return this.id == ofertaRecursos.id ...
146d6dbc-e6b0-40ce-bc02-2f1deb6fcfcc
8
public static void main(String[] args){ int minTO = 50; int maxTO = 1500; int timeoutCnt = 10000; int trials = 10; boolean sleep = false; long sleepTime = 50; MinContainer<Timeout> c = new MinContainer<>(); Timeout[] timeouts = new Timeout[timeoutCnt]; ...
8974a5cf-eefa-4f91-96d5-a8bc00d817e5
1
@Override public synchronized void sampleOccurred(SampleEvent sampleEvent) { if (SamplesUploader.isRunning()) { JSONObject sample = Utils.getJSONObject(sampleEvent); SamplesUploader.addSample(sample); } }
e4d84845-dbbe-4e08-bb3d-fb227232d6d1
6
public static boolean isAnagram(String a, String b){ if(a.length() != b.length()) return false; Map<String, Integer> map = new HashMap<String, Integer>();; for(int i=0; i<b.length(); i++){ if(map.containsKey(b.charAt(i))) map.get(b.charAt(i)); else{ char[] cArr = new char[1]; cArr[0] = ...
4451ba60-5a74-458a-b11f-c4fad95f66ab
2
public void paint(Graphics g) { Dimension size = getSize(); g.setColor(SystemColor.controlShadow); int y = (size.height / 2) - (thickness / 2); while (y < (size.height / 2)) { g.drawLine(0, y, size.width, y); ++y; } g.setColor(SystemColor.controlLtHighlight); y = size.height / 2; while (y < ((siz...
fffb75eb-cbb9-4efa-8ba9-b4943ac5b5e0
9
public void generate() { map = new HeightMap(CHUNK_SIZE*4); map.simplexF = 0.4f; map.simplexF2 = 0.4f; map.perturbF = 0.0f; map.perturbD = 0.0f; map.erodeLayers = 20; map.erodeF = 0.05f; map.smoothenLayers = 5; map.generate(x,z);...
3abd2fb8-ec3e-4a1f-9858-a60ad8199809
7
@Override public String compress(String source) { StringWriter writer = new StringWriter(); //prepare source List<JSSourceFile> input = new ArrayList<JSSourceFile>(); input.add(JSSourceFile.fromCode("source.js", source)); //prepare externs List<JSSourceFile> externsList = new ArrayList<JSSourceFil...
e5fe7f28-8e8f-4a30-8bef-ca6df5897a06
2
public static void main(String[] args) { try { f(); } catch (MyException e) { e.printStackTrace(); } try { g(); } catch (MyException e) { e.printStackTrace(System.out); } }
07c555ad-57bd-4f01-9826-69aa069eb710
3
private int hexToInt(String hex) { int total = 0; for (int i = 0; i < hex.length(); i++) { char c = hex.charAt(i); if (c >= '0' && c <= '9') total = total * 16 + c - '0'; else total = total * 16 + c - 'a' + 10; } return total; }
e194ce02-93c0-4705-8dd7-2f290cdee54a
2
public static void zmq_close(SocketBase s_) { if (s_ == null || !s_.check_tag ()) { throw new IllegalStateException(); } s_.close (); }
bab529c8-c06c-4eba-aa3d-469a6739004e
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://download.oracle.com/javase/t...
5439c004-6f9d-41bf-a762-66366fd64802
8
@Override public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { boolean stateModified = false; if (entity instanceof Auditable) { for (int i=0; i<propertyNames.length; i++) { if ("created".equals(propertyNames[i])) { if (state[i] == null) { ...
b58f40b2-72dc-4338-88e8-80815c46f542
6
private void BIC(int cluster, int size, double[] data, double[] trans, double[] mean, double[] var, double[] weight, File resFile) {//BICo try { File biclogFile = new File(resFile.getParentFile(), biclogFileName); OutputStreamWriter biclogOsw = new OutputStreamWriter(new FileOutputStream(biclogFile, true)); ...
0b447283-a89f-4893-842f-c5241527905b
9
public static void main(String [] args) throws Throwable { if (args.length < 2) { usage(); return; } Class stemClass = Class.forName("snowballstemmer.ext." + args[0] + "Stemmer"); SnowballStemmer stemmer = (SnowballStemmer) stemClass.newInstance(); Reader reader; reade...
91f7c3a5-ccee-4e85-87b8-5d5cbd8de4ca
4
public JPopupMenu makeMethodMenu(T occupant, Location loc) { this.occupant = occupant; this.currentLocation = loc; JPopupMenu menu = new JPopupMenu(); Method[] methods = getMethods(); Class oldDcl = null; for (int i = 0; i < methods.length; i++) { ...
6424473e-712a-4966-8370-cbfa3eed52ec
5
public void wyslijWiadomosc(String _wiadomosc, String _typWiadomosci) { try { out = new PrintWriter(sock.getOutputStream()); } catch (IOException e) {System.out.println("Błąd WysWiad: "+e.getMessage()); } ...
0d56579a-427b-499c-94c1-31d694880e80
6
public static void main(String[] args) { Scanner scan = new Scanner(System.in); int K = scan.nextInt(); for(int k=0;k<K;k++){ int N = scan.nextInt(); int NA = scan.nextInt(); int NB = scan.nextInt(); int[] A = new int[NA]; int[] B = new int[NB]; for(int i=0;i<NA;i++) A[i] = scan.nextInt(); ...
e956e280-864d-460e-811a-755352dd51eb
6
private String buildIdentity() { StringBuffer builder = new StringBuffer(); if (!StringUtils.isBlank(this.protocol)) { builder.append(protocol); builder.append("://"); } if (!StringUtils.isBlank(this.username)) { builder.append(this.username); if (!StringUtils.isBlank(this.password)) { builder.a...
1d7f8896-acfe-4185-92f3-9c1a9fd7b032
7
public static boolean functionWithDefinedValueP(Proposition proposition) { if (!(proposition.kind == Logic.KWD_FUNCTION)) { return (false); } { Stella_Object lastargument = proposition.arguments.last(); boolean resultP = Logic.testPropertyP(Logic.getDescription(((Surrogate)(proposition.operator)...
ec7a251e-1d7d-408f-bfab-94599289a25e
6
static public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextCol...
75ae2b59-d1d0-4738-bcc7-cf41e052645c
5
public void recevoir (Information <Boolean> information) { informationRecue = information; if (information.iemeElement(0) instanceof Boolean) { int nbElements = information.nbElements(); boolean [] table = new boolean[nbElements]; for (int i = 0; i < nbElements; i+...
af8ab3a5-4f58-40c6-97b0-2f2dca9cef93
4
@Override public void write( Writer writer ) throws IOException { writer.write( "{" ); Iterator<Map.Entry<String,JSONValue>> iter = this.map.entrySet().iterator(); int i = 0; while( iter.hasNext() ) { if( i > 0 ) writer.write( "," ); writer.write( " " ); Map.Entry<String,JSONValue> en...
348a15c1-6c61-4896-83d0-96a42a385223
0
public PitchHandler(boolean down) { this.down = down; }
b0c5dbc3-9907-4cbe-9118-d5d025221648
7
private void tweet(String msg) { msg = CMStrings.scrunchWord(CMStrings.removeColors(msg), 140); try { Class<?> cbClass = Class.forName("twitter4j.conf.ConfigurationBuilder"); Object cbObj = cbClass.newInstance(); Method cbM1=cbClass.getMethod("setOAuthConsumerKey", String.class); cbM1.invoke(cbObj,CM...
9e5c4986-ac21-4140-8e55-383463ada6b5
2
private void llenarMatrizVacio(){ for(int fila=0;fila<TAMANO;fila++) { for(int columna=0;columna<TAMANO;columna++) { // crea el campo vacio en la matriz this.matriz[fila][columna] = new EspacioVacio(this.refContenedor); // coloca el...
b5a310e2-0f99-436b-a71d-52b7543af446
8
@Override public boolean equals(Object object) { if (object == this) { return true; } if (!(object instanceof HugeIntLongArrayMap)) { return false; } HugeIntLongArrayMap other = (HugeIntLongArrayMap) object; if (size() != other.size()) { return false; } IntIterator keySet = keySet(); ...
57f3d1f5-1be1-4893-94b2-90517bd9da2d
7
@Override public Object execute(Object obj, Object[] args) { Method[] getterMethods = definition.getGetterMethods(); Integer[] parameterIndexes = definition.getParameterIndexes(); RowMapper<?> rowMapper = definition.getRowMapper(); int fetchSize = definition.getFetchSize(); // 获取实际用于执行的preparedSQL String a...
5ce463bc-7749-4ee4-b8b8-5d37bda1b9da
1
@Deprecated public void renderBackground(){ for (GameObject gameObject : backgroundTiles) { gameObject.render(); } }
145767bb-0050-4de2-b232-1d33497cb2d2
4
public static void main(String args[]) { /*Create and Initialize array of Object */ for(int i1=0; i1<TrainingDataSize; i1++) { TrainingData2[i1]= new ArrayBuff(); } for(int i1=0; i1< TestingDataSize; i1++) { TestingData2[i1]= new ArrayBuff(); ...
5359c7bd-1d0a-47e3-a282-b468e1cfb282
1
private void jjAddStates(int start, int end) { do { jjstateSet[jjnewStateCnt++] = jjnextStates[start]; } while (start++ != end); }
4c3128d3-41b3-43c1-b9bc-e22fbae888ed
2
public boolean equals(Object o) { Card other = (Card) o; if (compareTo(other) == 0 && other.suit == suit) { return true; } return false; }
e5b1ec77-0d8f-4435-9a45-0676f29ab2fc
1
public String isAllRowDataValid(List<Row> rows) { StringBuffer errorMessage = new StringBuffer(); for (Row row : rows) { String message = isRowDataValid(row); errorMessage.append(message); errorMessage.append("<br>"); } return errorMessage.substring(0, errorMessage.length() - 1); }
fe7ca82d-66f3-46f1-b0bd-97a35a7dc1eb
8
@Override protected synchronized Class<?> loadClass(String sClassName, boolean bResolve) throws ClassNotFoundException { log("Loading: %s (resolve=%b)", sClassName, bResolve); Class<?> c = null; try { // Step 1. Load from JAR. if (isLaunchedFromJar()) { ...
55d08330-d591-45da-9bcf-def568c4eb1e
7
public boolean removeSign(Location signLoc){ for(int i=1;signConfig.get("signs." + i)!=null;i++){ if(signConfig.get("signs." + i + ".DoorID")!=null){ if(signLoc.getWorld().getName().equals(signConfig.getString("signs." + i + ".location.world"))){ if(signLoc.getBlockX()==signConfig.getInt("signs." + i...
bcef4bfe-1627-41c3-98af-3720a4a8d4dd
7
@Test public void testParseCommandLine() { Train train = new Train(); for (SolverType solver : SolverType.values()) { train.parse_command_line(new String[] {"-B", "5.3", "-s", "" + solver.getId(), "-p", "0.01", "model-filename"}); Parameter param = train.getParameter(); ...
56c81441-061b-4151-a260-18130c74cffd
6
public CustomCanvas() { super("Custom Canvas"); // Demonstrates the use of a Swing component for rendering vertices. // Note: Use the heavyweight feature to allow for event handling in // the Swing component that is used for rendering the vertex. mxGraph graph = new mxGraph() { @Override public voi...
162c4ff0-d63c-41f1-b91b-648f4a2d1cad
4
public static int Cardinality(Object obj, Collection coll){ if(coll == null){ throw new NullPointerException(); } if(obj == null){ throw new NullPointerException(); } for(Object o : coll){ if(o.equals(obj)){ total++; } } return total; }
55589d04-421c-41aa-bd65-9db9ed90e0ad
9
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] params) { if (cmd.getLabel().equals("rewards")) { if (params.length < 1) { cs.sendMessage(ChatColor.GOLD + cmd.getUsage()); } else ...
57e6fd3d-ed26-4b8d-b9cf-6a4cb6e1182d
8
int getNumCellsInRow(int row) { if (row < 0) { return 0; } if (row == 0) { return 1; } if (row <= n) { return 6 * row; } if (row <= 2 * n) { return 3 * n + 3 * row; } if (row <= 3 * n) { r...
131a63de-2ba9-463e-a5fa-062eed132f27
4
public void lue() { ObjectInputStream input = null; try { input = new ObjectInputStream(new FileInputStream(new File(henkilonTiedot))); henkilot = (ArrayList<Henkilo>) input.readObject(); } catch (IOException ex) { Sy...
775f4f30-cb17-49fe-8c33-6c6f0a856961
4
public String toString(){ String str=""; String tab = " "; str += "ENTITY " + name + " IS"; if (generics.size() > 0){ str += tab + "\nGENERIC ("; Generic gen; for(int i=0;i<generics.size();i++){ gen = (Generic) generics.get(i); str += "\n" + tab + gen.toString()+";"; } str = str.su...
1a0823db-1ac7-4737-91bb-f820c2079543
5
public static String ZvoX(String x){ StringBuilder tmp=new StringBuilder(); boolean in=false; for(int i=0;i<x.length();i++){ char a=x.charAt(i); if(in){//ako e vlezeno vo "" if(a=='"'){ in=false; } if(a=...
b801e4af-48dd-4418-8059-4b4a3a22577a
6
private static void runString(Environment env, String sourceText, TurtleGraphics t) { try { LList code = Parser.parse(sourceText); Interpreter.init(code, env); while(true) { // execute until the interpreter is paused if (!Interpreter.runUntil(env)) { return; } // update the display until ani...
b25d986c-dd04-4b45-8491-b2d3f66462ab
1
public synchronized boolean cancel() { if (mWasExecuted) { return false; } mWasCancelled = true; return true; }
08b9edf5-9953-4db0-b0a1-f84cf5495109
3
public void renderWidthInvisColor(int xp, int yp, Sprite sprite, int color) { int w = sprite.getWidth(); int h = sprite.getHeight(); yp = this.height - yp; yp -= h; for (int y = 0; y < w; y++) { for (int x = 0; x < h; x++) { int col = sprite.getPixel(x + y * w); if (color != col) paintPixel(x ...
6d35d75f-a1f8-4a4e-9f26-632e59255b19
1
public JPanel getLoadingstatusChangesMenu() { if (!isInitialized()) { IllegalStateException e = new IllegalStateException("Call init first!"); throw e; } return this.loadingstatusPanel; }
96757c0c-29c6-432e-882a-3c82d15e01a1
1
private void baudComboBox_itemStateChanged(ItemEvent event) { if (serialPort != null) { setSerialPortParams(); } }
425392c2-c767-4a7c-bf1a-f24a7057ef34
2
@Override public void maritimeTrade(IPresenter presenter, int ratio, ResourceType inputResource, ResourceType outputResource) { MoveResponse response = presenter.getProxy().maritimeTrade(presenter.getPlayerInfo().getIndex(), ratio, inputResource, outputResource, presenter.getCookie()); if(response != null && re...
8db9a774-08ba-4715-b44b-1d0edae0182b
5
public void populateMovies() throws IOException { //Get search paths for movies model.getMovies().removeAllMovies(); MoviePathSearcher mps = new MoviePathSearcher(model); File[] roots = File.listRoots(); for (File r : roots) { Path p = Paths.get(r.getAbsolutePath()); EnumSet<FileVisitOption> opts = Enum...
e10ecb58-40b4-465f-bf80-b34714829e4a
7
public static String expand(String str, Configuration variables, FacetList fl) { if (variables == null || str == null) return str; String res = str; Pattern pattern = Pattern.compile("\\$\\{([^\\}]*)\\}"); for (;;) { Matcher m = pattern.matcher(res); if (!m.find()) break; String varNam...
373a44a6-7e0e-4050-811d-66b693bfda26
1
public void createComponents(boolean pipelined) { memory = new MemoryModule(); mbr = new MBR(); controlLine = new ControlLineImpl(mbr); controlLine.registerMemoryModule(memory); systemBusController = new SystemBusController(controlLine); memory.registerBusController(systemBusController); i...
683e24a5-c06f-478a-a048-5f7cd5d87a12
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 fe...
a316f559-4ba2-400b-b2ad-36b6444893d8
4
public DoublePair resolveCollisions(double amtX, double amtY) { final DoublePair amts = new DoublePair(amtX, amtY); ColliderComponent c = (ColliderComponent) getEntity().getComponent( ColliderComponent.ID); if (c == null) { return amts; } final AABB collider = c.getAABB(); final AABB collisionRange =...
3d818cab-b6cd-4afa-9406-34b30df9d835
8
public int compare(Integer i, Integer j) { List<String> tokens = mTokenization.tokenList(); for (int m = i, n = j, k = 0; k < mMaxSuffixLength; ++m, ++n, ++k) { if (m == tokens.size() || tokens.get(m).equals(mDocumentBoundaryToken)) { if (n == tokens.size() ||...
f798f5c4-000f-4b2d-ac04-43103a27bb26
2
public Texture getTextureByID(int ID) { for(int i = 0; i < textures.size(); i++) { if(textures.get(i).getTextureID() == ID) { return textures.get(i).getTexture(); } } return null; }
47a8eb5a-5aa7-4bc5-ac07-d8082364cbce
2
public void testGetField_int() { LocalTime test = new LocalTime(10, 20, 30, 40, COPTIC_UTC); assertSame(COPTIC_UTC.hourOfDay(), test.getField(0)); assertSame(COPTIC_UTC.minuteOfHour(), test.getField(1)); assertSame(COPTIC_UTC.secondOfMinute(), test.getField(2)); assertSame(COPTIC...
cb8967ae-c4d4-439d-b175-4fd001aaf51b
6
@Test public void cardUniquenessTwo(){ boolean unique = true; for(Player p: myGame.getPlayers()) for(Card c: p.getMyCards()) for(Player q: myGame.getPlayers()){ if(!(p.equals(q))) for(Card f: q.getMyCards()) ...
14bcabda-568a-47e7-a540-3515983c7d4c
2
@Override public void run() { //Parse json object JSONParser parser = new JSONParser(); try { JSONObject obj = (JSONObject) parser.parse(json.trim()); this.log.info(obj.toString()); commands.execute(obj, pm); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackT...
4aeb6da4-f716-4de9-99ce-1e9e6bd16227
8
public ArrayList<Case> determinerPersonnageDansUneZoneSpherique( Personnage lanceur, Position posDepart, int portee) { int calculDeplacement = 0; calculDeplacement = Math.abs(posDepart.obtenirX() - this.retournerPositionPersonnageEnX(lanceur)); calculDeplacement += Math.abs(posDepart.obtenirY() - this...
6a732478-9756-4303-a728-ee2f219cd04c
5
private boolean jj_3R_66() { Token xsp; xsp = jj_scanpos; if (jj_3_46()) { jj_scanpos = xsp; if (jj_3_47()) { jj_scanpos = xsp; if (jj_3_48()) { jj_scanpos = xsp; if (jj_3_49()) { jj_scanpos = xsp; if (jj_3_50()) return true; } } } } return false; }