method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
76edfcc3-b43f-4c4e-a109-d6652fb868d2
4
@Override public boolean startVideoCutting(List<VideoSection> videoSections, File inputVideo) { // Add "_out" to the output file name before extension String inputFilePath = inputVideo.getAbsolutePath(); String outputFilePath = inputFilePath.substring(0, inputFilePath.lastIndexOf...
e248e9c6-e52a-4f91-a040-eaaf37169879
2
@Override public void draw(Graphics2D g,float interpol) { if (!isConstructed) construct(); // g.setColor(Color.WHITE); // g.drawRect((int)position.x, (int)position.y, dims.width, dims.height); for (Item i : items) { i.draw(g,interpol); } }
838cedff-79f8-45e9-bc93-6d4d89cdca5c
2
public String retry(String q, ArrayList<String> prop, ArrayList<String> loc){ String newQ = q; Iterator<String> keys = commonErrors.keySet().iterator(); while (keys.hasNext()){ String current = keys.next(); int index = q.indexOf(current); if (index != -1){ newQ = q.replaceAll(current, commonErrors.ge...
283d4c01-aa02-43c2-89b7-cf8484619ef8
9
public void update() { maybeAddPher(); move(map.getSurround(xy)); if(map.home(xy)) { state = AntState.Searching; incr = state.getIncrement(); dir = Ordinal.getRandomDirection(); }else { Food f = map.getFood(xy); if(f != null && f.canTake() && carrying < CARRY_LIMIT) { carrying += f.take(); ...
9a01f22c-4660-4be2-a89d-7c8731677cd0
5
private void createButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createButtonActionPerformed try { String subject = subjectTextField.getText(); String description = descriptionTextField.getText(); ArrayList<String> options = new ArrayList(Arrays.asL...
b5331630-22c1-437d-9bbc-ab61b72a798d
4
public static int getPercentToLevel(final int index, final int endLvl) { if (index > SKILL_NAMES.length - 1) { return -1; } final int lvl = Skills.getRealLevel(index); if (lvl == 99 || endLvl > 99) { return 100; } final int xpTotal = Skills.XP_TABLE[endLvl] - Skills.XP_TABLE[lvl]; if (xpTotal == 0) ...
0338d513-ac6a-43a5-96fb-75fe479fb264
5
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!plugin.hasPerm(sender, "clear", true)) { sender.sendMessage(ChatColor.YELLOW + "You do not have permission to use /" + label); return true; } if (args.length == 0) return false; if (plugin.play...
c6064064-548c-47ea-a99b-a5d9178801de
2
@Override public void run() { String[] datos = new String[14]; String[] temp = new String[2]; try { URL pagina = new URL("http://chapuzas.comocreartuweb.es/documentos/datos.txt"); HttpURLConnection con = (HttpURLConnection) pagina.openConnection(); con.co...
0520ea1e-353f-4a11-99d9-5a057fbac5cd
4
public boolean update() { if(Keyboard.getButton() != 1 && show == 2) { show = 0; return true; } show = 0; int mx = Keyboard.getMouseX() - Frame.transx; int my = Keyboard.getMouseY() - Frame.transy; if(Collision.recToRect(mx, my, 0, 0, x, y, look[show].getWidth(), look[show].getHeight())) { ...
44519714-3708-46eb-b1ff-2a223cb0e4cc
7
final char[] optimizedCurrentTokenSource2() { //try to return the same char[] build only once char[] src = this.source; int start = this.startPosition; char c0 , c1; int hash = (((c0=src[start]) << 6) + (c1=src[start+1])) % TableSize; char[][] table = this.charArray_length[0][hash]; int i = newEntry2; while (+...
2ab6f2a2-cb19-4429-9ec5-480bba9ab7ba
8
public boolean isNavigationEvent(ColumnViewer viewer, Event event) { switch (event.keyCode) { case SWT.ARROW_UP: case SWT.ARROW_DOWN: case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.HOME: case SWT.PAGE_DOWN: case SWT.PAGE_UP: case SWT.END: return true; default: return false; } }
525b970b-670f-4f3b-85fb-28000ce46d5f
5
public static void main(final String[] args) { final File file = new File("D:/Program Files (x86)/Run 8 Studios/Run 8 Train Simulator/Content/RailVehicles"); for (String name : file.list()) { if (name.startsWith("R8_Boxcar_50ft_PlateF_") || name.startsWith("R8_C14Hopper_"...
6ed06929-f327-48dc-a47c-7bb2b46ffb31
1
public void push(int e) { if(len >= capacity) { throw new IllegalStateException("Error: capacity is bigger that len"); } heap[len] = e; len++; bubbleUp(len - 1); }
06854a43-4bdb-41bc-be52-49c2dd56c783
3
@Override public int compareTo(Object o) { if (o instanceof CycNumber) { final CycNumber other = (CycNumber) o; final Class thisNumberClass = this.number.getClass(); if (thisNumberClass.equals(other.number.getClass()) && Comparable.class.isAssignableFrom(thisNumberClass)) { ...
344c88f0-8ebf-4d71-b4d7-8de5b77833ac
1
public boolean hasNoJumps() { return successors.size() == 0 && predecessors.size() == 0; }
e5292b6e-2a1b-4171-9697-85a5a318a956
5
private void backTrackToLambda() { if (myLambdaStepMap==null) return; int index=0; while (index<myAnswer.size()) { for (ArrayList <Production> key: myLambdaStepMap.keySet()) { if (myLambdaStepMap.get(key).equals(myAnswer.get(index))) { //System.out.println("Found it = "+key); //Syste...
9f4501e7-8b70-4a90-b3a2-0a99412bf965
3
public CycList randomPermutation() { final Random random = new Random(); int randomIndex = 0; final CycList remainingList = (CycList) this.clone(); final CycList permutedList = new CycList(); if (this.size() == 0) { return remainingList; } while (true) { if (remainingList.size() ...
3ae7e85e-e924-4498-9439-c97e30169df0
0
public RandomListNode(int x){ this.label = x; }
48cf0d16-c2d1-4f5c-85e0-ac2a79cb7b12
9
public void kickPlayerFromClan(Client c, String name) { if (!isOwner(c)) { c.sendMessage("You do not have the power to kick players from this clan chat!"); return; } if (c.playerName.equalsIgnoreCase(name)){ c.sendMessage("You may not kick yourself from a clan chat!"); return; } if (c.clanId < 0) ...
35e216bf-b3a3-4c6d-b62e-7ab8ca73313e
6
@Override public List<DataRow> select(DataRow parameters) { String statement = "SELECT * FROM " + parameters.getTableName(); if(!parameters.isEmpty()) { statement += " WHERE "; } boolean isFirst = true; for(DataCell cell : parameters.row) { ...
75251c32-7e07-482e-9836-0f40468500aa
4
public static SessionState sessionRead(String sessionID, int versionNum, Server server) { SessionState session = null; try { DatagramSocket RPCSocket = new DatagramSocket(); RPCSocket.setSoTimeout(1000); String callID = UUID.randomUUID().toString(); // A unique id for this call // Prep the informati...
4d84de89-ef39-4820-b297-2a02e74fc0fd
7
static String toHex4ByteString(int i) { String hex = Integer.toHexString(i); if (hex.length() == 1) return "0000000" + hex; if (hex.length() == 2) return "000000" + hex; if (hex.length() == 3) return "00000" + hex; if (hex.length() == 4) return "0000" + hex; if (hex.length() == 5) return "000...
4488d5b0-d2f7-411f-b2f7-dd7f0b322d44
1
void moveX(boolean right) { if (right) x += speed; else x -= speed; }
a5a169af-45f0-4d53-8b12-56db8241a41c
1
public Instrumenter(Set<Local> set){//SootMethod m, Set<Local> set){//Map<Local, Set<Unit>> map) { // TODO Auto-generated constructor stub //method = m; // ins_map = map; // factory_already_created = new HashSet<String>(); getUtilClasses(); //for(Map.Entry<Local, Set<Unit>> entry: ins_map.entrySet()){ fo...
fc61d63a-9e92-492f-9047-ef91722cd55d
2
private final Element getArtistListNode(String artistName) throws GetHttpException, MusicbrainzUrlException, CreateDocException { String content= ""; content= this.getHttp.getWebPageAsString(MusicbrainzUrl.getMbArtistUrl(artistName)); if(content.equals("")) return null; this.artistDoc= CreateDoc.cr...
318a531a-047a-43bc-9f70-8ab6bec0179e
0
public void setCarriedKeyName(String value) { this.carriedKeyName = value; }
55f6d248-874f-4fe5-a8cd-fc4f0ccb422e
5
public void createLetters(int numberOfLetters, boolean randomOrder) { Array<Letter> letters = this.languageController.giveACombination(numberOfLetters); letters.shuffle(); float circleSpeed = 10;// previous 50 for (int i = 0; i < numberOfLetters; i++) { // First we create a body definition BodyDef bodyDef...
22c5e01b-8b6c-4218-b8b0-b63dd430f191
8
public Object getValueAt(int rowIndex, int columnIndex) { switch(columnIndex) { case 0 : return list.get(rowIndex).getNota(); case 1 : return list.get(rowIndex).getNama(); case 2 : return list.get(rowIndex).getPewangi(); case 3 : return list.get(rowIndex).getBerat...
b74e7a76-000f-4033-9cd6-286b4cfd44f8
9
public Ability(World world){ this.world = world; mainAbilityThread = new Thread(new Runnable(){ @Override public void run() { // TODO Auto-generated method stub while(OrbGame.isRunning) { Gdx.app.log(log, "Run method is getting called and booleans are being checked"); //checks if the abilit...
7f6a812a-8769-4ac2-8aa7-a71362da7eb1
4
public static void main(String[] args) { String line = ""; String message = ""; int c; try { while ((c = System.in.read()) >= 0) { switch (c) { case '\n': if (line.equals("go")) { PlanetWars pw = new PlanetWars(message); DoTurn(pw); pw.FinishTurn(); message = ""; } e...
90689caf-3964-4aba-8986-76a7093f8afa
8
private void parseMap() throws FileNotFoundException { Scanner scan = new Scanner(ResourceHandler.getLevelFile(levelID + ".map")); for (int i = 0; i < levelHeight; i++) { for (int j = 0; j < levelWidth; j++) { String text = scan.next(); if (text.equals("#")) ...
d7884705-56dc-4d79-9e4f-3a2744eb099b
4
@Override public void mouseWheelMoved(MouseWheelEvent e) { int a = e.getWheelRotation(); if (a < 0) { for(int i = 0; i < -a; i++) { keys[KeyEvent.VK_UP] = true; updateStatus(); keys[KeyEvent.VK_UP] = false; ...
41d35e4e-a85a-4263-b394-7bda7daf79b3
9
protected void flush() throws IOException { assert off > 0; long min = Long.MAX_VALUE, max = Long.MIN_VALUE; for (int i = 0; i < off; ++i) { min = Math.min(values[i], min); max = Math.max(values[i], max); } final long delta = max - min; int bitsRequired = delta == 0 ? 0 : PackedInts...
7d856e94-58a9-4dbb-b8fd-ce72e2f28f4e
3
public Component getColorDropdown() { if (colorDropdown == null) { colorDropdown = new JComboBox<Color>(); colorDropdown.setRenderer(new ListCellRenderer<Color>() { @Override public Component getListCellRendererComponent(JList<? extends Color> list, final Color value, int ind...
40953cf5-434a-4fd8-b15b-99469c5bdc55
4
@SuppressWarnings( "unchecked" ) private ByteBuf writeStatusPacket() { JSONObject root = new JSONObject(); JSONObject version = new JSONObject(); if(MCListener.pingAppearOffline) { version.put("name", "Offline"); version.put("protocol", 0); } else { version.put("name", "1.8.0"); version.put(...
fdee73da-ca6c-44b4-a51c-fd879e781919
1
private void emitTabs() { for (int i = 0; i < mDepth; i++) { mOut.print('\t'); } }
a870eab6-73b2-41f5-915e-2222643a281e
8
public String getPermutation(int n, int k) { int[] numSet = new int [n]; for (int i=0;i<n;i++){ numSet[i] = i+1; } int cur = 1; while (cur<k) { int exIndex = n-2; for (;exIndex>=0;exIndex--){ if (numSet[exIndex+1] >numSet[exInde...
9b0d9b0f-1d36-4c23-9361-cc171bab4ef3
1
public static DataTag getWorldData(int index){ Object obj = read("world/world_"+index); if(obj == null) return null; JSONObject data = (JSONObject) obj; return new DataTag(data); }
6ec4b2ee-ee62-45df-8868-fbe59a0613d0
0
public void setUser(User user) { this.m_user = user; }
1827cc79-b89b-4961-a6c3-ae0122d8199e
0
public void setGetAccountRequest(GetAccountRequest getAccountRequest) { this.getAccountRequest = getAccountRequest; }
6985efbb-7f0b-47c9-be34-68c7bcf4ae94
3
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof KnowMafiaMessage)) return false; KnowMafiaMessage that = (KnowMafiaMessage) o; if (!Arrays.equals(players, that.players)) return false; return true; }
d9667cd2-4ec0-423d-8cdc-c3952a2cd6b5
9
public void setup(Map attributes) { Map macAttrib = new HashMap(); macAttrib.put(HMac.USE_WITH_PKCS5_V2, Boolean.TRUE); byte[] s = (byte[]) attributes.get(IPBE.SALT); if (s == null) { if (salt == null) { throw new IllegalArgumentException("no salt specified"); } //...
42009d7d-0582-4eec-a4b0-75f0a86a8bae
1
public void updateProfile() { tUsername.setText(currentProfile.getUsername()); tDisplayName.setText(currentProfile.getDisplayName()); tStartDate.setText(currentProfile.getStartDate().toString()); if (currentProfile.isRightHanded()) tHanded.setText("Right"); else tHanded.setText("...
74b44022-1d73-40f4-ab9f-8b693a24e96d
7
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { // amazingly important that this happens first! super.executeMsg(myHost,msg); if((msg.targetMinor()==CMMsg.TYP_GET) ||(msg.targetMinor()==CMMsg.TYP_GIVE) ||(msg.targetMinor()==CMMsg.TYP_PUT) ||(msg.targetMinor()==CMMsg.TYP_PUS...
c1cb2978-b54d-489f-9c95-1091b8393d56
9
@SuppressWarnings("RedundantIfStatement") @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GitClone gitClone = (GitClone) o; if (localPath != null ? !localPath.equals(gitClone.localPath) : gitClone.localPath != null) return fal...
341956d4-3c81-43f6-8b13-900b4451a362
3
public static ArrayList<Order> parseOrdersList(String filePath, String XSDFilePath, Menu menu){ try { DocumentBuilderFactory documentBuilder = DocumentBuilderFactory.newInstance(); documentBuilder.setIgnoringElementContentWhitespace(true); Schema schema = SchemaFactory.newInstance( XMLCons...
41ade396-dec5-4986-b00c-2037dd935e26
2
private void selectIMGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectIMGActionPerformed JFileChooser imgChooser = new JFileChooser(); imgChooser.setFileFilter(new IMGFilter()); imgChooser.setDialogTitle(parser.parse("partitionManager:imgChooserTitle")); imgChoos...
2325cc63-8128-46dc-90b5-c4b9a6ac50f8
3
public void addMoveButton(){ panel=0; final JButton BackButton = new JButton("назад"); BackButton.setPreferredSize(new Dimension(220,60)); BackButton.setFont(arrFont); BackButton.setEnabled(false); final JButton ForwardButton = new JButton("вперёд"); ForwardButton.setPreferredSize(...
2c50a7c4-5682-474d-96d2-c10ec0683a52
9
public static long getTokenLongIntegerInternal(char[] buffer, int start, int end, int size) { { int length = end - start; int auxend = end; long result = 0l; boolean negativeP = false; int digit = 0; if (length < 0) { length = length + size; auxend = size; } ...
38d944b1-ffcf-4975-82dd-2bece2b07996
3
public static void beginQuit() { EnvironmentFrame[] frames = Universe.frames(); for (int i = 0; i < frames.length; i++) if (!frames[i].close()) return; //modified by Moti Ben-Ari if (gui.Main.getDontQuit()) NewAction.closeNew(); else System.exit(0); }
93a4763c-658c-474c-8b5e-3ec33d1319cb
1
@Override public void keyTyped(KeyEvent e) { if (e.getKeyChar() == '\b') { // Need to consume backspace here since the action we // added doesn't seem to supress the built-in backspace code. e.consume(); } }
ab605f26-0d10-4c28-8576-6f2007f2ef64
2
private String hashToString(byte[] hash) { String result = ""; for (byte b : hash) { int v = b & 0xFF; if (v < 16) result += "0"; result += Integer.toString(v, 16).toUpperCase() + " "; } return result; }
3a0b3b3f-f8d1-4b82-bdc2-c38d43ec1110
1
public void initializeNodes(State[] states) { myNodes = new Node[states.length]; /** Color all vertices white. */ for (int k = 0; k < states.length; k++) { Node node = new Node(states[k]); node.colorWhite(); myNodes[k] = node; } }
847da8df-2cfc-4ea0-a6ee-881a909e2e5e
2
public String getOverCurrentMode () { switch (getHubCharacteristics () & 0x0018) { case 0x00: return "global"; case 0x08: return "per-port"; default: return "none"; } }
3a3658e5-d776-4cd8-a85d-e86c988be9d8
4
public static void main(String[] args) { File file = new File("E:\\blackhand.jpeg"); if (!file.isFile()) { System.err.print("Error"); } InputStream stream = null; try { stream = new FileInputStream(file); } catch (FileNotFoundException ex) { ...
f6da4aae-4561-4e49-9a4a-5ba9c1d9b3b1
2
@EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { // do not act when disabled TODO, use unregister when available if ( !this.sheepFeedPlugin.isEnabled() ) { return; } Entity entity = event.getRightClicked(); if (entity.getType() == EntityType.SHEEP) { this.attem...
1bbae851-b173-404b-9b0f-bb5f955fb1c0
2
@Override public String execute(SessionRequestContent request) throws ServletLogicException { String page = (String) request.getSessionAttribute(JSP_PAGE); List<Country> countryList = (List<Country>) request.getSessionAttribute(JSP_COUNTRY_LIST); List<City> cityList = (List<City>) request.g...
8a2f3f6e-7f3f-473b-a69f-19d728d5fb76
8
@EventHandler(priority = EventPriority.HIGH) public void join(PlayerJoinEvent event) { if (!plugin.toggle) { try { final Player player = event.getPlayer(); plugin.Logger("Player " + event.getPlayer().getTotalExperience() + " XP: " + event.getPlayer().getTotalExper...
c94aeda2-9e8c-4a02-a716-a8578af23e74
2
public JSONObject putOpt(String key, Object value) throws JSONException { if (key != null && value != null) { this.put(key, value); } return this; }
2ccb7c43-dd2e-4a4a-adaa-98e2b2d4c436
2
@Override public int[] getAttributes() { Random r = new Random(); int[] local = {0, 0, 0, 0, 0, 0}; for (int i = 0; i < 6; i++) { int[] rolls = {0, 0, 0, 0}; for (int k = 0; k < 4; k++) { rolls[k] = r.nextInt(6) + 1; } Arrays.so...
f3ebdfad-a077-4a5a-b3ca-cae54b85802c
2
private <E extends Signable> String post(String apiStr, E object, Function<E, String> fn) throws MailChimpException { try { String toPost = fn.apply(sign(object)); final Request request = Request .Post(mailchimpHost + apiStr) .addHeader("Content-Type", "application/json") .body(n...
05468c7f-ec6b-46d3-9a9b-24799b2f8b8a
1
public void showWindow() { frame = new JFrame("Welcome to YAMG!"); centerPanel = new JPanel(); centerPanel.setLayout(new BorderLayout()); image = new ImagePanel(); JPanel bottom = new JPanel(); startButton = new JButton("Start Game"); startButton.addActionListener(new ButtonListener()); start...
b6ea7a55-a736-4c31-90b9-3b4b19011d4b
0
@Test public void testtomap() { Element nodeElement = document.addElement("data"); Student student = new Student(1, "2", "3", "4", "5"); Map<Object, Object> map = javabeanToMap(student); Map<Object, Object> m = new HashMap<>(); Map<Object, Object> mm = new HashMap<>(); mm.put("mm1", "mm1"); mm.put("mm2"...
bcfa0ada-6f4b-44a8-9d1f-618e5bb6d267
8
@Override public void onConnectionDataReceived(Connection connection, byte[] data, int length) throws Exception { if (!connection.isAdminMode()) { String datagram = FRAME_START + FRAME_STATUSSUCCESS + (connection.getIdentifier() >= 0? StringUtils.padLeft(Integer.toHexString(connecti...
3c75066b-9053-43b7-87d4-2cd18f54f6cd
7
public boolean wordBreak(String s, Set<String> wordDict) { if (s==null || s.isEmpty()) return false; if (wordDict == null || wordDict.size()==0) return false; for (int i=0; i<s.length(); ++i) { if (wordDict.contains(s.substring(0, i+1)) && wordBreak(s.substrin...
755af74b-bc9e-4c1a-bb12-439e33014ebb
3
public Vector<GameElement> getGameElementByTag(String Tag) { Vector<GameElement> Elements = new Vector<GameElement>(); for(GameElement element : GameElements) { if(element.getTag() != null && element.getTag().equals(Tag)) { Elements.add(element); ...
fcd61b22-a236-46b1-8080-cf0d3ef2a01c
9
@Override public synchronized void sendData (byte[] foo, int s, int l, boolean flush) throws IOException { // System.out.println("sendData: l="+l+" sendCount="+sendCount+" flush="+flush); if (foo != null && l <= 0) return; if (con == null) { connect (); } if (sendCount <= 0) { con...
7cbb7499-75b8-46e3-aa7f-26fc04ff1816
5
private void parseLoadout(JSONObject o) throws ProtocolException { try { if(!(o.get("message").equals("loadout"))){ throw new ProtocolException("Expected 'loadout', but got '" + o.get("message") + "' key"); } if(!Util.validateWeapon(o.getString("primary-weapon"))){ throw new ProtocolException("Inval...
745e4304-f905-4b26-9f96-a7d805bd2123
4
private void writeNode(XMLNode node, int tabIndex, FileWriter writer) throws IOException { String line = formTabs(tabIndex) + "<" + node.getName(); if (node.getAttributes().size() > 0) { for (int i = 0; i < node.getAttributes().size(); i++) { line += " " + formAttribute(node.getAttributes().get(i)); } ...
6dd3a2d6-dac9-44c5-a135-c156a339c4d2
4
@SuppressWarnings(value="unchecked") public void put(int field$, java.lang.Object value$) { switch (field$) { case 0: names = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>)value$; break; case 1: name = (java.lang.CharSequence)value$; break; case 2: favorite_number = (java.lang.Integer)...
328ce178-17e0-49e6-888e-607eeb26b919
7
private JSONWriter append(String s) throws JSONException { if (s == null) { throw new JSONException("Null pointer"); } if (this.mode == 'o' || this.mode == 'a') { try { if (this.comma && this.mode == 'a') { this.writer.write(','); ...
694c63e7-d8c3-4565-8435-bc574c18fb06
8
private void juliaMapPolar(int image_size) { double size = fractal.getSize(); double xcenter = fractal.getXCenter(); double ycenter = fractal.getYCenter(); double start; double center = Math.log(size); int pixel_percent = image_size * image_size / 100; double...
6437d911-a910-4e96-b731-c112ebfc205d
9
public void runGameTimedSpeedOptimised(Controller<MOVE> pacManController,Controller<EnumMap<GHOST,MOVE>> ghostController,boolean fixedTime,boolean visual) { Game game=new Game(0); GameView gv=null; if(visual) gv=new GameView(game).showGame(); if(pacManController instanceof HumanController)...
47b5dad5-32e2-4d63-990a-5c6a2951de31
8
protected void print(Data data, int indentLevel) { StringBuffer text = new StringBuffer(80); for(int i = 0; i < indentLevel; ++i) { text.append(indentationPrefix); } text.append(data.getName()).append(": "); if(data.isPlain()) { try { Data.TextValue textValue = data.asTextValue(); Strin...
7663f029-bbaa-4c56-b0a8-a2113977fde3
0
public static int randRange(int min, int max){ Random rn = new Random(); int range = max - min + 1; int randomNum = rn.nextInt(range) + min; return randomNum; }
1442d2e4-8eea-4496-b119-fa9a50b64904
6
public static int loadTexture(BufferedImage image, boolean linear, boolean flip){ int[] pixels = new int[image.getWidth() * image.getHeight()]; image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth()); ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight...
c1623ca8-93f6-4c8c-b785-c583078f8283
3
private char nextSkippingWhitespace() throws IOException { for (;;) { char c = next(); if (c == 0 || c > ' ') { return c; } } }
9520023e-3382-4df2-961b-e4edf1dbbe36
4
@Test public void testSetListenThreadServerOnSamePort() { LOGGER.log(Level.INFO, "----- STARTING TEST testSetListenThreadServerOnSamePort -----"); boolean flag1 = false; boolean flag2 = false; if (server1.getState() == Server.LISTEN) { flag1 = true; } if (...
ea01d895-b840-4116-9cc5-a78070639d3f
0
public boolean removeNode(Root node) { return branchs.remove(node); }
d0b30b4d-542a-42ec-9a71-16eccaa1c41c
7
private void executeReadWrite(final long count, int keyLen, int valueLen) throws IOException { final int defaultKeyLen = 8; final int defaultValueLen = 32; CacheConfig config = new CacheConfig(); config.setStorageMode(storageMode); cache = new BigCache<String>(TEST_DIR, config); List<String> keys = new Arr...
4b83546b-055a-435f-a16c-fcf862118ff8
6
synchronized public Class toClass() throws ClassNotFoundException, UtilEvalError { if (asClass != null) return asClass; reset(); // "var" means untyped, return null class if (evalName.equals("var")) return asClass = null; /* Try straightforward class name first */ Class clas = namespace.getClass(ev...
425b1084-4d0e-4ec9-bf12-a1167782346d
6
private static Event nextEvent() { Event e = null; if (Keyboard.next()) { if (Keyboard.getEventKeyState()) { e = new Event(EventType.KEY_PRESSED, Keyboard.getEventKey()); } else { e = new Event(EventType.KEY_RELEASED, Keyboard.getEventKey()); } } if (Mouse.next()) { if (Mouse.get...
57c1d3b9-618e-4b42-856d-74099c74d669
1
Map<Person, List<Score>> removeFromTable(Map<Person, List<Score>> table, Person p){ table.remove(p); table.values() .forEach(list -> list.removeIf(it -> it.self.equals(p) || it.target.equals(p))); return table; }
00faa96f-b1e6-4fa6-a585-695b4ddcdf98
5
@Override public void processKeyboard() { if(Keyboard.isKeyDown(Keyboard.KEY_1)) { map_.setTemperatureAlgo(temperature_algo_noise_); map_.generate(); } else if(Keyboard.isKeyDown(Keyboard.KEY_2)) { map_.setTemperatureAlgo(temperature_algo_linear_); map_.generate(); } else if(Keyboard.isKeyDo...
3f576e60-37c0-4c19-a6f5-0fcf1011538f
7
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
b95e3ec3-8602-4be6-b6fd-7a3161e8221b
4
public boolean httpGet(String url, String queryString, QAsyncHandler callback, Object cookie) { if (url == null || url.equals("")) { return false; } if (queryString != null && !queryString.equals("")) { url += "?" + queryString; } GetMethod httpGet = new GetMethod(url); httpGet.getParams().setParam...
f1e62eac-c684-4e9c-9ada-793b0ace5664
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...
c494d662-fe16-41b7-9366-60001f8af449
3
@Override public String execute() throws Exception { try { Map session = ActionContext.getContext().getSession(); setUser((User) session.get("User")); pid = (Long) Long.parseLong(publishid); Publish sitepublish; sitepublish = new Publish(getUse...
be6b9a01-a6dd-486b-9c51-bf6a8a90b61c
0
public void setRemotePort(int remotePort) { this.remotePort = remotePort; }
d575302f-651c-429a-8f00-b32680d245ed
9
@Override public boolean equals(Object o) { if(this == o) return true; if(o == null || getClass() != o.getClass()) return false; Rendering rendering = (Rendering) o; if(image.equals(rendering.image)) return true; if(!(image.getWidth() == rendering.image.getWidth())) return ...
d75d03e4-9fff-42ac-9853-1996d1f6747c
8
public void act() { setImage(grenade); if (distance <= 0) { if (distance == 0) { dealtDamage(this.x, this.y, 200, 200, 1, 0, 10.0, 200); Greenfoot.playSound("Sound//Bond//Grenade.mp3"); } y = 400; se...
1aa717cb-1fcb-4cb3-9678-3f917d6a4670
0
public String getCategoryName() { return categoryName; }
af6b18bc-6711-4262-be38-0f95aa591e9d
6
public static boolean deleteLocalPath(String path) { if (path == null || path.equals("")) { return false; } java.io.File f = new java.io.File(path); if (!f.exists()) { System.out.println("Local directory is not exist:" + path); retu...
a1293f78-9e8c-4325-a0fa-ca5f683377aa
0
private void initialize() { new JFrame(); this.setResizable(false); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize(WINDOW_SIZE); this.setLocation(screenSize.width/2-getWidth()/2, screenSize.height/2-getHeight()/2); this.setDefaultCloseOp...
3d80eee9-4781-4e70-9903-d2bef246e00b
2
private void crossOver(Chromo<T> offspring1, Chromo<T> offspring2){ T tmp; List<T> genes1 = offspring1.getGenes(); List<T> genes2 = offspring2.getGenes(); if (rand.nextDouble() < CROSSOVER_RATE){ int position = (rand.nextInt(genes1.size())); for (int i=position; i<genes1.size(...
01e6aa34-d846-4b39-b9b8-dd2c64911cf9
7
static int rotatedBinarySearch(Integer array[], int key, int start, int end) { if (start > end) return -1; int middle = start+(end-start)/2; // ****IMPORTANT if (array[middle] == key) return middle; // lower half is sorted if (array[start] <...
402ed7a7-9c34-476e-97ea-58050136036b
2
private boolean goToX(int xDestination) { if (x != xDestination) { if (!isOnPath()) { goToPath(); return false; } else { return stepInDirectionOfX(xDestination); } } else { return true; } }
4d163726-b7c1-4125-aa2a-28d919fe1567
6
public static Set<IvyPackageClasspathEntry> build(String basepath, String var, String ivyUserDir, ResolveReport report) { Set<IvyPackageClasspathEntry> result = new HashSet<IvyPackageClasspathEntry>(); HashMap<IvyPackageKey, IvyPackage> packages = new HashMap<IvyPackageKey,IvyPackage>(); for(ArtifactDownloadR...
6dab5445-34d9-49d0-ac62-9efb8f0dbae2
0
@Override protected boolean removeEldestEntry(Map.Entry<CacheKey, Object> eldest) { return size() > CACHE_SIZE; }
e5d08f39-c654-4278-9f2f-ccb51a52485c
7
public static void main(String[] args) { List<Integer> abundant = new ArrayList<Integer>(); for(int i = 1; i < limit; i++) { if(getSumOfProperDivisors(i) > i) abundant.add(i); } boolean[] canBeAbundantSum = new boolean[limit + 1]; for(int i = 0; i < abundant.size(); i++) for(int j = 0; j < abunda...