method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
8827c862-1a4e-4ca4-96b3-6303c99df004
3
public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); StringBuilder out = new StringBuilder(); while (in.hasNext()) { int n = in.nextInt(); int[] v = new int[n]; int[] r = new int[n]; for (int i = 0; i < n; i++) v[i] = r[n - i - 1] = in.nextInt(); int[...
6f28efee-54ba-4058-8a1d-1849d6c37616
9
@Override protected int[] ParsePosition( String ToParse ) { int Position[] = { 0, 0 }; if( ToParse.length() == 2 ) { switch( ToParse.toUpperCase().charAt( 0 ) ) { case('A'): ...
efbc53bd-900e-48df-b76d-0b9ec5580def
1
private StringBuffer prepareFile(JoeTree tree, DocumentInfo docInfo) { String lineEnding = PlatformCompatibility.platformToLineEnding(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_LINE_ENDING)); StringBuffer buf = new StringBuffer(); buf.append("<?xml version=\"1.0\" encoding=\"").appe...
a5aa7f44-8e17-4772-a7bf-6dda17152fe1
7
static boolean authenticate( String username , String hashString, PassthroughConnection ptc ) { try { String encodedUsername = URLEncoder.encode(username, "UTF-8"); String encodedHashString = URLEncoder.encode(hashString, "UTF-8"); String authURLString = new String( "http://www.minecraft.net/game/checkse...
eb3cf7ce-6c13-423a-93af-d8fca7841e4a
5
@Override public void show() { String[][] data = ScoreIO.loadScores(); names = data[0]; scoreStrings = data[1]; int[] scores = new int[5]; for (int i = 0; i < 5; i++) { scores[i] = Integer.parseInt(scoreStrings[i]); } currentScore = ScoreIO.getScore(); place = 5; while (place > 0 && currentScore >...
9995e285-0f81-450a-a91f-bdc85ad5c496
5
public Map<Integer, Integer> getGeneSpans(String text) { Map<Integer, Integer> begin2end = new HashMap<Integer, Integer>(); Annotation document = new Annotation(text); pipeline.annotate(document); List<CoreMap> sentences = document.get(SentencesAnnotation.class); for (CoreMap sentence : sentences) {...
0a0a58e6-e01a-4592-b619-17e3481e4dc7
1
public Identifier getRepresentative() { Identifier ptr = this; while (ptr.left != null) ptr = ptr.left; return ptr; }
4356b4ab-5596-4cd3-a218-e692946723b5
4
public static Vector2D getClosest(ArrayList<Vector2D> list, Vector2D vec) { Vector2D closest = null; double distance = 0; for (Vector2D close : list) { double val = close.getDistance(vec); if (closest == null || val < distance && close != vec) { closest =...
064991a2-3dda-4cf2-8613-8c3bdbdb92bf
5
private void findMax() { if(calibrationDataSize > 0) { int index = 0; while(!calibrationFlag[index]) { index++; } max = data[index]; index++; for(int i=index; i<data.length; i++) { if(calibrationFlag...
5a89dcca-09a0-4a8c-837f-1f85b6d61417
7
void viewExistingCustomers() { boolean quit = false; while (!quit) { System.out.println("------------"); System.out .println("1.) Print All Registered Customer Information"); System.out.println("2.) Print Customer by ID"); System.out.printl...
a5b7a840-36d5-43d6-9e95-834a76306730
7
@Test public void testQueryOrder() throws FileNotFoundException{; int count = 0; for (Player p : myGame.getPlayers()){ if (count == 0){ assertEquals(p.getName(), "Test name"); count++; } else if (count == 1){ assertEquals(p.getName(), "Elessar Telcontal"); count++; } else if (count == 2){ as...
4288009b-5a64-4fa8-8f43-20417f24f7d6
5
private String generateTRGFile(String csvFilename) { // If this is the first time this step has processed data, // mark the step as started if (!this.running){ this.running=true; this.logStart(); } // Make sure filename ends in .csv if (csvFilename.toLowerCase().endsWith(".csv")) { // Replace .csv ...
59d31121-f1d4-44f9-be4f-6d3cfdc79fd0
3
private void tickForwards(){ time++; if(time % 60 == 0) second++; if(second == 60){ minute++; second = 0; } if(time == maxTime) finished = true; }
ad1fc90f-3fdd-4a66-ae52-421709d05968
3
@Override public String toString() { if (currentSize == 0) { return "[Empty Stack]"; } StringBuffer sb = new StringBuffer(); for (int i = currentSize - 1; i >= 0; --i) { sb.append("Stack[" + i + "] = " + array[i]); if (i > 0) { sb.append("\n"); } } return sb.toString(); }
fa991fc2-858c-4699-b3e0-aa9127deefbb
7
private void removeAnimal(int index) { if (index < animals.size() && index >= 0) { //System.out.println("Removing row " + index); animals.remove(index); animalCount --; if (index == mother) { mother = -1; } else if (index < mother) { ...
1e222e25-b76f-469e-b5f8-60eb1935467f
5
public void renderOverlay(int mx, int my, boolean[] buttons) { super.renderOverlay(mx, my, buttons); float slotX = x; float slotY = y-amountScrolled; if(slots != null) { int slotIndex = 0; for(int i = slots.length-1;i>=0;i--) { UISlot slot = slots[i]; if(slot == null) continue; if(s...
95f89cbf-94d6-435c-b662-ae7be484007f
6
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub HttpSession session = request.getSession(); synchronized(session) { response.setContentType("text/html"); // Get a output writer to write the respons...
733c97a9-4e5f-438b-bf1c-f8d4992862cd
7
public static List<String> searchNineItems() { String searchUrl = SearchUrl.NINE_URL; List<String> urls = new ArrayList<>(); for (int i = 1; i <= 3; i++) { for (Map.Entry<String, List<String>> m : cidToKeyMap.entrySet()) { String cid = m.getKey(); List...
7e736f14-cd41-411f-a654-00cb62239a11
1
public Expression simplify() { if (subExpressions[0].getType().getCanonic() .isOfType(Type.tSubType(castType))) /* * This is an unnecessary widening cast, probably that inserted by * jikes for inner classes constructors. */ return subExpressions[0].simplify(); return super.simplify(); }
2ac1e59a-a564-40d8-8917-02688722eecc
1
public static void main(String[] args) throws Exception { Socket socket = new Socket("127.0.0.1",5001); OutputStream os = socket.getOutputStream(); InputStream is = socket.getInputStream(); os.write("hi ".getBytes()); byte[] buffer = new byte[200]; int length = 0; while(-1 != (length...
37609a59-7ddf-4872-b2ad-f12d6a87f11c
6
public ReportResult getFilteredReport(String[] spielerNamen, String startString, String endeString) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.GERMAN); Date start = sdf.parse(startString); Date ende = null; if (endeString == null) { ende = new Date(); } else ...
1ab7010e-48e5-4825-9932-4369469a5ec2
7
public synchronized BufferedImage[] getShadeOverlays( int size ) { if( shadeOverlays == null || size != shadeOverlaySize ) { shadeOverlays = new BufferedImage[16]; for( int i=0; i<16; ++i ) shadeOverlays[i] = Blackifier.makeShadeOverlay( size, (i & TileLayerData.SHADE_TL) != 0 ? 1 : 0, (i & TileLaye...
183f0937-c028-49a2-a9fc-0cfa893a2062
2
private prRegion createNewRegion(Player player) { int x1,y1,z1; try { x1 = player.getMetadata("x1").get(0).asInt(); y1 = player.getMetadata("y1").get(0).asInt(); z1 = player.getMetadata("z1").get(0).asInt(); } catch (Exception e) { player.sendMessage(ChatColor.RED + "Select point 1 first."); return...
6c34f2ef-7f92-4aa1-8a7e-177c7ad2c5ea
4
public boolean action(Event e, Object o) { if (e.target == ok) { hide(); dispose(); } return true; }
67769343-b2ec-4be2-b6d9-0e69b19f9c45
8
public void adaptToHost() { //Update host size to current actual value if(inScrollPane) hostSize = scrollPanel.getSize(); else hostSize = slidePanel.getSize(); //Derive the number of onscreen pixels for one increment of the 800x600 //grid used for specifying size and positioning in the XML double gr...
831b29d2-9a87-4d87-8173-dd029b871cfe
9
public static Stella_Object generateCaseBasedAnswer(LogicObject probe, Surrogate slot, List cases) { { int num = cases.length(); Vector slotVector = Logic.createCaseValueVector(cases, slot); Vector matchScores = Vector.newVector(num); int farthest = 0; Vector nearestNeighbors = Vector.newVec...
1951b65d-5aaf-48b0-b2e0-fe8ce1354728
1
public static void main(String[] args) { Iterable collection = null; Iterator iterator = collection.getIterator(); while (iterator.hasNext()) { Object o = iterator.next(); } }
19616942-b25c-4e24-af99-8adbb0e83e09
0
protected void onUserMode(String targetNick, String sourceNick, String sourceLogin, String sourceHostname, String mode) {}
c4511d78-1155-40fa-9504-601f38576c38
6
@GET @Path("{path:.*}") public Response getItem(@PathParam("path") String path, @QueryParam("download") boolean download, @QueryParam("info") boolean info) throws ContentRepositoryException, IOException { try { CollectionObject item = repo.getItem(path); if (item instanceof Folder) { return Response.o...
569f2d24-9c80-45df-b73e-bf8d10ab1729
5
private void incomingVehicleMonitor(Vehicle v) { if (v instanceof MotorCycle) { numMotorCycles++; } else if (v instanceof Car && ((Car) v).isSmall() == true) { numSmallCars++; numCars++; } else if (v instanceof Car && ((Car) v).isSmall() == false) { numCars++; } }
11937da7-e9d4-4d40-bc71-57f41a5a80f2
2
public String toString(){ String positif = "+ = "; String negatif = ", - = "; for(Entry<String, Boolean> entry : preferences.entrySet()){ String cle = entry.getKey(); Boolean valeur = entry.getValue(); if(valeur){ positif += cle+" "; } else{ negatif += cle+" "; } }...
e8ee7d86-a4a4-42a4-a707-66230945fcad
7
public static NymOfferDetails getNymOfferDetails(String serverID, String nymID, String transactionID) { NymOfferDetails nymOfferDetails = new NymOfferDetails(); OfferListNym offerListNym = Helpers.getNYMOffer(serverID, nymID); if (offerListNym == null) { System.out.println("getNym...
8e9a174f-87f8-40f8-b1e2-baa81e8c89ce
4
public void testObjectLargeArrayArraycopy() { Double[] data = new Double[]{1.12345, -1.54321, 100., -100., Double.MAX_VALUE, Double.MIN_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN, Double.MIN_NORMAL}; int startPos = 2; int length = 8; LargeArray.setMaxSizeOf...
116feaee-5703-4713-b783-7ea655d9bd87
2
public static void clearTable(JTable table) { for (int i = 0; i < table.getRowCount(); i++) { for (int j = 0; j < table.getColumnCount(); j++) { table.setValueAt("", i, j); } } }
45d54754-36c1-4a2e-ab5b-886ea5174ac2
2
public static byte[] createChecksum(String filename) throws Exception { MessageDigest complete; try (InputStream fis = new FileInputStream(filename)) { byte[] buffer = new byte[1024]; complete = MessageDigest.getInstance("MD5"); int numRead; do { ...
ad191532-2f8a-4d77-8d85-7d53bd32d350
7
private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); final JTextArea txtFilePath = new JTextArea(); txtFilePath.setEditable(false); txtFilePath.setBounds(10, 10, 290, 22); fra...
c7e3c150-b53b-4188-a53e-fa9279b0f8aa
3
public boolean validCoordinates(int r, int c) { return !(r < 0 || r >= GameConstants.HEIGHT || c < 0 || c >= GameConstants.WIDTH); }
ec9154c5-936e-4c43-bcdf-c9236e74aceb
7
public synchronized void loadCurrentResource() { String s = getResourceAddress(); if (s == null) { setLoadingMessagePainted(false); return; } setLoadingMessagePainted(true); if (FileUtilities.isRemote(s)) { s = FileUtilities.httpEncode(s); if (ConnectionManager.sharedInstance().isCachingAllowed())...
1428accf-4841-40b0-9a31-2a9754704769
2
private void calculateEnabledState(Document doc) { if (doc == null) { setText(TEXT); setEnabled(false); } else { setText(new StringBuffer().append(TEXT).append(" ").append(doc.getUndoQueue().getRedoRangeString()).toString()); if(doc.getUndoQueue().isRedoable()) { setEnabled(true); } else { se...
34641cc4-ebfc-45c0-ba9f-d8e252eff241
5
private boolean consideringHierarchy(Publish p) { boolean sent = false; for (Entry<Class<?>, List<SubscriberParent>> e : p.mapping.entrySet()) { if (e.getKey().isAssignableFrom(p.message.getClass())) { for (SubscriberParent parent : e.getValue()) { if (!predicateApplies(parent.getSubscriber(), p.message...
475f6770-efff-41c7-b1e7-6be790144a27
9
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == cancelButton) closeWindow(); else if (e.getSource() == okButton) { String name = (String) comboBoxUnitName.getSelectedItem(); double minPos = Utility.stringToDouble(textFieldMinPos.getText()); double maxPos = Utility.st...
09583353-a7c3-469d-b8b0-6cb8e5ab45c2
3
public Boss(int courtWidth, int courtHeight) { super(INIT_VEL_X, INIT_VEL_Y, INIT_X, INIT_Y, SIZE, SIZE, courtWidth, courtHeight); // Set img1 to the picture of ragnaros try { if (img1 == null) { img1 = ImageIO.read(new File(img_file1)); } } catch (IOException e) { System.out.println("Internal ...
930856c4-3a91-42db-a761-8a48572893e3
6
@SuppressWarnings("SpellCheckingInspection") private void printMostActiveActor(final List<Movie> movies) { // Java 7 style. final Map<Actor, Long> actorToMovieCount = new HashMap<>(); for (final Movie movie : movies) for (final Actor actor : movie.getActors()) act...
45d20fd0-5286-47ec-a40a-d53a7565c9cc
4
private boolean parseAliceBob() throws FormatterError { int ln = parseToken(true); if (ln == EOF_INDICATOR) { return false; } if (ln != WORD_INDICATOR) { throw new FormatterError("parseAliceBob : Bad first word"); } is_alice_line = s.equals("Ali...
44da89f9-023f-4991-a79e-c20d9109d036
7
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if(affected instanceof Room) if((CMath.bset(msg.sourceMajor(),CMMsg.MASK_MALICIOUS)) ||(CMath.bset(msg.targetMajor(),CMMsg.MASK_MALICIOUS)) ||(CMath.bset(msg.othersMajor(),CMMsg.MASK_MALICIOUS))) { if((msg.target()!=null) ...
67069c01-1209-4e52-b8a6-8c3f32077b2f
3
@Override public void run() { isAlive = true; try { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream())); while (isAlive) { String readLine = bufferedReader.readLine(); parseCommand(readLine); ...
56bbd573-d2a7-40c5-bb47-aed9d199c999
7
public void visitSwitchStmt(final SwitchStmt stmt) { if (stmt.defaultTarget() == oldDst) { if (FlowGraph.DEBUG) { System.out.print(" replacing " + stmt); } stmt.setDefaultTarget(newDst); if (FlowGraph.DEBUG) { System.out.println(" with " + stmt); } } final Block[] targets = stmt.targe...
59f69052-16b2-4ab2-860f-78b6b9cfe835
1
private void setName(String name) { if (name != null) this.name = name; }
c2195912-6cbf-4558-82a6-1a1dd3c01f38
1
public void clearBoard(){ gl.clearBoard(); for(int i=0; i< game.length; i++){ game[i].setIcon(null); } }
3aa2ea1f-aa54-4d5d-846c-3cd02317a56f
5
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("global")) { return cmdGlobal(sender, args); } else if (cmd.getName().equalsIgnoreCase("globalrules")) { return cmdGlobalRules(sender); } else if (cmd.getName().equals...
652e3098-691d-4f96-bd9f-49bf910f5068
9
public List<Location> adjacentLocations(Location location, int distance) { assert location != null : "Null location passed to adjacentLocations"; // The list of locations to be returned. List<Location> locations = new LinkedList<Location>(); if(location != null) { int row...
84c70af4-0ae3-4d62-b713-6f121608353f
1
public void saveToFile() { try { FileOutputStream fileOut = new FileOutputStream(FILE); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(this); out.close(); fileOut.close(); } catch (IOException e) { e.printStackTrace(); } }
9cd527a9-5cf2-4896-ae8d-24223746df88
1
@Override public void initialize(URL arg0, ResourceBundle arg1) { ConnectionPool.getConnection(); colItemName.setCellValueFactory( new PropertyValueFactory<ItemSaleModel, String>("itemName")); colPrice.setCellValueFactory( new PropertyValueFactory<ItemSaleMod...
89ef119a-5627-472c-917b-af2c186593fd
4
public void close() { try { if (resultSet != null) { resultSet.close(); } if (statement != null) { statement.close(); } if (connection != null) { connection.close(); } } catch(Exception e){ e.printStackTrace(); System.out.println(e); } }
ee2d4138-83aa-4722-b2ee-9e26d4438ab0
9
private synchronized AffineTransform bufferTransform(){ AffineTransform r=new AffineTransform(); for(int i=0;i<a1.size();i++){ int s1=a1.get(i);Object s2=a2.get(i);Object s3[]=null; if(s2 instanceof Object[])s3=(Object[])s2; if(s1==setTransform){r=makeTransform(s2); } ...
6a22c9d8-5346-41d9-9f41-8b877e704583
8
public void actionPerformed(ActionEvent e){ if(e.getSource() == btnRegister){ if (comboBox.getSelectedItem().equals("Patient")) { if (textField_1.getText().equals(textField_2.getText())) { NewPatientProfilePanel nup = new NewPatientProfilePanel(parent, textField.getText(), textField_1.getText()); ...
5a692afe-c45f-4bde-8446-36235f40dc94
0
public long getPersonId() { return this.personId; }
aa59a512-f047-48af-951d-4fd9e5a23ad9
6
public void upY(){ if (jump > 0) { // Jump case if (jump < 15) { // Go higher y -= moveY; ++jump; } else if (jump < 30) { // Go higher more slowly y -= moveY/2; ++jump; } else if (jump == 30) { // Stand ++jump; } else if (jump <= 45) { // Start reaching the ground y += m...
4e14847e-bd9c-45b8-b82c-2676b69954f3
6
public static String baseToDec(String num, int base) { String risultato = ERRORE; long risultato_num = 0; num = num.toUpperCase(); if (numeroValido_privato(num, base)) // Numero valido { if (base==1) // Se la base è 1 { in...
6564212c-b8fa-4867-8ad9-cb348989792b
0
public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub }
96a0dcf3-4051-4421-b412-603e319df6cf
6
final public String evaluate(String expression) throws InvalidInputException, RuntimeException { resetStructures(); tokenizeExpression(expression); insertImplicitMultiplication(); convertToPostfix(); int previousFunctionMode = Function.outputMode; int previousOperatorMode = Operator.outputMode; if (this....
ca761163-c72f-48d8-829b-c8ebd1d537ca
4
private static void writeText(Client c, int skillType) { c.getPA().sendFrame126(SKILLS[skillType], TITLE_LINE); for (int j = 0; j < LEVELS[skillType].length; j++) { c.getPA().sendFrame126(LEVELS[skillType][j], LEVEL_LINE + j); } for (int j = 0; j < DESCRIPTION[skillType].length; j++) { c.getPA().sendFrame...
a352c4af-4dd6-40c9-a240-0664a1bc0916
3
public boolean addMessage(ChatMessage chatMessage){ boolean returnValue = false; try { Socket socket = new Socket(SERVER_ADDRESS_CHAT, CHAT_PORT); socket.setSoTimeout(TIMEOUT); OutputStream outputStream = socket.getOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream( ...
2d882c94-930c-4bdd-a736-54718414c358
9
@Override public String toString() { StringBuilder sb = new StringBuilder("TransportResponse("); boolean first = true; sb.append("status:"); if (this.status == null) { sb.append("null"); } else { sb.append(this.status); } first = false; if (!first) sb.append(", "); sb....
cc407059-7f7c-4f0a-89ad-f126de64b058
1
@Override public void setValueAt(Object value, int row, int col) { if (col != 0) { super.setValueAt(value,row,col); } }
efe2efdd-1979-43f2-885c-91987af6d14b
5
public static void main(String[] args) { String path = "/home/jorge/quiz.txt"; try { Quiz quiz = QuizLoader.loadQuiz(path); for(Question question : quiz){ System.out.println("Id: " + question.getId()); System.out.println("Enunciado: " + question.getEnunciado()); System.out.println("Puntuación: " ...
17c6ce11-09b0-4bce-8cc0-7d970c9132ce
4
public static URL getURL(String resourceLocation) throws FileNotFoundException { Assert.notNull(resourceLocation, "Resource location must not be null"); if (resourceLocation.startsWith(CLASSPATH_URL_PREFIX)) { String path = resourceLocation.substring(CLASSPATH_URL_PREFIX.length()); URL url = SpringClassUtils....
c2cdb44e-7a4d-4668-ab17-663d9e62c5a4
5
public final void append(final File fileToAppendTo, final File content, int bytesToDiscard) { OutputStream out = null; InputStream in = null; if (!content.exists()) { return; } try { try { out = new OutputStream(fileToAppendTo, FileSystem.UTF8, true); synchronized (this) { this.openStre...
710a0c60-fc70-422a-b7e3-25e62dd8bf1b
5
@Override public void evaluateTheHand(Hand player){ dealerBrain = new DealerAI(player); Vector<Card> throwAway = dealerBrain.whichCardsShouldISwap(); int num = throwAway.size(); Hand newHand = new Hand(); for (int y = 0; y < hand.size();y++){ boolean seen = false; ...
3dd3801e-70b9-454f-ba3a-dd20918e9ec7
4
public static double paretoInverseCDF(double alpha, double beta, double prob) { if (prob < 0.0 || prob > 1.0) throw new IllegalArgumentException("Entered cdf value, " + prob + ", must lie between 0 and 1 inclusive"); double icdf = 0.0D; if (prob == 0.0) { icdf = beta; } else { if (prob == 1.0) { icdf...
1bf45867-88fc-4606-b978-e94f802a241d
8
int allocateClusters(int tailCluster, int count) throws IOException { // - bitmap of free clusters in memory? // - chunk with free block counting for sequential allocation? // - two stage allocation with "gray" // +final static int CLUSTER_GALLOCATED = 0x80000000; // +final...
090203e5-af56-4d53-a95a-60fdafe17254
0
public SendGUI() { initComponents(); }
bee14687-c45b-446b-8437-1fb2c51a47ca
1
public boolean isExpired() { if (keepAliveTimeMsecs == 0) { return false; } return ((System.currentTimeMillis() - keepAliveTimeMsecs) >= timeEntered); }
2cd219a1-75a8-4739-8a3f-f8c97218b69e
7
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Scanner scanner2 = new Scanner(System.in); String invoer, invoerOpnieuw; boolean opnieuw = false; System.out.print("Dit programma test of je invoer een palindroom is"); do { System.out.print("\nVoer een zin, woord of ci...
f9613949-5579-48da-a0a8-64ec81d4cb6e
5
public void reloadGMCommands() { gmcommands.clear(); try { ClassFinder classFinder = new ClassFinder(); String[] classes = classFinder.listClasses("net.sf.odinms.client.messages.commands.Jounin", true); registerGMCommand(new HelpGMCommand()); // register the helpcomma...
cac9b7c8-70e0-49d7-813c-1fee97578e46
5
public JSONObject increment(String key) throws JSONException { Object value = this.opt(key); if (value == null) { this.put(key, 1); } else if (value instanceof Integer) { this.put(key, ((Integer) value).intValue() + 1); } else if (value instanceof Long) { ...
29738925-f9f4-4d1c-ad7a-17b29a62ccf0
1
public java.io.Serializable fromDOM(Document document) { automatonMap.clear(); Automaton a = createEmptyAutomaton(document); Node parent = document.getDocumentElement() .getElementsByTagName(AUTOMATON_NAME).item(0); if(parent == null) parent = document.getDocumentElement(); return re...
094fd2bb-45ce-4e41-b895-82434809612f
6
public void insert(Node root, Node n){ if(root == null|| n == null) return; if(root.getData() > n.getData()){ if(root.getLeft() == null){ root.setLeft(n); System.out.println("Added node to left of "+root.getData()+" of value "+n.getData()); }else{ insert(root.getLeft(),n); } }el...
7ce0baa9-dc6e-4505-9264-fc57f18b8a5c
0
public Tile(int x, int y, TileType type, Match match) { this.x = x; this.y = y; this.type = type; bombers = new LinkedList<IBomber>(); this.match = match; }
392daec4-f090-452a-8139-a990c5cabc78
2
public boolean yatzy(){ for(int i=1; i<5; i++){ if(nopat[0].getValue()!=nopat[i].getValue()){ return false; } } return true; }
826b50c6-ccea-49d1-8d0b-464dcd52ed67
3
@Override public int hashCode() { int result = cueMovto != null ? cueMovto.hashCode() : 0; result = 31 * result + (cueNaturaleza != null ? cueNaturaleza.hashCode() : 0); result = 31 * result + (cueCuentaConcatenada != null ? cueCuentaConcatenada.hashCode() : 0); return result; }
5e9dce71-dafe-4fe9-92f2-9461fcede4be
4
@Override public void keyPressed(KeyEvent arg0) { // TODO Auto-generated method stub if (arg0.getKeyCode() == KeyEvent.VK_W) { this.canMove = false; this.move("up"); } if (arg0.getKeyCode() == KeyEvent.VK_S) { this.canMove = false; this.move("down"); } if (arg0.getKeyCode() == KeyEvent.VK...
add31546-76de-4c05-999f-8348cfebef25
8
private void evaluateClustersWithRespectToClass(Instances inst, String fileName) throws Exception { int numClasses = inst.classAttribute().numValues(); int[][] counts = new int[m_numClusters][numClasses]; int[] clusterTotals = new int[m_numClusters]; double[] best = new doub...
1e71d66f-7b1c-474a-89c7-acd579d6dd0f
2
public void switchMenu() { try { menuSwitch.get(); } catch (NullPointerException e) { while (isReadyFX == false) { } } menuSwitch.set(!menuSwitch.get()); }
b171cb1f-5585-48f4-a82b-74088a1b091f
3
@Override public void update(GameContainer gc, StateBasedGame sb, float delta) { if (cooldown <= 0) { cooldown = 0; onCooldown = false; } else if (onCooldown) { if(invincibleTime >=3000){ invincible=false; } cooldown -= delta; invincibleTime+=delta; } }
b8ab8616-02ae-43e2-9e03-a078f3573785
8
protected void alignText() { int xLoc, yLoc; int spacing = Math.max((int)Math.round(font.getSize() * spacingRatio), 1); int endIndex; switch (vAlign) { case (V_TOP) : yLoc = this.getLocationY(); break; case (V_CENTER) : yLoc = this.getLocationYC() - font.getSize(...
8e49c265-9b4d-4331-8250-fa06f476ee43
4
public void cleanTab(){ //Trovo il numero reale di elmenti nel vettore int num=0; //Trovo il nmero di descrittori mossa corretto for(int i=0;i<desmosse.length;i++) if(desmosse[i]!=null) ++num; //Creo il vettore ben dimensionato DescrittoreMossa[] res = new DescrittoreMossa[num]; int c=0;...
7d182739-c8df-4c51-a790-ae2212d73a8d
7
private void setLabelDropTarget() { fieldLabel.setDropTarget(new DropTarget(this, new DropTargetListener() { private final DataFlavor entityFieldDataFlavor = new DataFlavor(EntityField.class, EntityField.class.getName()); ...
0de6ba22-f5c3-4811-8d71-1b599e3752c8
4
@Override public Value evaluate(Value... operands) throws Exception { // we need two operands if (operands.length != input()) throw new EvalException("Error: wrong number of operands"); // get operands Value l = operands[0]; Value r = operands[1]; // if they are identical if (l.getType().isNumeric()...
8f0eba80-18be-49b6-b733-1716ecbb580e
3
public void moveTo(double toPosition) { //get the free space in front of us on this road double freeSpace = checkFreeSpaceAhead(); //calculate velocity double velocity = (_velocity / (_brakeDistance - _stopDistance)) * (freeSpace - _stopDistance); //System.out.println("V1 = " + velocity)...
a0d0ea28-762f-4e9a-a26d-3454185311dc
8
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 fe...
f38bf9ec-5e94-4013-ae34-cd436832907e
8
@Override public boolean canDespawn(LivingEntity entity) { if (entity == null) return false; final boolean async = !P.p().getServer().isPrimaryThread(); for (Entry<Plugin, Protector> entry : protectors.entrySet()) { if (!entry.getKey().isEnabled()) continue; Protector protector = entry....
3953b234-79e3-4021-8b3f-bcacf9bc90a1
1
String reverse(String s1){ char c[]=new char[s1.length()]; c=s1.toCharArray(); for(int i=0;i<(s1.length()/2);i++){ char temp=c[(s1.length()-1)-i]; c[(s1.length()-1)-i]=c[i]; c[i]=temp; } return new String(c); }
c3c4c7d0-0946-4aa0-ab48-9a49c5c5e13f
8
public boolean recursiveSymmetric(TreeNode left, TreeNode right) { if(left == null && right == null) return true; if((left == null && right != null) || (left != null && right == null)) return false; if(left.val != right.val) return false; boolean l = recursiveSymmetric(left.left, right.r...
b7038599-2230-41c7-9530-6f7e33662948
1
@Test public void heapTest(){ long start = System.currentTimeMillis(); for (int i = 0; i < 1000000; i++){ heap.insert(i); } long end = System.currentTimeMillis(); long totaltime = end - start; System.out.println("Time spent adding 1 000 000: " ...
b1bda2d8-e2cc-4c0a-87c2-d6e767b78033
3
public void Pesquisar() throws IOException, ClassNotFoundException{ Scanner sc = new Scanner(System.in); Reader fileReader = new FileReader("registros.txt"); BufferedReader br = new BufferedReader(fileReader); String showReg = null; System.out.println("Digite um nome"); String pesquisa = sc.next(); whil...
cae128ff-fe06-48af-93f7-65d7913a7181
8
public AnnealerAdapterI run() { aa.initialState(); double t = 0.5; double acceptRate = 0.5; for (int i = 1; i < evalSMax; i++) { aa.nextState(); // the normal annealing process if (aa.costDecreasing()) { aa.accept(); acceptRate = (1.0/500.0) * (499.0 * (acceptRate + 1)); } else { doub...
9e813fbb-3491-41bc-92cb-3584966a55d6
4
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_W) ya = -game.getSpeedx(); if (e.getKeyCode() == KeyEvent.VK_S) ya = game.getSpeedx(); if (e.getKeyCode() == KeyEvent.VK_A) xa = -game.getSpeedx(); if (e.getKeyCode() == KeyEvent.VK...
bb6ada43-cc63-435a-81f0-81f92f8554cd
6
public int[] getPlacementResourceCards(Coordinate coord) { coord = coord.normalizeCoordinate(); int cardsEarned[] = new int[5]; for (int i = 0; i < cardsEarned.length; i++) { cardsEarned[i] = 0; } // Get the node at the coordinate Node settlementLocation = nodeSet.get(...
89c54fe8-edb0-461e-a391-21e745d35a5c
0
public boolean isTintedGlass() { return tintedGlass; }