text
stringlengths
14
410k
label
int32
0
9
@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...
4
@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); } }
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...
2
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(); ...
9
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...
5
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) ...
4
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...
5
@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...
2
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())) { ...
4
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 (+...
7
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; } }
8
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_"...
5
public void push(int e) { if(len >= capacity) { throw new IllegalStateException("Error: capacity is bigger that len"); } heap[len] = e; len++; bubbleUp(len - 1); }
1
@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)) { ...
3
public boolean hasNoJumps() { return successors.size() == 0 && predecessors.size() == 0; }
1
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...
5
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() ...
3
public RandomListNode(int x){ this.label = x; }
0
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) ...
9
@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) { ...
6
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...
4
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...
7
void moveX(boolean right) { if (right) x += speed; else x -= speed; }
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...
1
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...
2
public void setCarriedKeyName(String value) { this.carriedKeyName = value; }
0
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...
5
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...
8
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...
9
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...
4
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("#")) ...
8
@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; ...
4
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...
9
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...
3
@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(...
4
private void emitTabs() { for (int i = 0; i < mDepth; i++) { mOut.print('\t'); } }
1
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...
8
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); }
1
public void setUser(User user) { this.m_user = user; }
0
public void setGetAccountRequest(GetAccountRequest getAccountRequest) { this.getAccountRequest = getAccountRequest; }
0
@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; }
3
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"); } //...
9
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("...
1
@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...
7
@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...
9
public static ArrayList<Order> parseOrdersList(String filePath, String XSDFilePath, Menu menu){ try { DocumentBuilderFactory documentBuilder = DocumentBuilderFactory.newInstance(); documentBuilder.setIgnoringElementContentWhitespace(true); Schema schema = SchemaFactory.newInstance( XMLCons...
3
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...
2
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(...
3
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; } ...
9
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); }
3
@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(); } }
1
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; }
2
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; } }
1
public String getOverCurrentMode () { switch (getHubCharacteristics () & 0x0018) { case 0x00: return "global"; case 0x08: return "per-port"; default: return "none"; } }
2
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) { ...
4
@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...
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...
2
@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...
8
public JSONObject putOpt(String key, Object value) throws JSONException { if (key != null && value != null) { this.put(key, value); } return this; }
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...
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...
2
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...
1
@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"...
0
@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...
8
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...
7
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); ...
3
@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...
9
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...
5
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)); } ...
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)...
4
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(','); ...
7
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...
8
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)...
9
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...
8
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; }
0
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...
6
private char nextSkippingWhitespace() throws IOException { for (;;) { char c = next(); if (c == 0 || c > ' ') { return c; } } }
3
@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 (...
4
public boolean removeNode(Root node) { return branchs.remove(node); }
0
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...
7
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...
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...
6
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; }
1
@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...
5
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...
7
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...
4
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...
6
@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...
3
public void setRemotePort(int remotePort) { this.remotePort = remotePort; }
0
@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 ...
9
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...
8
public String getCategoryName() { return categoryName; }
0
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...
6
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...
0
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(...
2
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] <...
7
private boolean goToX(int xDestination) { if (x != xDestination) { if (!isOnPath()) { goToPath(); return false; } else { return stepInDirectionOfX(xDestination); } } else { return true; } }
2
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...
6
@Override protected boolean removeEldestEntry(Map.Entry<CacheKey, Object> eldest) { return size() > CACHE_SIZE; }
0
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...
7