method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
a72658d3-cb64-4121-a3a4-0a3dd73056d7
2
public boolean matchesSub(Identifier ident, String name) { for (int i = 0; i < matchers.length; i++) { if (matchers[i].matchesSub(ident, name) == isOr) return isOr; } return !isOr; }
763802f9-eb8f-45f8-a959-10bcaeb9297e
7
public int trap1(int[] height) { int N=height.length; int water=0; for (int i=0;i<N-1;){ if(height[i]==0){ i++; continue; } // System.out.println("i "+i); int maxIndex=i+1; for (int j=i+1;j<N;j++){ if(height[j]>height[maxIndex]){ maxIndex=j; } if(height[j]>=height[i]){ ...
557d8b15-4625-44eb-b56d-c26e6bc49656
7
private Move(int col0, int row0, int col1, int row1) { assert ((col0 > 0) && (col0 < 8)) && ((col1 > 0) && (col0 < 1)) && ((row0 > 0) && (row0 < 8)) && ((row1 > 0) && (row1 < 8)); _col0 = col0; _row0 = row0; _col1 = col1; _row1 = row1; }
71ef1b14-cfff-46d9-a3d7-30c9934af2d1
9
public static String[] getDecoderNames(SeekableStream src) { if (!src.canSeekBackwards() && !src.markSupported()) { throw new IllegalArgumentException(JaiI18N.getString("ImageCodec2")); } Enumeration enumeration = codecs.elements(); Vector nameVec = new Vector(); St...
287420a0-1971-40c8-852f-778916db72ef
8
private void btn_SubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_SubmitActionPerformed //Checking for missing details if ( !txt_Name.getText().equals("") && cmbbx_DOBDate.getSelectedIndex() != 0 && cmbbx_DOBMonth.getSelectedIndex...
55bcda97-0331-439a-9b85-a798d5c8f211
7
public static int trap3(int[] a) { int l = a.length; int[] before = new int[l]; int[] after = new int[l]; int max = 0; for (int i = 0 ; i < l ; i++) { before[i] = max; max = max > a[i] ? max : a[i]; } max = 0; for (int i = l-1 ; i >= 0 ; i--) { after[i] = max; max = max > a[i] ? max : a[i]; ...
ebdecbd4-3a45-4a7c-baa1-06304caf972c
2
private Client getClientByName(String name) { for (Client client : clients) { if (client.getName().equals(name)) { return client; } } return null; }
7b56a6c3-aa66-4417-b55b-06bdc0aba2c8
8
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { int var5 = 0; if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID) { ++var5; } if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID) { ++var5...
4cc95e48-2b66-4fed-a558-0bc348d46196
6
private void debugAddGoodsToUnit(final Game serverGame, Unit unit) { Specification spec = serverGame.getSpecification(); List<ChoiceItem<GoodsType>> gtl = new ArrayList<ChoiceItem<GoodsType>>(); for (GoodsType t : spec.getGoodsTypeList()) { if (t.isFoodType() && t != spec...
3af7c938-747c-45ba-b9f8-4f6a68b1904f
0
@Override public void windowDeactivated(WindowEvent arg0) { }
006a0f85-b4c8-4305-9249-0d529e8e64bb
6
public static Object getAnnotatedFieldValue(Object source, Class<? extends Annotation> annotation){ Class<?> clazz = source.getClass(); try { for(Field field:clazz.getDeclaredFields()){ field.setAccessible(true); if(field.getAnnotation(Id.class) != null) return field.get(source); } return ...
bc46b3b5-e2a5-4102-886c-9b5bd248a993
8
public Object getObjectPosition(int x, int y) { for (int i = 0; i < getNumPlace(); i++) { PlaceUI p = (PlaceUI) getPlace(i); if (p.inPlace(x, y)) { selectedPlace = i; return p; } } for (int i = 0; i < getNumTransition(); i++) { TransitionUI t = (TransitionUI) getTransition(i); if (t.inTran...
b930811c-c426-4f42-afe2-aa0f23e1036a
4
public void actionPerformed( ActionEvent e ) { if( e.getSource() == this.buttonOK ) { InetAddress address = this.addressComboBoxModel.getSelectedAddress(); int port = this.portSpinnerModel.getNumber().intValue(); String protocol; if( this.radioTCP.isSelected() ) protocol = "TCP"; else ...
1d41e2f5-691b-4fd9-9173-9b2f4b164554
3
public static int min3(int a, int b, int c) { if( a > b ) return (( c > b) ? b : c); else return (( c > a) ? a : c); }
9ab3cdb8-2dc9-41ae-bcb0-9246bd4f582c
3
public static String encodeFromFile( String filename ) throws java.io.IOException { String encodedData = null; Base64.InputStream bis = null; try { // Set up some useful variables java.io.File file = new java.io.File( filename ); byte[] bu...
5dcbb339-25a1-41e9-af97-5a3f05fe1e3a
1
@Override public void actionPerformed(ActionEvent e) { JCheckBox source = (JCheckBox) e.getSource(); boolean state = source.isSelected(); if (state) { this.setTitle("JCheckbox example"); } else { this.setTitle(""); } }
d20785b8-8c31-46e4-a7d4-98906c49617b
3
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub String page=request.getParameter("page"); HttpSession session=request.getSession(false); String role=(String)session.getAttribute("role"); String id=(String...
cabfcd52-a992-49de-8390-e1431059876c
3
@Deprecated protected static Iterator<IPluggable> getIteratorFromComplexMap(Map<PlugMode, TreeSet<IPluggable>> map) { Iterator<IPluggable> it; PlugMode[] modes = PlugMode.getAllModes(); Set<IPluggable> set = new HashSet<IPluggable>(); for(PlugMode mode : modes) { it = map.get(mode).iterator(); while(i...
e576b6fe-1fee-499a-bc18-35e1a75e3bd3
6
public static void main(String[] args) { File file = new File("breast-cancer-wisconsin.data"); List<Point> data = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(file))) { String line; String[] values = new String[11]; double[] attributes = new double[9]; boolean valid ...
a12ff4cb-1561-4456-ba1c-f80d955f95b2
6
private boolean isSymmetricAux(TreeNode left, TreeNode right) { if (left == null && right == null) { return true; } if (left == null || right == null) { return false; } if (left.getVal() != right.getVal()) { return false; } re...
7cf48f13-6475-44d7-9daf-2963411cd5b3
4
private Canvas() { if (System.getProperty("com.horstmann.codecheck") == null) { frame = new JFrame(); if (!System.getProperty("java.class.path").contains("bluej")) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fr...
fbd7d7cc-ebce-4fe7-98cc-4e79d9827ae3
3
public static String[] trimArrayElements(String[] array) { if (isEmpty(array)) { return new String[0]; } String[] result = new String[array.length]; for (int i = 0; i < array.length; i++) { String element = array[i]; result[i] = (element != null ? element.trim() : null); } return result; }
c849be80-0167-4742-ac3b-9974db113c99
8
public void update(String line, LineStatus status, Scanner fileScan) throws IOException { ArrayList<UrlCard> allUrls = UrlCard.getAllUrls(); boolean isUrlObjectComplete = false; do { switch (status) { case BlankLine: { isUrlObjectComplete = true; } break; case ...
4ced8e01-cdf0-4672-ac8c-84410c794106
0
public static void main(String[] args) { new Test().howdy(); }
d0df9080-36fa-42d6-b954-be9eabd4df3d
0
@Override public String toString() { return "isAbstract()"; }
dfe4bb32-4013-46e1-9929-2874eb38ea9a
1
public void parseExpressions(String expressions, Handler handler) { for(String expression : expressions.split("[\n\r]+")) { parseExpression(expression, handler); } }
4570310c-e7e1-493c-a60c-7f5c622c9785
2
protected Object getDefault(String path) { Configuration root = getRoot(); Configuration defaults = root == null ? null : root.getDefaults(); return (defaults == null) ? null : defaults.get(createPath(this, path)); }
c9acf0fe-b2c3-48c2-bf4a-9986307b1b39
9
static void rellenarBlancos(int[][] mat, int posI, int posJ){ LinkedList<int[]> cola = new LinkedList<int[]>(); mat[posI][posJ]=3; cola.add(new int[]{posI,posJ}); while(!cola.isEmpty()){ int[] pos=cola.removeFirst(); if(pos[0]<mat.length-1&&mat[pos[0]+1][pos[1]]==0){ cola.add(new int[]{pos[0]+1,pos[1]...
d39c7a66-747f-4ed6-a93d-7aee1b9a9141
3
public JSONArray toJSONArray(JSONArray names) throws JSONException { if (names == null || names.length() == 0) { return null; } JSONArray ja = new JSONArray(); for (int i = 0; i < names.length(); i += 1) { ja.put(this.opt(names.getString(i))); } re...
63b6bc8e-e072-46ff-943e-6a1a2e8c5e80
2
public ParkingPlace getParkingPlace(long maxWaitMillis) throws ParkingException { try { if (SEMAPHORE.tryAcquire(maxWaitMillis, TimeUnit.MILLISECONDS)) { return pollParkingPlace(); } } catch (InterruptedException e) { throw new ParkingException(e); } throw new ParkingException("Timeout"); }
05353032-cd76-4cdb-bf0b-eac503513d0c
6
public void removeSolutions(int[] sol, int index) { ArrayList<PossibleSol> temp = new ArrayList<PossibleSol>(); for (int i= 0; i < sol.length; i++) { System.out.print(sol[i] + " "); } System.out.println(); for (PossibleSol current: this.possibleSol) { boolean found = true; for (int j = 0; j < in...
43778d9c-5783-48f8-91cf-ae30af6e2a68
4
public static void filledRectangle(double x, double y, double halfWidth, double halfHeight) { if (halfWidth < 0) throw new RuntimeException("half width can't be negative"); if (halfHeight < 0) throw new RuntimeException("half height can't be negative"); double xs = scaleX(x); double ys ...
d43ef7c9-abd3-4c7a-862a-16025084a00d
3
@Override public HallEventType getTypeByName(final String name) throws WrongTypeNameException { if (name == null) { throw new WrongTypeNameException("Type name is empty"); } switch (name) { case CONFERENCE_TYPE_NAME: case HACKATHON_TYPE_NAME: ...
e13f1641-c41d-47a2-bd15-d9719b4c3712
9
private void drawHeatFluxSensors(Graphics2D g) { List<HeatFluxSensor> heatFluxSensors = model.getHeatFluxSensors(); if (heatFluxSensors.isEmpty()) return; g.setStroke(thinStroke); Symbol.HeatFluxSensor s = new Symbol.HeatFluxSensor(false); float w = HeatFluxSensor.RELATIVE_WIDTH * model.getLx(); float h ...
4caba5da-4ff5-4bb8-b70e-8f255110cb62
9
private void collectTypeHierarchy(Set<Class<?>> typeHierarchy, Class<?> type) { if (type != null && !IGNORED_CLASSES.contains(type)) { if (typeHierarchy.add(type)) { Class<?> superclass = type.getSuperclass(); if (type.isArray()) { superclass = primitiveTypeToWrapperMap.get(superclass); } ...
9c588975-593e-48bf-8828-114e8f64165c
2
private boolean isName(String token) { boolean isPossible = false; for (String name : getNames()) { if (name.equalsIgnoreCase(token)) { isPossible = true; break; } } return isPossible; }
146b7d03-83ce-48b5-ae0c-11b92b68b35e
9
public static void main(final String[] args) throws Exception { int runs = 1; int eat = 0; if (args.length <= 1) { Nonstop.usage(); } for (eat = 0; eat < args.length; eat++) { if (args[eat].equals("-run")) { if (++eat >= args.length) { Nonstop.usage(); } runs = Integer.parseInt(args[...
38a4af4e-8217-4f3f-a5f7-3117ad3a80a8
0
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Signature") public JAXBElement<SignatureType> createSignature(SignatureType value) { return new JAXBElement<SignatureType>(_Signature_QNAME, SignatureType.class, null, value); }
3e86bbb6-7fab-4090-9b25-b5e2f31a6438
7
@Override public boolean matches(Object argument) { if (argument instanceof PropertyChangeEvent) { PropertyChangeEvent event = (PropertyChangeEvent) argument; return propertyName.equals(event.getPropertyName()) && event.getOldValue() != null && event.getNewValue() != null ...
f91152cd-1cc6-4241-ac54-318879ef96aa
1
public void makeSelection() { if(list.getSelectedIndex() != -1) { selection = list.getSelectedValue(); dispose(); } }
019bc276-4b63-48e2-92f7-7e5e39e49a8c
9
@Override public void performNavigateAction(KeyEvent evt) { if (evt.isControlDown()) { switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: if (txtUsuario.equals(this.getFocusOwner())) { txtSenha.requestFocus(); } else...
ca874236-389e-4f04-86c5-8f2b918bd213
5
private String tagStyle(Cell cell, CellStyle style) { if (style.getAlignment() == ALIGN_GENERAL) { switch (ultimateCellType(cell)) { case HSSFCell.CELL_TYPE_STRING: return "style=\"text-align: left;\""; case HSSFCell.CELL_TYPE_BOOLEAN: ...
5c29024c-6f7a-4093-a7c6-fa26726082e5
4
@Override public boolean setChartOption( String op, String val ) { boolean bHandled = false; if( op.equalsIgnoreCase( "Shadow" ) ) { setHasShadow( true ); bHandled = true; } else if( op.equalsIgnoreCase( "ShowLdrLines" ) ) { setShowLdrLines( true ); bHandled = true; } else if( op.equalsIgn...
3f1f9f18-b308-435e-8685-6b1812b8eb03
4
public Path getImgPath_CommandBtn(Imagetype type) { Path ret = null; switch (type) { case KEYFOCUS: ret = this.imgComBtn_KFoc; break; case MOUSEFOCUS: ret = this.imgComBtn_MFoc; break; case PRESSED: ...
c1f8f8fe-13ba-47a7-8871-419e5063d4db
3
public char skipTo(char to) throws JSONException { char c; try { long startIndex = this.index; long startCharacter = this.character; long startLine = this.line; this.reader.mark(1000000); do { c = this.next(); if...
fc789d30-aca7-4bc8-a066-5377b0bc56d4
3
private void dealCards() { // Give three cards to each player. for (int i = 0; i < players.length; i++) deck.dealCards(players[i].getHandPile(), 3); // Put two cards in the skat. deck.dealCards(skat, 2); // Give four cards to each player again. for (int i = 0; i < players.length; i++) deck.dealCards...
e9eda0ae-85f1-4078-a129-550333a981ed
1
public synchronized void removeMember(Long id){ if (ids.contains(id)){ int pos = ids.indexOf(id); ids.remove(pos); types.remove(pos); roles.remove(pos); } }
79fbd49b-d0c5-484e-85de-f2559861a5b7
7
private void calcRow(int step, String expression) { int variableCount = Expression.getVariableCount(); String binaryStep = Integer.toBinaryString(step); while (binaryStep.length() < variableCount) { binaryStep = "0" + binaryStep; } int binaryCounter = binaryStep.length() - 1; for (int i = expression.le...
68d38518-921d-4f99-a8ee-e5fa45072981
4
public String getShortSuit() { switch ( suit ) { case SPADES: return "S"; case HEARTS: return "H"; case DIAMONDS: return "D"; case CLUBS: return "C"; default: return "J"; } }
781c356b-c203-4015-a939-e16a9d83d860
7
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ContainerHolder that = (ContainerHolder) o; if (image != null ? !image.equals(that.image) : that.image != null) return false; if (u...
5e5477a9-2054-4ae9-9430-0a0d734a3673
8
public void scaleHunger() { // Cancel if the player is not applicable if (!utils.isValidWorld(player) || !utils.isEnabled()) { setCancelled(true); return; } if (utils.isExempt(player)) { setCancelled(true); return; } FileConfiguration c = plugin.getConfig(); // Scale the hunger if(play...
62b5595f-8fc9-4da1-86c1-6d762845d4f8
0
public double getEntrega() { return entrega; }
84802769-ef29-4418-86e0-fc183f42c6cb
4
private Weibo parseToWeiboSina(JSONObject info) { Weibo weibo = new Weibo(); try { String geo = info.getString("geo"); if (geo==null||geo.equals("null")) { return null; } if (setGeo(weibo,geo)==0) { return null; } JSONObject user = info.getJSONObject("user"); weibo.setUid(String.valueO...
9ecae5d6-1786-4f9e-ada4-b6d05bfb913d
3
@SuppressWarnings("serial") public Action graphLayout(final String key, boolean animate) { final mxIGraphLayout layout = createLayout(key, animate); if (layout != null) { return new AbstractAction(mxResources.get(key)) { public void actionPerformed(ActionEvent e) { final mxGraph graph = grap...
f8ece3f5-6333-488f-abb2-0c3122bc5c33
5
@Test public void TestaaVasemmaltaOikealleEste() { rakentaja = new Kartanrakentaja(10, 6); rakentaja.asetaEste(5, 3); rakentaja.asetaEste(4, 3); rakentaja.asetaEste(6, 3); char[][] kartta = rakentaja.getKartta(); Solmu aloitus = new Solmu(5, 0); Solmu maali = ...
6d800951-66e1-48ca-bf82-740c91e10a40
2
@Override public void run() { this.init(); while (running) { this.doLoop(); this.calculateDelta(); drawManager.draw(); try { Thread.sleep(20); } catch (InterruptedException e) {} } }
346f15fc-1b01-4637-ba17-24458698e26d
4
public void keyReleased(KeyEvent e) { int key=e.getKeyCode(); if(key == KeyEvent.VK_UP) dy=0; if(key == KeyEvent.VK_DOWN) dy=0; if(key == KeyEvent.VK_LEFT||key == KeyEvent.VK_RIGHT){ dx=0; ChangeTex(1); } }
1b902bda-faa7-4508-b9f7-6aeff6d0c8dd
4
public static Graph randomTree2() { int depth = 10; Graph graph = new Graph(depth * 50, depth * 50); int a = 0; int b = -1; int c = 0; for (int i = 0; i < depth; i++) { for (int j = 0; j <= i; j++) { graph.addVertex(new Vertex(c++, 25 + 25 * (depth - i - 1) + 50 * j, 25 + 50 * i)); } i...
8a45a9a4-951b-4d5e-8377-e1a4e4a68298
4
public static void notifyEOS( String sourcename, int queueSize ) { synchronized( streamListenersLock ) { if( streamListeners == null ) return; } final String srcName = sourcename; final int qSize = queueSize; new Thread() { ...
2a49d344-5201-495e-bac6-cfbd29d5f15c
7
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(target,null,null,L("<S-NAME> <S-IS-...
e5162fea-0aca-4e8e-b871-0f0e7f3bd11b
9
public void stepTestOn(PrintWriter oo) { Stepper stepr; ScruSet keyPile; ScruSet valuePile; SetTable tab; oo.print("Test fetching of steppers (stepper at a key).\n"+ ""); keyPile = testKeys(); valuePile = testValues(); tab = SetTable.make(testCS()); Stepper stomper = keyPile.stepper(); for (; stomper.hasValue...
b8daf6b0-95df-41fd-b8a4-2b491cc370b1
9
private HttpRequestBase getMethod(String url, HttpMethod requestMethod, Map<String, String> headers, Map<String, String> params, File data) { if (requestMethod == HttpMethod.POST) { HttpPost httpPost = new HttpPost(url); setReqHeaders(httpPost, head...
cdcdc00b-ac51-4679-9a3a-bac06ae91740
4
public static String logging(String xliffFilename, String applicationName) { System.getProperties().put("proxySet", "true"); System.getProperties().put("proxyHost", "www-proxy.cs.tcd.ie"); System.getProperties().put("proxyPort", "8080"); LoggerStatus status = null; Properties pr...
e743e83f-6a7c-4502-aca2-6277ae6e6466
8
public void processEdit() { // set new size to accommodate additional components setSize(GUI_WIDTH_AFTER_EDIT, GUI_HEIGHT_AFTER_EDIT); // create south JPanel south = new JPanel(new BorderLayout()); south.setBackground(Color.LIGHT_GRAY); // create topSouth JPanel and add components to it JPanel topSouth...
5ff3fbda-200a-4268-8fd6-7f168c182307
4
public static void main(String[] args) { File inputFile = new File("QuickSort.txt"); String inputFilePath = inputFile.getAbsolutePath(); // read and parse input file try { String strLine = ""; int count = 0; FileInputStream fstream = new FileInputStream(inputFilePath); DataInputStream in = new Data...
0d9d5631-f480-4b50-9eb7-d95e3375f321
8
public static int getCategoryIdByName(String categoryName) { ResultSet rs=null; Connection con=null; PreparedStatement ps=null; int result=0; try{ String sql="SELECT CATEGORYID FROM CATEGORY WHERE CATEGORY_NAME=?"; con=ConnectionPool.getConnectionFromPool(); ps=con.prepareStatement(sql); ps.setSt...
5ea9df29-2a5b-4851-b20a-c5e87d34cf13
1
public Combination<Colors> generate(){ List<Token<Colors>> combination = new ArrayList<Token<Colors>>(); List<Colors> colors = Colors.getColors(); Random r = new Random(); for (int i = 0; i < Combination.SIZE; i++) { int n = r.nextInt(colors.size()); combination.add(new Token<...
5077cdda-85d4-4422-b71e-cc107fca4e94
6
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); ArrayList<Integer> primes = primeNumbers(32769); while ((line = in.readLine()) != null && line.length() != 0) { in...
5bf8190f-8a15-4338-81a1-2aad8d76244c
3
@Override public int hashCode() { int result = access != null ? access.hashCode() : 0; result = 31 * result + (refresh != null ? refresh.hashCode() : 0); result = 31 * result + (scope != null ? scope.hashCode() : 0); return result; }
518c1298-5b0c-491d-ac80-9a6a13034ff3
7
public ArrayList subledger1(String type, String loanid, float amount) { //get all details subledger needs arrayTemp= new ArrayList(); String query = "select * from loan_dtl where loanid="+loanid+" and amordate between to_date('"+startDate.substring(0, 10)+"','yyyy-mm-dd') and to_date('"+endDa...
159849b3-942b-4e40-9f00-d90a9ec0d7e8
8
private static boolean isValidCharCode(int code) { return (0x0020 <= code && code <= 0xD7FF) || (0x000A == code) || (0x0009 == code) || (0x000D == code) || (0xE000 <= code && code <= 0xFFFD) || (0x10000 <= code && code <= 0x10ffff); }
b685a503-6cac-4cfe-a531-2d76fbf92251
0
protected boolean canBreed() { return getAge() >= getBreedingAge(); }
3b95d346-6d9c-48d8-ab8d-b492c14bcb67
8
protected boolean hasGotCollision(Position myFreeposition, List<Position> piecesPositions) { int x = myFreeposition.getX(); int y = myFreeposition.getY(); Position tmp = new Position(x + 1, y - 2); if (piecesPositions.contains(tmp)) { return true; } tmp.setY(y...
c2297d71-171d-46e7-9522-d65120f12093
8
public boolean addRecord(long value, int blockID){ //System.out.println( "addRecord() " + value + ", " + blockID ); boolean success = false; if( !isLeafNode() ){ //System.out.println( "Adding record to internal node! " ); //System.out.println( "addRecord() " + value + ", " + blockID ); //...
e0dcaeea-7968-43c0-97cf-889bdfb4f834
9
public boolean checkOpposites(String elementDesc) { String oppositeElement, oppositeElement2 = ""; elementDesc = elementDesc.toLowerCase(); if(elementDesc.equalsIgnoreCase("earth")) oppositeElement = "lightning"; else if(elementDesc.equalsIgnoreCase("arcane")) oppositeElement = "life...
7bb2f713-4e4a-4f27-812b-f125737bc175
7
public ListNode deleteDuplicates(ListNode head) { if(head == null) return null; ListNode preHead = new ListNode(0); ListNode lastNot = preHead; preHead.next = head; head = head.next; while(head != null){ if(lastNot.next.val != head.val && lastNot.next...
3465482c-b1e1-41f5-90d8-ddfeee2fbc10
4
@Test public void testThrowExceptionOnReceiveTimeoutIfClosed() { try { consumer = new AbstractMessageConsumer(mockTopic) { }; assertNotNull("No subscription was made", mockTopic.getTopicSubscriber()); FutureTask<Message> f = getMessageFuture(consumer, 50); consumer.close(); Message m = f.get(...
11a5c800-a223-4582-8b88-f97e3443dfc6
8
public boolean initializeGame(ArrayList<String> playerNames, ArrayList<String> playerTypes) throws FileNotFoundException { isLoaded = false; this.playerNames = playerNames; this.playerTypes = playerTypes; board = new Board(); try { // Reads countries file reader = new BufferedReader(new FileReader(...
0dfdb6f8-48cb-428d-ae10-8b8f0483b435
9
public String addOperator(String s){ if (position ==0){ return getMessage(); } if (position ==1){ if(s.equals("=")) return getMessage(); setCalculatorSequence(position,s); return getMessage(); } if (position ==2){ ...
ed539319-0048-44dd-b90b-796110d7c3ef
1
public static void mouseRelease() { if(mousePressed) { mousePressed = false; mouseHeld = false; //mouseRelease = new Point2D.Double(Mouse.getX(), -(Mouse.getY() - Camera.get().displayHeight)); } }
66503133-2b7b-45e5-b1b0-0cd17a75b0f5
7
public TurnContext playTurn(Game g) { TurnContext state = new TurnContext(g, false); currentCx = state; if (!getHand().isEmpty()) switchToHand(state); else if (!getFaceUp().isEmpty()) switchToFaceUp(state); else if (!getFaceDown().isEmpty()) switchToFaceDown(state); if (hasValidMove(state) || sta...
4bccdfa5-3b65-4bc2-83f6-2b82de668d34
1
public void testSetDayOfYear_int2() { MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8); try { test.setDayOfYear(366); fail(); } catch (IllegalArgumentException ex) {} assertEquals("2002-06-09T05:06:07.008+01:00", test.toString()); }
3f47a679-c44e-4ed8-8f00-11680a522254
1
private static ConcurrentHashMap<String, String> readHashMap( String directory) throws IOException, ClassNotFoundException { FileInputStream fin; try { fin = new FileInputStream(directory); } catch (FileNotFoundException e) { writeHashMap(directory, new ConcurrentHashMap<String, String>()); fin = new ...
2dafc099-f521-4803-adb4-0480fc263e7d
5
public void doAction(String value) { char choice = value.toUpperCase().charAt(0); while (choice != 'A' && choice != 'B' && choice != 'C' && choice != 'D') { System.out.println("Invalid selection"); choice = getInput().toUpperCase().charAt(0); } if (choi...
87bdf172-3f32-44a1-84ae-7f77831bed5f
7
public void nextFlight(ArrayList<Flight> currentPath, ArrayList<String> visited, String fromDest, String toDest) { Flight recentFlight = currentPath.get(currentPath.size() - 1); // Are we at our destination? if (recentFlight.getToDest().equals(toDest)) { // This is...
67a8cd58-7a6d-4a3c-aab1-319079e917b4
3
public boolean isMember(User user) { if (this.isAdmin(user)) return true; for (int i = 0; i < members.size(); i++) { if(members.get(i)==user) return true; } return false; }
ca92c432-853f-47d1-a90d-2cc33a726183
7
public LinkedList<Theater> getTheatersList(int zone) throws RemoteException{ if(this.lastRequest == -1) this.lastRequest = System.currentTimeMillis(); if(connectionTimout()){ System.out.println("Connection timout"); return null; } if(list.size() > 0) for(LinkedList<Theater> l : list) if...
c0515dca-e918-4700-b57f-f7675679a72b
6
private int processZipFile(File file, String targetPath) { List<Branch> branchs = CsvTool.getBranchs(); int count = 0; for (Branch branch : branchs) { if (file.getName().length() < 10) { continue; } /** * 4~10byte are bank code of branch file ext name should be .zip */ if (file.getName().s...
01834473-30f7-4d26-a7fc-abc8c188490c
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Detallecotizacion)) { return false; } Detallecotizacion other = (Detallecotizacion) object; if ((this.idDetalle...
fd7bc875-a4ca-458b-bb78-f50b741cec5a
5
public void testRec(Configuration conf,byte depth){ depth++; nbAppelListeFils++; if (depth == 2) System.out.println("nbappelListeFils : "+nbAppelListeFils); ArrayList<Configuration> listeConfig = listeFils(conf); if (depth<depthMax){ for (Configuration c : listeConfig) { testRec(c, depth); ...
be83a3f9-d3a6-4721-8eef-b996fb5be5b2
8
@Override public boolean tick(Tickable ticking, int tickID) { if((affecting()==null)||(!(affecting() instanceof MOB))) return false; final MOB mob=(MOB)affecting(); if((affected==mob) &&(mob!=getCharmer()) &&((mob.amFollowing()==null)||(mob.amFollowing()!=getCharmer())) &&(mob.location()!=null) &&(mo...
6a968f06-e297-4f79-b499-0844d91a3c31
5
private CorbaOrocosConnection(OrocosDataPort port, ConnectionType connectionType, boolean init, LockPolicy lockPolicy, boolean pull, int bufferSize, int transport, int dataSize, String connectionName) throws CNoCorbaTransport, CNoSuchPortException { logger = Logger.getLogger(CorbaOrocosConnection.class); t...
0aaa5ac2-dc0d-4c66-bbe3-d79206180d7a
8
public List<Posizione> adiacenti(Posizione posizione) { List<Posizione> adiacenti = new LinkedList<Posizione>(); int x = posizione.getX(); int y = posizione.getY(); for(int i = -1; i<2; i++) { for(int j = -1; j<2; j++) { adiacenti.add(new Posizione(x+i, y+j)); } } Iterator<Posizione> it = adiac...
e2dcdd06-4aff-43c7-8b15-126967af858c
4
public Light(String color, String location) { this.color = color; this.location = location; light.addMouseListener(this); switch (location) { case "north": rotate(180); updatePosition(320, 220); break; case "east": rotate(27...
ae9c7d8c-d4db-4f64-9c3e-d23906032310
9
public static AppServer getInstance(String strTypeConn) throws Exception { if (strTypeConn == null || strTypeConn.equals("Oracle")) { if (instanceOracle == null) { instanceOracle = new AppServer("Oracle"); } return instanceOracle; } else if (strTypeConn == null || strTypeConn.equals("MySQL")) ...
25fe3e17-6e11-4546-a419-8cfba8e1fedb
0
@Test public void resolve() { print(digitalSum(1000)); }
e79741a5-dae1-4568-b7ad-212ce6a0a691
3
public void givereward(int cluelevel) { if (cluelevel == 1) { cluereward(Clues.randomClue1(), Clues.randomClue1(), Clues.randomNonClue1(), Clues.randomNonClue1(), Clues.randomRunes1(), 1, 1, 1, 1, 500); deleteItem(2681, GetItemSlot(2681), 1); cluelevel = 0; cluestage = 0; clueid = 0; savemoreinfo(); } if (cluelevel == ...
5aa6dbb0-859a-4d8a-99b4-1948a0ca658b
4
@Override public void action() { if(agente.getPasso() == 9 && agente.getCuponsCompradosComSucesso().size() > 1){ System.out.println("PASSO 9 AI"); for(ListaDeCupons lista : agente.getCuponsCompradosComSucesso()){ for(Cupom cupom : lista){ System.out.println("************************************...
c3d5ac02-d45b-4096-8b4e-73ed8fd15477
8
public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) { String s = remapper.mapFieldName(className, name, desc); if ("-".equals(s)) { return null; } if ((access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) == 0) { if ((acce...
c99dae9a-dd1c-45ac-8d0f-3cb77eb41123
7
public static List<TestData> loadData(final String componentName) { List<TestData> result = new ArrayList<TestData>(); File componentDir = new File("res/testdata/" + componentName); if (!componentDir.exists() || !componentDir.isDirectory()) { throw new IllegalArgumentException("Test directory does not exist or...