method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
ce94fded-f1dd-455c-ac76-17bcd87abcc9
4
private int getDoorPos(){ //TODO: EITHER check if floors are on both sides of the door. OR let doors be placed in places with one exit, easter egg saying "You've walked into a brick wall". - Tamfoolery if(getTile(tileX + 1, tileY).equals(Tile.wallTile) && getTile(tileX - 1, tileY).equals(Tile.wallTile)) return 3; ...
21b08b2a-1537-4ed7-a0dc-3a85e084ba17
5
public void setSetting(String group, String name, String value) { String compiledName = group + "." + name; this.settings.put(compiledName, value); try { Element propertiesElem = getOrCreateCollection("properties"); Node setting = Utilities.selectSingleNode(propertiesElem, "./c:property[@c:name='" + comp...
d7f4d31e-d9a3-4fd6-9976-e0283fd174a8
2
@Override public int compare(Integer o1, Integer o2) { // TODO Auto-generated method stub // Sort topic word index according to the probability of each word // in topic k if (sortProb[o1] > sortProb[o2]) return -1; else if (sortProb[o1] < sortProb[o2]) return 1; else return 0; }
998ea3fe-6966-48d5-a89d-8cfe1082cfd2
9
public BipMatch() { try { io = new Kattio(System.in, System.out); long start, end; // Tid tagnings variabler if (DEBUG) { System.err.println("\nreadBipartiteGraph"); } readBipartiteGraph(); if (DEBUG_TIME) { System.out.println("Start timing"); start = System.currentTimeMillis(); } ...
aaffb053-6e47-4d01-b3a4-2e02520c0331
7
private static void testInvalidNode(ListNode p) { System.out.println("p.isValidNode() should be false: " + p.isValidNode()); try { p.item(); System.out.println("p.item() should throw an exception, but didn't."); } catch (InvalidNodeException lbe) { System.out.println("p.item() should throw...
530484d2-f510-4a0b-bcd9-5399ab80b55e
9
public void setPurchaseDate(String purchaseDate) { if (purchaseDate == null || purchaseDate.length() != 8 || !purchaseDate.matches("\\d{8}")) throw new IllegalArgumentException("The purchase date field in the " + frameType.getId() + " frame contains an invalid value, " + purchaseDate + ". It must hav...
7bbdae8f-ade0-41c9-846c-2b1a7351cbb5
1
public void createUser(UserBean user){ try { String queryString = "INSERT INTO user values('?', '?', '?', '?', ?, ?, NULL);"; PreparedStatement statement = this.db.createStatement(queryString); statement.setString(1, user.getName()); statement.setString(2, user.ge...
99025713-187d-4ad7-a8fa-5425c995f440
2
public final void displayStatus() { System.out.println("Name: " +playerName); System.out.println("Health: " +health +"/100"); System.out.println("Sanity: " +sanity +"/100"); System.out.println("Hunger: " +hunger +"/100"); System.out.println("Fatigue: " +fatigue +"/100"); ...
a3944782-cd23-4f48-bae1-86cf7b540434
0
public static boolean verify(byte[] data, String publicKey, String sign) throws Exception { // 解密由base64编码的公钥 byte[] keyBytes = SecurityCoder.base64Decoder(publicKey); // 构造X509EncodedKeySpec对象 X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes); // ALGORITHM 指定的加密算法 KeyFactory keyFactory = K...
b2928be5-e4d3-4d06-9438-1c2ce0385b63
2
private void portComboBox_itemStateChanged(ItemEvent event) { String selected = (String) event.getItem(); if (event.getStateChange() == ItemEvent.SELECTED) { if (! selected.equals("-")) { openSerialPort((CommPortIdentifier) tableOfPorts.get(selected)); } ...
6485f9de-a804-4328-81be-984f6df96307
8
@Override public void ordena(int[] vector, DatosEstadisticos de) { long tiempo = System.currentTimeMillis(); for (int i = 0; i < vector.length - 1; i++) { for (int j = i; j < vector.length; j++) { if (vector[j] < vector[i]) { int aux = vector[...
7e4ac06a-64d1-4601-888e-089c21069d12
4
public boolean proceed(Player p, Location target) { if (!region.contains(toWEVector(target.toVector()))) return true; if (players.contains(p.getName())) return false; for (String group : groups) if (InvisibleWallsPermission.isInGroup(p, group)) return false; return true; }
68f296f8-0d24-4b78-834e-183e9defd378
5
void closestColor(int red, int green, int blue, Search search) { if (nchild != 0) { for (int id = 0; id < 8; id++) { if (child[id] != null) { child[id].closestColor(red, green, blue, search); } ...
d103b6f9-fdc5-417d-81b2-40db1ffdcc86
1
public boolean canCollectCoin(EntityPlayer player){ return posX == (int)((player.getxPos() + 16) / 32) && posY == (int)((player.getyPos() + 16) / 32); }
a21eeac6-69bc-4572-bca0-d1bae52c9ab1
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; UrlPair other = (UrlPair) obj; if (longUrl == null) { if (other.longUrl != null) return false; } else if (!longUrl.equals(other.longUrl)...
5340341c-0fdc-46c9-ad31-37a7064812c8
2
public void destroy(Long id) throws NonexistentEntityException { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); Professor professor; try { professor = em.getReference(Professor.class, id); ...
56b6c6e2-b9c7-4c98-9e73-52412ad9d4de
7
private static boolean tryFindSentence(final Map<Integer, Set<String>> words, final int[] indexes, int startIndOfCurrWord, int currWordNumberInOrder, final int phoneLength) { Set<String> wordsByIndex = words.get(startIndOfCurrWord); if (startIndOfCurrWord >= phoneLength || wordsByIndex == null || wordsB...
6047c85a-9e25-4b6a-8548-042138aa4f26
3
public Configuration[] getValidConfigurations() { // A state is valid for return if it is normal. ArrayList list = new ArrayList(); Iterator it = configurationToButtonMap.values().iterator(); while (it.hasNext()) { ConfigurationButton button = (ConfigurationButton) it.next(); if (button.state == Configura...
10e2b0f5-e964-4355-b66b-4da15516a82e
7
public void mainloop() { Initialisierung(); //Rand erstellen Lines.clear(); Lines.add(new int[]{0, 0, blaenge, 0}); Lines.add(new int[]{blaenge, 0, blaenge, bbreite}); Lines.add(new int[]{blaenge, bbreite, 0, bbreite}); Lines.add(new int[]{0, bbreite, 0, 0}); //Standardtor setzen Goals.clear(); G...
b70aa3d3-47d6-4b9b-99e5-2f9e1d547b12
8
private static String maskPassword(String proxyString) { String retVal = proxyString; if (proxyString != null && !"".equals(proxyString.trim())) { boolean hasSchemeDefined = proxyString.contains("http:") || proxyString.contains("https:"); boolean hasProtocolDefined = proxyString....
b94ee78c-6cf6-4f51-bb29-0c8ae1b14686
2
public Object put(Object key, Object value) { for (Iterator i = backing.iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); if (key.equals(entry.getKey())) return entry.setValue(value); } backing.add(new SimpleEntry(key, value)); return null; }
3670a0d2-37cb-45cf-8b40-fb394cd5c4d9
6
public void ReceivePacket() throws IOException, ServiceException { boolean serviceLock=true; Logger.getInstance().log("HID","getting device name from user"); String targetDevice = getTarget("device name"); Logger.getInstance().log("HID","getting device name " + targetDevice); i...
af5284ba-813b-4b93-a138-0a70da0063de
5
private void saveImageFromXML(Match documentRoot) { if (documentRoot.attr("image") != null) { File filePath = new File(documentRoot.attr("image")); // Verifica daca path-ul este absolut. if (filePath.isAbsolute()) { this.imagePath = filePath.getAbsolutePath(); } else { this.imagePath = (new File(...
9ffed99a-a612-46f5-8b2b-c7ddbccc3a29
1
@Override public void actionESC() { if (_DEBUG) System.out.println("Press ESC from Level"); Fenetre.setState(StateFen.MenuPause); }
ba0d8b95-ce72-4f8c-949e-3d4ca3bcf460
3
@Override public void tick(ServerKontext kontext) { // dirty fix if(!_satt && _raum != null && !istEinSpielerImRaum(kontext, _raum)) { bewegeKatze(kontext); } }
a461a92f-02e7-4790-affe-24ab7b0deaad
7
public synchronized void processCas(CAS aCAS) throws ResourceProcessException { JCas jcas; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new ResourceProcessException(e); } String output = null; String lineID = null; int so; int eo; int start, end; int ...
66e1c2c0-9605-433a-86b1-7b04e7416410
0
public Entity(Level level, int x, int y) { this.x = x; this.y = y; this.level = level; level.entities.add(this); hWidth = 16; hHeight = 16; }
6711a547-8a13-40d5-a91f-b5272ca9a382
1
public int getCount(ArrayList<FilterBean> hmFilter) throws Exception { int pages; try { oMysql.conexion(enumTipoConexion); pages = oMysql.getCount("backlog", hmFilter); oMysql.desconexion(); return pages; } catch (Exception e) { throw n...
c44116fe-2c74-4b31-bf70-55385b83d871
0
public Serializable decode(File file, Map parameters) { throw new ParseException("This codec is not implemented yet."); }
a5a6f05e-919a-443d-a954-42453203ee66
7
public String getImageName() { String path = ""; String extension = ".png"; switch (getId()) { case 1: return path + "c_contact" + extension; case 2: return path + "c_creativity" + extension; case 3: return path...
7c1611d2-ca42-4bb1-be87-0b512b533b1e
7
@Override public boolean isCellEditable(int row, int column) { Project prj = this.getProjectAt(row); switch (column) { case ProjectTableModel.COLUMN_CHECK: case ProjectTableModel.COLUMN_TITLE: case ProjectTableModel.COLUMN_COLOR: case ProjectTableModel.COLUMN_CREATED: return true; case ProjectTable...
af7e5fe3-ffc5-4d6d-ac02-003fa939f92e
0
public void setFunNitCxc(Integer funNitCxc) { this.funNitCxc = funNitCxc; }
7d010ad9-bf57-49f0-af50-6102ab32d61f
7
public static double jauTf2a(char s, int ihour, int imin, double sec ) throws JSOFAIllegalParameter { double rad; /* Compute the interval. */ rad = ( s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double) abs(ihour) ) + ( (double) abs(imin) ) ) + ...
54304113-94cf-4f66-9382-84ce51c9de29
5
@Override public int compare(AAccount o1, AAccount o2) { String val1, val2; try { try { val1 = o1.getClass().getMethod(methodName, null).invoke(o1).toString(); val2 = o1.getClass().getMethod(methodName, null).invoke(o2).toString(); return (...
4f4af3ce-5bf7-4d93-a14e-4536ddded7b1
4
@Override public Script create(ResourceDefinition definition) throws ResourceException { String compileAttr = definition.getAttribute("compile"); boolean compile = (compileAttr != null && compileAttr.equals("false")) ? false : true; String file = definition.getValue(); if (file.isEmpty()) { throw new ...
436cf002-06e7-4423-a67a-814bb5674a8d
7
private static final void post(char levelCode, Context context, String msg, Throwable throwable) { StringBuilder buffer = new StringBuilder(); buffer.append(levelCode); buffer.append(SEPARATOR); buffer.append(FORMAT.format(new Date())); buffer.append(SEPARATOR); if (context != null) { buffer.append(conte...
c21a7bb9-018b-445c-a3db-0335407c27c1
0
@Override public String getHome() { return "/"; }
a39f4b6e-3838-4ed0-b884-e244b2ec6d6c
7
public int [] usingHashing(int [] arrA, int [] arrB){ //Insert all the elements of arrA in hash Table, //Element as key and its count as its value //Navigate through arrB, check element's presence in Hash table //if it is present then takes its value (count) and insert into arrA. //Once arrB is completed, tak...
24cb6b5c-36a3-47f3-8bee-46f56db1b2c8
7
public int getMinimum(int[] numbers, int goal){ int m=0, tmp=goal; while(tmp>0){ m++; tmp = tmp>>1; } int[] count = new int[m]; for(int i=0; i<numbers.length; i++){ if((goal|numbers[i])==goal){ for(int j=0; j<m; j++){ ...
61c18549-29c3-4eed-a3f2-d50cd340d0cf
6
private void Merge(ObservableArray tab, int left, int center, int right) { Double[] temp = new Double[(right - left) + 1]; int leftIndex = left; int rightIndex = center + 1; int i = 0; while (leftIndex <= center && rightIndex <= right) { if (tab.Less(leftIndex, righ...
2da2ea7f-856d-4112-b640-d726f3cd02ee
2
public void printVisit( Tree.Node<String> node, int depth ) { for ( int i = 0; i < depth; ++i ) { System.out.print("-"); } System.out.println( node.getData() ); List<Tree.Node<String>> children = node.getChildren(); for( int i = 0; i < children.size(); ++i ) {...
0f3885c8-af64-4b2b-8c4b-6827c733d0ef
8
public static void loadItemDefinitions() { try { int parsedIndex = 0; setDefinitions(new ItemDefinition[7956]); DataInputStream inputStream = new DataInputStream(new FileInputStream("./data/item_definition/ItemDefinitions.dat")); while (inputStream.available() > 0) { ItemDefinition itemDefinition = ne...
107a972c-5b5d-405c-aade-1df2fe7a8fc0
0
public void setPreference(Preference pref) { this.pref = pref; }
468c4d65-20de-4b26-ab70-3fcfb76b4ffb
0
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Bob Joe dListModel = new DefaultListModel<String>(); channelUserList = new JList<String>(dListModel); menu...
c460d0f2-3aa1-4bec-bc20-6d814d93d0a9
0
public BesieForm (ArrayList<Excel> allEx) { allex = allEx; setColoredExes(); }
0def6d3d-4b5e-4c28-a9ae-d22c96ac7f46
6
private void fillCompositeInfo(IFileInfo[] srcStat, IFileInfo[] destStat) { this.srcComp.setLayout(new GridLayout(2, false)); this.destComp.setLayout(new GridLayout(2, false)); if(srcStat.length >= destStat.length) { for(int i = 0; i < srcStat.length; ++i) { IFileInfo srcFileInfo = srcStat[i]; Te...
5c7ef090-253b-4268-a63e-f25492c657cc
7
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
1fd8ce6a-5a02-40bb-8ab8-846f838db595
0
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabelTitre = new javax.swing.JLabel(); jSeparatorTitre = new javax.swing.JSeparator(); jButtonValider = new javax.swing.JButton(); ...
9a7265bd-ce4c-494f-ac13-c747653d59bc
4
private void generateElements(PrintStream out) { for (Element element : repository.elements()) { if (element instanceof ClassElement) { generateNodeDefForClass(out); generateClassElement(out, (ClassElement) element); } else if (element instance...
586ac2d2-c8ca-4169-a356-79ca2df82360
5
public AttendanceReadList getAttendanceReadList( int aiMaxSize, String asLastId, String asRoom, Boolean abExcludeTapNGo) { String lsParam = ""; if (aiMaxSize > 0) { lsParam += "&max_size=" + Integer.toString(aiMaxSize); } if (UtilityMethods.isValidString(asLastId)...
3abc1333-be59-4360-a67a-e323adea5017
8
@Test(timeout = 1000) public void testConcurrentStreamPiping() throws Exception { final int charCount = 30; final char[] vals = "123456789".toCharArray(); final int n = vals.length; InputStream[] istreams = new InputStream[n]; // Generate n istreams with charCount equal elem...
c1b1f23c-cc60-4565-b768-249cca21a83b
1
public static Class<? extends Property> getPropByType(String name){ return Types.get(name); }
6b815ab4-1260-4bb2-ab11-f863f80de32e
9
void process_downloaded_changeset_wayrelation_attributes( Node passed_l2_item, String passed_l1_item_type, String passed_changeset_number, int passed_arg_debug, String passed_arg_out_file, PrintStream passed_myPrintStream ) { if ( passed_l2_item.hasAttributes() ) { NamedNodeMap node_attributes = passed_...
2628b71b-b044-44a2-86da-47db96a70b5e
7
@Override public PlayerLeftGameMessage LeaveGame(int playerID) { Player player = _state.GetPlayer(playerID); ServerGame game = _state.TryGetGameByPlayerId(playerID); if (game == null) return MessageCreator.CreatePlayerLeftGameMessage(Arrays.asList(playerID),null,player,null); ...
886e2f1d-5fe4-4cd5-a2e5-3d012a9a5cce
0
public String toString() { return pattern; }
f50eb942-49a4-4175-a35c-510e8c266c59
1
private void addToCouleurNonVoulue(TreeMap<String,TreeMap< Integer, TreeSet<Integer>>> tree, String agent, Integer noeud, Integer badColor) { TreeMap< Integer, TreeSet<Integer>> tempTree = tree.get(agent); try{ TreeSet<Integer> listBadColor = tempTree.get(noeud); listBadColor.add(badColor); } catch(Excep...
2a925e68-f18d-4263-9d1c-cee864e519f3
5
private void setupQualifiers(EntityRegistry registry) { // for (Field f : qualifierRegistry.getDeclaredFields()) { // FieldId fann = f.getAnnotation(FieldId.class); // if (fann == null) { // continue; // } // Object key; // try { // ...
f6471578-29b4-4319-8076-6a18a8605fe3
3
public void delete(int index) { if (index >= size() || index < 0) throw new IndexOutOfBoundsException(); if (group != null) group.removeElementAt(index); list.remove(index); _showNotify(); }
2b0a9d08-b019-438d-8d42-eea76755462c
9
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int t = 0; t < T; t++) { int n = sc.nextInt(); int m = sc.nextInt(); int[] arr = new int[(int) Math.pow(2, n)]; for (int i = 0; i < m; i++) { ...
d0a20fb0-3141-46a5-aca7-dd4b142d032e
6
public static boolean confirm() { WidgetChild button = getChild(CONFIRM_BUTTON); final Item it = getItem(getCurrentIndex()); final int count, amount; return it != null && canConfirm() && visible(button) && (count = it.getStackSize()) != 0 && (amount = getAmount()) != 0 && button.click(true) && new TimedCond...
5814c7fb-2431-4b2c-970d-2f50c1ae9e62
7
static final RasterToolkit method1969(byte[] is, int i) { anInt8546++; if (i != -5901) anInt8550 = 83; if (is == null) throw new RuntimeException(""); for (;;) { try { Image image = Toolkit.getDefaultToolkit().createImage(is); MediaTracker mediatracker = new MediaTracker(NpcDefinition.aClie...
0fea682c-7409-43a6-afe6-62d65f06b21b
9
private static char ConvertToLetter(int num) { char letter = 'A'; switch(num) { case 1: letter = 'B'; break; case 2: letter = 'C'; break; case 3: letter = 'D'; break; case 4: letter = 'E'; break; case 5: letter = 'F'; break; case 6: letter = 'G'; ...
164da7a3-1197-4f0e-9d6a-e62aaf9ab05c
5
private void initialize() throws ParseException { controleInstitucional = new ControleInstitucional(); controleAtividade = new ControleAtividade(); recursosSelecionados = new HashMap<>(); frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); ...
5418d406-c064-4286-97a6-3238091e7113
4
@Override public void draw(int x, int y) { TexInfo currentTexInfo = texinfo; Color4F color = currentTexInfo.getColor4F(); glColor4f(1f, 1f, 1f, 1f); glColor4f(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); Boot.getTexHandler().bindTexture("entities"); float xloc = 0; ...
3415734a-b0c3-4624-ae0e-442c96822a47
2
public void insertString(int offset, String str, AttributeSet set) throws BadLocationException{ if(str == null){ return; }else if((getLength() + str.length())<= limit){ super.insertString(offset, str, set); } }
59e2fe5f-a576-46c1-9ecd-dd2c3d47e927
2
public double getMaximumDifference_as_double(){ double diff = 0.0D; if(this.type==0 || this.type==1){ double max = this.getMaximum_as_double(); double min = this.getMinimum_as_double(); diff = max - min; } else{ throw new IllegalArgumentExc...
72d4c695-4f7d-4186-82f9-2defb7cd6037
5
public static boolean save() { if (HoleList.size() == 0) { // If queue is empty OR economy is disabled. HoleFile.delete(); Golfcraft.Log(Level.INFO, "No holes to save."); return true; } Golfcraft.Log(Level.INFO, "Saving " + HoleList.size() + " holes..."); try { if (!HoleFile.exists()) { if (...
bc2cc43e-43c6-42b2-ae09-b0efbfb853c3
2
public void union(int p,int q){ int pid = id[p]; int qid = id[q]; for(int i = 0;i<id.length;i++) if(id[i] == pid)id[i]=qid; }
d2ff17c3-91fd-4327-8927-4d0e775ab922
2
public void handleProjectileHitEvent(ProjectileHitEvent e) { if(e.getEntity() instanceof Snowball) { Snowball s = (Snowball)e.getEntity(); if(area.isInArea(s.getLocation())) { s.getWorld(). dropItemNaturally(s.getLocation(), new ItemStack(Material....
e2fbc6e2-0a37-4cc3-9c38-2bdce29cc5ba
2
public Node getNodeForState(State state) { /** Search through all nodes for state. */ for (int k = 0; k < myNodes.length; k++) { Node node = myNodes[k]; if (node.getState() == state) return node; } return null; }
99d519aa-5ed4-44c7-8358-91086b39bd3a
9
public void setValue(Object target, Class<?> type, long fieldOffset, Object value) { if (type == int.class) unsafe.putInt(target, fieldOffset, (Integer) value); else if (type == short.class) unsafe.putShort(target, fieldOffset, (Short) value); else if (type == long.class) unsafe.putLong(target, fieldO...
af2acf42-2e97-47bb-bba5-b8126f91952a
8
public void testJGRP_1876() throws Exception { e=createChannel("E", true); f=createChannel("F", true); g=createChannel("G", true); h=createChannel("H", true); Util.waitUntilAllChannelsHaveSameView(10000, 500, a, b, c, d, e, f, g, h); enableInfoSender(false, a,b,c,d,e,f,g,...
cf3974c2-baeb-4742-83b1-f39cbcbd2a79
0
@POST @Path("participate/{participant}/{idEvent}") @Consumes(MediaType.TEXT_PLAIN) public void participate(@PathParam("participant") String participant,@PathParam("idEvent") int idEvent){ System.out.println("Add a participant to an event"); JpaTest.eventService.addParticipant(idEvent, participant); }
d78bf2f9-401a-43cb-a87f-87fc56289c90
5
@Override public boolean equals(Object object) { if(object == null) { return false; } if(object == this) { return true; } if(!(object instanceof Node)) { return false; } Node aNode = (Node)object; if(aNode.getHostname().equals(this.hostname) && aNode.getIpAddress().equals(this.ipAddress...
d7c42f6b-899c-4a7f-9d33-5ff4c42e160e
6
public short alphaBeta(AiNodeMaster node, int depth, int Max, short alpha, short beta){ if (depth == 0) { return node.getNodeValue(); } if (MaxNode(Max, node.getBoard())) { for (int i = 0; i < node.childNode.size(); i++) { alpha = max(alpha, alphaBeta(node.childNode.get(i), depth-1, Max, alpha, beta));...
5927db73-b673-4704-b6dd-371cd1e5af16
4
@Override public void run() { int count = 10; while (count > 0) { synchronized (prev) { synchronized (self) { System.out.print(name); // if(name.equals("C")) System.out.println(); count--; try { Thread.sleep(5); } catch (InterruptedException e) { e.printStackTrace(); ...
29d4dbdb-61f6-487f-ac3a-206aa22e6430
7
public void printResult(String fileName) { FileWriter fw = null; BufferedWriter bw = null; try { fw = new FileWriter(fileName); bw = new BufferedWriter(fw); // 写入文件 for (int i = 0; i < InstanceNumber; i++) { bw.write(String.valueOf(data[i][FieldCount]).substring(0, 1)); bw.newLine(); } /...
12f9d3d5-9cfb-49dc-8b53-7541a2b77830
2
public static void noConcurrentTest() { final int BUFFER_SIZE = 10; final int NUM_PRODUCERS = 5; final int NUM_CONSUMERS = 3; Buffer buffer = new RingBuffer(BUFFER_SIZE); for (int i = 0; i < NUM_PRODUCERS; ++i) { new Thread(new Producer(buffer)).start(); } ...
84b5a7b0-6f7c-4940-a2b5-bf2f3fe2b168
0
public void forward(int velocity) { controls.forward(velocity); }
0e32553d-f670-4369-8eed-d352f1313e1a
9
public ArrayList<ArrayList<Integer>> zigzagLevelOrder(TreeNode root) { // Start typing your Java solution below // DO NOT write main() function ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>(); if (root == null) return res; ArrayList<TreeNode> cur, next; cur = new ArrayList<TreeN...
31b6306c-17fe-4815-8b33-506dbe388f4c
7
public static <V> ArrayList<V> shortestUnweightedPath(Graph<V> graph, V source, V end){ // the parent of a node is the node that discovers it HashMap<V, V> parent = new HashMap<V, V>(); // the source has no parent parent.put(source, null); // this list will contain the path to the node from the source node...
7952c8a8-bdee-47ed-b1cc-852f16021f85
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...
f6a7cd7d-ec93-4ee0-97be-70b00429d304
5
public Collection<DepartamentoDTO> buscarTodos() { Connection con = null; PreparedStatement pstm = null; ResultSet rs = null; try { con = UConnection.getConnection(); String sql = "SELECT d.* FROM ubdepartamento d"; pstm = con.prepareS...
cad94fc0-426f-411d-99fb-bc0ee1e80a8f
0
@Override public void keyPressed(KeyEvent e) { myTank.keyPressed(e); }
e77815f2-27c5-4124-913d-670a4f2e0a4c
0
public K getKey(){ return mKey; }
4979ffab-25e0-4e3b-81f5-6cd4f7112f99
4
@Override public void loadPlayers() throws PersistenceException { PlayerContainer pCon = PlayerContainer.instance(); CsvReader csvReader = null; try { csvReader = new CsvReader(FILENAME, DELIMITER); csvReader.skipLine(); csvReader.skipLine(); csvReader.readHeaders(); csvReader.readRecord(); // ski...
374d8c38-3247-4c2e-8576-323909283e78
2
private Type returnTypeFromDesc(String desc) throws BadBytecode { CtClass clazz = null; try { clazz = Descriptor.getReturnType(desc, classPool); } catch (NotFoundException e) { throw new BadBytecode("Could not find class in descriptor [pos = " + lastPos + "]: " + e.getMes...
338de4e0-7e4e-4e04-b50e-c02ed2b9cd28
5
private static int stringSize(int num, int radix) { int exp; if (radix < 4) { exp = 1; } else if (radix < 8) { exp = 2; } else if (radix < 16) { exp = 3; } else if (radix < 32) { exp = 4; } else { exp =...
f60bd03a-f087-42bf-b298-fbf3c6ef7ec1
9
@Override public void executeCommand(CommandSender sender, Command cmd, String[] args){ CommandHelper helper = new CommandHelper(sender, cmd); Player player = (Player) sender; Location loc = player.getLocation(); //Usage: /ghostsquadron setspawn lobby if(args.length == 2){ if(args[0].equalsIgnoreCase("...
dba4d8d2-1d8f-4d95-a88b-93014408b412
6
public void draw(Graphics g, int brickSize, int anagramOn, HashSet<Integer> bricksClicked, HashSet<Point> bricksWordle, boolean gameOver) { g.translate(position.x * brickSize, position.y * brickSize); for(int i = 0; i < this.getNumberOfBricks(); ++i) { boolean clicked...
62b08ab6-3594-4370-8c23-0b39fb965cef
7
public void actionPerformed(ActionEvent e) { String[] ex=e.getActionCommand().split("/"); if(ex[0].equals("showOthers")){ otherBlocksMenu.show((Component)e.getSource(), 0, 0); } else if(ex[0].equals("add")){ if(codeBased.isSelected()) ((Flowchart)a...
6c59ea65-be99-49e1-8f25-fb64fd065bc3
7
public boolean hasPathSum(TreeNode root, int sum) { if (root == null) return false; if (root.left == null && root.right == null) return (root.val == sum); if (root.left != null && hasPathSum(root.left, sum - root.val)) return true; if (root.right != null && hasPathSum(root.right, sum -root.val))...
fc282991-e396-4002-9940-3d0401e6c452
2
protected void endStatistics(String html) { //calculate compression time if(generateStatistics) { statistics.setTime((new Date()).getTime() - statistics.getTime()); statistics.getCompressedMetrics().setFilesize(html.length()); //calculate number of empty chars Matcher matcher = emptyPattern.matcher(...
167a4d88-7464-421d-ba51-ac17956daf28
9
private void findSolidObjects(GameDescription game){ ArrayList<SpriteData> avatars = game.getAvatar(); ArrayList<SpriteData> staticSprites = game.getStatic(); for(SpriteData sprite:avatars){ for(SpriteData solid:staticSprites){ boolean isSolid = true; ArrayList<InteractionData> interactions = game.g...
ab7ac010-5229-43ad-b1c9-37d0ab38f323
8
public DemoFrame() { setTitle("Swing Preview"); // use name to target the frame getContentPane().setName("Frame"); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); final DefaultTableModel model = new DefaultTableModel(new String[]{"Key", "Value"},0); ...
3631794b-2a04-4961-a69d-301e87251d5d
8
public void loadAll() { JFileChooser chooser = new JFileChooser(); chooser.setSelectedFile(preferredFile); int result = chooser.showOpenDialog(null);//this); if (result == JFileChooser.APPROVE_OPTION) { preferredFile = choo...
8004f66c-bc4b-4896-930e-65feda8bcbd7
8
private boolean r_un_accent() { int v_3; // (, line 215 // atleast, line 216 { int v_1 = 1; // atleast, line 216 replab0: while(true) { ...
7c41963c-c037-4c22-9d8c-6edcc5e4bc77
5
public String correct(String x) { String ret = ""; char[] prs = x.toCharArray(); int cnt = 0; boolean flag; queueNode n; while(cnt<prs.length) { n = iHead; flag = false; while(n!=null&&!flag) { if(n.getData() == prs[cnt]) flag = true; n = n.getNext(); } if(!flag) re...
0c7e3fbe-70ed-4a66-a9bf-388f676d1f4e
9
private void setupKeys() { // for (Field f : keyRegistry.getDeclaredFields()) { // FieldId ann = f.getAnnotation(FieldId.class); // if (ann != null) { // Object okey; // try { // okey = f.get(TKey.class); // } catch (IllegalAcc...
4c85e9cd-eb5e-4a58-be6b-2e0041ce4122
7
public void run() { // TODO: add in thread logic here while (!getRequestQueue().isEmpty()){ ArrayList<Integer> curRequest = popRequest(); fromFloor = curRequest.get(0); destFloor = curRequest.get(1); while (!this.onElevator){ if (destFloor ...