method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
72d2b0c6-805b-4de5-bea4-a99efead9317
4
public MessageSender getSender(long waitTimeMillis) { try { if (!freeSender.tryAcquire(waitTimeMillis, TimeUnit.MILLISECONDS)) throw new RuntimeException("Timeout waiting for idle object in the pool."); } catch (InterruptedException e) { throw new RuntimeException("Int...
b857b559-4488-4503-93d8-ecde6d6d07b5
3
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { Map<String, Integer> keyWordMap = new HashMap<String, Integer>(); Integer count = 0; for (Text val : values) { String keyWord = val.toString(); if (keyWordMap.containsKey(keyWord)) { ...
8ab9fb1a-6dd9-43f4-abe0-39783a0195eb
8
public boolean batchExecGenericQuery(String command, BatchExecSetter setter) throws SQLException { boolean value = false; Connection connection = null; PreparedStatement stmt = null; try { Class.forName(driver); connection = DriverManager.getConnection(url, username, passwd); connection.setAutoComm...
570269dc-2066-44ab-9c9c-3ec4fa0f49af
9
static protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = maxNextCharInd = 0; available = tokenBegin; } else if (tokenBegin < 0) bufpos...
180c1811-17ef-478a-b731-26019d940b69
5
public static String getNameOfOS() { String os = System.getProperty("os.name").toLowerCase(); if(os.contains("win")) { return "Windows"; } if(os.contains("sunos") || os.contains("solaris")) { return "Solaris"; } if(os.contains(...
c046f230-cab6-47c0-92f4-9ff7cabba301
5
public static String encodeHTML(String plainText) { StringBuffer out = new StringBuffer(); for(int i=0; i<plainText.length(); i++) { char c = plainText.charAt(i); if(c > 127 || c=='"' || c=='<' || c=='>') { out.append("&#"+(int)c+";"); } else { out....
d2cecc94-2494-49ba-85ac-36818e57df23
0
public listByWeek() { // TODO Auto-generated constructor stub }
ccc056ac-a07a-4f16-82dd-60f3f9a466be
6
public static int getStateMetricMaxVal() { switch(STATE_METRIC) { case DIV: return 0x4000; case DSum: return 0x100; case RNG: return 0x10000; case RNG1: return 0x100; case RNG2: return 0x100; case RANDOM: default: return 0x100; } }
92ec1c04-6e3d-47c7-9c3a-117d3ebf37d8
5
@Test public void test_mult_matrix_identity() { int dim = 3; Matrix a = new MatrixList(dim, dim); Matrix identity_matrix = new MatrixList(dim, dim); for (int i = 1; i <= dim; i++) { for (int j = 1; j <= dim; j++) a.insert(i, j, (double) (2 * i - j)); } for (int i = 1; i <= dim; i++) { for (int...
3ce2fb74-6421-41ae-98a7-11e2708204ef
0
public List<Artist> getArtists() { return artists; }
cc635b01-697f-4758-a95c-c79423e29027
9
public void checkCurrentGameInputs(KeyEvent e) { if(e.getKeyCode()==38) { if(snake.isSnakeDown()==false) { snake.setSnakeDown(false); snake.setSnakeRight(false); snake.setSnakeLeft(false); snake.setSnakeUp(true); } } else if(e.getKeyCode() == 40) { if(snake.isSnakeUp() == false) { sna...
4298f3c4-fb75-44ef-a6d0-e411b273a974
8
public void postTweet(int userId, int tweetId) { //1. post to user feeds record TreeMap<Long,Integer> postFeeds=postFeedMap.get(userId); if(postFeeds==null) postFeeds=new TreeMap<>(); postFeeds.put(time.incrementAndGet(),tweetId); postFeedMap.put(userId,postFeeds); //2. p...
e83c226b-b9d8-4b9c-874b-edc6cdc889a3
9
@RequestMapping(value = "/ayl", method = RequestMethod.POST, params = "lisa_alluv") public String lisaAlluv( @ModelAttribute("adw") AdminYksLiikView adw, // sessioonist listid @RequestParam("ayl_alluv_ID") String alluv_ID, ModelMap model) { String Yl_ID = adw.getCurrent().getYl_id(); int alluvID; i...
1eff3f1b-7f24-46d4-8ed2-0f2a78794c72
4
@Override public void run() { try { loadJarURLs(); dir = new File(SystemUtil.getGameDirectory(frame.getCurrentServerIndex()) + File.separator + "bin" + File.separator); if (!dir.exists()) { dir.mkdirs(); } downloadJars(); downloader.addCompleteListener(new ActionListener() { @Override p...
6b2a2e3c-7d63-47ee-b1b4-0f42859b0536
2
public void updateChat (String x) { for (int i = 0 ; i < flexclients.size() ; i++) { //System.out.println("Sending to client " + i); try { System.out.println("Sending to client: " + i); ((TcpThread) flexclients.get (i)).Soutput.writeObject (x); ((TcpThread) flexclients.get (i))....
a1496292-593b-427d-ad83-9b939054240b
7
@EventHandler public void GhastSpeed(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getZombieConfig().getDouble("Ghast.Speed.Dodge...
26ee5bdd-569e-40f1-8381-c6060a9e1d9f
3
public static HTMLElement compileObjectToPage(Object o) { if (o instanceof HTMLElement) { return (HTMLElement) o; } else if (isPage(o)) { return compilePage(o); } else if (isPartial(o)) { return compilePartial(o); } else { return new DIV(o.toString()); } }
f0612f2f-3e47-4bc2-a5be-72f5f21a9839
4
public boolean removeAt(int index) { if (indexWithinCurrentSize(index)) { System.arraycopy(array, index + 1, array, index, array.length - index - 1); array[array.length - 1] = null; // last element currentSize--; if (index == currentSize) { int i = index - 1; while (array[i] == null && i >= 0) { ...
cc44c33e-c20e-419d-8280-ae4bd492e556
4
public static void innerJoin(EntityManager entityManager) { System.out.println("THE IN OPERATOR and INNER JOIN"); System.out.println("--------------------------------"); System.out.println("SELECT r"); System.out.println("FROM Customer AS c, IN( c.reservations ) r"); Query query = ...
a9959e08-d3af-49ee-b652-68531e8faf5d
7
public void initialize() { lastxpos = lastypos = 0; cellRange = cellSize; cellSize = cellRange + 2*intpad; jPlColHeader = new JPanel() { private static final long serialVersionUID = -9098547751937467506L; java.awt.Rectangle r; public void paint(Graphics g) { r = g.getCli...
6b3a7ed0-d12b-40f5-afa6-3ca7f44cc950
9
@Override public void setEntityValue(ResultSet rs, int index, Object entity) throws Exception { Field f = getField(); Integer enumId = rs.getInt(index); Enum<?> value = null; if(enumId == null) { getField().set(entity, value); return; } @SuppressWarnings("unchecked") Class<? extends Enum<?>...
3bb27493-cf2a-4a22-b5e8-1fbfbc08dc25
8
private LegacyContact convertMsnContact(MsnContact msnContact) { LegacyContact legContact = new LegacyContact(); MsnObject obj; legContact.displayName = msnContact.getDisplayName(); legContact.email = msnContact.getEmail().getEmailAddress(); legContact.personalMessage = msnContact.getPersonalMessage(); ...
9515462e-0725-494a-ba7e-0ea1247ee07b
6
protected void deleteDebate() { Object topicO = topicDBJlst.getSelectedValue(); String topicValue= null; if (topicO != null) { topicValue = topicO.toString(); } if (topicValue != null) { if (debateList != null) { for (int i = 0; i < debateList.size(); i++) { if (debateList.get(i).getTopic().equ...
6e76233c-9ee1-4391-9c86-39e7c78b1acb
0
public static void CHTTLSetting(){ System.setProperty("http.proxyHost", DYNA_PROXY_HOST); System.setProperty("http.proxyPort", DYNA_PROXY_PORT); System.setProperty("https.proxyHost", DYNA_PROXY_HOST); System.setProperty("https.proxyPort", DYNA_PROXY_PORT); }
bdd0400b-c9bd-4565-98a7-7e3c1b9c3599
1
private void loadContent() { try { menu_image = ImageIO.read(this.getClass().getClassLoader().getResource("img/menu.PNG")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
ca9cd5e4-615b-4609-af35-75b1084d15ab
6
private JPanel getAdvancedConfigurationMenuHandler(final JButton editButton, final JButton deleteButton){ // Create the advance panel JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // -------- Add the Edit button -------- // editButton.setToolTipText("Edit - " + getCleanName...
2691681c-d748-4f50-a01a-b55a0a868295
6
public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: Clustering prop.clusterprop"); return; } PropertyHandler propHandler = new PropertyHandler(requiredProps); Properties properties = propHandler.readPropertiesFile(args[0]); if (propHandler.checkP...
56c91671-411b-4fed-b386-715ab1604e88
1
@Override protected URL getThemeURL() { File themeFile = new File("data/ui/chutzpah.xml"); URL url = null; try { url = themeFile.toURL(); } catch (MalformedURLException e) { e.printStackTrace(); } return url; }
0842d043-5c78-4dd6-8cba-9b8b31c1b741
4
public void inscribir(Jugador unJugador, Partido unPartido) { //SI EL PARTIDO ESTA INCOMPLETO LO AGREGO SIN PROBLEMAS if (unPartido.partidoIncompleto()){ unPartido.inscribir(unJugador); } //SI EL PARTIDO ESTA SEMICOMPLETO ME TENGO QUE FIJAR SI HAY UN CONDICIONAL PARA PODER REEMPLAZAR //A ESE CONDIC...
32afc33d-d809-40b7-979e-fffc9c683155
9
@Override public void setValueAt(Object aValue, int row, int column) { Object oldValue = getValueAt(row, column); // not change anything. if (oldValue != null && oldValue.equals(aValue)) { return ; } // Get the Object of line. Vector rowVector = (...
45f5d294-79ac-449f-aae8-87fa80e97972
0
@Override public long getStartLiveTime() { return startLiveTime; }
c371661c-9a77-4c92-aaa6-7bc87c7d0982
7
@Override public void mouseDragged(MouseEvent me) { this.drag = true; tp.mx = me.getX(); tp.my = me.getY(); int x = me.getX() / scale; int y = me.getY() / scale; tp.setDrag(new Vector3f(x, y, 0)); Color c = null; if(SwingUtilities.isRightMouseButton(me)) { c = bg; } else if(SwingUtilit...
32d26fdf-e578-441b-a2d9-e0997547c826
2
public int compareTo(Object s) { double difference = ((StrategyRanker)s).getAverage() - average; if(difference == 0) { return 0; } else if (difference > 0) { return 1; } else { return -1; } }
c004873d-c63f-42d1-875b-4899c1dd5e5d
6
public ArrayList<HashMap<List<Integer>, HashSet<Integer>>> lshBucketN(HashMap<Integer, ArrayList<Integer>> sigList, HashMap<Integer, ArrayList<Integer>> semanList) { ArrayList<HashMap<List<Integer>, HashSet<Integer>>> lshBuckets = lshBucket(sigList); for (HashMap<List<Integer>, HashSet<Integer>> lshBuck...
82d8a1e5-fd50-469b-967c-249797491991
1
private void closeOutput(){ try { leavesNodeFileWriter.write("結束時間: " + getRightNowTimeStr("/", ":", " ") + "\r\n"); leavesContentFileWriter.write("結束時間: " + getRightNowTimeStr("/", ":", " ") + "\r\n"); leavesNodeFileWriter.close(); leavesContentFileWriter.close(); } catch (IOException e) { // TODO A...
14cf9520-c611-45c7-9b89-1d2126598f27
0
public FileHandler getFileHandler() { return fileHandler; }
456d8c91-40e7-4b5e-941a-cc58714f4e25
9
public Item getItem(int id) throws SQLException { PreparedStatement pStatement = connection.prepareStatement("select " + "items.id as item_id," + "items.media_type," + "items.format," + "items.title as item_title," + "items.cover," ...
b5011cd2-7dc8-48bb-b9b7-db720acde929
1
public void startLogin(User myUser) { //Datenbankverbindung LoginDB myLoginDB = new LoginDB(); // es wird geprüft, ob die angegebene Benutzername/Password-Kombination // in der Tabelle "users" vorhanden ist int numRow = myLoginDB.login(myUser); // Wenn die Benutzerdaten korrekt sind, wird die Bücherverw...
a78f4e6a-7fa5-4646-a5b9-3eb1258e5ebd
0
public King(boolean isWhite, ImageIcon imgIcon) { super(isWhite, imgIcon); this.setIcon(); }
d54cf706-a15e-405e-a321-3b5f56925ba5
0
public Step getById(Integer stepId) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Step.class); criteria.add(Restrictions.eq("id", stepId)); return (Step) criteria.uniqueResult(); }
6c9f10af-0454-42ef-bea4-a93f5500b222
7
public static void reviewHands(Dealer dealer, Player player) { int playerScore = player.getDefaultScore(); int dealerScore = dealer.getDefaultScore(); // Check for either hand busting, first of all. if(checkForBust(dealer, player)) { /* Go no further. Declare winner or tie. Round is over, so 'continueRoun...
5b36e590-c639-441c-be78-6287a37bfcfd
8
private void insertObject(Object changedObject){ String table = changedObject.getClass().getSimpleName(); switch(table){ case "User": User user = (User) changedObject; dataStorage.users().addUser(user); break; case "Group": ...
bf86b1ab-a86b-4366-96fb-afca416d258c
7
protected PairVector<Room,Exit[]> findRooms(XMLTag piece, Map<String,Object> defined, Exit[] exits, int direction) throws CMException { try { final PairVector<Room,Exit[]> DV = new PairVector<Room,Exit[]>(); final String tagName="ROOM"; final List<XMLLibrary.XMLTag> choices = getAllChoices(null,null,null,...
ac57a28d-977b-4aaf-b7ac-6ff7c5c6dcf3
1
private void cutAds(File inputVideo, File outputVideo, IMediator mediator, List<VideoSection> sectionsToCut) { try { long videoDuration = VideoUtils.getVideoDurationInSeconds(inputVideo); ProgressReportingAdapter progressReporter = new ProgressReportin...
f0fd5223-4c77-4ec4-846a-69218b54de8b
7
public int[] computeIntStats(String sequence) { int[] stat = new int[26]; for (int i = 0; i < sequence.length(); ++i) { char aminoAcid = sequence.charAt(i); int index = acids.indexOf(aminoAcid); if (index >= 0) { ++stat[index]; } if ("AGILV".indexOf(aminoAcid) > -1) { ...
df55cb29-2aad-4b86-af35-387e0dc0f1f6
2
private FilePrefixer() { ResourceBundle rb = ResourceBundle.getBundle( "org.hodgson.development.fileprefixer", Locale.getDefault()); baseDir = rb.getString("base.directory").replace('/', File.separatorChar); if (baseDir.endsWith(File.separator) == false) { baseDir += baseDir + File.separator; } ...
82d40a8f-8f99-4fa7-8956-60cd96682ecc
1
public Object clone() { Prototype p = null; try { p = (Prototype) super.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } return p; }
ae0433c7-fd19-4437-b807-c120aca4cd27
7
public void cancelOrder(Order order) throws SessionNotFound { Book book = books.get(order.security.toUpperCase()); if(book == null) { logger.error("Book not fount for: " + order.security.toUpperCase()); return; } Order toCanc...
7be2fde7-7675-45c9-aa37-981cd887f2fb
0
public Coffee() { this.setName("Coffee"); this.setPrice(new BigDecimal(10)); }
1bfa64e8-aa06-401f-a75e-948cffd93542
7
public static void main(String[] args) { int top = 1, bottom = 1; for(int a = 10; a <= 99; a++) { for(int b = a + 1; b <= 99; b++) { String numerator = String.valueOf(a); String denominator = String.valueOf(b); for(int i = 0; i < numerator.length(); i++) { String digit = String.valueOf(nume...
b97ac9de-526d-4c0a-9aff-32c127f9dafa
0
protected void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice) {}
3b8cb97d-749f-4472-9bc9-a6f04d1c3181
8
final Document doc(int n, FieldSelector fieldSelector) throws CorruptIndexException, IOException { seekIndex(n); long position = indexStream.readLong(); fieldsStream.seek(position); Document doc = new Document(); int numFields = fieldsStream.readVInt(); for (int i = 0; i < numFields; i++) { ...
310180a5-5863-4ad2-b16c-518c7b7fc5f2
9
public MeetingRoomGUI() { //Get size of screen without taskbar screenSize = Toolkit.getDefaultToolkit().getScreenSize(); screenMax = Toolkit.getDefaultToolkit().getScreenInsets(meetingRoomDialog.getGraphicsConfiguration()); taskbarSize = screenMax.bottom; screenWidth = (int)screenSize.getWidth(); screenHeig...
356bc16d-b4c5-4a5b-a7f4-b91f2db257fe
0
@Override public void setValue(Object o) { // instance must encapsulate a FileMetadata this.embeddedImageLink=(FileMetadata) this.convertObject(o); Id3v2PictureFrame.updateNodePictureType(this); }
c95ec7dd-4616-4ad8-89f6-7bedc3684b9a
7
public static LinkedListNode addHelper(LinkedListNode a, LinkedListNode b, int increase) { if(a == null && b == null && increase == 0) return null; int sum = increase; if(a != null) sum += a.val; if(b != null) sum += b.val; LinkedListNode head = new LinkedListNode(sum%10); head.next = add...
293f9004-5d64-465d-8390-d97f9e5c9afc
7
public static void qrupdt_f77(int n, double a[][], double u[], double v[]) { /* Here is a copy of the qrupdt FORTRAN documentation: SUBROUTINE QRUPDT(NR,N,A,U,V) C C PURPOSE C ------- C FIND AN ORTHOGONAL (N*N) MATRIX (Q*) AND AN UPPER TRIANGULAR (N*N) C MATRIX (R*) SUCH THAT (Q*)...
7dffcec5-f5ee-470f-9a91-75f4a21a60e4
1
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Composition document = new Composition(); //IEditorController controller = new EditorController(document); EditorController controller = new EditorController(document); new ui.swing...
98c72138-69e6-4705-947b-bc1cc774e562
8
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for (; ; ) { StringTokenizer st = new StringTokenizer(in.readLine().trim()); double H = parseInt(st.nextToken()); if(H==0)break; double U = parseInt(st.nextToken()), D = par...
1a243837-7f65-4c5e-ac4d-25f5a23e5d52
4
private List<Map<Integer, Double>> getMaxTermsByTopics(ParallelTopicModel LDA, int limit) { Alphabet alphabet = LDA.getAlphabet(); List<Map<Integer, Double>> topicList = new ArrayList<Map<Integer, Double>>(); int numTopics = LDA.getNumTopics(); List<TreeSet<IDSorter>> sortedWords = LDA.getSortedWord...
6c751bf8-b888-4d20-a4e1-6add7f7078b1
2
public static void main(String[] args) { // TODO Auto-generated method stub boolean b; b = false; System.out.println("b is " + b); b = true; System.out.println("b is " + b); if(b) System.out.println("This is executed."); b = false; if(b) System.out.println("This is not executed."); Syste...
53e037d6-3d73-42ef-a5a2-b05c1becd7d6
4
public static void login() throws TwitterException, IOException { // The factory instance is re-useable and thread safe. Twitter twitter = TwitterFactory.getSingleton(); twitter.setOAuthConsumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET); RequestToken requestToken = twitter.getOAuthReque...
2aef3f11-f3ca-4129-94a9-47dedf702bdf
9
private static List<String> getAllFiles(File folder, boolean validate){ List<String> files=new ArrayList<String>(); if(folder.isDirectory()){ File[] children=folder.listFiles(); if(children!=null){ for(File child:children){ if(child.isDirectory()){ files.addAll(getAllFiles(child,validate)); }els...
e85e19e8-e8a2-4cfb-9dcb-044cc3d3a9f1
6
public ArrayList<GameCoreInstruction> readNetworkMessages() { if ( isServer ) { if ( GameCore.getInstanceOfGameCore().getGameState().equals(GameState.WAITING_FOR_PLAYERS) ) { if ( server.waitForPlayer() ) { //client connected to server: ArrayList<GameCoreInstruction> ret = new ArrayList<GameCore...
d9dfb116-c6de-4525-bdc9-8507902abf25
8
public void onKeyPressed(KeyEvent e) { switch (e.getKeyCode()) { case VK_UP: case VK_W: directions.add(Direction.UP); break; case VK_DOWN: case VK_S: directions.add(Direction.DOWN); break; case VK_RIGHT: case VK_D: directions.add(Direction.RIGHT); break; case VK_LEFT: case VK_A: ...
ea8a7cde-8480-4f29-adca-b1fb523f4cd2
0
public static void main(String[] args) throws Exception { Car car = new Car(); ExecutorService exec = Executors.newCachedThreadPool(); exec.execute(new WaxOff(car)); exec.execute(new WaxOn(car)); TimeUnit.SECONDS.sleep(5); // Run for a while... exec.shutdownNow(); // Interrupt all tasks }
c23077a9-b360-48c6-8999-f86d0226d7d9
4
private int getAttributes() { // skips the header int u = header + 8 + readUnsignedShort(header + 6) * 2; // skips fields and methods for (int i = readUnsignedShort(u); i > 0; --i) { for (int j = readUnsignedShort(u + 8); j > 0; --j) { u += 6 + readInt(u + 12)...
c97ea9e5-e983-4c38-b87a-24c6b957094a
2
public static void addURL(URL url) throws IOException { URLClassLoader systemClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class<?> systemClassLoaderClass = URLClassLoader.class; try { Method method = systemClassLoaderClass.getDeclaredMethod("addURL", parameters...
c46786e7-e022-4554-a566-8d4abbf4daa5
2
static void writeObject(DataOutput out, BTXObject obj) throws IOException { writeString(out, obj.getName()); out.writeInt(obj.getAttributeCount()); { Iterator<BTXAttribute> attrs = obj.getAttributes(); while (attrs.hasNext()) { writeAttribute(out, attrs.next()); } } out.writeInt(obj.getChildrenCo...
8bbf3a43-0693-4748-a32c-3ee9a1bea366
0
public void encrypt(String file, String encrypted_file) throws Exception { FileInputStream input_file = new FileInputStream(file); FileOutputStream PGP_file = new FileOutputStream(encrypted_file, true); PKESKP keyPacket = new PKESKP(key, pub_exp, mod); keyPacket.dump(PGP_file); D...
687c83cd-3df0-418b-9c03-8f2ae7041d2b
9
public List<scripture> searchForScrip(String line, Map<String, List<String>> map) { List<scripture> scriptures = new ArrayList<>(); String temp = ""; String book; int chapter; int firstVerse = 0; int lastVerse = 0; line = line.replace("(", ""); li...
f6b20af8-ea12-40f7-b179-94f5c7cba195
1
public List<String> getAuthors(int id){ String query="select authors from authorlist where paperid="+id; ResultSet rs=sqLconnection.Query(query); try { rs.next(); String []authors=rs.getString("authors").split(","); authorList=Arrays.asList(authors); } catch (SQLException e) { e.printStackTrace(); ...
5040057f-dfe3-4d49-b2db-934ca59f3ea0
4
@Override public boolean include(Entry<? extends ResultTableModel, ? extends Integer> entry) { if(filterType == -1) return true; ResultTableModel rtm = entry.getModel(); int row = entry.getIdentifier(); int type = rtm.getTypeAt(row); if(type == filterType) return true; return false; }
9891a7b8-b3c0-4f06-820c-2c1e1f5339a9
0
public ProcessedCell getPrevCell(){ return prevCell; }
d28a76ee-accb-4bbb-bbea-0f554045b6d6
7
private void insertFixUp(NoeudRN z) { while (z != racine && z.getPere().getCouleur() == Couleur.Rouge){ if(z.getPere() == z.getGrandPere().getGauche()){ NoeudRN y= z.getGrandPere().getDroit(); if(y.getCouleur() == Couleur.Rouge){ z.getPere().setCouleur(Couleur.Noir); y.setCouleur(Couleur.Noir...
fa675eab-0cd3-4345-8c0d-d09decf4e421
2
public static void adjustWeights(List<ObjFunc> ofs) { int noOf = ofs.size(); for (ObjFunc of : ofs) { if (Double.isNaN(of.getWeight())) { of.setWeight((double) 1 / noOf); } } }
8a026ef7-2e3b-4f58-93e7-ffef5d137d17
3
public boolean rosterExists(Date toDate) { if (startDate.getTime() == null) throw new InvalidQueryException("Nonexistent route"); rosterIDs = database.busDatabase.select_ids("service_id", "roster", "weekStart",toDate, "service_id"); if(rosterIDs.length > 0) return true; else { RosterM...
f30fbbf1-5d09-42e5-b4de-c12360ceca9f
8
public void updateTextPanel() { textPanel.removeAll(); studentMsg.removeAll(); studentMsg=new JPanel(); if(Integer.parseInt(studentNumberComboBox.getSelectedItem().toString())<5 || Student.studentListText.size()<=5) studentMsg.setLayout(new GridLayout(5,1,10,5)); else studentMsg.setLayout(new BoxLayout...
85fe5257-cd03-4b7a-82a6-96225e56f65f
9
private void compareIvos152V155(PrintWriter outFile) { boolean noExceptions = true; // outFile.printf("%s enter compareIvos152V155%n", TAG); // outFile.flush(); outFile.printf("%n********** ********** ********** "); outFile.printf("********** ********** **********%n%n"); outFile.printf("Listin...
0ea7331f-54b1-40bc-b448-1d942740c219
0
@Test public void isEmptyReturnsTrueWhenEmpty() { assertTrue(q.isEmpty()); }
a271495a-6a53-46ab-acb8-f19acf5c397e
4
public static void UpperName(){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try{ conn.setAutoCommit(false); PreparedStatement stmnt ...
37bf1b16-a6eb-4842-9a09-f18241cf61fd
5
public Object getValueAt(int row, int col) { Account account = accounts.getAccounts(accountTypes.getBusinessObjects()).get(row); if (col == 1) { return account.getType(); } else if (col == 2) { AccountType type = account.getType(); BigDecimal saldo = account.getSaldo(); if(type.isInv...
83da65c5-f6c4-4012-9ff8-70fa5db9c679
2
public Quaternion nlerp(Quaternion dest, float lerpFactor, boolean shortest) { Quaternion correctedDest = dest; if (shortest && this.dot(dest) < 0) correctedDest = new Quaternion(-dest.getX(), -dest.getY(), -dest.getZ(), -dest.getW()); return correctedDest.sub(this).mul(lerpFactor).add(this).normalized(); }
71a4e83c-6cf3-4400-8d15-74f78967f1d9
5
public void characterSound() { if (selection == 1) { Greenfoot.playSound("Sound//White//whiteChosen.mp3"); } else if (selection == 2) { Greenfoot.playSound("Sound//Bond//bondChosen.mp3"); } else if (selection == 3) { ...
0ce77b8e-d654-44b5-aa83-c8257fa0b47b
4
public JSONObject toJSONObject(JSONArray names) throws JSONException { if (names == null || names.length() == 0 || this.length() == 0) { return null; } JSONObject jo = new JSONObject(); for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this....
20f9301a-7f92-4bdc-b151-f141e9312c1f
7
public void setZeroes(int[][] matrix) { Set<Integer> rows = new HashSet<Integer>(); Set<Integer> cols = new HashSet<Integer>(); for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[0].length; j++) { if (matrix[i][j] == 0) { rows.add...
3cdcea30-f470-4949-ae88-46d65d76abf5
8
public byte[] ReceiveByte() { // Prep int read = 0; byte[] fetched = null; int sleepFOR = 25; // a very small fraction of a second int sleeptFOR = 0; // sleep counter // Wait (block) for data try { while (receive.available() == 0) { try { Thread.sleep(sleepFOR); } catch (InterruptedExcept...
0ec1e961-3ae6-4367-bd24-7c2361c30e84
0
public String getMajor() { return major; }
05817240-901b-4a16-a2d6-c5731730889b
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...
30296c36-65bb-4ec8-9acc-95b212ddbda3
6
public boolean remove(int key) { int index; Element element = elements.get(key); if (element == null) { return false; } if (elements.remove(key) == null) { return false; } for (Integer destination : element.getConnections()) { elements.get(destination).removeConnection(key); } CompoundEdi...
175c402c-08a4-4d31-bdb6-c7eb8ee8adc1
7
public static int optimize(Map<Integer,ZState> states){ //FIXME не реалізовано int power = 0; for (ZState state : states.values()) { if(state.fromConnections.size() > 1){ for (int i = 0; i < state.fromConnections.size(); i++) { Connection curr = st...
be23bd04-37b0-4960-a655-3304066ef994
3
public static void analyze(String songName, int CHUNKSIZE){ Score song = new Score(); Read.midi(song, songName); Part[] songParts = song.getPartArray(); int i=0; for(Part curPart:songParts){ int j=0; Phrase[] phrases = curPart.getPhraseArray(); for(Phrase curPhrase: phrases){ int offset = 0; ...
46889f1c-2e9a-46e7-a684-b35fd9f84d65
2
private CardPower isFlush(CardGroup[] signGroups) { if (signGroups[0].cards.size() >= 5) { CardPower power = new CardPower().add(5); for (int i = 0; i < 5; i++) { // only the highest cards of the flush power.add(signGroups[0].cards.get(i).value.ordinal()); } return power; } else { return null; ...
0ead9032-3e09-463d-b293-f78d42d5f785
4
@Override public void createMap() { int random; Colour[][] tiles = new Colour[getSize()][getSize()]; int waterCount = 0, area = getSize() * getSize(); int waterLimit = (int)(area * 0.1); Random rand = new Random(); for (int i = 0; i < tiles.length; i++) { for (int j = 0; j < tiles[i].length; j+...
992adb7e-1e5c-400c-9559-613029026b6f
3
@Override public void actionPerformed(ActionEvent e) { if(e.getSource() == this.addBtn) { try { this.model.addNewItem(); this.table.repaint(); } catch(Exception exception) { JOptionPane.showMessageDialog(this, Utilities.getStackTrace(exception), exception.getMessage(), JOptionPane.ERROR_MESSAGE); ...
ad47c9f3-bf88-471a-8af4-1c366db10bb2
3
public int getNodeMaxDepth() { int maxnodedepth = 0; ArrayList<TreeNode> tips = this.getTips(); for (int i = 0; i < tips.size(); i++) { TreeNode curnode = tips.get(i); int tnodedepth = 0; while (curnode != this) { tnodedepth += 1; curnode = curnode.getParent(); } if (tnodedepth > maxnodedep...
734dfde1-1283-4bf7-a9b6-465843d2ddfa
6
private String getComverMover(int fila, int columna, int turno){ if(this.fila==fila){ if(this.columna>columna||this.columna<columna) return getTorre(turno); }else if(this.columna==columna){ if(this.fila>fila||this.fila<fila) return getTorre(turno); ...
3a7fea05-e9b7-4f33-9b10-31daa937d2f4
4
private FileEntry getFile(String dest) { FileEntry fe = null; for(int i=0; i<files.size(); i++) { fe = files.get(i); if(fe.dest.equalsIgnoreCase(dest)) { break; } } if(fe!=null) { if(!fe.dest.equalsIgnoreCase(dest)) { ...
99ecb9f3-5dc5-45b6-b1e9-e9a21e472e3b
1
public void dispose() { // Method to close the open device if (captor != null) { System.out.println("Captor - " + captor); captor.breakLoop(); captor.close(); // Closes the device } isDisposed = true; }
b856dee5-ad6b-48e9-9c14-532aef15e756
3
public static void move(int column) { switch(column){ case 0: cell0 = MainClass.currentXorO + "|"; break; case 1: cell1 = MainClass.currentXorO; break; case 2: cell2 = "|" + MainClass.currentXorO...
bfb07403-ae2f-4249-b605-363258e50cf1
6
private void updateTracePanel() { synchronized (newAlerts) { for (Alert alert : newAlerts) { try { if(!isAlertVisible(alert)) { //If not visible, skip this alert in the loop continue; } //Pick a style to print with Style styleToPrint = null; switch (alert.level) { case ERRO...