text
stringlengths
14
410k
label
int32
0
9
@Override public String toString() { if (isNan()) { return "Nan"; } else if (isPositiveInfinite()) { return "PositiveInfinite"; } else if (isNegativeInfinite()) { return "NegativeInfinite"; } else { BigDecimal r = this.getBigDecimal(); if (r.equals(0)) { if (negative) return "-0"; e...
5
@Test public void testAddCopiesCorrectBook() throws BookStoreException { // Add a copy of a book int copies_to_add = 1; Set<BookCopy> bookCopiesSet = new HashSet<BookCopy>(); bookCopiesSet.add(new BookCopy(TEST_ISBN, copies_to_add)); storeManager.addCopies(bookCopiesSet); // Get books with that ISBN Se...
8
@POST @Path("/optimize") @Produces("application/json; charset=UTF-8") public BestPlanning processOptimize(String request) { try { List<Flight> flights = new ObjectMapper().readValue(request, new TypeReference<List<Flight>>(){}); LOGGER.info("flightsCount: " + flights.size()); if (flights.size() < 1000) {...
8
public int hashCode() { T[] a = arr.get(); if(a == null) return(0); int ret = 1; for(T o : a) ret = (ret * 31) + System.identityHashCode(o); return(ret); }
2
public static void sort(Comparable[] a) { for (int i = 0; i < a.length; i++) { for (int j = i; j > 0; j--) { if (less(a[j], a[j - 1])) exch(a, j, j - 1); else break; } } }
3
public static void main(String[] args) { // TODO Auto-generated method stub int n = 10; int input[] = {5,7,9,3,4,5,1,6,2,7}; // 采用动态规划方法。 // len存储的是到input(i)截止的最长递增长度 int len; // max 存储的是到input(i)截止的最长递增长度为s的末尾的最小值 int min[]= new int [n]; // 辅助数组,用来最终输出单调递增子序列 int b[] = new int[n]; for(...
7
public boolean playerHasPermissions(Player player) { if (this.permissions == null) { return true; } if (P.p.permission.has(player, this.permissions) || player.isOp()) { return true; } return false; }
3
@Override public void run() { if (t != null && t.isRunning()) { t.stop(); } else { t = new Timer(TIMER_TIME, displayError); t.setRepeats(false); } setMsgLabel(txt); msgLabel.setForeground(Color.white); pane.setBackground(Color.red); for (Component c : errorComps) if (c != null) ...
4
public String mulHelper(String num, char c, int power) { StringBuffer sb = new StringBuffer(); if (c == '0') { return "0"; } int m = (c - '0'); int carry = 0; for (int i = num.length() - 1; i >= 0; i--) { char cc = num.charAt(i); int i1 = (cc - '0'); int r = i1 * m + carry; if (r >= 10) { ...
5
private Client_Response armeen_hinzufuegen_betreten(){ Zustand=Spielzustaende.Armeen_hinzufuegen; Client_Response zwischen = new Client_Response(DieSpielwelt, Zustand, aktueller_Spieler, false); if (ist_erste_runde==true){ switch (dieS...
5
public void run(){ while(!END_AReceber){ try { //try { Thread.sleep(1000); } catch (InterruptedException ex) {} //Console_println("AR1"); Transporte tr = new Transporte(initTransportePSH); Da...
6
public void setPN(Boolean x) { if(intPort == 0) intPort = 5252; if(x!=null) blPN = x; //Kill/Reset connection if(blPN == true && internetCon == null) { internetCon = new DroneClient(serverAddress, intPort); internetCon.setBase(me); serverAddress = internetCon.getServerIP(); intPort = intern...
6
public BarControllerImpl(BarService barService) { this.barService = barService; }
0
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
public final int getMaxLineLength() { return InputThread.MAX_LINE_LENGTH; }
0
@Override public Class getColumnClass(int column) { Class returnValue; if ((column >= 0) && (column < getColumnCount())) { if(getValueAt(0, column)==null) return String.class; returnValue = getValueAt(0, column).getClass(); ...
3
public GameSelecter() { boolean test = false; if (test || m_test) { System.out.println("GameSelecter :: GameSelecter() BEGIN"); } JFrame newChoose = new JFrame(); setChooseFrame(newChoose); getChooseFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); newChoose.setTi...
5
public static int insertMstxImage(int mid, File fileName, Date imageTime) { int result = 0; int id = MstxDao.getMaxNumber("mstx_image"); MstxDao.updateMaxNumber(4);// 将该字段值加1 FileInputStream fis = null; Connection con = DBUtil.getConnection(); PreparedStatement pstmt = null; try { fis = new FileInputSt...
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Vector other = (Vector) obj; if (Float.floatToIntBits(theta) != Float.floatToIntBits(other.theta)) return false; if (Float.floatToIntBits(x)...
6
private void selectClient() { List<Client> clients = dc.getAllClients(); System.out.println("Select client:"); int index = 0; for(Client client : clients) { System.out.println(++index + ") " + client.getFirstName()); } System.out.print("> "); BufferedR...
5
public void menu(int a){ switch (a){ case 0 : System.out.println("\nGOOD BYE!"); break; case 1: addContactToPhonebook(); break; case 2: searchByName(); break; case 3: contactList(); break; case 4: addCompanyToPhonebook(); break; case 5: searchByEmail(); break; case 6:...
8
public int getMOV() { return mov; }
0
@EventHandler public void onSign(PlayerInteractEvent event) { if(!event.getPlayer().getWorld().getName().equals(p.getWorld())) return; if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return; if(event.getClickedBlock().getType() != SIGN_POST && event.getClickedBlock().getType() != WALL_...
7
@Override public byte[] getBytes() { VariableLengthIntegerMessage length = getMessageFactory().createVariableLengthIntegerMessage(ints.length); VariableLengthIntegerMessage[] varInts = new VariableLengthIntegerMessage[ints.length]; for (int i = 0; i < ints.length; i++) { varInts[i] = getMessageFactory().cre...
3
@EventHandler(priority = EventPriority.NORMAL) public void onEntityDeath(final EntityDeathEvent event) { final int i = ran.nextInt(100); final Entity entity = event.getEntity(); if (!(entity instanceof Player)) { return; } final Player player = (Player) entity; ...
9
public void setLugar(int x, int y) { if (x < 0 || y < 0) { throw new IllegalArgumentException("Las coordenadas x(" + x+ ") o y(" + y + ") tienen que ser positivas" + ""); } this.x = x; this.y = y; }
2
private void extractEnvelope(XMLEventReader xrd) throws XMLStreamException { XMLEvent xev = xrd.nextTag(); if (xev.isStartElement() && xev.asStartElement().getName().getLocalPart().toLowerCase().contains("lower")) { // skip attributes,comments and whitespace do { ...
9
public static int allocateSlots(Expression exp, int nextFree, SlotManager frame) { if (exp instanceof Assignation) { ((Assignation)exp).setSlotNumber(nextFree); int count = ((Assignation)exp).getRequiredSlots(); nextFree += count; if (frame != null) { ...
9
public static void main(String[] args) { // TODO code application logic here int opcion=0; Scanner oScanner=new Scanner(System.in); do{ System.out.println("Digite la opcion que desea"); System.out.println("1: Ejercicio 1"); System.out...
5
private boolean processFields() { boolean newSecurity; // // Validate the security information // int type = securityType.getSelectedIndex(); if (type < 0) { JOptionPane.showMessageDialog(this, "You must select a security type", ...
9
public Boolean close() { try { this.con.close(); return true; } catch (SQLException e) { log.severe("Couldn't close Connection: "); LogHandler.writeStackTrace(log, e, Level.SEVERE); return false; } }
1
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 synchronized void removeListener(Class c, Object listener) { if (array == null || array.length == 0) return; if (listener == null || c == null) throw new IllegalArgumentException(); int index = 0; while (index < array.length) { if (array[index] == c && array[index + 1] == listener) break; ...
8
void render(float[][] dest, int nsamples) { assert (nsamples <= V2Instance.MAX_FRAME_SIZE); float voice[] = inst.vcebuf; float voice2[] = inst.vcebuf2; //memset(voice, 0, nsamples * sizeof(*voice)); // clear voice buffer for (int i = 0; i < nsamples; i++) { voice[i] = 0.0f; voice2[i] = 0.0f; } ...
7
static Font createFont(Device device, int points, int style) { if(SWT.getPlatform() == "win32") { return new Font(device, "Verdana", points, style); } else if (SWT.getPlatform() == "motif") { return new Font(device, "Times", points, style); } else if (SWT.getPlatform() == "gtk") { return new Font(de...
4
public static boolean isPrime(int x) { if (x == 2) { return true; } if (x % 2 == 0 || x == 1) { return false; } for (int i = 3; i * i <= Math.abs(x); i += 2) { if (x % i == 0){ return false; } } return true; }
5
public static void checkStructureIntegrity() { for (File f : dirList) { if (!f.exists()) { try { Log.debug("Creating: " + f.getName() + "(" + f.getPath() + ")"); f.mkdir(); } catch (Exception e) { Log.error...
5
private ArrayList<Entry> toArrayList(double startTime, double finishTime) { ArrayList<Entry> subProfile = new ArrayList<Entry>(); startTime = Math.max(startTime, currentTime()); Iterator<ProfileEntry> it = avail.itValuesFromPrec(startTime); Entry fe = null; // get first entry or create one if the profil...
5
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } CFG.INTERNET = Assistant.isInternetReachable(); File jar = new File(CFG.DIR, "Vloxlands.jar"); UniVersion.offline = !CFG.INTERNET;...
4
public void run() { // TODO Auto-generated method stub try { // Apertura Socket servidor = new ServerSocket(9003); Socket serv; PartidaChip objeto_rx; PartidaChip objeto_tx_play = new PartidaChip("PLAY", nick, 0, 0); enviarJugada(objeto_tx_play); while (true) { // Acepta cx entrantes ...
8
public static String numberToString(Number number) throws JSONException { if (number == null) { throw new JSONException("Null pointer"); } testValidity(number); // Shave off trailing zeros and decimal point, if possible. String string = number.toString(); if (string...
6
public boolean equals(Species other) { if(num != other.getDexNum()) return false; if(!species.equals(other.getName())) return false; if(canEvo != other.canEvolve()) return false; if(!Arrays.equals(types,other.getTypes())) return false; if(!Arrays.equals(baseStats,other.getBaseStats())) return ...
9
public void openFletching(int item) { if (item == 1511) { c.getPA().sendFrame164(8880); c.getPA().sendFrame126("What would you like to make?", 8879); c.getPA().sendFrame246(8884, 250, 839); // middle c.getPA().sendFrame246(8883, 250, 841); // left picture c.getPA().sendFrame246(88...
6
protected boolean scanImage(byte[] imageData) { ImageInfo ii = new ImageInfo(); ii.setInput(new ByteArrayInputStream(imageData)); if (ii.check()) { // grokked this.imgHeight=ii.getHeight(); this.imgWidth=ii.getWidth(); this.imgBitsPerPixel=ii.getBitsPerPixel(); if(th...
4
public void visitForceChildren(final TreeVisitor visitor) { if (visitor.reverse()) { expr.visit(visitor); } else { expr.visit(visitor); } }
1
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TestTransaction)) return false; TestTransaction that = (TestTransaction) o; if (amount != that.amount) return false; if (entity != null ? !entity.equals(that.entity) : that.entity != ...
9
@Override public void actionPerformed(ActionEvent e) { String comando = e.getActionCommand(); switch (comando) { case "DEPOSITO MANUAL": depoManual = new DepoManual(); depoManualControlador dmc = new depoManualControlador(depoManual, model, this); ...
9
private static void solve(StringBuilder pStr, StringBuilder vStr) { ArrayList<Integer> al = new ArrayList<>(); for (int i = 0; i < pStr.length(); i++) { int numErrors = 0; int numCounted = 0; int index = i; for (int j = 0; j < vStr.length(); j++) { if (index >= pStr.length()) { numErrors = numE...
8
public BooleanResource(int value) { this.value = (value != 0); }
0
public void testEncryptBlock() { byte[] key = ByteHelper.convertBinaryStringToByteArray("00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001".replace(" ", "")); byte[][][] subKeys = new byte[][][] { KeyCalculator.generateSubKeys(key) }; byte[] block = ByteHelper.convertBina...
1
private void canSeeAnythingAction() { switch (this.getType()) { case "Goalie" : //MP- Do nothing, if not the ball or the goal the goalie doesn't need to do anything break; case "Attacker" : //Will run the player into s...
7
public static void runPostRaceScreen() { try { while (!exit && !goToMainMenu) { // If the display is not visible (minimised), add much more // delay if (!Display.isVisible()) { Thread.sleep(200); } // If the display is requested to close, exit the program else if (Display.isCloseReque...
7
public Object getValueAt(int row, int column) { if (row >= listData.size()) throw new IndexOutOfBoundsException("Table row "+row+" is not valid"); AmortizationElement element = listData.get(row); Object value; switch (column) { case 0: ...
5
public static void main(String[] args) throws UnknownHostException { MongoClient client = new MongoClient(); DB courseDB = client.getDB("school"); DBCollection collection = courseDB.getCollection("students"); System.out.println("before count: " + collection.count()); DBCursor cursor = collection.find(); tr...
6
public static void main(String[] args) throws Exception { Configuration configData = QcConfigDataHandler.getConfigDataHandler().getConfigData(); String resultFilename = configData.getString("qc.result.file"); String resultClass = configData.getString("qc.result.class"); String className = "co...
2
public ValidationErrorList validate(){ Person person = patient.getPerson(); ValidationErrorList errorList = new ValidationErrorList(); Validator instance = ESAPI.validator(); DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); if ( (instance.getValidInput("username", userAccount.getUsername(), "Name", ...
9
public double getAvb() { return delegate.getAvb(); }
0
double findLength(String[] s){ double length=0; boolean find=false; int i=0; while(find ==false && i<s.length){ String tmp = s[i]; if(tmp.contains("Len=")){ find=true; String tmpNum=tmp.split("\"")[0]; length=Double.parseDouble(tmpNum.substring(4)); } i++; } return length; }
3
public void storeRelease(RSS feed) { Release r; String firstSeen = null; for (Item item : feed.getChannel().getItems()) { try { r = Release.parseItem(item, this.name); if (firstSeen == null) firstSeen = r.toString(); if (lastSeenTitle!=null && lastSeenTitle.equals(r....
6
private void findExtremes() { this.MAX_TEMP = Long.MAX_VALUE; this.MIN_TEMP = Long.MIN_VALUE; if (alloy.getS() < alloy.getT()) { this.HIGH_TEMP = alloy.getT(); this.LOW_TEMP = alloy.getS(); } else { this.HIGH_TEMP = alloy.getT(); this.LOW_T...
3
public Customer getRecord(String custId) { Customer cust = null; String sql = "SELECT * from Customer WHERE id=?"; if(conn == null){ boolean result = openConnection(); if(result != true){ logger.error("Unable to connect to the DB "); return cust; } } try { preparedStmt = conn.prepa...
8
public void sendCommand(String command) { System.out.println("command " + command + "| cientFeatures " + clientFeatures + "| lobby " + lobby); try { if ((!command.startsWith(util.Protocol.CMD_SAID) || (clientFeatures != null && clientFeatures .contains(util.Protocol.FEAT_CHAT))) && (!command.starts...
9
@Override public void serialize(Buffer buf) { buf.writeShort(bonesId); buf.writeUShort(skins.length); for (short entry : skins) { buf.writeShort(entry); } buf.writeUShort(indexedColors.length); for (int entry : indexedColors) { buf.writeInt(ent...
4
private void writeJSON(Object value) throws JSONException { if (JSONObject.NULL.equals(value)) { write(zipNull, 3); } else if (Boolean.FALSE.equals(value)) { write(zipFalse, 3); } else if (Boolean.TRUE.equals(value)) { write(zipTrue, 3); } else { ...
8
public boolean save() { try { boolean hasSaved = false; if (databaseType == DatabaseType.FLATFILE) { hasSaved = FDFlatFileHelper.saveFlatFile((FlatFile)dataBase); } if (!hasSaved) { System.err.println("DATABASE DID NOT SAVE!!!"); return false; } else { System.out.println(...
3
public void downloadTextFile(URL url) throws IOException { String fileName = null; File tempFile = null; BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); // This case means that is index that is being processed if (url.getPath().equalsIgnoreCas...
8
public Session stopWatching(Session session) { watcherToUser.remove(session); Session clientSession = null; boolean deleteSet = false; for(Map.Entry<Session, Set<Session>> watchers : userToWatchers.entrySet()){ if (watchers.getValue().remove(session)) { deleteSet = watchers.getValue().isEmpty(); clie...
3
@SuppressWarnings("unchecked") public String loadUsers() { PreparedStatement st = null; PreparedStatement ust = null; ResultSet rs = null; ResultSet urs = null; JSONArray json = new JSONArray(); try { conn = dbconn.getConnection(); st = conn.pr...
4
public void encoder(Circuit c, String endroit){ try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuild = docFactory.newDocumentBuilder(); Document doc = docBuild.newDocument(); root = doc.createElement...
3
private void renderGhost(Screen screen) { Point[] gSelection = tetromino.getGhost(this).getSelection(); for (Point point : gSelection) { int yy = point.getY()-HIDDEN_ROWS; if (yy >= 0) { int x = point.getX()*BLOCK_SCALE+getX(); int y = yy*BLOCK_SCALE+getY(); screen.renderHue(x, y, Art.GHOST, tetro...
2
public void waitAndResponse(MessageHandler handler) { while (true) { if (messageResponse.size() > 0) { synchronized (this) { for (String id : messageResponse.keySet()) { MessageAdaptor response = handler .handle(messageResponse.remove(id)); messageSource.add(response); } } ...
4
public static Customer getByNumber(final Long number) { JSONArray fetchByNumber = null; try { fetchByNumber = fetchByNumber(ApiProperties.get().getToken(), object, number); } catch (IOException e) { e.printStackTrace(); } List<Customer> formatOutputs = formatOutputs(fetchByNumber); if (formatOutputs.s...
2
public static boolean matches(AudioFormat format1, AudioFormat format2) { //$$fb 19 Dec 99: endian must be checked, too. // // we do have a problem with redundant elements: // e.g. // encoding=ALAW || ULAW -> bigEndian and samplesizeinbits don't matter // sample siz...
9
public void run(){ byte arr1[] = new byte[576]; dack = new DatagramPacket(arr1, arr1.length); try{ //keeps reading from server while (lBound<totPacket){ dsock.receive(dack); // receive the packet byte[] data = dack.getData(); int ack = getAcknowledgmentNumber(data); receivedTime[ack...
5
@EventHandler public void oreGinInteraction(PlayerInteractEvent event) throws IOException { Block clicked = event.getClickedBlock(); Player creator = event.getPlayer(); if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) { if (clicked.getState() instanceof Dispenser) { //Create and/or upgrade ...
8
public synchronized void stopInternalAudioPlayer() { //TODO remove here all not used players // may try to use the stream, if is connected, remove it again for (final AudioPlayer_Mplayer player : allPlayers) { if(player != null) { player.stopPlaying(); player.killThread(); } } ...
4
private void doServerModule(final String moduleName) { assert moduleExists("server", moduleName); this.serverLoginModule = moduleName; // confirm that runtime loaded the login file final Configuration config = Configuration.getConfiguration(); // we o...
7
private List<byte[]> doLayering(PngImage baseImage, PngImage layerImage, List<byte[]> baseRows, List<byte[]> layerRows) throws IOException { final List<byte[]> result = new ArrayList<>(baseRows.size()); final PngImageType baseImageType = PngImageType.forColorType(baseImage.getColorType()); final PngImageType lay...
9
static void print(int[] A){ for(int i=0;i<A.length;i++){ System.out.printf("%d ", A[i]); } System.out.println(); }
1
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Projeto other = (Projeto) obj; if (this.id != other.id && (this.id == null || !this.id.equals(other.id)))...
5
private final void drawGlobalDetails(Graphics2D g) { String altString = String.format("ALTITUDE : %s", "----.--"); String disString = String.format("DISTANCE : %s", "----.--"); if(lander != null && model.positions.get(lander) != null && landingPad != null && model.positions.get(landingPad) != ...
4
private boolean _execCommand(String command, boolean reset) { logPanel.add("Sent command <strong>" + command + "</strong>", LogPanel.OK, true); String xmlString = null; try { URL url = new URL(HTTP_CAMERA_SERVER + HTTP_PATH_EXEC + "?" + command); xmlString = _readText(url.openStream()).trim(); D...
7
public ArrayList<Object> lowerOutliersAnscombe_as_double(double constant) { switch (type) { case 1: double[] dd = this.getArray_as_double(); lowerOutlierDetails = lowerOutliersAnscombeAsArrayList(dd, constant); break; case 12: BigDecimal[] bd = this.getArray_as_BigDecimal(); ArrayList<Object> ret ...
3
private void tryOnBadIntervalException(double startValue, double endValue, double step) { try { if (startValue < Integer.MIN_VALUE || endValue > Integer.MAX_VALUE) { throw new BadIntervalException("Invalid borders of interval!"); } if (endValue <= startValue)...
5
@Override public void visitIincInsn(final int var, final int increment) { if (currentBlock != null) { if (compute == FRAMES) { currentBlock.frame.execute(Opcodes.IINC, var, null, null); } } if (compute != NOTHING) { // updates max locals ...
7
public void setDestinationStation(String value) { this._destinationStation = value; }
0
public void freeze(int layer){ assert(layer >= 0 && layer <= layers.size()-3); frozen = layer; }
1
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { matchLabel = new javax.swing.JLabel(); newTournButton = new javax.swing.JButton(); addPlayerButton = new javax.swing.JButton(); addWorldButton = new jav...
2
public Unit getDivisors(int number){ if(map.containsKey(number)){ return map.get(number); } Unit unit=new Unit(); for(int div=2;div<number;div++){ if(number%div==0){ Unit unit1=getDivisors(div); Unit unit2=getDivisors(number/div); for(Integer div1:unit1.divisorSet){ for(Integer div2:un...
7
private void runSoak() { final int cap = 10*1000; HashedSetInt set = new HashedSetInt(0, 5); // general put-get for (int v = 0; v != cap; v++) org.junit.Assert.assertTrue(set.add(v)); org.junit.Assert.assertEquals(cap, set.size()); for (int v = 0; v != cap; v++) org.junit.Assert....
8
public final void clearEffects() { for(int e = 0; e<effectList.length;e++) { effectList[e] = Effect.CLEAR; } }
1
public int getIntelligentY() { return intelligentY; }
0
public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) { SpringLayout layout; try { layout = (SpringLayout)pa...
7
private String readLine(BufferedReader clientRequest) { String clientCommand = null; this.log.info("before read Line"); do { if (this.currentThread.isInterrupted()) { this.log.info("current Thread is Interrupted"); closeClientSocket(); this.log.info("ClientHandler " + id + " finish"); return nu...
3
public void mouseDragged(MouseEvent event) { adapter.mouseDragged(event); }
0
@Test public void test() { int[] arr = {3, 7, 8, 6, 5, 5, 4, 3, 1}; // Sort an array a[] of N integers between 0 and R - 1 for(int i : arr) System.out.print(i); System.out.println(); Strings.keyIndexedCounting(arr, 9); for (int i : arr) System.out.print(i); }
2
public int bracket_matcher(String str){ //Initialize result to 0 by default; int result = 0; //This List<String> brackets stores the brackets in the input String. List <String> brackets = new ArrayList<>(); //This is a counter for the number of opening brackets int open = 0; //This is a counter for t...
9
public static boolean deepEquals(boolean[] array1, boolean[] array2){ if (array1.length != array2.length) return false; for (int i = 0; i < array1.length; i++){ if (!(array1[i] == array2[i])) return false; } return true; }
3
private final String getChunk(String s, int slength, int marker) { StringBuilder chunk = new StringBuilder(); char c = s.charAt(marker); chunk.append(c); marker++; if (isDigit(c)) { while (marker < slength) { c = s.charAt(marker...
5
static void indexShrink(){ /* * remove half old entries in the index */ System.out.println("Index size before shrinking: "+index.size()); resultRecord.println("Index size before shrinking: "+index.size()); int max = index.size()/migratePara; int count = 0; Iterator<Entry<String, long[]>> ite...
3