method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
855b4acd-50f9-41d3-a2b1-37db096c0c0a
4
public boolean typeString(String op1, String literal1, String op2, String literal2){ if (literal1.equals(literal2)){ if (op1.equals(op2)){ return true; }else{ return false; } }else{ //if (!literal1.equals(literal2)){ if (op1.equals("=") && op2.equals("=")){ return false; }else{ return...
dca8071f-0442-4b89-8347-acf6ebaedcb7
6
public int getAmicableSum(int limit){ HashSet<Integer> set=new HashSet<Integer>(); for(int number=1;number<limit;number++){ if(set.contains(number)) continue; Unit unit1=getDivisors(number); if(unit1.sum<limit&&unit1.sum!=number){ Unit unit2=getDivisors(unit1.sum); if(unit2.sum==number){ s...
d0020c69-d891-4197-a9d1-41f0ea2fdb4f
5
public String stOpenBrowserInstance (int dataid,int expVal, String flow){ int actVal=1000; String returnVal=null; hm.clear(); hm=STFunctionLibrary.stMakeData(dataid, "Post"); String url = hm.get("URL"); String newwindowtitle = hm.get("NewWindowTitle"); try { Block : { ...
4b736a32-fbf0-47d8-929e-2fc5254dd823
4
boolean dinicBfs(int src, int dest, int[] dist) { Arrays.fill(dist, -1); dist[src] = 0; int[] Q = new int[V]; int sizeQ = 0; Q[sizeQ++] = src; for (int i = 0; i < sizeQ; i++) { int u = Q[i]; for (Edge e : ady[u]) { if (dist[e.t] < 0 && e.f < e.cap) { dist[e.t] = dist[u] + 1; Q...
ee31846a-3309-41be-ade8-ab8a68db3ade
7
private boolean isValidLocation(int tileId) { int x = tileId % size_x; int y = tileId / size_y; if (x < 0 || x >= size_x) { return false; } else if (y < 0 || y >= size_y) { return false; } else if (y == size_y - 1 && x % 2 == 1) { return false...
6996131e-018e-465e-ba6c-6e8fc48f43f9
3
public Process remove(long id) // Remove process from the list. { Process p = find(id); if(p != null){ if(p == peek()){ //if head make new head head = p.next; head.previous = null; return p; }else if(p == tail){ //if tail make new tail p.previous = tail; p.previous.next = null; ...
a4cea57e-d7f3-4e5b-a23b-6c122774567a
0
public DebuggerVirtualMachine(Program program, Collection sourceLines) { this.program = program; this.sourceLines = (List<SourceLine>) sourceLines; setBreakableLines(); this.restart(); }
d0edc10a-15b0-42d0-a7b6-b506340ba091
0
public EnvironmentFrame getEnvironmentFrame() { return myEnvFrame; }
269e5e74-1aea-43f2-898b-443c73c23332
7
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Notification that = (Notification) o; if (message != null ? !message.equals(that.message) : that.message != null) { return false; } if (title != null ? !...
dba5f6d3-0db3-4c03-8b0e-7c5919c422bc
4
public static void main(String args[]) { EventQueue.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { ...
54ebf63f-b723-4c40-99b1-6e46068e6766
1
public double[] nextDoubles(int n) throws IOException { double[] res = new double[n]; for (int i = 0; i < n; ++i) { res[i] = nextDouble(); } return res; }
f175d160-20ef-44cc-8444-fe06ddba11d9
4
private void loadID3v2(InputStream in) { int size = -1; try { // Read ID3v2 header (10 bytes). in.mark(10); size = readID3v2Header(in); header_pos = size; } catch (IOException e) {} finally { try { // Unread ID3v2 header (10 bytes). in.reset(); } catch (IOExcepti...
8926948a-6661-41de-9f71-d0c70b1a9a6f
0
@Column(name = "person_id") @Id public int getPersonId() { return personId; }
0445053c-2364-4943-a143-d097b6cbce14
5
private void handleItemPickup(Message m, GameSession s) { final Player p = s.getPlayer(); int x = m.readShortA() & 0xFFFF; int y = m.readShort() & 0xFFFF; final RSTile location = RSTile.locate(y, x, s.getPlayer().getLocation().getZ()); final int id = m.readLEShortA() & 0xFFFF; final GroundItem i = World.get...
83d89c1f-0437-4215-bf22-53b995df2412
2
public void visit_astore(final Instruction inst) { // When we store an object to a local variable, we need to keep // track of whether or not the object being stored (and hence the // variable into which it is stored) is preexistent. final LocalVariable var = (LocalVariable) inst.operand(); final HashSet set ...
4a520a68-f3f2-484e-a5cf-7febd3cbea43
3
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { args = CommandLineTokenizer.tokenize(args); if (sender instanceof Player) { xAuthPlayer p = plugin.getPlyrMngr().getPlayer((Player) sender); String response = null; if (p.isAuthenticated()) { boolean succes...
b5f8b7b8-66a3-4391-9db6-079be2391212
9
public ArrayList<Blockelement> regelmaessigeBlockelement( Umlaufplan umlaufplan, Fahrplan fahrplan) { ArrayList<Blockelement> blockelementList = new ArrayList<Blockelement>(); for (int j2 = 0; j2 < umlaufplan.getFahrtZuUmlauf().size(); j2++) { if (umlaufplan.getFahrtZuUmlauf().get(j2).getElementType() == 1)...
d28c7876-5bcf-4cd7-80a4-0c4f249fa11b
9
private static boolean canAttributeValueBeUnquoted( final char[] buffer, final int valueContentOffset, final int valueContentLen, final int valueOuterOffset, final int valueOuterLen) { if (valueContentLen == 0 || valueOuterLen == valueContentLen) { // Cannot be u...
4a771d9c-2a90-42f1-ada5-3bc29d7885dc
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...
1a61e160-ba2c-41f9-8f2f-ce91d3ae0166
0
public void setBreakpoint() { breakpointSet = true; }
c8df7a8e-24b4-4791-a1f6-31ba8d55b96e
9
private void method37(int arg0) { if (!Client.lowMem) { if (Rasterizer.texturePriorities[17] >= arg0) { IndexedSprite indexedSprite = Rasterizer.textures[17]; int k = indexedSprite.width * indexedSprite.height - 1; int j1 = indexedSprite.width * anInt9...
94694595-1c6b-45bf-8e14-2011b946c204
3
public void display() { // EXTRA: Make it so that when you hover over a valid target it shows you the path to it. for (Tile tile : validTargetPaths.keySet()) { tile.setBackground(PropertiesLoader.getColour("target_tile")); } for (Tile tile : invalidTargets) { tile.setBackground(PropertiesLoader.getColo...
f2c7f33c-b7fd-43af-9dd9-048487a0ba04
4
private void handleSettingsInput(StateBasedGame game, GameContainer container) { //handleGraphicsScale(container); //TODO handleSpeedModifying(container); if(container.getInput().isKeyPressed(Input.KEY_ESCAPE)){ container.exit(); } if(container.getInput().isKeyPressed(Input.KEY_M)){ Sounds.toggleM...
ddfd2bb6-807f-4761-b646-9dfd73dea989
3
public Integer getNumber(ConnectionWrapper cw, String name) throws SQLException { if(name == null) { return null; } Integer res = nameToNumber.get(name); if (res == null) { // has an unknown name appeared in the database? loadData(cw); res = nameToNumber.get(name); if (res == null) { ...
96319723-b5db-45cd-ad52-c852bf1b2406
0
public PrioritizedTask(int priority) { this.priority = priority; sequence.add(this); }
77e65768-441c-442c-9808-17d626d8671f
9
public int candy(int[] ratings) { if (ratings == null || ratings.length == 0) { return 0; } int[] candies = new int[ratings.length]; Arrays.fill(candies, 1); for (int i = 1; i < ratings.length; i++) { if (ratings[i] > ratings[i - 1] && candies[i] <= candie...
353baad1-16ed-4db6-be2b-b5b7cbe230cc
9
private static int editDistanceTranspose(CharSequence cSeq1, CharSequence cSeq2) { // cSeq1.length >= cSeq2.length > 1 int xsLength = cSeq1.length() + 1; // > ysLength int ysLength = cSeq2.length() + 1; // > 2 int[] twoLastSlice = new int[ys...
c529e1d1-80d8-4bd0-ac0b-7d9957f58dc5
1
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } GUI gui = new GUI(); gui.open(); }
fdbf9f9c-0f10-4df5-9548-89747e84d30e
4
private JPanel createPanel() { //Create and populate the panel. panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JPanel containerUsername = new JPanel(new FlowLayout()); JLabel labelUsername = new JLabel("Username", JLabel.TRAILING); contain...
4a1d24b1-1d83-4454-965d-00c099367d4c
9
public static List<TipoClasificacion> listaDeClasificaciones() { try { conexion = DataSourceFactory.getMySQLDataSource().getConnection(); } catch (SQLException sqle) { System.out.println("Error: " + sqle); } TipoClasificacion tipoClasificacion; List<Ti...
52f4df40-a8c7-4740-a4a8-d2bf7a92add5
9
public static int splitByLine(File sourceFile, File targetDir,int rows) { int ret=0; if (!sourceFile.exists() || rows <= 0 || sourceFile.isDirectory()) { System.out.println("源文件不存在或者输入了错误的行数"); return -1; } if (targetDir.exists()) { if (!targetDir.isDirectory()) { System.out.println("目标文件夹错误,不是一个文件...
efe3136a-2250-467f-9d7a-90a5252e3689
4
public List<List<String>> solveNQueens(int n) { List<List<String>> res = new LinkedList<>(); if(n<=0){ return res; }else if(n==1){ List<String> l = new ArrayList<String>(1); l.add("Q"); res.add(l); return res; } int half = n/2; for(int i=0;i<half;i++){ for(int j=0;j<half;j++){ nqueen(g...
99c96daa-a1e6-4dca-ba87-466a93d33f5b
1
public JSONObject getJSONObjectItem(String... names) throws ReaderException { Object result = getItem(names); if (result instanceof JSONObject) { return (JSONObject) result; } throw new ReaderException("No key exists with this type, keys: " + _parseMessage(names) + ". In file: " + ConfigurationManager.con...
e3761532-0dc2-4573-97d2-480c9f1e82a6
9
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("bang")) { if (!(sender instanceof Player)) { sender.sendMessage("This command can only be run by a player."); } else { ...
384e433f-ebbd-4218-9db1-f5b50152cab0
9
private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); } else { jj_lastpos = jj_scanpos = jj_scanpos.next; } } else { jj_scanpos = jj_...
60220afb-a530-4dee-b474-4da0cb7b8bf7
7
public static void main(String[] args) { ExecutorService executor = Executors.newSingleThreadExecutor(); Future<?> future = executor.submit(new Callable<Object>() { public Object call() throws Exception { System.out.println("Starting things..."); try { Thread.sleep(5000); } catch (Interrupt...
2104d6fe-540b-466b-8e83-b72668c1f980
6
public void playerMessageToClan(int playerId, String message, int clanId) { if (clanId < 0) return; if (Connection.isMuted((Client)Server.playerHandler.players[playerId])) { Client c = (Client)Server.playerHandler.players[playerId]; c.sendMessage("You are muted and are not permitted to speak!"); return;...
ffec7cdd-153d-4865-858e-0a893c2d9fee
1
public Menu(Cong cong){ this.cong = cong; // load the menu spritesheet try{ ss_image = loader.loadImage("/sprite_sheet_menu.png"); ss = new SpriteSheet(ss_image); } catch(IOException e){ } // build the menu for the current state r...
d10dd213-600b-442d-b3a4-0f2de5eabc97
8
protected boolean getSubCommand(CommandSender sender, String[] args) { if (args.length == 1) { sender.sendMessage(getMessage("Message16")); } else if (args.length > 1) { if (args[1].equalsIgnoreCase("entrada")) { if (!(sender instanceof Player)) { ...
a7b33a22-b9ef-4f51-a967-158bdd8df60c
3
private void autonomous() { double rotation = autoTurn; double[] speeds = new double[]{ rotation*RobotMap.wheelSpeedEdit,-rotation*RobotMap.wheelSpeedEdit,rotation*RobotMap.wheelSpeedEdit,-rotation*RobotMap.wheelSpeedEdit }; if(rotation != 0) for(int i = 0; i < ...
ad8cec60-4778-470d-b63f-2739036e1b85
4
public static boolean estPositionValide(Position position){ if(position.travee >= 0 && position.travee < Parametres.NB_TRAVEES && position.rangee >= 0 && position.rangee < Parametres.NB_RANGEES){ return true ; } else { return false ; } }
d2086b8d-6651-470e-8014-4919e8d3e12a
6
public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Pair)) return false; @SuppressWarnings("unchecked") final Pair pair = (Pair) o; if (first != null ? !first.equals(pair.first) : pair.first != null) return false; if (second != null ? !second.equals(pair.second...
d3fd7b68-366b-4d97-9722-dfe44fbf0792
3
public void visit_aupdate(final Instruction inst) { Integer depth = (Integer) inst.operand(); if (Tree.AUPDATE_FIX_HACK) { // Hack to fix a bug in old bloat-generated code: if (depth.intValue() == 1) { final Expr object = stack.peek(); if (object.type().isWide()) { depth = new Integer(2); ...
baf342b5-41bc-4d73-a96e-c6d94ccee06a
9
public static IntNode generate(int mindepth, int maxdepth) { if (maxdepth < mindepth || maxdepth <= 0) return null; IntNode root = null; int possibilities; if (mindepth > 0) possibilities = randInt(2) + 1; else if (maxdepth == 0) possibilities ...
a1069e60-d551-4786-9a55-7ccbc7758749
6
public boolean loadMap(File mapFile) { // removes all the obstacles already loaded obstacles.clear(); // loads the new obstacles try { FileInputStream inStream = new FileInputStream(mapFile); BufferedReader lineReader = new BufferedReader(new InputStreamReader(inStream)); String docLine; // Check ...
a62eaf1a-2722-4a07-b55b-5f1a5de0e019
6
@Override protected Value evaluate(ExecutionContext context) throws InterpretationException { Value val1 = ((AbsValueNode) this.getChildAt(0)).evaluate(context); Value val2 = ((AbsValueNode) this.getChildAt(1)).evaluate(context); if (val2.getType() == VariableType.STRING) { if ...
856e3a6c-39b3-49ae-accc-e11f2b8d4c6f
7
private void readContent(/*Element element*/ ) throws ParseException, IOException { readPossibleCharData(/*element*/ ); boolean keepGoing = true; while (keepGoing) { if (isETag()) keepGoing = false; else if (isReference()) { // appendText( element, readReference() ); ...
a7c25e61-eeae-46cf-9d4a-2fb652c46777
8
private void buildData(URL[] urls) { data = new Object[urls.length][columnNames.length]; for (int i = 0; i < urls.length; i++) { for (int j = 0; j < columnNames.length; j++) { switch (j) { case 0: data[i][j] = new Integer(i + 1); ...
21a95b8b-c5a2-4584-9ff7-6e3e9c9d7159
7
@SuppressWarnings("rawtypes") private static String select_login() { String result = null; System.out.print("available login: "); Map<String, UserManager.User> users = UserManager.getInstance().users(); Iterator it = users.entrySet().iterator(); int i = 0; while (it.hasNext()) { Map.Entry pairs...
32f43bde-6ace-4fff-a14a-0594cc56f8a5
6
public MIDletData getMIDlet(int i) { String value = getValue("MIDlet-" + i); if (value == null) return null; int p1 = value.indexOf(','); String name = null; String icon = null; String cls = null; if (p1 != -1) { name = value.substring(0, p1).trim(); int p2 = value.indexOf(',...
2dacebf4-ecb7-435f-95c7-4e3e655612b3
2
private ArrayList<String> getSentences(String[] input, HTMLDocument doc) throws BadLocationException { ArrayList<String> result = new ArrayList<String>(); for (String word : input) { result.add("Sentences that contains " + word); Pattern pattern = Pattern.compile("([^.\\n]*\\b(" ...
b9048339-5818-43c8-a41c-293be4820ff3
5
public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case FIRST_NAME: return isSetFirstName(); case LAST_NAME: return isSetLastName(); case STATUS: return isSetStatus(); case ID: return isSetId(); ...
2bc6fcf4-0881-4046-a8e3-c38cd449a57f
2
public void update(InputHandler inHandler){ if(getLifeTimer().isReady()){ if(lifeCounter<2){ setWidth(getWidth()+15); lifeCounter++; setLifeTimer(new Timer(getIntervall())); }else{ Level.entities.remove(this); } } setX_Point(getPlayer().getX_Point()+ (getPlayer().getWidth()*Math.max(...
e86a05e8-5823-4a33-a107-843ec38373bb
3
public boolean isClassInjected(Class<? extends Injectable> clazz) { for (Injectable i : getInjected()) { if (i.getClass().getName().equalsIgnoreCase(clazz.getName())) { return true; } } return false; }
e8a16401-d825-4339-a2d6-4ee1d33e2fcc
9
@Override public void endElement (String uri, String localName, String qName) { if (qName.equals("title")) { entry.setTitle(accumulator.toString()); } else if (qName.equals("login")) { entry.setLogin(accumulator.toString()); } else if (qName.equals("password...
351a44ee-d65d-49fc-bff6-6c370e8807bd
9
private void setNextTokens(int nextType, int[][] nextTokensPosition, TokenNext[][] nextTokens) { switch (nextType) { case 1:// the I token setPositionForCase1(nextTokensPosition, 0); break; case 2:// the J token setPositionForCase2(nextToke...
d7f982ff-cbd8-4dbf-810c-db039b46fc4a
2
public static void AddUserName(String userName) throws Exception { ClientGUI.userName = userName; ClientGUI.userNameLabel.setText("Username: " + userName); ClientGUI.mainWindow.setTitle("Cr@p Talk: "+ userName); StringBuilder users = new StringBuilder(); users.append("#?!"); for(User a: mapTest.values(...
d9630a61-959a-428e-993c-c9e456c8aec1
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...
fc317b86-ac24-4221-bb88-d30955feb966
2
public int getOrdnung() { int ordnung = 0; if(left != null) { ordnung ++; } if(right != null) { ordnung++; } return ordnung; }
97b663f9-a838-4ce8-b7c3-d84743c27af3
3
public double dameGananciaMedia(Nodo n) { int ganancia = 0; int num = 0; for (Nodo ady : memoria.getAdjacents(n)) { if (!ady.isEstimacion()) { ganancia += ady.ganancia; num++; } } if (num != 0) { return ganancia / num; } return 0; }
18473b65-73b2-4723-b5c0-a905a20a5fa3
7
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { HttpSession sesionOk = request.getSession(); if (sesionOk.getAttribute("usuario") != null) { response.setContentType("text/html;charset=UTF...
81ec15cd-3d2f-4f65-b83e-9694f1bd7ff6
4
@Override public void paintScreen(){ Graphics g; try{ g = panel.getGraphics(); if(g != null && dbImage != null){ g.drawImage(dbImage, 0, 0, pWidth * StatePanel.SCALE, pHeight * StatePanel.SCALE, null); } if(g != null) g....
3aeb7b69-ff68-4755-b241-68000d1f77be
1
public void registerContent(Content content){ if(initialized)throw new IllegalAccessError("Content must be started before Content is initialized"); this.content.add(content); }
d462f1fa-10fa-4048-838c-9a08ce252b66
5
public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); d: do { line = br.readLine(); if (line == null || line.length() == 0) break d; if (line.startsWith("|")) ...
413e4feb-eec3-46df-8103-60165e92b62d
7
public void paintComponent(Graphics g) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); if (backgroundImage != null) { int imax = getWidth() / iconWidth + 1; int jmax = getHeight() / iconHeight + 1; for (int i = 0; i < imax; i++) { for (int j = 0; j < jmax; j++) { backgr...
5ac6cef7-9218-4f3a-a54b-664410317f21
4
@SuppressWarnings("unchecked") private void rehash() { int newBuckets = nBuckets*2; ListNode<T> newHtbl[] = new ListNode[newBuckets]; for(int i=0;i<newBuckets;i++) { newHtbl[i] = new ListNode<T>(); } for(int i=0;i<nBuckets;i++) { ListNode<T> curreNode = htbl[i]; if(curreNode == null) ...
ee42e4e8-f509-41cb-93b9-97d182fd3283
1
@Test @Ignore public void test_PersonalEventsPost() { PersonalEventList laPEList = new PersonalEventList(); PersonalEvent laPE = new PersonalEvent(); laPE.setId("");// pd_id: // 20120122185840014954000000 laPE.setDate("2010-10-22"); // laPE.setDate("2011.10.05"); laPE.setStartTime("3:00 PM"); // laPE...
79c4b815-ec41-4bb2-9ad9-34d53b4137f7
8
public int store(char[] word, INFO inode) { int child_index, new_index; int i, j; int widx; TNODE parent; if(word.length == 0) { return -1; } // it first searches the trie structure with the word search(word); // it stores the part of the word not in the structure widx = search_end; if (...
7855027a-6dfa-4138-b4a7-cfc9351a7395
3
private int goTo(int index) { int state = state(); int low = 1; int high = gotoTable[index].length - 1; int value = gotoTable[index][0][1]; while(low <= high) { // int middle = (low + high) / 2; int middle = (low + high) >>> 1; if...
1f0f2e54-7789-4834-ab21-a0bdef6ea3ce
4
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((datum == null) ? 0 : datum.hashCode()); result = prime * result + genreNr; result = prime * result + ((prijs == null) ? 0 : prijs.hashCode()); result = prime * result + ((titel == null) ? 0 : titel.hashCode(...
9d19f466-2fac-47e2-9e65-87e95b7e0262
7
public void endTurn( Player player, int space ){ // Check to see if player passed in was the active player // If player passed in was active player, check for multiple // jump (space is none negative) if ( activePlayer == player ){ // Inform the player that the move was not valid, // or to make ant...
303982a0-a79d-4e34-95d5-1db16dbadd8c
8
@Override public final void mouseDragged(MouseEvent me) { int sliderIndex = 0; for (TButton slider : sliders) { if (slider.inUse) if (orientation == VERTICAL) { slider.y = me.getY() - 12.5f; if (slider.y < y) slider.y = y; else if (slider.y > y...
53f4a542-8463-4dec-abb6-9dd5902a3b4f
0
public String toString() { return String.format("%2d : %s", getSuppliercode(), getName()); }
1a4a8c0a-402d-4b80-b649-45c644b36033
2
@Override public Component getListCellRendererComponent(JList<? extends ICPBrasilCertificate> jlist, ICPBrasilCertificate e, int i, boolean isSelected, boolean isHasFocus) { JLabel label = (JLabel) cellRenderer.getListCellRendererComponent(jlist,"", i, isSelected, isSelected); //JLabel label = new J...
595b2836-e825-4bd3-97cb-143e2af4a50a
1
public static void clearTable(ManageEmployeePage manageEmp){ int rows= manageEmp.getTable().getRowCount(); int i=0; while(i<rows){ manageEmp.getTable().setValueAt("",i,0); manageEmp.getTable().setValueAt("",i,1); i++; } }
5328636a-7a11-4e70-8889-1330c38e3355
9
@Override public void toggled() { if (!hasBeenOpened) { //first time openeing - set item levels to player level +3 Player p = registry.getPlayerManager().getCurrentPlayer(); for (int i = 0; i < inventorySize; i++) { int qty = inventory.getQtyF...
efe13e13-ee61-4e4a-9540-f2ecaf9b1e4d
4
private ArithmeticResult term(Block codeBlock) throws IOException, SyntaxFormatException { ArithmeticResult leftFactor = factor(codeBlock); if (leftFactor != null) { while (checkCurrentType(TokenType.TIMES) || checkCurrentType(TokenType.DIVIDE)) { TokenType op = lexer.getCurrentToken().getType(); moveToN...
a0b77123-98fd-45c5-a0d2-032b7ea7bd3c
7
protected void assertLongRangeSplit(final long lower, final long upper, int precisionStep, final boolean useBitSet, final Iterator neededBounds ) throws Exception { final OpenBitSet bits=useBitSet ? new OpenBitSet(upper-lower+1) : null; NumericUtils.splitLongRange(new NumericUtils.LongRangeBuilder() ...
bee25fc7-b047-4ad7-921c-65fc3559ce4e
5
@Override public ExecutionContext run(ExecutionContext context) throws InterpretationException { Value val1 = ((AbsValueNode) getChildAt(0)).evaluate(context); Value val2 = ((AbsValueNode) getChildAt(1)).evaluate(context); if (getChildAt(0) instanceof ThingVNode && val1.getType() == Variab...
70dfee2d-a92b-4197-9616-2d82a832b27e
3
public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } if (++bufpos >= maxNextCharInd) FillBuff(); char c = buffer[bufpos]; UpdateLineColumn(c); return c; }
bba9ee32-0355-45d4-aded-93bd647a0be5
1
@Override public E get() throws InterruptedException { lock.lock(); try { while (isEmpty()) { notEmpty.await(); } E item = (E) chairs[oldest]; chairs[oldest] = null; oldest = (1 + oldest) % chairs.length; notF...
536a9478-6ac3-4174-9a2d-6aac4eac70b7
8
int threeSumClosest (int[] num, int target) { int n = num.length, closest = 0; boolean flag = false; //if or not closest has been initialized int min, mid, max, sum; Arrays.sort(num); int k = n-1, j = k-1, i; while (k > j) { i = 0; j = k-1; max = num[k]; while (j > i && k > j) { min = nu...
3a743849-7880-4b42-a99c-a5b729630cf6
8
public int getNextAvatarIndex(int action, int currentAvatarIndex){ int x = currentAvatarIndex%8; int y = currentAvatarIndex/8; if(action==UP){ y--; } if(action==RIGHT){ x++; } else if(action==DOWN){ y++; } else if(action==LEFT){...
166d7026-3ed7-4ed1-913d-48f8fc458ce1
6
public static bNode findNextInOrderSucessor(bNode root, int origin){ //Due to the properties of a BST (left child is <= and right child is >), we can use the following algorithm: //If right subtree exists, find the left most leaf in right subtree //else backtrack upwards until you find a node su...
566fb77b-aa66-49e1-b7fb-04ed7249cfe0
0
private void setActionBox(final EventHandler<ActionEvent> event) { final HBox actionBox = super.getActionBox(); actionBox.getChildren().clear(); actionBox.setSpacing(15); Button okBtn = new Button("Yes"); okBtn.getStyleClass().add("submit-button"); okBtn.setPrefWidth(75); okBtn.setOnAction(new EventHandl...
70702a6c-e514-4f7c-aac9-0ec3be3c1138
6
public static void main(String args[]) { if(args.length == 1) { if(args[0].equals("-s")) { cmd(); } if(args[0].equals("-t")) { //runwp("wp_test"); rundir("test"); } else { usage(); } } else if(args.length==2) { ...
f0ea9a84-557b-4e5c-b83c-ec614271f2c5
1
public static long fib(int n) { if (n <= 1) return n; else return fib(n-1) + fib(n-2); }
c0d37af1-e827-46f4-bc2d-cc0722f2d6dd
9
public void setInstances(Instances newins) { m_attribIndex = 0; m_as = null; m_data = new Instances(newins); if(m_colorAttrib!=null) { m_colorAttrib.removeAllItems(); m_colorAttrib.addItem("No class"); for(int i=0; i<m_data.numAttributes(); i++) { String type = ""; switch (m_data.att...
bad671a6-440a-4545-8ed9-f508e7738fd0
8
private void createGroundImage() { // Reinitialize ground tiles Random r = new Random(); // independent final int NUM_HORZ_TILES = battleField.getWidth() / groundTileWidth + 1; final int NUM_VERT_TILES = battleField.getHeight() / groundTileHeight + 1; if ((groundTiles == null) || (groundTiles.length !=...
2e649af6-2689-4930-90df-d35aeac76dd2
1
public static void toggleMoveableAndClearText(Node currentNode, JoeTree tree, OutlineLayoutManager layout) { CompoundUndoablePropertyChange undoable = new CompoundUndoablePropertyChange(tree); toggleMoveableAndClearForSingleNode(currentNode, undoable); if (!undoable.isEmpty()) { undoable.setName("Toggle Movea...
03802a56-5473-486d-89cc-746cdcd39ba5
3
@Override public double calcula(Nodo n) { Nodo l = estado.mapa.getNode(n.id); int dist = 0; if(n.score<0){ l.score = -10; return -10; } if(visitados.contains(n)){ n.score = -5; l.score = -5; return n.score; } visitados.add(estado.getActual()); n.score = 9999; dist = this.memoria.getDi...
8b59cc46-8eb3-46a9-9c62-c857d58ad4b6
1
public static void appendError(String message) { try { console.append(message + NEWLINE); int pos = console.getText().lastIndexOf(message); console.getHighlighter().addHighlight(pos, pos + message.length(), new DefaultHighl...
8bdb5008-62d6-43eb-ab58-42af8335255f
6
@Override public void paint(Graphics g){ g.clearRect(0, 0, 670, 670); for(int i = 0; i < boardSize; i++){ for (int j = 0; j < boardSize; j++){ g.drawRect(offset+(i*squareSize), offset+(j*squareSize), squareSize, squareSize); assert board[i][j] != null : board[i][j]; if(board !=null && board[i][j]!=...
084786d8-d926-4c74-bb41-d2032957671c
2
int getNumMembers() { int numMembers = 0; memberIdList = new ArrayList<Integer>(); for (int i=0; i<memberList.size(); i++) { memberIdList = memberList.get(i); for (int j=0; j<memberIdList.size(); j++) { numMembers++; } } return numMembers; }
4ddaaf80-bbbf-41db-b661-8ca9f071476e
4
private void logErrorsRangeCheck(byte[] data) throws IOException { if (ProduceCSV.produceLog) { if (errorsRangeCheck.size() == 0) { return; } if (fileRangeCheckLog == null) { openRangeCheckLogFile(); } fileRangeCheckLo...
89453e46-003d-44fc-9c94-a2d83f467034
9
public static void main(String[] args) throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); for (String line; (line=in.readLine())!= null;) { StringTokenizer st = new StringTokenizer(line); int m = Integer.parseInt(st.nextToken(...
c6098ceb-741a-4915-9cd0-7a3317c22e29
2
public static boolean isUnix() { String OS = System.getProperty("os.name").toLowerCase(); return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0); }
23205925-1bfc-4812-8169-bcba044d2cab
2
public static Set<Integer> evenDivisors(int number){ Set<Integer> result= new HashSet<>(); int sqrt=(int) (Math.sqrt(number)+1); for(int i=2;i<sqrt;i++){ if(number%i==0){ result.add(i); result.add(number/i); } } result.add(1); return result; }
af04b5af-0cfb-445e-a9aa-cef137b8861d
6
public static String encodeData(String data) { StringBuilder buffer = new StringBuilder(); int length = data.length(); for (int i = 0; i < length; i++) { char ch = data.charAt(i); if (ch == '<') { buffer.append(LESS_THAN_ENTITY); } else if (ch == '>') { buffer.append(GREATER_THAN_ENTITY); } ...
7f1b33b1-b08f-4078-8499-27eb3f4a7e63
3
@Override public boolean authorize(AuthorizationToken token) { if (token.getType().equals(getType())) { Calendar cal = Calendar.getInstance(); if (cal.get(Calendar.HOUR_OF_DAY) > minHour && cal.get(Calendar.HOUR_OF_DAY) < maxHour) { return true; } System.out.println("Access denied."); } else { ...