method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
f105c8d2-8f03-4388-81ed-e8dbaa23ded8
7
public void init(int num, int x,int y, int amplitude){ if (amplitude < 3 || amplitude > 11){ throw new PreConditionError("Amplitude non autorisée lors de la création de la bombe"); } checkInvariants(); super.init(num, x, y, amplitude); checkInvariants(); if (super.getNumero() != num){ throw new PostCo...
468f7172-69a6-42c7-ab48-568f8b6bed18
6
public void actionPerformed(ActionEvent e) { String source = ((AbstractButton)e.getSource()).getText(); //Recupere le nom du bouton source. TradePanel TP = null; if(source == "Echange"){ TP = new TradePanel(model); //Pour le bouton construire } else if (source == "Construire") { nbChoiceAllow = 3; (...
817b501c-382f-4876-bebc-ceef74932d30
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ArraySelectorNode other = (ArraySelectorNode) obj; if (selector == null) { ...
5c38c834-b6d7-4a6d-b1cc-26e94a6fb5ed
3
public TopicObj getById(int topicId) { TopicObj item = null; String sql = "select * from Topic where topic_id = ?"; try { connect(); PreparedStatement pre = con.prepareStatement(sql); pre.setInt(1, topicId); ResultSet rs = pre.executeQuery(); ...
b119a1a6-baf7-4d94-bb51-cea0798e2062
3
public Decimal round(Double factor, int scale, RoundingMethod roundingMethod) { switch (roundingMethod) { case DOWN: return roundDown(factor, scale); case UP: return roundUp(factor, scale); case HALF_UP: return roundHalfUp(factor, scale); default: break; } return null; }
7eb04381-3b14-420d-84b0-6acd2d606b24
6
public void cargarArbol() { //inicializo el arbol inicializarArbol(); //cargo las cuentas hijo r_con.Connection(); int count = 0; int aux = 0; Enumeration e = root1.breadthFirstEnumeration(); while (e.hasMoreElements()) { par...
9e243afc-e7f6-41c6-b845-8a4d74b3f791
4
public static String classifyFromModel(ArrayList<Word> model, ArrayList<String> email) { boolean ham; //ham is hypothesis, p = 0.5 since training sets of equal size were used double probHam = Math.log10(0.5); double probSpam = Math.log10(0.5); for (String word : email) { for (Word check : model) { ...
68593657-9abe-4c4c-a3cc-460c612bde5c
6
@Override public Collection<IGameMap> provide(final File file) throws FileNotFoundException, IOException { if (!file.exists()) throw new FileNotFoundException(file.getAbsolutePath() + " does not exist."); Collection<File> filesToRead = new ArrayList<File>(1); if (!file.isDirectory()) { if (!...
6b164108-b7f0-401b-a3ce-a87342d661d6
0
void setAccelaration(SimpleVector acceleration) { this.acceleration = acceleration; }
359ff3e7-e152-4457-9874-8484bed68627
1
private void next() throws JSONException { // aktualisieren info(0); // könnte man würfeln? if (lastChar.getString("cont").equals("rollthedice")) { return; } // weiter info(1); }
a9d6acb7-0b99-434f-bb49-0e3b67af99a7
5
private static int[] randomEdgeLoc(int size) { int r, c; Random rand = new Random(); int num = rand.nextInt(2); if (num == 0) { //random vertical edge coordinate r = rand.nextInt(size - 3) + 1; while (r % 2 == 0) r = rand.nextInt(size - 3) + 1;// somewhere b/t row(1) to row(size-2) c = rand.nextIn...
fdc9e158-59be-40e6-a37a-7e479559fdfb
6
@EventHandler public void onServerListPing(ServerListPingEvent event) { if (!HyperPVP.isCycling()) { int minutes = HyperPVP.getTime(); int left = HyperPVP.getMinutesLeft(); int third = minutes / 3; int one = minutes; int two = minutes - third; int three = minutes - third - third; ChatColor ...
fce1f347-5485-4676-a43d-9bd1d63bfc65
7
public TimeView(final TimeCont control) { // control.setShowSec(false); control.count(); setResizable(false); setUndecorated(true); setAlwaysOnTop(true); setContentPane(new JPanel()); getContentPane().setBackground(Color.BLACK); lblTime = new JLabel("00:00:00"); lblTime.setFont(new Font("Courier", F...
9e200786-1369-4c75-b302-ada6e069fbf3
5
protected void createSource() throws JavaLayerException { Throwable t = null; try { Line line = AudioSystem.getLine(getSourceLineInfo()); if (line instanceof SourceDataLine) { source = (SourceDataLine)line; //source.open(fmt, milliseconds...
e5fd43d3-fc06-4848-8b88-3f8146206a4a
3
private void valitseOikeaTapahtumaKunOkNappiaPainetaan(){ if (ok.getText().equals("Seuraava")){ kertauspaneeli.naytaSeuraava(); } else if (ok.getText().equals("Valitse kerrattavat")){ kertauspaneeli.tallennaOsaamistasonTunniste(); kertauspaneeli.haeKerrattavat(); ...
83b0f2d3-5f4e-4c57-ba30-f69d57ca1cba
8
public double minct() { sortClass(); calculateWeight(); dmMinminCost = new double[iSite][iCPUMaxNum]; dmMinminTime = new double[iSite][iCPUMaxNum]; double[] daMinminTimeBySite = new double[iSite]; boolean lastActivity; // find the current fastest site for the acitvities. while (getRestLength() > 0) { ...
1e322323-f74a-4d4c-862b-133ae7ab3742
7
public static void fireFirstDeclaredCause(Throwable t, Class... declaredTypes) { Throwable cause = t; while (cause != null) { cause = cause.getCause(); if (cause == null) { break; } if (declaredTypes != null) { for (Class de...
bbc8cfae-d51f-48d5-abc1-9b7b171b0d19
6
private void behaviour(){ if(playerState == 0){ //like the defender and goalie behaviour, turns to face the ball in place turnTowardBall(); //the the player moves to intercept the ball if the ball gets to a certain distance away from the player if(distanceBall <= ...
34808258-b60a-47d7-8cad-e059fe18b8ab
3
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D)g; g2d.setColor(Color.white); g2d.setFont(new Font("Ariel", Font.PLAIN, 20)); if (!gameStarted){ g2d.drawString("Press Space to Jump", 100, 100); } //g2d.rotate(Math.t...
3241a74d-ece9-45b6-8bdb-9790c9fac221
6
void onKeyPress(int key, int scancode, int action, int mods) { switch(action) { case GLFW_PRESS: for(KeyDownEvent e : _keyDown) { e.run(key, mods, false, scancode); } break; case GLFW_REPEAT: for(KeyDownEvent e : _keyDown) { e.run(key, mods, true, scancode); } break; ...
2d38e82a-4f46-499d-a20c-54834a5bfeeb
1
private void notifyOfUndoWillHappen() { for (OutlineModelListener listener : getCurrentListeners()) { listener.undoWillHappen(this); } }
89018d14-d16b-490d-89aa-03f7e67582d3
8
public /*@non_null pure@*/ String toString() { if (m_RangeStrings.size() == 0) { return "Empty"; } String result ="Strings: "; Enumeration enu = m_RangeStrings.elements(); while (enu.hasMoreElements()) { result += (String)enu.nextElement() + " "; } result += "\n"; result +=...
c69ec6a5-90a1-4d3f-94f7-3ace9dc006b8
5
public boolean matchIgnoreCase(String s) { int lc = low.compareToIgnoreCase(s); if (high != null) { int hc = high.compareToIgnoreCase(s); return (lc * hc < 0 || (low.closed && lc == 0) || (high.closed && hc == 0)); } else { return lc == 0; } }
38336770-c017-4292-8290-93c99b189d37
4
private static void extract(ZipInputStream in, String destinationPath) throws IOException { ZipEntry zipEntry = in.getNextEntry(); while (zipEntry != null) { String entryName = zipEntry.getName(); File newFile = new File(entryName); String directory = newFile.getParent(); if (directory == null) {...
aa2cd972-d571-4dbb-b054-1344aa04eb02
6
private void checkGameOver(IGameState gameState, HumanEntity player){ if(gameState.isGameOver() && player instanceof Player){ ((Player) player).sendMessage(ChatColor.RED + config.getPhrase("game-over")); //Check for new highscore Entry<String, Long>[] hs = highscores.getSorted(); //Is the current score a ...
cb0d4689-6d44-40db-8393-4d4ac6ea51bb
2
public GroundDecoration getGroundDecoration(int y, int x, int z) { GroundTile groundTile = groundTiles[z][x][y]; if (groundTile == null || groundTile.groundDecoration == null) { return null; } else { return groundTile.groundDecoration; } }
dfccbe1e-106b-4ec0-a24d-662aa5c96919
4
public static void reverse(int[] arr, int from, int to){ int iters=0; if(from>to){ iters=((arr.length-from)+to+1)/2; } else { iters=(to-from+1)/2; } while(iters>0/*to!=from && to+1!=from && (to==0&&from==arr.length-1)*/){ swap(arr,from,to); iters--; if(++from>=arr.length){ from=0; } if(--...
768c2e5f-f0ec-4967-b3df-94701a56d18c
6
static List parse(Element root, Channel channel, boolean updateChannel) throws java.net.MalformedURLException { LinkedList itemList = new LinkedList(); // Now look for the channel nodes within this file. NodeList nodes = root.getChildNodes(); int numNodes = nodes.getLength();...
598f8241-d169-48da-8f3e-ae202aad35ae
1
public String getFieldName(Field field){ String fieldName; if (field.isAnnotationPresent(SetFieldName.class)) { fieldName = field.getAnnotation(SetFieldName.class).name(); } else { fieldName = field.getName(); } return fieldName; }
1481fdb0-e366-43a5-b775-c87d2f9672aa
8
protected void writeSuiteSummary() { int totalPassedTests = 0; int totalSkippedTests = 0; int totalFailedTests = 0; long totalDuration = 0; writer.print("<table>"); writer.print("<tr>"); writer.print("<th>Test</th>"); writer.print("<th># Passed</th>"); ...
b2037821-123c-4c1d-85e3-29aee5043729
1
public BU01Knapsack(int n, int capacity, int w[], int v[]) { knap = new int[capacity + 1]; knap[0] = 0; for (int i = 1; i <= capacity; i++) knap[i] = Integer.MIN_VALUE; knapsack(n, capacity, w, v); }
79e681ba-977a-4a2e-8166-93531d4bab82
5
@BeforeSuite public void setup(){ try{ if(System.getProperty("device")!=null){ if(System.getProperty("device").equalsIgnoreCase("Android")) driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), getCapabilities()); else if(System.getPrope...
8bcb4afd-1af9-4297-8af2-3fbb35383760
9
@Test public void testCastingToBoolean() { assertEquals(true, ValueType.BOOLEAN.cast(true)); assertEquals(false, ValueType.BOOLEAN.cast(false)); try { ValueType.BOOLEAN.cast(null); fail(); } catch(ClassCastException e) { // empty block } try { ValueType.BOOLEA...
1682a725-2346-46d7-80ed-fe21b32202e1
6
public static boolean addExp(String player, String job, double amount) { PlayerCache checkPlayer = getPlayerCache(player); if(checkPlayer._jobexp.containsKey(job)) { double value = checkPlayer._jobexp.get(job) + amount; Integer level = checkPlayer._joblevel.get(job); ...
47fc5be5-87c4-4df5-aab0-4f10ad81a280
2
@Override public RgbImage clone() { RgbImage cloned = shallowClone(); for (int x = 0; x < getWidth(); x++) { for (int y = 0; y < getHeight(); y++) { cloned.setPixel(x, y, RED, getPixel(x, y, RED)); cloned.setPixel(x, y, GREEN, getPixel(x, y, GREEN)); cloned.setPixel(x, y, BLUE, getPixel(x, y, BLUE))...
c066b737-fff3-4977-8182-3b6b43ad0aaf
4
public static Object[] parseThemeColor( String colorval, double tint, short type, Theme t ) { /** * TODO: read this in from THEME!!! */ final String[][] themeColors = { { "dk1", "000000" }, { "lt1", "FFFFFF" }, { "dk2", "1F497D" }, { "lt2", "EEECE1" }, { "accent1", "4F81BD" }, { "acce...
eafa73bd-356e-491d-ab4e-73436c907552
1
public void executeSearch() throws ListHandlerException { try { List resultsList = contactDao.loadAll(); setList(resultsList); } catch (Exception e) { throw new ListHandlerException(); } }
4ae8faab-7c81-4a61-86fc-4e1916e4e8e8
5
private Hashtable<Integer, Integer> uponReceiveMessages(int r) { Hashtable<Integer, Integer> decisionValues = new Hashtable<Integer, Integer>(); while (true) { int F = suspects.size(); int n = p.getNo(); synchronized (valMessages) { decisionValues = valMessages.get(r); } if (decisionValues != n...
88dd8409-4568-4b2b-b9bd-5a288be6c043
2
public Animation getAnimationRight(){ if(dead){ return death; } if (type == Type.CAT){ return catAnimRightWalking; } else { return dogAnimRightWalking; } }
7414156f-5add-4478-af1c-e84a744002ba
1
protected void _readFile() throws ReaderException { File config_file = new File(ConfigurationManager.config_file_path); if (config_file.exists()) { _setConfigFile(config_file); } else { throw new ReaderException("Configuration file was not found on the provided location: " + ConfigurationManager.config_fil...
c1de3855-3fa6-4f55-8e04-62dec8ac00af
4
private boolean parseAfterMillion(){ // If no more tokens, it's still valid if (peek() == null){ return true; } int[] parsed = parsePrefix(); if (parsed == null){ // Error parsing return false; } NumberToken ne...
54d60d45-ef7b-4a74-b129-b604b755c549
2
private void writeRow(BufferedWriter fwriter, String[] entries){ try { for(int i = 0; i < (entries.length - 1); i++){ fwriter.write(entries[i]); fwriter.write(", "); } fwriter.write(entries[entries.length -1]); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace...
c98cdb7e-584f-4236-81fb-98498fbb4cbd
1
public LinkedHashMap<Integer, Persona> leerPersonaXStream(String rutaFichero) { XStream xstream = new XStream(); rutaFichero = rutaFichero + ".xml"; LinkedHashMap<Integer, Persona> personas = new LinkedHashMap<>(); try { personas = (LinkedHashMap<Integer, Persona>) xstream.fr...
658e90f0-ef51-4787-a9fc-ba05b2628775
1
static public Login instancia() { if (UnicaInstancia == null) { UnicaInstancia = new Login(); } return UnicaInstancia; }
90690844-3946-487b-8364-9bc8d7c5a0ff
9
public static String quotify(char quote, String s) { int n = s.length(); StringBuilder sb = new StringBuilder(n + 2); sb.append(quote); for (int i = 0; i < n; i++) { char c = s.charAt(i); int j = charEscape.indexOf(c); if(j>=0) { if((qu...
9e7f2484-8daf-44a4-b7b2-310c317e7cb8
5
public static void insertMember(Member m){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Adress a = m.getAdress(); try{ conn.setAutoCom...
f72925be-06b6-4e70-84ac-e809c77b92c0
2
public WebCrawler(String ruta) { this.enlacesListado = new ArrayList<String>(); this.finalizado=false; this.enlacesRecorridos = new ArrayList<String>(); this.enlacesImagenes = new ArrayList<String>(); this.enlacesDocumentos = new ArrayList<String>(); this.enlacesVide...
0405feac-d976-4574-899d-3844a1e030cd
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Star star = (Star) o; if (temperature != star.temperature) return false; if (starClass != star.starClass) return false; return true; ...
c84fb41f-2c38-4c60-9d3a-75e81ad50af8
8
public P366E() { Scanner sc = new Scanner(System.in); N = sc.nextInt(); M = sc.nextInt(); K = sc.nextInt(); int s = sc.nextInt(); upper = new int[K]; lower = new int[K]; highest = new int[M][K]; lowest = new int[M][K]; fo...
2db053bd-0d38-417d-a094-0422a85a7543
8
private void manyItemsTestInternal(final int testWidth, final int testHeight) { // generate 100 items and insert them int objectCnt = 5000; int moveCnt = 5; Random rand = new Random(); int itemX, itemY; Rectangle boundingBox; TestingObject item; List<TestingObject> list = new ArrayList<TestingObject>()...
586524ac-cbbc-4d06-beef-aedc37887e28
8
public Model getRotatedModel() { if(desc == null) return null; Model model = method450(); if(model == null) return null; super.height = model.modelHeight; if(super.anInt1520 != -1 && super.anInt1521 != -1) { SpotAnim spotAnim = SpotAnim.cache[super.anInt1520]; Model model_1 = spotAnim.getModel(...
ab905d8d-735e-4d72-bbf9-b42b2a88ea38
1
private void sendSwitchcoderMove(){ check(isMyTurn() && currentMove == VERIFY); this.sendSwitchcoderOperation(coderId, guesserId, state); }
40c8e2e4-8759-451a-b0ac-6f7e71a687e2
9
protected boolean unplayMe(MOB mob, MOB invoker) { if(mob==null) return false; final Ability A=mob.fetchEffect(ID()); if((A instanceof Play) &&((invoker==null)||(A.invoker()==null)||(A.invoker()==invoker))) { final Play P=(Play)A; if(P.timeOut==0) { P.timeOut = System.currentTimeMillis() ...
2830d720-0c38-457b-9788-e453d97f2268
3
public void run() { Thread.currentThread().setName("GameSocketServer"); ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(port); } catch (IOException e1) { e1.printStackTrace(); } System.out.println("GameServer listening on " + port + "..."); while (listening) { try { S...
df685317-d516-4827-aed2-9e26704de30b
5
private void parseContext(Collection<String> lines, String context) { boolean insideContext = false; for (String line : lines) { if (isNamedContext(line, context)) insideContext = true; else if (insideContext && isContext(line)) insideContext = false; else if (insideContext) configuration.putAl...
111b170b-07e5-46ef-8086-e13277df5b0b
3
public static String[] getFileListByExtension(final String location, final String extension) { File file = new File(location); if (file.isDirectory()) { String[] lists = file.list(new FilenameFilter() { public boolean accept(File dir, String name) { if (name.endsWith(extension.toLowerCase()) || name.end...
3298c709-0d3a-4139-91eb-d1aabbdc9233
0
public void clearTable() { tableModel = new DefaultTableModel(new String[] { "Treść odpowiedzi"}, 0); table = new JTable(tableModel); }
4c5f737a-f339-475c-8cae-0bf20312637e
0
public String getKit() { return kit; }
fca4e720-bb61-4b6f-9739-435b589d93ba
2
private Object[] arrayFuser(Object[] a1, Object[] a2)// combines 2 int arrays into // one. Not used...yet. { Object[] returned = new Object[a1.length + a2.length]; for (int x = 0; x < a1.length; x++) { returned[x] = a1[x]; } for (int x = a1.length; x < a1.len...
d5fec7eb-059b-449d-b0f1-8eefb4b6bd81
5
private int getNumPiecesInDiagonal(int startRow, int startCol, int endRow, int endCol) { int count = 0; // Check all positions on board and count only those that are on the // diagonal and not empty for (int rowCounter = 0; rowCounter < SIZE; rowCounter++) { for (int colCounter = 0; colCounter < SIZE; col...
0ad38930-8901-493d-b765-8b974bab4df0
6
public void run() { RawTile rawTile; ArrayList<ArrayList<DataTile>> tiles; while (true) { rawTile = ThreadStorage.pollDataTileResults(); if (rawTile == null && ThreadStorage.isEndProcess()) { break; } else if (rawTile != null) { try { tiles = rawTile.getRwaDataTile(); processTile(tiles,...
500309df-6f83-42a5-96bf-b9a159526319
9
public String getOauthUrl(String url, String httpMethod, String customKey, String customSecrect, String tokenKey, String tokenSecrect, String verify, String callbackUrl, List<QParameter> parameters, StringBuffer queryString) { String parameterString = normalizeRequestParameters(parameters); String urlWit...
65781e41-e12e-4b2d-bb67-dc098b4c49d9
8
public void kill() { if((Stomach()==null)||(lastKnownLocation()==null)) return; // ===== move all inhabitants to the dragons location // ===== loop through all inhabitants of the stomach final int morselCount = Stomach().numInhabitants(); for (int x=morselCount-1;x>=0;x--) { // ===== get the tasty...
e529dddf-fdf0-47f7-b7f5-c068e827594a
9
public static TreeMap<Integer, Meter> read(String fileIn, TreeMap<Integer, Account> accountsReference){ TreeMap<Integer, Meter> meters = new TreeMap<Integer, Meter>(); File meterFile = new File(fileIn); try { Scanner in = new Scanner(meterFile); //Parse the meters file int meterID, accountID; bo...
a3748a49-b31e-4c6b-a668-187dc91e50d9
2
public boolean rankExons() { boolean changed = false; int rank = 1; for (Exon exon : sortedStrand()) { if (rank != exon.getRank()) { exon.setRank(rank); changed = true; } rank++; } return changed; }
798c153b-5416-4310-a0eb-82c03571cd40
2
public void setNextSort(IntegerNode newNode) { if (newNode.n >= this.n){ if (this.next == null){ this.next = newNode; } else { this.next.setNextSort(newNode); } } else { int x = this.n; temp = this.next; this.n = newNode.n; newNode.n = x; this.next = newNode; this.next....
48c14dd4-2822-4c51-9c9a-ad98fecf27fa
0
public List<SkillRating> getSkills() { return skills; }
86d41b93-88a1-4387-89aa-92f47b45afaf
6
Gene findOrCreateGene(String geneName, String trId, Chromosome chromo, int start, int end, int strand) { Marker tr = new Marker(chromo, start, end, strand, trId); List<Gene> genes = genesByName.get(geneName); int geneIndex = 0; if (genes != null) { for (Gene gene : genes) { if (gene.intersects(tr)) { ...
ded31137-c17f-457e-835c-25e7e6a8696f
0
public void clearEncoder(){ _leftEncoder.reset(); _rightEncoder.reset(); }
c3f4c5f1-2098-4b01-a453-96b4a3c9ff59
4
private int[] parseFile() { int[] r = {-1, nextReadedNumber}; CSVParser csvParser; int count = 0; try { csvParser = new CSVParser(new FileInputStream(logPath)); headline = new Headline(csvParser.getLine()); while (true) { try { lines.add(new InformationLine(csvParser.getLine(), headline)); ...
1226c112-74f0-47a2-96a3-a42e638626ad
8
public boolean isPalindrome(String s) { char[] cs = new char[100000]; int idx = 0; for( char c : s.toLowerCase().toCharArray()){ if((c >= 'a' && c <= 'z') || (c >='0' && c <= '9')) cs[idx++] = c; } for(int i = 0; i<idx; i++){ int j = idx - (i+1) ; if(i>j) ret...
8fa03902-da9b-4e6b-8639-80d1d704aa05
2
public static void cheat(){ for (int u = 0;u<8;u++){ for (int i = 0;i<8;i++){ board.set(i,u,null); } } board.set(4,7,new King("W")); board.set(4,0,new King("B")); board.set(0,0,new Rook("B")); board.set(7,0,new Rook("B")); board.set(7,7,new Rook("W")); board.set(0,7,new Rook("W")); board.se...
227f343d-0cb8-4bc5-8fed-56fe3d6c0778
6
public boolean pickAndExecuteAnAction() { synchronized(orders){ for (CookOrder order: orders){ if(order.s==OrderState.cooked){ ServeOrder(order); return true; } if(order.s==OrderState.pending){ TryToCookOrder(order); return true; } } } /*synchronized(marketOrders){ for (MarketOrd...
4761b889-f569-4915-8476-ef69e4aed3c7
2
public long getLong(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); } catch (Exception e) { throw new JSONException("JSONObject["...
8aa78d80-8c4b-491f-b9eb-d0148ade38af
4
private Image findGameElementImage(ItemInfo element) { if (ChargedIdentityDisc.class.isAssignableFrom(element.getClass())) return chargedIdentityDisc; else if (IdentityDisc.class.isAssignableFrom(element.getClass())) return identitydisc; else if (LightGrenade.class.isAssignableFrom(element.getClass())) r...
622c45b9-0fb5-4aa7-92ff-468062433e26
3
public boolean clearPathInRankBetween(Field from, Field to) { // Is vertically path between fields clear? for (char file='a'; file<='h'; file++) { if (this.fileBetween(file, from.file, to.file) && this.getField(file, from.rank).hasPiece()) { return false; } } return true; }
b8a86b45-04a1-40d3-ba7b-c6c6ad37b74c
4
public static void main(String[] args){ short tal = (short)(-10); System.out.println(tal & 0xffff); Cpu cpu = new Cpu(null); int[] arr = new int[]{ 0x7c01, 0x0030, 0x7de1, 0x1000, 0x0020, 0x7803, 0x1000, 0xc00d, 0x7dc1, 0x001a, 0xa861, 0x7c01, 0x2000, 0x2161, 0x2000, 0x8463, 0x...
525fbb09-1610-45f1-9d0d-205c4320114f
7
private int processOrderList(ArrayList<Trade> trades, OrderList orders, int qtyRemaining, String side, String takerId, int time, boolean verbose) { // TODO Have already checked 'side' before this function is called so, // for efficiency, should probably have a processBestAsks and processBestBids. ...
f587ad96-6b6f-496c-85b8-4c059e3036f3
4
public ArrayList<Integer> findSequence(String sequence, Node node) { if (sequence.length() == 0) { return findPosition(node); } for (int i = 0; i < node.children.size(); i++) { if (sequence.startsWith(input.substring(node.children.get(i).stringStart, node.children.get(i).str...
f35ee0f7-ab7c-4b16-82e7-5d4a728fe1f9
4
private long getCPtrAddRefContactAcct(ContactAcct element) { // Whenever adding a reference to the list, I remove it first (if already there.) // That way we never store more than one reference per actual contained object. // for(int intIndex = 0; intIndex < elementList.size(); intIndex++) { Object theObject = e...
56f5cc9c-7a63-4430-8183-65b3a40044c3
4
public void addObject(PhysicalObject paramPhysicalObject) { if ((paramPhysicalObject.getLayer().compareTo("") != 0) && (paramPhysicalObject.getLayer() != null)) { SimpleContainer localSimpleContainer = null; addLayer(paramPhysicalObject.getLayer()); localSimpleContainer = (SimpleContainer)th...
c500dfcd-bdad-4507-a0ec-d0c12f416715
8
public void renderProjectile(int xp, int yp, Projectile p) { xp -= xOffset; yp -= yOffset; for (int y = 0; y < p.getSpriteSize(); y++) { int ya = y + yp; for (int x = 0; x < p.getSpriteSize(); x++) { int xa = x + xp; if (xa < -p.getSpriteSi...
10e86930-53e1-43d0-a501-4a2f2dbe352f
9
private void connectAVerbInstanceToRule(int fromStart, double weight, int toStart, double dynamicWeight, CABot3Net ruleNet) { for (int verbInst = 0; verbInst < 5; verbInst++) { // for each neuron in the body 40 excitatory neurons // half of the rule neurons get 4 connections (the rest 0) for...
354b2484-63a0-4ccd-ac9b-622b3a077d54
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Model)) { return false; } Model other = (Model) object; if ((this.modelPK == null && other.modelPK != null) || ...
85a828e4-ed5d-4747-9b6d-03d51e71cbcd
7
public void menu(Scanner scanner) { System.out.println("Welcome to Ski-pass system!"); System.out.println("---------------------------"); int option = -1; while (option != 0) { System.out.println("\n1 - buy a ski-pass"); System.out.println("2 - make 1 passage"); ...
aaaf8449-bc67-49e0-a21a-50e2ff5565d8
7
public ClassReference addClass(String qualifiedName) { if (qualifiedName.indexOf('.') < 0) { String element = qualifiedName; int arrayDepth = 0; while (JavaArrayType.isJavaArrayRepresentation(element)) { arrayDepth++; element = JavaArrayType.g...
c00fe673-a457-49e2-941c-d75670235be2
1
public void testWithFieldAdded2() { YearMonthDay test = new YearMonthDay(2004, 6, 9); try { test.withFieldAdded(null, 0); fail(); } catch (IllegalArgumentException ex) {} }
f2fb9e3f-f378-44f2-9c2e-31aecd9d8ab8
5
private void computeUtility(Bundle resources) { utility = 0.0; for (ResourcePile pile:resources){ if (pile.type == Resource.food) utility += Math.max(0.0, preferences.get(Preference.foodUtil)*Math.log(pile.amount)+0.02); else if (pile.type == Resource.goods) utility += Math.max(0.0, preferences.get(Preference...
2b152f65-bd06-428e-8645-99092385bce5
1
public static boolean getKeyDown(int keyCode) { return getKey(keyCode) && !lastKeys[keyCode]; }
9582519f-de5a-4445-becf-9fb43eae1c70
9
private void init(AbstractToggleableAction a, String iconKey, boolean showText) { enablePlasticWorkaround = UIManager.getLookAndFeel().getClass().getName().startsWith("com.jgoodies.looks.plastic."); setAction(a); addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEve...
c6df61b5-3d32-4ee0-b285-cf2f13a39414
1
public String getReason() { if (message != null) return message; else return this.toString(); }
46f2efaf-ea30-41ba-8ad1-aea366cd29ff
6
public String toDiffString(String jobId) { String f1 = "%1$-3.0f"; String f2 = "%1$-3.1f"; float mOUdf = exOU - rmOU; float xOUdf = exOU - rxOU; float mNGUdf = exNGU - rmNGU; float xNGUdf = exNGU - rxNGU; float xHeapUdf = exHeapU - rxHeapU; float RSSdf = exHeapU - rxRSS; float mOUrt = rmOU == 0 ...
95fe8b87-9dcf-43fa-b3ef-1ad1e26af94d
6
public void run() { Object var1 = NetworkManager.threadSyncObject; synchronized (NetworkManager.threadSyncObject) { ++NetworkManager.numReadThreads; } while (true) { boolean var12 = false; try { var12 ...
189b21cf-95fe-41bc-ad2b-6a229a24fa0a
4
private long generateFromExpression(Object from, MVContext context) throws TransactionException { String sql = "insert into mview_expression(mview_id, type, table_owner, table_name, table_alias, expr_order) values(?, 'from', ?, ?, ?, ?)"; if(from instanceof SQLJoinTableSource) { return gener...
0b137afc-e93e-48f7-84be-0e61e7b8162e
2
@EventHandler public void onInventoryClick( InventoryClickEvent e ){ if( e.getSlot() == 38 ){ if( e.getCurrentItem() != null){ Player p = (Player) e.getWhoClicked(); p.setHealthScale(20); } } }
f78260e1-1286-4146-862f-c112848a6a94
0
protected double getBreedingProbability() { return breeding_probability; }
d9611f25-5d9b-455e-982b-bed6b8e12582
0
@Test public void testGetRandom() { System.out.println("getRandom"); Flip instance = new Flip(3,6,9); int expResult = 3; int result = instance.getRandom(); assertEquals(expResult, result); }
f289acc7-5f54-4ba9-899e-7569668af188
2
public String getUserInput(String prompt) { String inputLine = null; System.out.print(prompt + " "); try { BufferedReader is = new BufferedReader( new InputStreamReader(System.in)); inputLine = is.readLine(); if (inputLine.length() == 0 ) return null; } catch (IOException e...
820e3075-a46e-433f-bd1f-630064148064
5
public boolean containsNode(Node node) { if (this.equals(node)) { return true; } else { if (leftChild != null) { if (leftChild.containsNode(node)) { return true; } } if (rightChild != null) { if (rightChild.containsNode(node)) { return true; ...
670a0aa9-6bdf-4c23-8c65-ebb8a09616d0
5
public static int getIndexOfMax(ArrayList<Integer> arr){ int max = -1; boolean tie = false; for(int i=0;i<arr.size();i++){ if(max<0 || arr.get(i)>arr.get(max)){ max = i; tie = false; }else if(arr.get(i)==arr.get(max)){ tie = true; } } if(tie){ max = -1; } return max; }