method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
c7fea2cb-e08f-4a6c-a602-2994abdb772d
7
private void initButton(){ bCancel = new JButton("Cancel"); bCancel.setSize(dimButt); bCancel.setToolTipText("Exit program"); bCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.dispose();...
30295a98-006b-4e4e-bdc7-97ba0b8603ef
8
public static int solveQuartic(double c[], double s[]) { /* normal form: x^4 + Ax^3 + Bx^2 + Cx + D = 0 */ double A = c[3] / c[4]; double B = c[2] / c[4]; double C = c[1] / c[4]; double D = c[0] / c[4]; /* substitute x = y - A/4 to eliminate cubic term: x^4 + p...
f4960eca-87b9-4363-adf9-ee0335afd5f0
3
@Override public int compareTo(Address o) { if (ipAddress.compareTo(o.ipAddress) == 0) { if (tcpPort < o.tcpPort) { return -1; } else if (tcpPort > o.tcpPort) { return 1; } else { return 0; } } else { return ipAddress.compareTo(o.ipAddress); } }
b97be246-151b-49ff-8a72-efbafe6745d1
4
public ArrayList<Building> getPlayersBuildings(Player player) { ArrayList<Building> buildings = new ArrayList<Building>(); for (Cell[] cell1 : cells) { for (Cell cell : cell1) { if (cell.getBuilding() != null) { if (Teams.comparePlayers(cell.getBuilding().getOwner(), player)) { buildings.a...
171e8554-ea3e-40ae-93cb-45a0490b8545
1
public static boolean areFilenamesEquivalent(String filename1, String filename2) { if (isWindows()) { // Windows is not case sensitive so we need to ignore case. return filename1.equalsIgnoreCase(filename2); // Should be expanded to handle the ~ thing. } else { return filename1.equals(filename2); } }
d2809a92-7b93-430c-9b7e-ab8d6a674e7d
5
public void set(HLLCounter h) { p = h.getP(); M = h.getByteArray(); k = h.getK(); if(h.isIntersectable()){ s = h.getMinHash().size(); } else { s = 0; } if(minhash == null || minhash.length != s){ minhash = new long[s]; } int i = 0; if(h.getMinHash() != null){ ...
f33afe72-9a10-4d5f-b115-f1ba17156ed4
4
private static String getArrayExtractor(LinkedList<String> parts) { String counter = getStreamExtractor(parts); int extra = 0; if (counter == null) { extra = Integer.parseInt(next(parts)); counter = getStreamExtractor(parts); } List<String> streams = new ArrayList<String>(); List<String> fields = new ...
0273cb2b-b9c6-4dcf-a718-e4cd302003cb
1
public int getNumberOfCoauthors() { return (coauthors == null) ? 0 : coauthors.size(); }
98ce48a9-3b20-45f0-b8f1-72ae20cee11c
2
private void authenticate(NetMessage n) { Authentication a = n.getAuthentication(); if (a.getVersionID() == Parameters.VERSION_ID && a.getPassword().compareTo(Parameters.PASSWORD) == 0) { isVerified = true; manager.statusMessage(id, name, "Client "+id+" is verified"); } else { connection.close(); } // ...
72cb4506-7fb9-4340-b074-e00b5c7d039e
0
public void layoutInCircle() { layout(0, Math.PI, 2*Math.PI); }
d30746f7-411f-4ffa-8499-6530c8b45fa8
1
private void unpackList (String list) { myPeerList = new HashMap<String, String>(); list = list.substring(0, list.length() - 1); String[] strs = list.split(";"); for (String s : strs) { myPeerList.put(s.split(":")[1].trim(), s.split(":")[0].trim()); } }
5a8ba571-60cf-4020-9d0d-e1a315a7c382
6
private int pathLengthFromLocation(int x, int y, AStarPathFinder pathfinder, Map toPlay) { Path path = pathfinder.findPath(null, x, y, toPlay.getWidthInTiles() - 1, 0); if (path != null) { return path.getLength(); } Tile closestKey = null; int shortestLength = Integer.MAX_VALUE; for (Tile key :...
4d13166c-176b-4bdc-a458-439152cf1668
6
public static String vectorPlaceToHTML(Vector<Place> rs){ if (rs.isEmpty()) return "<p class=\"plusbas\">Il n'y a plus de places disponibles.</p>"; String toReturn = "<TABLE BORDER='1' width=\"1000\">"; toReturn+="<CAPTION>Les places disponibles (#) sont :</CAPTION>"; int i=0; for (int j=1;j<=10;j++){ ...
c8e2f726-c698-4aed-acb7-be35b7265c5e
3
@Override protected Value evaluate(ExecutionContext context) throws InterpretationException { Value val = ((AbsValueNode) this.getChildAt(0)).evaluate(context); if (val.getType() == VariableType.ARRAYLIST) { ArrayList<Value> list = (ArrayList<Value>) val.getValue(); return l...
c8a44e09-3760-4e0c-9502-e44fa3d05902
2
public void visitPhiStmt(final PhiStmt stmt) { if (stmt instanceof PhiCatchStmt) { visitPhiCatchStmt((PhiCatchStmt) stmt); } else if (stmt instanceof PhiJoinStmt) { visitPhiJoinStmt((PhiJoinStmt) stmt); /* * else if (stmt instanceof PhiReturnStmt) * visitPhiReturnStmt((PhiReturnStmt) stmt); */...
199f1611-3915-4a16-8319-10839eb25949
3
public static void rSort (int[] array, int start, int end) { if (start == end) return; for (int i = start; i <= end; i++) { if (array[start] > array[i]) { array[start] ^= array[i]; array[i] ^= array[start]; array[start] ^= arra...
af49cc17-824a-45f7-8576-fc8b2787386c
4
private static void writeMetricsForResources(String sampleDir, String sampleName, String prefix, int sampleCount, int k, String posfix, BookmarkReader reader) { String topicString = ((posfix == null || posfix == "0") ? "_" : "_" + posfix); for (int i = 1; i <= k; i++) { for (int j = 1; j <= sampleCount; j++) { ...
c6d55ddc-0878-4dd2-8796-5b85b86684b6
9
public OnScreenKeyboard(Class<? extends JButton> c) { // setOpaque(true); // content panes must be opaque buttonCreator = null; try { final Constructor<? extends JButton> constructor = c.getConstructor(); buttonCreator = new ButtonCreator() { @Override public JButton create() { try { retu...
90478fa8-c87c-47a0-94aa-7cac5ce1aff4
1
public boolean setUserlistHeight(int height) { boolean ret = true; if (height <= 0) { this.userlist_Height = UISizeInits.USERLIST.getHeight(); ret = false; } else { this.userlist_Height = height; } somethingChanged(); return ret; ...
8699ae6a-ab36-4f7c-be95-afdcc02920b1
7
public void generateImage() { if( icon instanceof ImageIcon) icon.getImage().flush(); // Set up temp image at native resolution BufferedImage temp; // needs to be in color if overlays will be displayed: if( p_selected || r_selected || c_selected ) { temp = new BufferedImage(width,height,BufferedImag...
1bfea4f7-33f4-490b-869c-5e38f8a3dcb6
5
public static <AnyType extends Comparable<? super AnyType>> void shellsort( AnyType [ ] a ) { int j; for( int gap = a.length / 2; gap > 0; gap /= 2 ) for( int i = gap; i < a.length; i++ ) { AnyType tmp = a[ i ]; for( j = i; j >= gap && ...
4ac669dd-61e7-489d-8c80-b92368f70717
6
private final void runPlans() throws FatalError, RestartLater { // first check for old not finished task if (!User.getStatus().equals(User.Status.nothing)) { for (int i = 0; i < 3 && !this.finishOldWork(); i++) { Control.sleep(3600); } if (!User.getStatus().equals(User.Status.nothing)) { throw ne...
50915656-326c-4ba2-bc52-8a82dedb2dbd
8
public void execute(String commandLine, String path, CommandGui gui) { executing = true; int size = filters.size(); if (size < 1) { return; // All done! } String title = "<Command> " + commandLine; String pathTitle = "<Path> " + path; TextPanel outp...
14407aa2-1985-456a-821c-886222ab74e5
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Food other = (Food) obj; if (field == null) { if (other.field != null) return false; } else if (!field.equals(other.field)) return fa...
7ab3c600-ea04-41cc-b6ed-10ebe23233ec
2
public AnnotationVisitor visitAnnotation(String name, String desc) { AnnotationVisitor v = av.visitAnnotation(name, renamer.mapDesc(desc)); return v == null ? null : (v == av ? this : new RemappingAnnotationAdapter(v, renamer)); }
d78af647-7b9a-42e1-bc17-2916fadf1bb4
6
private String mutate(String child) { for (int i = 0; i < child.length(); i++) { if (rand.nextInt(mutateRate) == 1) { if (child.charAt(i) == '0') { String bit = ""; if (child.charAt(i) == 0) { bit = "1"; ...
bd95d870-ffd2-4f98-884e-6f4dd217fb9f
7
private List<String> shuffleData(){ List<TaskProgress> mapTaskList; try { // Get the map task list whitch are completed. mapTaskList = getJobTrackerServiceProvider().getCompletedMapTasks(taskID); if( mapTaskList == null){ System.out.println("Failed to grab the completed Map Tasks."); return nul...
83757a59-950f-4426-bffb-90391b3f9228
6
public void handleTrace(TraceEventObject e) { if (e.getCmd() == TRACE) { if (!isBroke) trcstream.println(e.getLine()); // System.out.println("Writing: "+e.getLine()); } else if (e.getCmd() == LAYOUT) { if (!isBroke) open(); } else if (e.getCmd() == DISPLAY) { if (!isBroke) trcstream....
f04cecbb-73f9-4cc4-ad9a-801d2db6386f
9
public String[] generate(String[] results) { List<Country> countries = new ArrayList<>(); for (int i = 0; i < results.length; i++) { String[] result = results[i].split(" "); boolean a = false, b = false, c = false; for (int j = 0; j < countries.size(); j++) { Country country = countries.get(j); if...
4f156e47-17d0-4726-a854-fc897c62c84c
1
public static Class getClazz(String name) { try { return getClassObject(name); } catch (ClassNotFoundException e) { throw new RuntimeException( "$class: internal error, could not find class '" + name + "' (Desc.useContextClassLoade...
4551ba6b-199b-4be0-8d38-2f6cb23b8ef2
0
protected StringBuffer prepareFile(JoeTree tree, DocumentInfo docInfo) { //String lineEnding = Preferences.platformToLineEnding(docInfo.getLineEnding()); StringBuffer buf = new StringBuffer(); // write the prelude to data // TBD // write the data //Node node = tree.getRootNode(); //for (int i = 0...
80f5b231-7471-49b6-affb-97134443e9bd
1
@Override public void actionPerformed(ActionEvent e) { String name = this.nameField.getText(); String password = String.copyValueOf(this.passwordField.getPassword()); if (this.database.login(name, password)) {// ¼ɹ MainFrame frame = new MainFrame(database, name); this.dispose(); frame.setVisible(true); ...
dec6adc2-0e83-4b69-9bcb-69113a8e675e
0
public IrcCommandHandler(AprilonIrc plugin){ Parent = plugin; }
5b8a3998-4420-441e-ada7-0a597670f2b7
2
public static void handleAction(String params) { if ( getActiveTab() instanceof ServerTab ) { showNotActiveChannelWarning(); return; } if ( params.isEmpty() ) params = "neumí používat IRC klienta."; // :) String channel = getActiveTab().getTabName();...
bd60a6b3-b01d-4ab3-9810-169f74b0dcd7
1
private final void setto(String s) { int l = s.length(); int o = j+1; for (int i = 0; i < l; i++) b[o+i] = s.charAt(i); k = j+l; }
2a6ba400-75c1-4eb1-80a1-c4246680d9ea
9
public int getScore(String s, int boardSize) { switch (s.length()) { case 0: case 1: case 2: return 0; case 3: return boardSize <= 4 ? 1 : 0; case 4: return 1; case 5: return 2; case 6: return 3; case 7: return 5; ...
53eb91e9-bd49-43cf-b88e-8f2cf4c4b54a
5
final boolean method2939(int i, int i_7_, int i_8_) { anInt6807++; if (i_7_ != 2) return true; if (((Class348_Sub18) this).anInt6809 > i || (i ^ 0xffffffff) < (((Class348_Sub18) this).anInt6819 ^ 0xffffffff) || ((((Class348_Sub18) this).anInt6812 ^ 0xffffffff) < (i_8_ ^ 0xffffffff)) || (...
24fb29d7-a154-40b8-b741-c6347db5b602
8
public void wordsInInterrogativeSentencesWithCurrentLength(int length, String resultFilePath) throws IOException{ if(text == null) return; HashSet<Word> result = new HashSet<>(); for(int i = 0; i < text.numberOfParagraph...
9040173f-a949-4eed-baf4-5b2a66430b75
6
@Override public void setVisible(boolean visible) { // // Centering About windows // if (visible && fWhichAbout != kMessageReceived) { ComponentUtil.centerComponent(this, fParentFrame.getLocation(), fParentFrame.getSize()); } // // Restore / Save ...
fefcf889-44af-4982-879d-b378b4ae87c8
0
public static void main(String[] args) { float x = 1.3f; float y = 1.8f; System.out.println((int) (x + y)); // 3 System.out.println((int) x + (int) y); // 2 }
13acbafd-57c7-4d0b-866f-83edac171b3e
4
public void loginWithEmailAndNotPassword(DriverGenerator dg) { // boiler plate WebDriver wd = dg.generate(); ParallelPrepHelper pph = new ParallelPrepHelper(wd); // setup boolean madeItToPage = pph.goToURL(AMAZON_HOME_PAGE); boolean clickOnSignIn = pph.clickOnVisibleElement(HOME_PAGE_CLICK_TO_GET_TO_SIGN_IN...
aac8ae50-679f-495f-8f1a-d4475e3bc57a
4
public void addUnit(UnitModel unit, int x, int y) throws GameFieldException { if (!checkPosition(x, y)) { throw new GameFieldException(String.format( "Accesing square with invalid position (%d, %d).", x, y)); } switch (map[y][x]) { case GRASS: units[y][x] = unit; break; case MOUNTAIN: case WAT...
7191f073-c82a-4583-8442-5d295413af03
3
public int midPriceLookback( int optInTimePeriod ) { if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) ) optInTimePeriod = 14; else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) ) return -1; return (optInTimePeriod-1); }
26163b56-8d5d-4c1f-8763-e37d70c0a9a6
1
public static synchronized ClassPool getDefault() { if (defaultPool == null) { defaultPool = new ClassPool(null); defaultPool.appendSystemPath(); } return defaultPool; }
1e587dbc-9cb1-4efb-8e2b-46ff0b84bead
5
public Model getRotatedModel() { Model model = aSpotAnim_1592.getModel(); if(model == null) return null; int j = -1; if(aSpotAnim_1592.aAnimation_407 != null) j = aSpotAnim_1592.aAnimation_407.anIntArray353[anInt1593]; Model model_1 = new Model(true, Class36.method532(j), false, model); if(j != -1) ...
cfd8dfb2-220d-44d0-945e-9da85611c335
4
private int isAvailable(int begin, int end, int numPE, long startTime, long endTime) { // if the required slot is empty or not occupied if (begin == NOT_FOUND) { return SUCCESS; } ARObject obj = null; long time = 0; // a temp ti...
f628fb43-c90f-40ae-a9ec-48115cc8d7a0
0
@Override public void setAcademicLevel(String academicLevel) { super.setAcademicLevel(academicLevel); }
9898ac7f-933e-415d-969a-16bd2bf4c681
2
public Eisenstein inc() { if(this.b >= this.a-1) return new Eisenstein(0, -this.a-1); else if(this.b < 0) return new Eisenstein(this.a+1, this.b+1); else return new Eisenstein(this.a, this.b+1); }
5ae65602-43fb-44e5-948d-c872af81f2b8
2
public int getSimpleCreaturesAmount() { int n = 0; synchronized (simpleCreatures) { List<SimpleCreature> sList = Collections .synchronizedList(simpleCreatures); for (Iterator<SimpleCreature> it = sList.iterator(); it.hasNext();) { SimpleCreature c = it.next(); if (c.getClass().equals(SimpleCreature.c...
d279ea9c-b80b-4abd-a49f-e3e0e086f9ba
2
public String get(int index) { if((index < 0) || (index >= getLength())) { return "Out of bounds"; } return items[index]; }
03215ddf-ae97-4467-b4b3-5fb8387245f5
5
@Override public SceneNode build(Node node) { SceneNode sceneNode = super.build(node); Direction dirName = null; String decalName = null; NodeList nodeLst = node.getChildNodes(); for (int s = 0; s < nodeLst.getLength(); s++) { Node fstNode = nodeLst.item(s); if (fstNode != null) { if (fstNode...
b85b72ec-e166-4504-ac4c-7bbf8cb3bb86
3
public Connection getConnection() throws PersistenceException { try { if(this.connection == null || this.connection.isClosed()) { this.connection = ConnectionProvider.getInstance().getConnection(); } } catch(SQLException sqlException) { throw new Pers...
67ae936d-5832-4562-9e94-1a2e6301df46
2
public void renderSquare(int xp, int yp, int w, int h, int color) { yp = this.height - yp; yp-=h; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { paintPixel(x + xp, y +yp, color); } } }
39842058-2ffb-429e-aca9-e8c9fbe54470
3
public void setDifficultyFactor(int level) { switch (level) { case EASY: difficultyFactor = EASY; break; case NORMAL: difficultyFactor = NORMAL; break; case HARD: difficultyFactor = HARD; break; default: difficultyFactor = NORMAL; } }
959d02d5-d9b3-4a19-906b-3a963711c3d6
7
private ArrayList<KeyButtons> checkKeys(KeyEvent e) { ArrayList<KeyButtons> keyPressed = new ArrayList<KeyButtons>(); if (e.getKeyCode() == KeyEvent.VK_UP) { keyPressed.add(KeyButtons.UP); keyPressed.add(KeyButtons.JUMP); } if (e.getKeyCode() == KeyEve...
e6d5710c-02f5-4bc7-8aec-442b6186340a
7
public boolean isNormalized() { Multiset<S2Point> vertices = HashMultiset.<S2Point>create(); S2Loop lastParent = null; for (int i = 0; i < numLoops(); ++i) { S2Loop child = loop(i); if (child.depth() == 0) { continue; } S2Loop parent = loop(getParent(i)); if (parent != ...
bd6ab1d4-60de-46c6-b794-9ca6b535006d
0
public void setValue(T x, T y) { coordonnees.set(0, x); coordonnees.set(1, y); }
98cc59ee-5a21-4814-bd94-5746e473db3d
0
@Override public String toString() { return "[name=" + name + ", age=" + age + ", beanName=" + beanName + "]"; }
5149710f-3107-456b-986b-52bd55600d42
2
public Grille (EnvironnementAbs env){ super(env); Border blackline = BorderFactory.createLineBorder(Color.black,1); for(int i= 0 ; i < env.taille_envi;i++){ for(int j= 0 ; j < env.taille_envi;j++){ agent[i][j].setBorder(blackline); } } pan.setBorder(blackline); }
efbc8536-5149-41f1-b9be-211ef5f9dd4f
7
@Override public Object getValueAt(int row, int col) { Food theFood = (Food) theData.get(row); switch(col) { case 0: return String.format("%06d",theFood.getCode()); case 1: return theFood.getFoodName(); case 2: ...
6697e035-53f1-43bf-8d60-5af9aa093bf1
6
public Mesh makeMeshObject() { // Make a new mesh mesh = new Mesh(filename, materialLibraryName); if (materialLibrary != null) { mesh.importMaterials(materialLibrary.getMaterials()); } // Add the vertices to the Mesh for (int vertex = 0; vertex < vertexData.siz...
6aa9a1d1-9525-4d9d-9605-480fe29e78f1
0
@Override public String toString() { return "Idle Action on " + being.ID(); }
9c1fc5a8-1729-4fc6-9e97-5237a2992366
1
public java.security.cert.X509Certificate[] getAcceptedIssuers() { java.security.cert.X509Certificate[] chain = null; try { TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); KeyStore tks = KeyStore.getInstance("JKS"); tks.load(this.getClas...
610c18e6-dcd0-441b-a263-eb751fd665b9
6
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { Object ret = null; if (component instanceof PickList) { Object dualList = ((PickList) component).getValue(); @SuppressWarnings("unchecked") DualListModel<Autor> dl = (DualListModel<Autor>) dualList; ...
e391f136-b87c-4cc4-b193-3272943e0070
5
private void process(DatagramPacket packet) { String string = new String(packet.getData()); if (raw) System.out.println(string); if (string.startsWith("/c/")) { // UUID id = UUID.randomUUID(); int id = UniqueIdentifier.getIdentifier(); String name = string.split("/c/|/e/")[1]; System.out.println(name ...
c897928b-24f9-435f-9f3f-8e971183f960
9
public void mapWorld() { // Просмотр игровой карты String mapSave = world[PLAYER_POS_X][PLAYER_POS_Y]; world[PLAYER_POS_X][PLAYER_POS_Y] = player; for (int y = 0; y < WORLD_Y; y++) { for (int x = 0; x < WORLD_X; x++) { if (world[x][y].equals(GlobalParams.wall) || world[x][y].equals(GlobalParams.paling) ...
d9e53260-73d1-4281-a337-b6a6b713987e
3
public void testStream() { try { InputStream id3in = in.getRawID3v2(); int size = id3in.available(); Header header = in.readFrame(); if (out != null) { out.println("--- "+filename+" ---"); out.println("ID3v2Size="+size); out.println("version="+header.version()); out.println("version_...
4b6f7871-fd60-4c65-b01d-385ddbe7342e
4
public static boolean isCompativel(Tipo tipo1, Tipo tipo2) { if(tipo1 != tipo2){ return (tipo1 == REAL && tipo2 == INTEIRO) || (tipo1 == CADEIA && tipo2 == CARACTERE); } else { return true; } }
c1f614f7-c301-45e2-83cc-880c2f1b0bfb
4
private void readTests(String fileName) throws Exception { BufferedReader is = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream(fileName))); String inputLine; while ((inputLine = is.readLine()) != null) { if (inputLine.length() == 0 || inputLine.startsWit...
3a08d617-9d44-4ca6-b134-0e52a37143e8
6
public static void readExcelFile(ArrayList<ArrayList<Block>> blockList){ try { InputStream excelFile = new FileInputStream("src/data_readme/Input_data_set_5.xls"); //要讀的檔案 jxl.Workbook readWorkBook = Workbook.getWorkbook(excelFile); //將其讀入workbook中 Sheet readSheet = readWorkBook.getSheet("Inbound Trai...
6196e76c-2384-4dde-a8b5-f7968975d181
0
public String getSku() { return sku; }
18bea2b5-df19-44a5-b9ed-145f8ae98886
4
@Override public boolean checkConnection() { if (this.connection == null) { try { open(); return true; } catch (MalformedURLException ex) { this.writeError("MalformedURLException: " + ex.getMessage(), true); } catch (Instant...
30608cf2-af0e-43eb-a207-cecf2c44573f
2
private String getRandomOrderId(String prefix) { String orderId; Date date = new Date(); StringBuilder sb = new StringBuilder(); if (prefix != null) { sb.append(prefix); sb.append("_"); } SimpleDateFormat df = new SimpleDateFormat("MMkkmmssSSSS"); ...
91eabe88-0611-49cb-8ff3-fde417093321
9
public static void main(String[] args) { MyLogger.setLogLevel(MyLogger.logLevelInformation); InterpretCommandLineArguments(args); if (Photons.action == Photons.actionShowUsage) { MyLogger.displayInformationMessage(usage); System.exit(errorCode); } final Path logPath = Paths.get(Photons.destina...
5f6fdf23-7386-4e26-ae39-0b72ae310a4e
6
public static boolean ecrireFichier(ZoneGeographique zone){ Tournee tournee = zone.getTournee(); String idFichier = getHeure(Calendar.getInstance().getTime()).replace(":", ""); String nomFichier = "./src/test/resources/feuilleDeRoute_"+idFichier+".txt"; BufferedWriter fichier = null; try{ fichi...
5de4f8a8-fcb3-48d4-89e9-7605f198d111
7
public String toXMLBIF03() { if (m_Instances == null) { return("<!--No model built yet-->"); } StringBuffer text = new StringBuffer(); text.append(getBIFHeader()); text.append("\n"); text.append("\n"); text.append("<BIF VERSION=\"0.3\">\n"); text.append("<NETWORK>\n"); text.ap...
05c7da5d-2a9d-4777-96b0-23a338bc8538
5
public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append("Neural network with " + n + " layers:" + newLine); for(int i = 0; i < n; i++) { result.append(" x: "); for(int j = 0; j < x[i].length; j++) result....
20c7c7d1-d58e-4185-85e1-23980b18688d
3
public static void writeCSV(List<String[]> data) { File file = new File(CSV_DST); if(file.exists()){ // 如果文件已存在,先删除 try { Files.delete(file.toPath()); } catch (IOException e) { logger.error(String.format("刪除已存在文件[%s]失败", CSV_DST)); } } CSVWriter writer = null; try { logger.info(Stri...
17bd8cbd-5522-4e65-9fbc-1d2b1ceecb12
5
@Override public void update(Input input, int delta) { if(input.isKeyPressed(Input.KEY_SPACE)){ setCurrentState(new JumpingState<Jori>()); } else if(input.isKeyPressed(Input.KEY_LEFT)){ setCurrentState(new WalkingState<Jori>()); setDirection(DIRECTION.LEFT); } else if(input.isKeyPressed(Input.KEY_RI...
f3a77834-2e74-453d-a809-aa08125940fe
2
@Override public void run() { try { Socket socket = new Socket(localIP ,25565); toServer = new ObjectOutputStream(socket.getOutputStream()); Thread listener = new Thread(new Listener(socket)); listener.start(); beginConnection(); } catch (UnknownHostException e) { e.printStackTrace(); } catch...
baf076fa-e85a-4dfe-ab44-66a67e9c822e
2
public static void main(String[] args) { Echo frame = new Echo(); frame.setSize(400, 300); frame.setVisible(true); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (socket != null) { try { socket.close(); } catch (IOException ioEx) ...
663a551a-5390-49fc-a052-263d7ca18c02
6
public void run() { while(ballAlive) { try{Thread.sleep(speed);}catch(Exception e){} switch(_state) { case state_inGame: if(!stateAnimated) { ballIsInBarr(); if(MetalBreaker.blocks!=null) ballIsInBlock(); move(); } else animateBall(); break; case state_M...
2a98ca8a-7f62-425e-8b81-1c7f3f8d9897
7
private void doBlockCollisions() { for(int x1 = -1;x1<=w;x1++) { for(int y1 = -1;y1<=h;y1++) { int gridX = (int) ((x1+x)/Block.BLOCK_WIDTH); if(gridX < -1) gridX -= 1; int gridY = (int) ((y1+y)/Block.BLOCK_HEIGH...
b13a5a00-a203-4f74-8092-ff983fe2ea7e
8
final public void Program_body() throws ParseException { /*@bgen(jjtree) Program_body */ SimpleNode jjtn000 = new SimpleNode(JJTPROGRAM_BODY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { Component_declarations(); Progra...
418e2b68-ff25-4601-9888-0d065cb2eaf2
1
private void saveDictionnaire(PrintStream out) throws IOException { out.println("<h3>Dictionnaire des informations</h3>"); out.println("<table class=\"cadre\">"); out.println("<tr>\n<td><B>Nom</B></td>"); out.println("<td><B>Code</B></td>"); out.println("<td><B>Type</B></td...
bdeccf25-d2ed-4806-a9e9-7abe0fd96b33
4
* </ul> */ public void select (int index) { checkWidget (); if (!(0 <= index && index < itemsCount)) return; selectItem (items [index], (getStyle () & SWT.MULTI) != 0); if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) { redrawItem (index, false); } getAccessible().selectionChanged(); }
ab829094-224a-4d17-a9e6-814bf94eeb46
0
public void setSex(Boolean sex) { this.sex = sex; }
19b88958-7926-4c33-bc0f-ff359425eb21
2
private void recoverSitesHasVar(int writeVarIndex) { for(int i: sitesHasVar(writeVarIndex).keySet()) { Site site = sitesHasVar(writeVarIndex).get(i); if(!site.isFailed()) { site.recoverVar(writeVarIndex); } } }
c239be34-01c9-4eca-9bd0-0d3814c7ad1c
3
@Override public void draw(Graphics2D g2) { g2.drawImage(background, 0, 0, GamePanel.WIDTH, GamePanel.HEIGHT, null); g2.drawImage(coin, GamePanel.WIDTH - coin.getWidth() - 105, 7, coin.getWidth(), coin.getHeight(), null); g2.setFont(newFont(45)); // argument: font-size(float) g2.drawString(PlayerData.playerDat...
59221602-5447-464a-88cf-a95d73ecf829
4
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_W) { p.moveUp(); } else if (e.getKeyCode() == KeyEvent.VK_A) { p.moveLeft(); } else if (e.getKeyCode() == KeyEvent.VK_D) { p.moveRight(); } else if (e.getKeyCode() == KeyEvent.VK_S) { p.moveDown(); } }
1f1a7a13-fff5-4ff1-b382-5a9b3f86d046
8
@Override public void actionPerformed(ActionEvent e) { JButton button = (JButton)e.getSource(); if (button.equals(Q2)) { Boolean applicationQ2 = application.isQ2Associated(); if (associatedQ2 == false && applicationQ2.equals(false)) { Q2.setText("Q2 - ASSOCIATED (Click to Disassociate over Q2)"); ...
6401c632-153c-4ab7-8b2d-a8bc9619d923
6
public int partition(Comparable[] a, int low, int high) { int i = low; int j = high + 1; Comparable v = a[i]; while (true) { while (less(a[++i], v)) { if (i == high) { break; } } while (less(v, a[--j]...
9b070d29-42b0-457c-858a-1d68f318c531
7
public static void main(String[] args) throws Exception { if (min(5, 8, 6, 6) != 5) { System.out.println("1) Неправильно для a"); //вывод=5 } if (min(-1, -3, -2, -5) != -5) { System.out.println("2) Неправильно для отрицательных чисел"); //вывод=-5 ...
acc1f5e2-4cc9-4571-b0b5-4d1112e7bc9a
8
public static ImageProcessor convolve(ImageProcessor ip, double[][] kernel) { // get image and kernel sizes int image_width = ip.getWidth(); int image_height = ip.getHeight(); int kernel_width = kernel.length; int kernel_height = kernel_width; // NOTE: assume square kernel int kernel_half_width = (int)M...
0610b18a-5c8d-48bf-a61e-dd0587295079
1
@PUT @Path("/v2.0/ports/{portId}") @Produces(MediaType.APPLICATION_JSON) public Response updatePort(@PathParam("portId") String portId, final String request) throws MalformedURLException, IOException{ Object port; port = JsonUtility.fromResponseStringToObject(request,ExtendedPort.class); //Convert input object...
62573431-1363-4042-9787-22b66242cf5b
9
protected int transform(JavaMethod javaMethod, List tokens, int i) { JavaIdentifier token = (JavaIdentifier)tokens.get(i); if (i < tokens.size() - 1 && ((tokens.get(i + 1) instanceof JavaCallStart) || (tokens.get(i+1) instanceof JavaIdentifier))) { return i; } if (i > 0) { JavaToken pre = (JavaToken) toke...
a6cff158-be3e-431f-b456-bb8b4379e579
9
private void cleanUpInconsistency() { //Clean up max nick length if(settings.getMaxNickLen() == 0 && settings.getNickLen() != 0) { settings.setMaxNickLen(settings.getNickLen()); } if(settings.getMaxNickLen() != 0 && settings.getNickLen() == 0) { settings.setNickLen(settings.getMaxNickLen()); } /...
c90610cb-cfc3-4dcf-9b42-24282c6bb5ba
6
public static int dehexchar(char c) { if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'F') { return c - ('A' - 10); } if (c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; }
2283e3b3-8fa8-4967-bd0b-e694da0e8cd8
5
public static String generateRandomString(int aiLengh) { String lsRandomString = ""; if (aiLengh > 0) { char[] larrRandomChar = new char[aiLengh]; int c = 'A'; int r1 = 0; for (int i = 0; i < aiLengh; i++) { r1 = (int) (Math.random() * 3); ...
aa16efbb-4cee-4a3d-a378-a75742eafe92
0
public void setDate(int date) { this.date = date; }