method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
297ab629-5b98-4138-afd1-ff442a2d9565
0
public void actionPerformed(ActionEvent arg0) { Component apane = environment.tabbed.getSelectedComponent(); JComponent c=(JComponent)environment.getActive(); SaveGraphUtility.saveGraph(apane, c,"BMP files", "bmp"); }
521b73e1-a738-4aa0-a47e-39a8be1c5327
1
protected void calcDIR_NTRes() { byte[] bTemp = new byte[1]; for (int i = 12;i < 13; i++) { bTemp[i-12] = bytesOfFAT32Element[i]; } DIR_NTRes = byteArrayToInt(bTemp); }
c01ecc69-5779-4344-8376-77a505af311e
1
public static String toString(byte[] data) { ByteArrayInputStream bais = new ByteArrayInputStream(data); DataInputStream dis = new DataInputStream(bais); try { return dis.readUTF(); } catch (IOException e) { } return null; }
797e6271-6c81-4f54-919f-182568565671
7
public void setActionEnabled(String type, boolean enabled){ if(type.equals("undo")){ toolBarUndo.setEnabled(enabled); editUndo.setEnabled(enabled); } else if(type.equals("redo")){ toolBarRedo.setEnabled(enabled); editRedo.setEnabled(enabled); ...
839f77f0-022b-4fe8-9764-d565d2e6feec
0
@Override public LoggerAppender[] getAppenders() { return (LoggerAppender[])appenders.toArray(new LoggerAppender[appenders.size()]); }
b3724054-8160-410c-800a-bdbdbce2409d
5
public static double romberg(SingleVarEq f, double a, double b, int steps){ // TODO: Fix this to start at index 0 rather than 1; // It works as is, but allocates one dimension of extra array space than necessary. // since the 0th row and column is never used. double[][] R = new double[3][steps + 1]; double...
caefccca-1d13-425d-bdd4-9b2e48a6e6d6
0
public void reset() { startTime = System.currentTimeMillis(); }
f178cc2c-3d85-4296-851c-010d4504a947
5
public void loadConfig(String config){ int configlength = config.length(); for (int i = 0; i < 81; i++){ int[] xy = indexToXY(i); int x = xy[0]; int y = xy[1]; String cellValue = ""; if (i < configlength){ char configValue = config.char...
ccb3fe11-601d-45e1-86a6-74eae07cea66
0
public RouterPacket(byte[] buf, int length, InetAddress address, int port, int time, int sequence) { //set the sequence number of the packet this.sequence = sequence; //set the time created timeCreated = time; //create the packet dPacket = new DatagramPacket(buf,lengt...
90db231a-aea0-4b8e-9750-8b887b9f1e7a
1
public void render(Graphics graphics){ for(int i=0;i<object.size();i++){ tempObject = object.get(i); tempObject.render(graphics); } }
8690278c-102c-4144-9e6e-3169a9db4ff7
5
private int getHeaderEndIdx(byte[] buf) { int idx = 0; while (idx + 3 < buf.length) { if (buf[idx] == '\r' && buf[idx + 1] == '\n' && buf[idx + 2] == '\r' && buf[idx + 3] == '\n') { return idx + 4; } idx++; } return 0; }
743f8ce8-d65d-4024-84a0-edbf68573437
9
@Override public final void actionPerformed(final ActionEvent evt) { if (ePomodoroTime == pomodoroTime) { ePomodoroTime--; // To ensure progress is not 100% at start if (isLongBreakNow) { taskPanel.setStatus(CurrentTaskPanel.WORKING_THEN_LBRK); } ...
6ac8a8e2-0f39-4f25-99f4-7a2438e930a3
8
protected String toJSONFragment() { StringBuffer json = new StringBuffer(); boolean first = true; if (isSetCreditInstrumentId()) { if (!first) json.append(", "); json.append(quoteJSON("CreditInstrumentId")); json.append(" : "); json.append(quoteJSO...
b8cb5809-fa03-4c2c-a9f2-d96d422c0030
7
private void updateBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateBtnActionPerformed question = questionField.getText(); instructions = instructionField.getText(); // set the match patter of "[]" Matcher matcher = Pattern.compile("\\[([^\\]]+)").matcher(que...
1a35c518-18b7-447c-8819-d6e64d895f86
1
public IntegerNode pop(){ while (isEmpty() != true){ IntegerNode nextInLine = this.top; this.top = this.top.getNextTop(); count--; return nextInLine; } return null; }
1781ac8c-d8f1-4b79-8fff-621a36b3c6ef
8
private void iniReader() throws IOException { FileReader iniFile = new FileReader("D:\\search.ini"); BufferedReader reader = null; try { reader = new BufferedReader(iniFile); String str = ""; if((str = reader.readLine()) != null ) { field.setText(str); } if((str = reader.readLine()) != null ) {...
318c6c95-827b-4807-9d68-06eb857a2e12
1
void parseAttlistDecl() throws java.lang.Exception { String elementName; requireWhitespace(); elementName = readNmtoken(true); requireWhitespace(); while (!tryRead('>')) { parseAttDef(elementName); skipWhitespace(); } }
08e67deb-d57f-4f50-b21f-dde6d65a4089
9
private final int toIndex(Object base, Object property) { int index = 0; if (property instanceof Number) { index = ((Number) property).intValue(); } else if (property instanceof String) { try { index = Integer.valueOf((String) property); } catch (NumberFormatException e) { throw new IllegalArgume...
e710e97c-2c80-43d0-ad16-d3409d8254f2
9
final int method854(int i) { anInt10827++; Class259 class259 = method868((byte) -125); int i_32_ = aClass99_10893.anInt1281; boolean bool; if ((class259.anInt3258 ^ 0xffffffff) != -1) { bool = aClass99_10893.method1089(anInt10889, class259.anInt3283, -21712, class259.anInt3258); } else { bool = aClass...
e01c8dc7-ecd6-4b12-b459-041c6461c321
8
public static long parseLongWithTable(String s, int radix){ boolean negative = false; if(radix < 2 || radix > 36){ throw new NumberFormatException(); } char[] chars = s.toUpperCase().toCharArray(); if(chars[0] == 45){ negative = true; chars = removeChar(chars, (char)45); } chars = reverse(chars);...
b3aa0b90-91e0-4b06-b5dc-c7548375611a
5
public static void main(String[] args) { long sum = 0; outer: for (int i = 1; i <= 100_000_000; i++) { if (!isPrime(i)) continue; int n = i - 1; int end = (int) Math.ceil(Math.sqrt(n + 1)); for (int j = 2;...
3dc695c4-7cc1-41a0-86d7-7c31197986de
8
boolean placeDomino(int i) { if (i == D.length) { for (int d = 0; d < D.length; d++) { System.out.println(D[d]); } return true; } for (int x = 0; x < w; x++) for (int y = 0; y < h; y++) { if (tryPlace(i, x, y, x - 1, y) || tryPlace(i, x, y, x + 1, y) || tryPlace(i, x, y, x, y + 1) || try...
a71c1518-e296-435a-80f8-9e65348c065e
7
public int checaDia(int diaTemp) { int ultimoDiaMes[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if (diaTemp > 0 && diaTemp <= ultimoDiaMes[mes]) { return diaTemp; } else if ((mes == 2 && diaTemp == 29) && (ano % 400 == 0) || ((ano % 4 == 0) && (ano % 100 != 0))) { ...
89ab7589-4cce-46c2-bfd5-d3044413d813
4
public Writer(String fileName) throws UnsupportedCharsetException { if (System.getProperty("file.encoding").equalsIgnoreCase("UTF-8") == false) { String explainString // Chack whether the encoding property is correct = "\n\tThe system property: \"file.encoding\" should set to \"U...
365c0be1-0a4b-4f32-b857-d665b38c56c3
8
public CreateDirectories() { try { String binning = "Bins"; boolean success = (new File(binning)).mkdir(); if(success) { System.out.println("Folder 'bins' created"); } for(int ab = 0; ab<4; ++ab) { // alpha/beta designation for(int d=0; d<10; ++d) { // distance for (int delta=0; del...
abc65f7f-09dc-4249-8b7c-0425686ede77
5
public static <A, B> Equal<Either<A, B>> eitherEqual(final Equal<A> ea, final Equal<B> eb) { return equal(e1 -> e2 -> e1.isLeft() && e2.isLeft() && ea.f.f(e1.left().value()).f(e2.left().value()) || e1.isRight() && e2.isRight() && eb.f.f(e1.right().value()).f(e2.right().value())); }
b14c8618-b597-4e3f-ae46-dd21cc7b79cd
4
public static <A> Equal<List<A>> listEqual(final Equal<A> ea) { return equal(a1 -> a2 -> { List<A> x1 = a1; List<A> x2 = a2; while (x1.isNotEmpty() && x2.isNotEmpty()) { if (!ea.eq(x1.head(), x2.head())) return false; x1 = x1.tail(); x2 = x2.tail(); } ...
c2c7c754-a4bf-4a89-a3b5-3ae33a1ee1c4
7
private boolean isTrueSNP(VariantCandidate v) { if (v.val("max.qual.minor") > 59.699 && v.val("total.depth") <= 82.149 && v.val("allele.balance") >= 0.067) { return true; } else if(v.val("max.qual.minor") <= 60.101 || v.val("total.depth") > 60.973 || (v.val("allele.balance") > 0.048 && v.val...
69557252-bd08-4c15-aa23-120129ae58f2
7
private static void writeOperator(Writer output, AuOperator.Descriptor desc) throws IOException { if(desc == IntArithmetic.intAdd) { output.write("ia"); }else if(desc == Products.productType) { output.write("prt"); }else if(desc == Products.product) { output.write("prv"); }else if(desc instanceof Li...
e9d33e43-f88b-449b-8d6e-cd1f784d3397
8
public void append(double d[], int n) throws Exception { double tmp[]; int ln = n * stride; if (d == null || d.length == 0 || n <= 0) { throw new Exception("DataSet: Error in append data!"); } if (data == null) data = new double[increment]; // Copy the data locally. if (ln + length < data.length...
741191e6-c107-4d86-8cac-1efd45ace395
7
private static boolean isCompatible(Class[] paramTypes, Class<?>[] actualTypes) { if (actualTypes.length != paramTypes.length) return false; boolean found = true; for (int j = 0; j < actualTypes.length; j++) { if (!actualTypes[j].isAssignableFrom(paramTypes[j])) { ...
e3079884-9e6c-4904-a0d7-3bb87de865ca
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...
b9deb429-1a08-4c2a-b546-47e863ca8304
3
public static void main(String[] args) { int a = 10, b = 20; if( a > b ) { System.out.println(a + ">" + b); } else if ( a < b ) { System.out.println(a + "<" + b); } else if ( a == b ){ System.out.println(a + "==" + b); } }
5d797665-8dd7-425f-be3d-d6328c041f08
6
@Override public void mouseExited(MouseEvent e) { if(e.getSource()==recordBut){ recordBut.setIcon(recordIcon); }else if(e.getSource()==playBut){ playBut.setIcon(playIcon); }else if(e.getSource()==stopBut){ stopBut.setIcon(stopIcon); }else if(e.getSource()==saveBut){ saveBut.setIcon(saveIcon); }el...
4a33ec80-0846-47f7-a2a1-5087d5799d5f
4
public void setProperty(String property, String newvalue){ try { r = new BufferedReader(new FileReader(config)); } catch (IOException e1) { } String temp = ""; try { p = new PrintWriter(config); while((temp = r.readLine()) != null){ if(!(temp.startsWith(property))){ p.println(temp); } ...
61b42324-7075-4722-b7d6-3f361cf00c24
0
public int getID() { return IDNumber; }
d384fc2e-b76a-4de4-88fb-890ab3786ad5
0
protected Element createTransitionElement(Document document, Transition transition) { Element te = super.createTransitionElement(document, transition); MealyTransition t = (MealyTransition) transition; te.appendChild(createElement(document, TRANSITION_READ_NAME, null, t.getLabel())); ...
1d35df6b-57cb-4a67-8813-54f6d23b0a31
9
public GuiView() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); setLocationRelativeTo(null); try { GuiView.b...
aba287e0-ebe3-4373-bbf6-6f1ef49eae0b
4
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder out = new StringBuilder(); int nCases = Integer.parseInt(in.readLine().trim()); for (int nCase = 0; nCase < nCases; nCase++) { String word = in.readLine().trim()...
f3db1154-4ba1-4b22-885b-7a58969b6a77
7
public synchronized BufferedImage getSample(int width, int height) { BufferedImage sample = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D sampleEditor = sample.createGraphics(); sampleEditor.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ...
df8a306f-b8af-4d30-b29c-a06f97c2643b
7
public static Rule_DOT parse(ParserContext context) { context.push("DOT"); boolean parsed = true; int s0 = context.index; ArrayList<Rule> e0 = new ArrayList<Rule>(); Rule rule; parsed = false; if (!parsed) { { ArrayList<Rule> e1 = new ArrayList<Rule>(); int s1 =...
cc08cf0e-0d2d-4dca-be2d-6f007552f5dc
6
private void addInvoice() { Scanner sc = new Scanner(System.in); int orderID; boolean success; int testOrderID; do { success = true; System.out.println("Please enter the order id (enter -1 to exit):"); testOrderID = inputInteger(); ...
2b4059dc-da61-4b27-b8fd-afc3c31cc9e5
7
public void addAtIndex(int data, int position){ if(position == 1){ addAtBegin(data); } int len = size; if (position>len+1 || position <1){ System.out.println("\nINVALID POSITION"); } if(position==len+1){ addAtEnd(data); } if(position<=len && position >1){ Node n = new Node(data); Node cur...
f0792042-304f-4298-aa88-23f047b8b53c
9
private void outputTotalsRow( int groupLevel, ICalculator[] calcForCurrentGroupingLevel){ if(distribOfCalculatorsInDataColsArray.length != dataCols.size()){ //TODO: improve throw new IllegalArgumentException("dataRows and distributionOfCalculators arrays should have the same length"); ...
0af6ff46-d4ac-43af-bcd0-ab9e5d5632e4
0
public void setSink(boolean isSink) { this.isSink = isSink; }
c6c08287-cecd-4fc1-a88f-1cfaa0f1e092
5
public void initSoldats() { // Ajout des Héros heros = new Armee(NB_HEROS); for (int i=0; i<=NB_HEROS; i++){ int x, y; do{ x = (int) (Math.random() * (IConfig.LARGEUR_CARTE / 2)); y = (int) (Math.random() * IConfig.HAUTEUR_CARTE); ...
f98c27f2-11fc-4ac3-b5b7-4a6233882ccb
1
public static boolean userName(String username){ if(username.matches("[a-zA-Z](\\w){8,29}")) return true; return false; }
bfe611db-9c03-4a49-affb-b1a0c701df5a
4
private boolean isSocialNetworkAccountAdded(SocialNetworkAccount socialNetworkAccount) { for(int i=0; i<addedSocialNetworkAccountCount; i++) { SocialNetworkAccount addedSocialNetworkAct = socialNetworkAccounts[i]; //If they have the same account type ... if(addedSocialNetworkAct.getSocialNetworkAccoun...
6b3298a2-fa0b-4552-866c-f8bcf524d1ca
3
public void test_constructor() { BaseDateTimeField field = new MockPreciseDurationDateTimeField(); assertEquals(DateTimeFieldType.secondOfMinute(), field.getType()); try { field = new MockPreciseDurationDateTimeField(null, null); fail(); } catch (IllegalArgumentEx...
600093bf-6e0b-4548-ac53-764ddd5fba20
8
protected void onSelectionChanged(DiagramFieldPanel field) { if(field.isSelected()) queryBuilderPane.sqlBrowserViewPanel.addSelectList(field.getQueryTokenColumn()); else queryBuilderPane.sqlBrowserViewPanel.removeSelectList(field.getQueryTokenColumn()); packFields(); ...
bfb55c62-f5db-40a7-8259-46986542e3e6
1
public boolean exists() { return question != null && answer != null; }
b44c3767-632f-4ceb-ad19-4915881cdd8c
0
@Override public boolean supportsComments() {return true;}
b34bfa3d-b482-4a5b-976f-828928f7ab17
7
private void handleExitButton(ExitButton button) { // Check input if (button == null) throw new IllegalArgumentException("ExitButton can't be null"); // Check a tile is currently selected if (selectedTileButton != null) { Point2D from = selectedTileButton.getBoardPosition(); // Ca...
90316a90-1e8f-44d2-b780-4f57ea0df940
3
private static void caratInputValidator(){ while (!validInput) { try { System.out.print("You selected to search by carat. Please enter a carat: "); caratInput = actionInput.nextDouble(); System.out.println("You entered: " + caratInput); validInput = true; if(data1.is...
b35cb12b-90c3-4235-9ffd-79b39e22dafa
7
public static void main(String[] args) { try { File file = new File("C:\\Users\\Collin\\Downloads\\words.txt"); Scanner readFile = new Scanner(file); int maxLines = 0; int answer = 0; String wordList = readFile.nextLine(); String[] words; words = wordList.replace("\"","").split(","); for (int ...
62046310-4fd7-470f-b163-59fc2780f059
9
@Override protected void updateDefinition(final JeksCell cell, final String cellAddress, final String value) { if (currentTierOneHeader == TIER_ONE_HEADERS.FIELDS) { if (columnHeaderMapping.get(CodecUtils .getColumnFromString(cellAddress)) == TIER_TWO_...
101c3c2f-9df1-4e52-a0dd-e4e290892137
4
public void update(Game game) { super.update(game); if(age == 2) { for(Vector2d u : Types.BASEDIRS) { if(game.getRandomGenerator().nextDouble() < spreadprob) { int newType = (itype == -1) ? this.getType() : itype; ...
e6b8649d-fec8-44e4-9754-965331c32848
9
private void drawTableGrid() { Object[][] cellData = new Object[0][headers.length]; tableGridModel = new DefaultTableModel(cellData, headers) { private static final long serialVersionUID = 880033063879582590L; public boolean isCellEditable(int row, int column) { ...
43eca06a-b02b-4c69-9666-9e681a9f755d
6
@Override public void emettre() throws InformationNonConforme { Float[] tabFloat = new Float[informationRecue.nbElements() * nbEch]; for (int i = 0; i < informationRecue.nbElements(); i++) { if (informationRecue.iemeElement(i)) { for (int j = i * nbEch; j < (i + 1) * nbEch; j++) tabFloat[j] = ampMax; ...
8bf1104d-83a7-45b1-a776-0a4bed3c3d0b
8
public static void matchListings(List<Listing> listings, final Map<String, Product> productMap, final ManufacturerLookup manufacturerLookup) { System.out.println("Matching listings..."); // // single threaded implementation // for(Listing listing : listings) { // // // match product name // String prod...
a3134209-5fca-4a1d-b5fa-b9945a40e6b2
0
public void set(String key, Object value) { datas.put(key, value); }
f570c86d-4004-457c-b52b-5aa82e2dfe95
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...
667bc4d5-3217-4e42-9223-42aa5687efae
5
private void checkSymbols(char[] symbols) { if (symbols.length != this.numTapes) { throw new InvalidTransitionException("Specified " + symbols.length + " symbols for " + this.numTapes + " tapes."); } //Check that the symbol is valid for (char symbol : symbols) { boolean isContained = false; for (char ...
c0258a79-b96a-4f24-88ac-fb2ddbec896d
3
public static void main(String[] args) throws IOException, TechnicalException { MPSConnector mps = new MPSConnector(9302); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Write to test, f.e. \"0\". \"q\" to quit."); String s =in.readLine(); ...
78fdd675-79fd-485d-bf64-0e8aa9a29a47
8
private MethodST method() throws UnexpectedTokenException { StringBuilder signature = new StringBuilder(); this.expect(PLUS, MINUS, TILDE); signature.append(this.getToken().data); this.nextToken(); this.expect(IDENT); String type = this.type(); signature.append(type); this.expect(LPAREN, IDENT); if(t...
cfc47b15-2ab0-4c96-881d-0a8719a47088
7
public javax.sound.midi.Sequence createMidiSequence() { javax.sound.midi.Sequence s = null; try { s = new javax.sound.midi.Sequence(javax.sound.midi.Sequence.PPQ, 16); int channelNum = 0; for (Track t : tracks) { int tickCount = 0; javax.sound.midi.Track javaTrack = s.createTrack(); javaTrack.a...
99bd1f11-43a8-4e9a-8d7f-69bc516dba47
0
public void setSeatType(long value) { this._seatType = value; }
44de807c-1868-4cbc-b8a0-89f61727542a
3
@Override public void actionPerformed(ActionEvent e) { String s = promptUserForDirectory(); if (s == null) { return; //if user pressed cancel or close do nothing. } try { //todo tidify? //das magic registryHandler.setPathEnvironmentVari...
2eae5daa-f197-41e9-9b81-763ade346c42
2
protected void notifyObservers() { if(observers != null) for(PositionChangedObserver o : observers) { o.update(this); } }
a1ab38fe-9a56-49d8-a353-775e75073fb4
9
public static void main(String[] args) throws Exception { processConfigFile(args[1]); try { maxFiles = Integer.parseInt(args[2]); } catch (Exception e) { maxFiles = Integer.MAX_VALUE; } try { SpotSigs.minIdf = Double.parseDouble(args[3]); System.out.println("minIdf=" + SpotSi...
c98f4ccb-8308-4f9a-9d59-32ea5ea9bee4
5
public void run() { int seconds = 0; while(connected) { try { Thread.sleep(1000); } catch(InterruptedException e) { // nah } seconds = (seconds + 1) % idleTimeout; if(seconds == 0) { if(idle) { try { disconnect(); } catch(IOException e) { connected = false; ...
bfdd9f78-4aed-4eca-9156-e9ca4147691a
7
private static boolean isValid(int m, int d, int y) { if (m < 1 || m > 12) return false; if (d < 1 || d > DAYS[m]) return false; if (m == 2 && d == 29 && !isLeapYear(y)) return false; return true; }
ae1af086-6aa0-40c4-ac7a-2b04253f4674
8
@Override public boolean apply(Course course) { final int startTime = (startHours.getSelectedIndex() % 12) * 60 + startMinutes.getSelectedIndex() * 10 + startAmPm.getSelectedIndex() * 12 * 60; final int endTime = (endHours.getSelectedIndex() % 12) * 60 + endtMinutes.getSelectedIndex() * 10 + endAmPm.getSelectedInd...
cca2e8cd-b3a1-451c-8a01-51905240b14a
8
private static Trajectory secondOrderFilter( int f1_length, int f2_length, double dt, double start_vel, double max_vel, double total_impulse, int length, IntegrationMethod integration) { if (length <= 0) { return null; } T...
e6149326-e01f-4e1e-a859-f608f0cfe10f
0
public int numberSelected() { return selected.size(); }
3bc809fe-9160-480e-af7c-c535be495830
6
public void remove(Integer start, Integer end){ Interval toRemove = new Interval(start,end); List<Interval> affected = new LinkedList<Interval>(); for (Interval currInterval : sched){ if (!currInterval.isDisjoint(toRemove)) affected.add(currInterval); if (currInterval.start > toRemove.end) break;...
cb3c9d83-f664-4144-afb2-5767452fdbf0
6
public Graph randCreator(){ int p = 0,q = 0; g = new Graph(true); g.addColumn("id", int.class); g.addColumn("value", String.class); g.addColumn("source", String.class); g.addColumn("Edgetype", String.class); //This loop is used to create the nodes of the random graph. //We ensure same ...
7beb18d1-09ea-43c2-b985-0ff7dc618a24
9
private static int diff_commonOverlap(String text1, String text2) { // Cache the text lengths to prevent multiple calls. final int text1_length = text1.length(); final int text2_length = text2.length(); // Eliminate the null case. if (text1_length == 0 || text2_length == 0) { return 0; } // Truncate...
b963cc66-9c2b-4604-a093-d1ea58b94bdc
8
@Override public String getColumnName(int column) { switch(column) { case 0 : return "Nota"; case 1 : return "Nama"; case 2 : return "Pewangi"; case 3 : return "Berat"; case 4 : return "Masuk"; case 5 : return "Ambil"; case 6 ...
e76c0982-b03c-407a-9988-79a431db5ffc
0
public void resume_egress() { ++resume_egress_count; }
c95602e6-9c64-422a-83f5-7c7fc1259d9c
7
void addMapChanges(PropertyMapImpl propertyMap, ConstMap mapChanges) { HashMap map = (HashMap) changes.get(propertyMap); if (map == null) { map = new HashMap(); changes.put(propertyMap, map); } for (ConstMapIterator iterator = mapChanges.constIterator(); iterator.atEntry(); iterator.next()...
06e201de-ffeb-4045-a569-c161576db712
2
public static void main(String[] args) throws JFAuthenticationException, JFVersionException, Exception { final ITesterClient client = TesterFactory.getDefaultInstance(); client.setSystemListener(new ISystemListener() { @Override public void onStart(long processId) { LOGGER.info("onStart"); } @Ove...
e9942c68-9064-4d50-8b70-b36e72c9114d
8
private void externalReflection(Atom a) { double x0 = getX(); double x1 = getX() + getWidth(); double y0 = getY(); double y1 = getY() + getHeight(); double radius = a.sigma * 0.5; if (a.rx - radius < x1 && a.rx + radius > x0 && a.ry - radius < y1 && a.ry + radius > y0) { switch (RectangularObstacle.borde...
b113fbfd-820e-4842-895c-eedf4f12d09b
7
public void setInstalledDirectory(File targetDirectory) { if (installedDirectory != null && installedDirectory.exists()) { try { FileUtils.copyDirectory(installedDirectory, targetDirectory); FileUtils.cleanDirectory(installedDirectory); } catch (IOExceptio...
bf20ced3-ffa2-4e86-8678-6beb7a4db105
6
public boolean isComplete() { int size = board.length; for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { if (x == size - 1 && y == size - 1 && board[x][y] == -1) return true; if (board[x][y] != y * size + x + 1) return false; // Bail early } } return fals...
c2034b7a-e14f-477e-b067-4b44b719d3b4
2
public void Render() { for(int x = 0 ; x < this.mapImageWidth ; x++ ) { for(int y = 0 ; y < this.mapImageHeight ; y++) { this.tileMap[x + y * this.mapImageWidth].render((x << this.shiftCount) + xOffset , (y << this.shiftCount) + yOffset); } } }
1f018696-5425-4f41-824b-6afcad6a2de9
4
private boolean checkFieldLineWinn(int lineNumber, char cellValue){ boolean checkLine = true; for (int i = 0; i <= fieldSize - WIN_NUMBER_OF_CELLS ; i++){ checkLine = true; for(int j = i; j < i + WIN_NUMBER_OF_CELLS; j++){ if( field[j][lineNumber] != cellValue) ...
807c86ed-a015-4815-ab94-f15095034cfb
7
public static void combineMonomeConfigurations() { Configuration configuration = Main.main.configuration; if (configuration.getMonomeConfigurations() == null) { return; } @SuppressWarnings("unchecked") HashMap<Integer, MonomeConfiguration> tmpMonomeConfigurations = (HashMap<Integer, MonomeConfigurati...
fbda5267-820f-4a04-867b-055f17fd68a7
5
public boolean setParallelJobProbabilities( double uLow, double uMed, double uHi, double uProb) { if (uLow > uHi) { return false; } else if (uMed > uHi-1.5 || uMed < uHi-3.5) { return false; } else if(uProb < 0.7 || uProb > 0.95) { return false; } this.uLow = uLow; ...
9f9f6269-1f26-4913-83e0-e20127c8214a
9
private static void createFoldSVM(String[] args) throws FileNotFoundException, IOException { String orgDataFile = args[1]; int noFolds = Integer.parseInt(args[2]); BufferedReader br1 = new BufferedReader(new FileReader(orgDataFile)); ArrayList<String> posData = new ArrayList<String>(); ...
76a553a9-9ac1-4bda-8dfd-571bf73c26c0
9
@SuppressWarnings("rawtypes") public List<Claim> getClaims(String actionType, String team) { List<Claim> claimList = new ArrayList<Claim>(); Element claimE; Claim claim; if (actionType.equals(CLAIMSUBCLAIM)) { List<Claim> claimList1 = getClaims("claim", team); List<Claim> subclaimList = getClaims("subcla...
bb6e1a40-ffb1-43a5-9d52-57953b092576
5
int multiply(int a, int b) { boolean negative = false; // Sign if (a < 0) { negative = !negative; a = sub(0, a); } if (b < 0) { negative = !negative; b = sub(0, b); } int res = 0; while (b != 0) { if ((b & 1) == 1) { res = add(res, a); } a <<= 1; b >>= 1; // 算术移位 } return n...
01d41db1-1ede-4a4a-8dfa-4acff940f798
2
void send(String data) { if (socket == null) { println("Cannot operate with a null socket"); return; } PrintStream output; try { output = new PrintStream(socket.getOutputStream()); output.println(data); } catch (IOException e) { println("An exception has occured while sending to the socket"); ...
eeb9ccb0-f942-4cea-b884-0f354042a859
3
public ChannelEvent nextEvent() throws ChannelError, InterruptedException { ChannelEvent event; ChannelError error; if ((error = resetError()) != null) { throw error; } if ((event = resetEndEvent()) != null) { return event; } eve...
5d333a61-7406-4c2a-92b9-2474d684268f
1
public Bitstream(InputStream in) { if (in==null) throw new NullPointerException("in"); in = new BufferedInputStream(in); loadID3v2(in); firstframe = true; //source = new PushbackInputStream(in, 1024); source = new PushbackInputStream(in, BUFFER_INT_SIZE*4); closeFrame(); //current_frame_number = -...
124ed261-38cf-4340-9771-2b2a877641ed
3
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed Transferable clipboardContent = getToolkit().getSystemClipboard().getContents(this); if ((clipboardContent != null) && (clipboardContent.isDataFlavorSupported(DataFlavo...
e090bd3c-589a-45e0-96a3-ec28e41d3463
9
public static boolean writeWikiSample(BookmarkReader reader, List<UserData> userSample, String filename, List<int[]> catPredictions) { try { FileWriter writer = new FileWriter(new File("./data/csv/" + filename + ".txt")); BufferedWriter bw = new BufferedWriter(writer); int userCount = 0; // TODO: check en...
c4e902ab-8771-432a-a47a-8c3c440967c6
3
private static <T> List<T> filterToList( Iterable<T> source, Filter<T>... filters ) { List<T> dest = new ArrayList<T>(); for ( T each : source ) { filter_loop: for ( Filter<T> filter : filters ) { if ( filter.accept( each ) ) { dest.add( ea...
c228cad8-a2ab-4dca-bad1-634b076e1cd7
2
public static int getIndexSelectedValue(String name){ switch(name){ case "USD": System.out.println("USD"); return 2; case "CLP": System.out.println("CLP"); return 1; } return 0; }
66c1debd-5263-478d-9cea-b1c7bd3a26d8
8
public Node getEntrance(Node head){ if(head == null || head.next == null) return null; Node slow = head.next; Node fast = head.next.next; while(slow !=null && fast.next != null && fast != slow){ slow = slow.next; fast = fast.next.next; } if(slow == null || fast.next == null) return null; ...