method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
231548db-f322-4f7e-936c-78ff41483e23
9
private Map<Integer, Double> calcUptime(File experiment) throws Exception{ //takes in a file, creates the average of each 1m distance bucket in terms of connected or not Map<Integer, List<Integer>> values = new HashMap<Integer, List<Integer>>(); BufferedReader reader = new BufferedReader(new Fil...
3736e3a0-c68b-4738-8cc3-49471784a139
5
public static boolean matchesTypeName(Class<?> clazz, String typeName) { return (typeName != null && (typeName.equals(clazz.getName()) || typeName.equals(clazz.getSimpleName()) || (clazz.isArray() && typeName .equals(getQualifiedNameForArray(clazz))))); }
473d403d-7370-4210-a763-4a8ad07cbd0d
3
@Test public void canGetShoppingCart() { Map<Integer, Integer> sc = new LinkedHashMap<>(); try { insertShoppingCart(user1.getEmail(), prod_id1, 20); insertShoppingCart(user1.getEmail(), prod_id2, 10); sc = shoppingCart.getShoppingCart(user1); deleteShoppingCartUser(user1); } catch (WebshopAppExcept...
26d38ca7-0b05-4b01-8f03-f6a0986cffb1
0
public int getType() { return type; }
ceb19752-9ea5-4da5-818e-ed17f71af5e9
9
public String getBoardSurface() { String ret = ""; for(int y = 0; y < 9; y++) { ret += "P" + (y+1); for(int x = 0; x < 9; x++) { Player player; if (attacker.getPieceTypeOnBoardAt(new Point(x, y)) > 0) player = attacker; else player ...
463b2250-328b-44ae-bc23-284644a3bc4b
1
public void setTile(int x, int y, int num) { if(isTile(x,y)) sea[x][y] = num; }
7d9a0c8d-d5d6-4481-bee8-7ba2af4719c1
8
public AutoCompletion(final JComboBox comboBox) { this.comboBox = comboBox; model = comboBox.getModel(); comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!selecting) highlightCompletedText(0); } });...
8c7e9486-7d92-4580-afca-8cd5bf505ca2
7
private static boolean check(HashMap<String, Boolean> wordMap, String word, boolean isSub) { if (isSub && wordMap.containsKey(word)) { // don't check for the // original // word, only for sub-words System.out.println(word); return wordMap.get(word); } for (int len = 1; len < wor...
106f368d-311b-4475-a231-6b0faeaa6094
9
public static void main( String[] args ) throws InterruptedException, IOException { ExecutorService executeService = ThreadPool.getInstance().getExecutorService(); List<Future<Integer>> resultList = new ArrayList<Future<Integer>>(); //约车日期 String date = DateUtil.getFe...
1017c132-ee96-48f7-b0f1-1baae9f37559
6
public void updateTab(int alg, int alg_){ if(permutation_.get(alg).size() == 0){ for(int i = 0 ; i < tab.size(); i++){ if(tab.get(i) == alg){ tab.remove(i); } } } boolean isOnTab = false; for(int i = 0 ; i < tab.size(); i++){ if(tab.get(i) == alg_){ isOnTab = true; } } if(!isOnT...
9f21b627-8170-47b9-b3e2-aed8f671b756
9
public void close () { Connection[] connections = this.connections; if (INFO && connections.length > 0) info("kryonet", "Closing server connections..."); for (int i = 0, n = connections.length; i < n; i++) connections[i].close(); connections = new Connection[0]; ServerSocketChannel serverChannel = this.se...
474f789d-0c53-480e-a36e-186c717bfeef
7
public boolean pickAndExecuteAnAction(){ /* * if cashier has just started, go to position */ if (mOrders.size() > 0){ synchronized(mOrders) { for (MarketOrder iOrder : mOrders){ //notify customer if an order has been placed if ((iOrder.mStatus == EnumOrderStatus.PLACED) && (iOrder.mEvent == Enum...
c387dfad-44ff-4a94-9be2-7463f07ed953
2
@Override public Converter put(String key, Converter value) { Converter v = super.put(key, value); if (v != null) { throw new IllegalArgumentException("Duplicate Converter for " + key); } return v; }
271a26ae-d91d-4991-a8b6-580bbb11d899
1
public void dumpInstruction(TabbedPrintWriter writer) throws java.io.IOException { /* * Only print the comment if jump null, since otherwise the block isn't * completely empty ;-) */ if (jump == null) writer.println("/* empty */"); }
8f40ba47-ea95-48bf-853b-b3c892a92653
8
public void onKeyReleased(KeyEvent e) { switch (e.getKeyCode()) { case VK_UP: case VK_W: directions.remove(Direction.UP); break; case VK_DOWN: case VK_S: directions.remove(Direction.DOWN); break; case VK_RIGHT: case VK_D: directions.remove(Direction.RIGHT); break; case VK_LEFT: ca...
57411cf1-7ac7-4db9-bd1d-dbca4ec3c1ee
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...
815c3dbb-2145-4aa1-a6b9-56eb1f1b5642
8
public int DoSet(Pos setPos, Stone myColor, boolean provisionalFlg) { int reverseCnt = 0; // 設置可能な方向をすべて取得 ArrayList<Pos> doSetDirection = canSetDirection(setPos, myColor); // 設置可能な方向があるか判断 if (doSetDirection.size() > 0) { // 設置開始位置に一石置くため、反転カウントに1加算 reverseCnt++; if (provisionalFlg) { setColor...
c16f5305-0c68-4261-ae8d-1d6713a6d6da
1
@Override public void startSetup(Attributes atts) { String min = atts.getValue(A_MIN); String max = atts.getValue(A_MAX); String def = atts.getValue(A_DEFAULT); try { this.lowerBound = Integer.parseInt(min); this.upperBound = Integer.parseInt(max); this.defaultValue = Integer.parseInt(def); } cat...
67c0f888-d30c-490b-8c14-ce46ca9ddb38
2
@Test public void testTransform() { System.out.println("transform"); byte[] rawdata = {1,2,3,15,16}; boolean[] expResult = { false,false,false,false,false,false,false,true, false,false,false,false,false,false,true,false, false,false,false,false,false,fals...
82dce767-8126-4b5c-a6d3-cd7d532e71a7
2
private static void readData(String path) throws XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); File file = new File(path); try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { XMLStreamReader reader = factory.createXMLStream...
a6bf2f5f-c4de-443e-8dfa-373a9e496704
6
private int checkFourOfAKind(int player) { int[] hand = new int[players[player].cards.size()]; int i = 0; for (int card : players[player].cards) { hand[i++] = card % 13; } int matchCount = 0; for (int j = 0; j < hand.length; j++) { for (int k = 0; k < hand.length; k++) { if (j != k) { ...
345d0a03-5784-4cf4-b0ff-ab7e1c9587f5
6
public static void main(String args[]) throws RemoteException, MalformedURLException { /* 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 an...
68a20c62-f385-4b0f-b015-96f2f2275334
1
@EventHandler(priority = EventPriority.MONITOR) public void onSellTransaction(TransactionEvent event) { if (event.getTransactionType() != SELL) { return; } String firstLine = SELL_TRANSACTION_FIRST_LINE .replace("%client", event.getClient().getName()) ...
43b75c49-48e2-4719-b5c7-984523bd27d2
3
@Override /** * This method will be used by the table component to get * value of a given cell at [row, column] */ public Object getValueAt(int rowIndex, int columnIndex) { Object value = null; Contestant contestant = contestants.get(rowIndex); switch (columnIndex) { case COLUMN_CONTESTANT: value =...
a0dd38e0-c3f8-45d2-8acb-834370d52410
8
@Override protected void fixAfterInsertion(N x) { x.setColour(RED); while (x != null && x != getRoot() && x.getParent().getColour() == RED) { if (parentOf(x) == leftOf(parentOf(parentOf(x)))) { N y = rightOf(parentOf(parentOf(x))); if (colorOf(y) == RED) { s...
4e7511a5-614b-4c7e-9b09-300a43e831a4
4
@SuppressWarnings("static-access") @EventHandler(priority = EventPriority.HIGH) public void onMobDeath (EntityDeathEvent event) { Entity entity = event.getEntity(); World world = event.getEntity().getWorld(); if (entity instanceof Skeleton) { Skeleton lich = (Skeleton) entity...
06db966b-54f1-4497-a2e1-4e9bba4ed180
6
private void verifyEntry(Entry entry) { for (Object key : entry.getExtensionAttributes().keySet()) { QName qname = (QName) key; // Foundation 1.9 assertEquals(NAMESPACE, qname.getNamespaceURI()); } // Atom 2.2 assertTrue(entry.getId().toString...
b04bf897-8bdf-48b3-8921-edcd305c0d4d
9
public void setAction(final Action action) { if (this.action != null) { removeActionListener(this.action); action.removePropertyChangeListener(this); } this.action = action; String imgName = LARGE_ICONS.equals(iconDisplay) ? (String) action.getValue(Action.IMAGE_PATH) : ( SMALL_ICONS....
fc086334-acf9-4fb2-b674-4e3828b1571c
6
private static HashMap<String, HashMap<String, Double>> getMap() throws Exception { BufferedReader reader = new BufferedReader(new FileReader(ConfigReader.getMbqcDir() + File.separator + "dropbox" + File.separator + "raw_design_matrix.txt")); HashMap<String, HashMap<String, Double>> map =new LinkedHa...
dbc0d1be-0968-4af8-90d7-32360484b5a9
4
public Obstacle(){ super((Math.random()*Board.getWIDTH()-Board.robots.get(0).getWidth()), (Math.random()*Board.getHEIGHT()-Board.robots.get(0).getHeight()), 0.0f); switch(Board.getTheme()){ case "Desert": ii = new ImageIcon(this.getClass().getResource("/resourc...
5c5b67ee-514c-49c5-a667-805e9502a0c8
9
protected void handleTaskSubmittedRequest(Runnable runnable, Address source, long requestId, long threadId) { // We store in our map so that when that task is // finished so that we can send back to the owner // with the results _running.put...
35a330a2-7d7d-4f5b-a20d-33c6607672ee
8
public void listShowTimes() { int index = 0; _showTimes = new ArrayList<ShowTime>(); // To be used for update and remove showTime System.out.println("ShowTimes"); System.out.println("========="); for(Cineplex cineplex: cineplexBL.getCineplexes()) { List<Movie> movies = cineplex.getMovies(); if(movies...
38db0221-2982-4341-9cd3-bdfce993ae21
0
public void actionPerformed(ActionEvent event) { Universe.frameForEnvironment(environment).save(true); }
2a1e2fb9-be2d-42d4-a928-a7c406f748f6
5
@Override public String saveNewAlbum(Album album) throws RemoteException { try { List<Album> albums = getAlbums(); album.setUuid(UUID.randomUUID().toString()); List<Artist> artists = getArtists(); Artist artist = null; for (Artist artist1 : artist...
55628d45-d9c9-48a8-bb18-2c612107ac0b
5
private void doUrls(Document oDoc) throws ForceErrorException, SQLException { // TODO StringIndexOutOfBoundsException Elements oLinks = oDoc.select("a[href]"); HashMap<String, Link> links = new HashMap<String, Link>(); int counter = 0; for (Element oLink : oLinks) { counter++; if (counter > Bot.ma...
e95243be-43b7-45c0-a564-67a293fc6f28
5
public static final HashMap<String, Course> loadCourseCatalog() throws IOException { LOGGER.log(Level.INFO, "Loading course catalog.."); HashMap<String, Course> courses = new HashMap<String, Course>(); JSONParser parser = new JSONParser(); File[] files = new File(COURSE_ROOT).listFiles(); for (File file :...
8985fcca-3a83-4178-b49e-495fb37db4de
0
public String getTime() { return time; }
e0e241be-6ad1-42ab-9936-470538e814dc
1
private void closeStatement(Statement statement) { try (Connection connection = statement.getConnection();) { connection.commit(); statement.close(); connection.close(); } catch (SQLException e) { e.printStackTrace(); } }
6c10bc3d-8ccc-49ea-aa88-84bdc7b734c8
9
public int[][] makeReflection(int img[][], int kernel) { for (int i = 0; i < img.length; i++) { for (int j = 0; j < img[i].length; j++) { //---- Top ----// if (i == 0) { int a = i+2; //if(a>9) a=9; if(a>im...
d126f9fe-37bc-471b-abd2-967a29784569
3
@Override public void run() { try { bw = new BufferedReader(new InputStreamReader( client.getInputStream())); try { while (true) { String line = bw.readLine(); server.handleMessage(clientNR, line); } } catch (IOException e) { e.printStackTrace(); } } catch (IOException e1) ...
156d73a7-e8ca-404e-9ebe-77b0d0355652
8
private void linkSrgDataToCsvData() { for (Entry<String, MethodSrgData> methodData : srgFileData.srgMethodName2MethodData.entrySet()) { if (!srgMethodData2CsvData.containsKey(methodData.getValue()) && csvMethodData.hasCsvDataForKey(methodData.getKey())) { srgM...
ade3deaa-7783-4882-b618-0e43ae85586b
9
private void validate() { if ( ( getPresentCount() != COUNT_DEFAULT ) && ( getPresentCharacters().size() > 0 ) && ( getPresentCount() != getPresentCharacters().size() ) ) { throw new IllegalStateException( "present characters size and count are unequal" ); } if ( ( ge...
ba19afdb-2c34-423c-ba3e-bcd5e7ecec8e
0
public SqlParameter(int type, Object value) { this.type = type; this.value = value; }
2c805578-2dcd-438e-a57b-5ba512ea41c0
2
public void tickDownStatuses(int currentPlayerIndex) { // Tick down all of the tile's status effects. for (TileStatus status : statuses) { status.tickDown(currentPlayerIndex); if (status.getRemainingDuration() <= 0) { statuses.remove(status); //TODO: If we had multiple statuses, then this would cause ...
0d356f62-9f16-4d2d-bb31-2fc7b2192125
1
public boolean Apagar(Endereco obj){ try{ PreparedStatement comando = banco.getConexao() .prepareStatement("UPDATE enderecos SET ativo = 0 WHERE id= ?"); comando.setInt(1, obj.getId()); comando.getConnection().commit(); return true; }ca...
011bef98-40c3-4994-97c8-7d30772a2363
5
public static void playerTurn(Scanner scan, Color player, Board board) { boolean cont = true; while (cont) { System.out.printf("Column to play %s on: ", player.getChar()); int num = 0; // Gets the players column choice and drops their token there ...
4c917b5e-3e73-46db-b376-1a854cc6438b
1
public static void main(String[] args) { int p[] = { 0, 1, 5, 8, 9, 10, 17, 17, 20, 24, 30}; TDRodCutting topDown = new TDRodCutting(10, p); System.out.println("Read as, Length of Rod : Cuts : Maximal Revenue"); for ( int i = 1; i <= topDown.n; i++) System.out.println(i + " : " + topDown.cuts[i] + " : " + t...
75e9f263-4cbb-4bc4-b890-c1abd4067682
4
@SuppressWarnings("nls") public void write(File file) { try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(file)))) { mOut = out; mDepth = 0; mOut.println("<?xml version=\"1.0\" ?>"); mOut.println("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple...
1a1ce471-a776-4886-9282-9a2c097bcaec
4
public static void main(String[] args) { ArrayList<ArrayList<Integer>> lists = new ArrayList<ArrayList<Integer>>(); lists.add(new ArrayList<Integer>()); lists.add(new ArrayList<Integer>()); setReader(); int row = 1; ArrayList<Integer> newList = lists.get(row%2); ArrayList<Integer> oldList = lists.get...
428ee148-e8de-4e7b-8701-afeb53f2b1f5
0
public LongDataType getCounter() { return counter; }
fc7d7e22-e2c3-4749-91fe-a35b6a947d15
8
public void setVisible(boolean paramBoolean) { this.Visible = paramBoolean; PhysicalObject localPhysicalObject; int i; String str; if (paramBoolean) { Enumeration localEnumeration = this.Loopers.elements();////<Vector> while (localEnumeration.hasMoreElements()) { loc...
f403dc75-5652-475f-bde3-b3eb34428726
2
public void InsertaFinal(int ElemInser) { if ( VaciaLista()) { PrimerNodo = new NodosProcesos (ElemInser); PrimerNodo.siguiente = PrimerNodo; } else { NodosProcesos Aux = PrimerNodo; while (Aux.siguiente != PrimerNodo) Aux = Aux.siguiente; NodosProcesos Nuevo=new NodosProces...
4f987c37-b5a0-47db-90e1-cd1f2dec4dfd
5
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { lbNome = new javax.swing.JLabel(); tfNome = new javax.swing.JTextField(); tfEndereco = new javax.swing.JTextField(); lbBairro ...
8745bf1e-53a7-4299-a5b4-bc101de56c57
5
public static ArrayList<MeetingRoom> searchRoomByID(String ID) { try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<MeetingRoom>...
b43d81ed-a3c4-4a4f-8e45-f45627c9f3e2
2
@Override public void parse(CommandInvocation invocation, List<ParsedParameter> params, List<Parameter> suggestions) { ParsedParameter pParam = this.parseValue(invocation); if (!params.isEmpty() && params.get(params.size() - 1).getParameter().equals(pParam.getParameter())) { ...
d3a2de9f-1ef4-4543-947c-583cd2d4a9e7
6
@Override public void keyReleased(KeyEvent e) { if ((e.getKeyCode() == KeyEvent.VK_W) || (e.getKeyCode() == KeyEvent.VK_UP)) { jumpKeyPressed = false; } if ((e.getKeyCode() == KeyEvent.VK_D) || (e.getKeyCode() == KeyEvent.VK_RIGHT)) { rightKeyPressed = false; } if ((e.getKeyCode() == KeyEvent.VK_A) || ...
d090e4b3-0ef8-47e1-ab4f-f079e08e133a
2
public static void writeElementEnd( StringBuffer buf, int depth, String line_ending, String name ) throws IllegalArgumentException { if (isValidXMLElementName(name)) { indent(buf, depth); buf.append("</").append(name).append(">"); if (line_ending != null) { buf.append(line_ending); } } el...
83be89b8-6873-44d2-82e8-4a74c4a12522
8
private boolean nextPerm(int[] inPerm){ // returns true if this was successful in finding the next permutation int[] outPerm = new int[inPerm.length]; for(int i = 0; i < outPerm.length; i++){ outPerm[i] = inPerm[i]; } // have function (incrementWolf) which returns the next wolf ID, or zero if none ...
81ecab95-df5b-490d-b954-d91bd50d0e60
5
@Override public int compareTo(HelperPoint o) { if (o.relX == relX && o.relY == relY) return 0; int f = this.relativeCross(o); boolean isLess = f > 0 || f == 0 && relativeMDist() > o.relativeMDist(); return isLess ? -1 : 1; }
d291475b-403f-481b-9256-d81105f0abbb
7
@Override public boolean fits(HasPosition p) { /* * Check if fits inside the container (i.e parent) */ if (! ( (getLeftUpperCornerX() <= p.getLeftUpperCornerX()) && (getLeftUpperCornerX() + getWidth() >= p.getLeftUpperCornerX() + p.getWidth()) && (getLeftUpperCornerY() <= ...
84a2906c-aace-4602-b6e5-cabce557845f
1
public static void main(String[] args) { for (Seasons season : Seasons.values()) { System.out.println(season.name() + " -> " + season); System.out.println("getName(): " + season.getName() + " getId():" + season.getId()); } }
97424d17-ff8c-45b7-b25f-c156aa814650
7
public static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double)o).isInfinite() || ((Double)o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); ...
71f22dc1-07ae-4a71-bb2a-3d30a21c89fb
9
private boolean evaluateMvdClause(String clause) { if (model instanceof MesoModel) return false; if (clause == null || clause.equals("")) return false; String[] sub = clause.split(REGEX_AND); Mvd.Parameter[] par = new Mvd.Parameter[sub.length]; boolean scalar = false; byte id; float vmax; String d...
2e0a90ba-392d-4790-a635-98ab9926312f
4
public boolean deleteGroup(int groupId) { Connection connection = ConnectionManager.getConnection(); if (connection == null) { logger.log(Level.SEVERE, "Couln't establish a connection to database"); return false; } TopicManager topicManager = new TopicManager(); ...
596582ee-340a-4ff8-845c-8c9c0f09323d
2
public void createTweetStruct() throws ParseException,IOException { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy"); simpleDateFormat.setLenient(true); String line = null; BufferedReader intermediateDumpReader = new BufferedReader(new FileReader(...
fa517d7f-5a41-4ef2-9f01-8de73c86329c
2
public void sortConfectionByCost() { Collections.sort(confections, new Comparator() { public int compare(Object ob1, Object ob2) { Confections co1 = (Confections) ob1; Confections co2 = (Confections) ob2; if (co1.getCost() > co2.getCost()) { ...
916c221b-3dfb-4a0d-8f40-73df57e1f01a
9
public void start(List<TickerQuotes> _quotes){ try{ System.out.println("Running Quote Thread"); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); DateFormat idateFormat = new SimpleDateFormat("HH:mm:ss"); System.out.println("STILL ALIVE");...
ccd52580-b3f7-43eb-8fa7-07439d0cc46e
0
public Integer getId() { return id; }
fe777405-6685-479b-b27a-7e5e2c7af074
4
@Override public void exec(String channel, String sender, String commandName, String[] args, String login, String hostname, String message) { try { SourceServer tf4 = new SourceServer("tf4.joe.to"); tf4.initialize(); System.out.println(tf4.getServerInfo()); th...
981f836e-ad8d-4a0a-a3d9-2c6c30958c7e
0
public void addLocation(DataPoint loc) { this.locations.add(loc); }
f105c5f6-de28-41f9-89d0-78718ec8f456
3
protected SolexaFastqParser(String id) { Matcher m = Pattern.compile(REGEX).matcher(id); // Last guard block if (!m.matches()) return; setAttribute(IdAttributes.FASTQ_TYPE, NAME); for (IdAttributes a : regexAttributeMap.keySet()) { String value = m.group(regexAttributeMap.get(a)); if (value != null) ...
2a9dbb4d-9706-4f9c-ada4-28e6ed547933
5
public void modify() throws IOException{ /*Allows user to modify Questions on a given Test. Questions are modified in the Question classes themselves. This overloaded method of Test also includes modifying of Question answers.*/ boolean repeat = true; String s; int val = 0; while(repeat){ display(); Out....
7df9c46d-c544-40a3-ab45-08f07ada6cdb
7
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
c57d97ed-18f5-4ecb-b7d5-f35b16f29787
0
@Override public int hashCode() { return (int) this.appt.getId(); }
49ee94fd-4723-47be-8dac-54c8bdd1458e
4
@Override public int hashCode() { int result = id != null ? id.hashCode() : 0; result = 31 * result + (UUID != null ? UUID.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (links != null ? links.hashCode() : 0); return resul...
f23eb9a0-25a8-4edf-ab92-9bdf5b93f79d
8
public boolean conflictWith(Word other) { int tdx, tdy, odx, ody; tdx = tdy = odx = ody = 0; switch ( this.getOrient() ) { case RIGHT: tdx = 1; break; case DOWN: tdy = 1; break; } switch ( other.getOrient() ) { case RIGHT: odx = 1; break; case DOWN: ody = 1; break; } int tx = this.getX(), ty...
2bfb032c-73f6-414a-b06d-c5cf8b8bd312
2
public static void main(String[] args){ MasterFind masterfind = new MasterFind(); ArrayList<String> Master = masterfind.find_baseNumOfCowork(); FileWriter fw; try { fw = new FileWriter("parserResult/master.csv"); PrintWriter pw = new PrintWriter(fw); for(int i = 0; i < Master.size(); i++){ pw.print...
7c2a0c67-524a-43b0-a60f-dbe9e5fb4442
5
public static void multiThreadUpload(String projectName, File loc, String rmPath){ Travel t=new Travel(); t.directoryTravel(loc); HashMap<String, ArrayList<File>> tl=t.returnTravelList(); ArrayList<File> dl=tl.get("directories"); ArrayList<File> fl=tl.get("files"); SFTP ...
37d8bcd1-a35d-4be4-b8b1-7aa237e5eff4
6
private static RealMatrix csvToMatrix(final String sourceFilePath) throws IOException { BufferedReader in = new BufferedReader(new FileReader(sourceFilePath)); double[][] matrixArray = null; while (in.ready()) { String currentLine = in.readLine(); if (currentLine.starts...
f7c5b90d-6542-49a5-846d-cfc5b50deede
1
private void loadDatabaseWithData(String root) { time = System.currentTimeMillis(); // try to load from obj else { root += File.separator + "sm" + File.separator; System.out.println("---*****************************--->>>>>>>" + root); files_q = new File(root + "q").list(); Arrays.sort(files_q); files_y =...
0b050ea1-d227-4133-babc-091e68f0642c
5
public static List<Integer> sieveOfEratosthenes(final int max) { final SieveWithBitset sieve = new SieveWithBitset(max + 1); // +1 to include max itself for (int i = 3; (i * i) <= max; i += 2) { if (sieve.isComposite(i)) continue; // We increment by 2*i to skip even multiples of i for (int multiplei =...
594cb610-4ecd-4a84-b5c8-20679b3fbc15
1
private static void printAll() { String value; Iterator iter = queue.iterator(); while(iter.hasNext()) { value = (String)iter.next(); System.out.print(value+", "); } System.out.println(); }
9ff886c0-ef11-49a2-93c7-5b7b41abfaac
8
private boolean onCommandQuery(CommandSender sender, Command command, String label, String cmd, String[] args) { if (sender.hasPermission(ReplicatedPermissionsPlugin.ADMIN_PERMISSION_NODE)) { String queryPlayerName = getQueryPlayerName(sender, args, 1); if (!queryPlayerName.equals("CONSOLE")) { Ha...
a988236b-72a3-4eee-ae3f-1ffce0e16bde
5
@Override protected void paintComponent(Graphics g) { if(!isShowing()) return; super.paintComponent(g); if(!loadingDone && faderTimer == null) return; Insets insets = getInsets(); int x = insets.left; int y = insets.top; int width = getWidth() - insets.le...
d3d03b91-e884-40b0-9c0f-91bc6d378cd8
4
public static void editAdress(Adress a){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try{ conn.setAutoCommit(false); PreparedStatemen...
aeb7040e-6f4b-4210-97b1-b3bcc0357c50
6
public static void readCollection(BusinessCollection businessCollection, File parentFolder){ String businessCollectionName = businessCollection.getName(); File xmlFile = new File(parentFolder, businessCollectionName+".xml"); try { DocumentBuilderFactory documentBuilderFactory = Docu...
d0ab7534-84f0-4584-9390-ba37dbba6817
6
public static <T extends Comparable<? super T>> void sort(List<T> input) { if (input.size() <= 1) { return; } // Going only till input.size() - 1 because as result of swapping the biggest element would be at last index // naturally for (int i = 0; i < input.size() - 1...
4e3aad4c-eda9-4bb0-bee9-82eb745dc3ba
4
@EventHandler public void equipmentClick(PlayerInteractEvent e) { Player player = e.getPlayer(); if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){ ItemStack stack = player.getItemInHand(); if (stack.getTypeId()==397 || stack.getTypeId() == 384 ){ e.setCancelled(tr...
21cd654b-c6f5-4bd4-8e4a-4fb5a56833fa
4
private JPanel getPanCode() { if (panCode == null) { panCode = new JPanel(); panCode.setBorder(BorderFactory.createTitledBorder("Code :")); panCode.setLayout(new BoxLayout(this.panCode,BoxLayout.Y_AXIS)); ButtonGroup group=new ButtonGroup(); for(int i=0;i<=Interface.CODES.values().length;i++) { fin...
d5850a44-7859-4461-839e-cc1127029861
8
public static void deleteUnusedFiles(File residentDir, Set<String> fileNames) { int count = 0; if (residentDir.isDirectory()) { File[] children = residentDir.listFiles(); if (children != null) { for (File child : children) { try { String f...
79accec4-d02e-45da-9c4d-1352f0c8d082
7
void history(int pt) throws ScriptException { if (statementLength == 1) { // show it showString(viewer.getSetHistory(Integer.MAX_VALUE)); return; } if (pt == 2) { // set history n; n' = -2 - n; if n=0, then set history OFF checkLength3(); int n = intParameter(2); if (n < 0) invalidArgumen...
4cce321b-0d9f-4189-9406-560a6f62ae25
5
public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<Connection.KeyVal>(); // iterate the form control elements and accumulate their values for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; // contents are form listabl...
9c0780f1-8f20-43ea-b73d-20a165427d13
8
public List<Float> getFloatList(String path) { List<?> list = getList(path); if (list == null) { return new ArrayList<Float>(0); } List<Float> result = new ArrayList<Float>(); for (Object object : list) { if (object instanceof Float) { r...
7b2bd3c8-ce8e-4e3b-995b-1a63c92074cd
2
public final LogoParser.expression_return expression() throws RecognitionException { LogoParser.expression_return retval = new LogoParser.expression_return(); retval.start = input.LT(1); Object root_0 = null; LogoParser.logical_return logical33 =null; try { // /...
6ccc7683-a044-48e1-a971-641bc8ab420e
8
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Student student = (Student) o; if (age != student.age) return false; if (group != null ? !group.equals(student.group) : student.group != null) ...
e7d02436-ead7-442c-8dfd-e76143851acb
4
public void update() { for (int i = 0; i < population.size(); ++i) { population.get(i).update(); } for (int i = 0; i < buildings.length; ++i) { for (int j = 0; j < buildings[i].length; ++j) { if (buildings[i][j] != null) { buildings[i][j].update(); } } } }
d273c3e2-5a9c-4c82-a7a4-7837de38a7c4
6
public 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.or...
ce15e6ee-4a31-4465-9423-4cfd8ed655d5
2
public static Inventory fromString(String s) { YamlConfiguration configuration = new YamlConfiguration(); try { configuration.loadFromString(Base64Coder.decodeString(s)); Inventory i = Bukkit.createInventory(null, configuration.getInt("Size"), configuration.getString("Title")); ...
bd4df75d-ff73-4002-b42d-f6adb13a7945
1
public static void setupAmbient(){ File dir = new File(Params.testFolder); if(dir.exists()){ Ambient.clearAmbient(); } dir.mkdir(); }
1e760651-4884-4cbe-9cbb-3be8f08d325a
5
public void eliminar(String nombre){ NodoPersonas q = this.inicio; NodoPersonas t = null; boolean band = true; while(q.getInfo().getNombre() != nombre && band){ if(q.getLiga() != null){ t = q; q = q.getLiga(); }else{ band = false; } } if(!band){ System.out.println("No se encont...