Java Code Examples for it.unimi.dsi.lang.MutableString#indexOf()
The following examples show how to use
it.unimi.dsi.lang.MutableString#indexOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Chars.java From tagme with Apache License 2.0 | 6 votes |
/** Splits the input string in char sequences using char c as delimiter (c is discarded). * @param input * @param c * @return the splitted sub-strings. */ public static CharSequence[] split (MutableString input, char c){ if (input.indexOf(c)<0) return new CharSequence[]{input}; ObjectArrayList<CharSequence> tokens = new ObjectArrayList<CharSequence>(); int pos=-1, last=0; while((pos=input.indexOf(c, last))>=0) { if (last<pos) tokens.add(input.subSequence(last, pos)); else tokens.add(new MutableString("")); last = pos+1; } if (last < input.length()) tokens.add(input.subSequence(last, input.length())); return tokens.toArray(Chars.EMPTY_STRINGS); }
Example 2
Source File: BuildRepetitionSet.java From BUbiNG with Apache License 2.0 | 5 votes |
public static void main(String[] arg) throws IOException { if (arg.length == 0) { System.err.println("Usage: " + BuildRepetitionSet.class.getSimpleName() + " REPETITIONSET"); System.exit(1); } final FastBufferedReader fastBufferedReader = new FastBufferedReader(new InputStreamReader(System.in, Charsets.US_ASCII)); final MutableString s = new MutableString(); final LongOpenHashSet repeatedSet = new LongOpenHashSet(); final String outputFilename = arg[0]; final ProgressLogger pl = new ProgressLogger(); MutableString lastUrl = new MutableString(); pl.itemsName = "lines"; pl.start("Reading... "); while(fastBufferedReader.readLine(s) != null) { final int firstTab = s.indexOf('\t'); final int secondTab = s.indexOf('\t', firstTab + 1); MutableString url = s.substring(secondTab + 1); if (url.equals(lastUrl)) { final int storeIndex = Integer.parseInt(new String(s.array(), 0, firstTab)); final long storePosition = Long.parseLong(new String(s.array(), firstTab + 1, secondTab - firstTab - 1)); repeatedSet.add((long)storeIndex << 48 | storePosition); System.out.print(storeIndex); System.out.print('\t'); System.out.print(storePosition); System.out.print('\t'); System.out.println(url); } lastUrl = url; pl.lightUpdate(); } pl.done(); fastBufferedReader.close(); BinIO.storeObject(repeatedSet, outputFilename); }