/** Returns the element at the specified position in this front-coded list by storing it in a mutable string. * * @param index an index in the list. * @param s a mutable string that will contain the string at the specified position. */ public void get( final int index, final MutableString s ) { frontCodedStringList.get( permutation[ index ], s ); }
@Override public int size() { return frontCodedStringList.size(); }
protected static char[] byte2Char( final byte[] a, char[] s ) { final int length = a.length; if ( s == null ) s = new char[ countUTF8Chars( a ) ]; int b, c, d; for( int i = 0, j = 0; i < length; i++ ) { b = a[ i ] & 0xFF; if ( ( b >> 4 ) < 8 ) s[ j++ ] = (char)b; else if ( ( b >> 4 ) < 14 ) { c = a[ ++i ] & 0xFF; if ( ( c & 0xC0 ) != 0x80 ) throw new IllegalStateException( "Malformed internal UTF-8 encoding" ); s[ j++ ] = (char)( ( ( b & 0x1F) << 6 ) | ( c & 0x3F ) ); } else { c = a[ ++i ] & 0xFF; d = a[ ++i ]; if ( ( c & 0xC0 ) != 0x80 || ( d & 0xC0 ) != 0x80 ) throw new IllegalStateException( "Malformed internal UTF-8 encoding" ); s[ j++ ] = (char)( ( ( b & 0x0F ) << 12 ) | ( ( c & 0x3F ) << 6 ) | ( ( d & 0x3F ) << 0 ) ); } } return s; }
FrontCodedStringList frontcodedList = new FrontCodedStringList(stringList, 8, true);
/** Returns the element at the specified position in this front-coded list by storing it in a mutable string. * * @param index an index in the list. * @param s a mutable string that will contain the string at the specified position. */ public void get( final int index, MutableString s ) { if ( utf8 ) { final byte[] a = byteFrontCodedList.getArray( index ); s.length( countUTF8Chars( a ) ); byte2Char( a, s.array() ); } else { int res = charFrontCodedList.get( index, s.array() ); if ( res < 0 ) { s.length( s.array().length - res ); res = charFrontCodedList.get( index, s.array() ); } else s.length( res ); } }
/** Returns the element at the specified position in this front-coded as a mutable string. * * @param index an index in the list. * @return a {@link MutableString} that will contain the string at the specified position. The string may be freely modified. */ public MutableString get( final int index ) { return MutableString.wrap( utf8 ? byte2Char( byteFrontCodedList.getArray( index ), null ) : charFrontCodedList.getArray( index ) ); }
QuasiSuccinctEntityHash quasiSuccinctEntityHash = new QuasiSuccinctEntityHash( surfaceForm2Position, cutPointsArray, valuesA, new EliasFanoLongBigList( entityValues ), new FrontCodedStringList( entityNames, 8, true ) ); LOGGER.info( "Creating stats" );
/** Returns the element at the specified position in this front-coded list by storing it in a mutable string. * * @param index an index in the list. * @param s a mutable string that will contain the string at the specified position. */ public void get( final int index, MutableString s ) { if ( utf8 ) { final byte[] a = byteFrontCodedList.getArray( index ); s.length( countUTF8Chars( a ) ); byte2Char( a, s.array() ); } else { int res = charFrontCodedList.get( index, s.array() ); if ( res < 0 ) { s.length( s.array().length - res ); res = charFrontCodedList.get( index, s.array() ); } else s.length( res ); } }
/** Returns the element at the specified position in this front-coded as a mutable string. * * @param index an index in the list. * @return a {@link MutableString} that will contain the string at the specified position. The string may be freely modified. */ public MutableString get( final int index ) { return MutableString.wrap( utf8 ? byte2Char( byteFrontCodedList.getArray( index ), null ) : charFrontCodedList.getArray( index ) ); }
@Override public CharSequence getEntityName( int id ) { return entityNames.get( id ); } }
public int size() { return frontCodedStringList.size(); }
pl.itemsName = "words"; pl.start( "Reading words..." ); final FrontCodedStringList frontCodedStringList = new FrontCodedStringList( new LineIterator( new FastBufferedReader( new InputStreamReader( zipped ? new GZIPInputStream( System.in ) : System.in, encoding ), bufferSize ), pl ), ratio, utf8 ); pl.done();
/** Returns the element at the specified position in this front-coded list by storing it in a mutable string. * * @param index an index in the list. * @param s a mutable string that will contain the string at the specified position. */ public void get(final int index, MutableString s) { if (utf8) { final byte[] a = byteFrontCodedList.getArray(index); s.length(countUTF8Chars(a)); byte2Char(a, s.array()); } else { s.length(s.array().length); int res = charFrontCodedList.get(index, s.array()); if (res < 0) { s.length(s.array().length - res); res = charFrontCodedList.get(index, s.array()); } else s.length(res); } }
/** Returns the element at the specified position in this front-coded as a mutable string. * * @param index an index in the list. * @return a {@link MutableString} that will contain the string at the specified position. The string may be freely modified. */ @Override public MutableString get(final int index) { return MutableString.wrap(utf8 ? byte2Char(byteFrontCodedList.getArray(index), null) : charFrontCodedList.getArray(index)); }
protected static char[] byte2Char( final byte[] a, char[] s ) { final int length = a.length; if ( s == null ) s = new char[ countUTF8Chars( a ) ]; int b, c, d; for( int i = 0, j = 0; i < length; i++ ) { b = a[ i ] & 0xFF; if ( ( b >> 4 ) < 8 ) s[ j++ ] = (char)b; else if ( ( b >> 4 ) < 14 ) { c = a[ ++i ] & 0xFF; if ( ( c & 0xC0 ) != 0x80 ) throw new IllegalStateException( "Malformed internal UTF-8 encoding" ); s[ j++ ] = (char)( ( ( b & 0x1F) << 6 ) | ( c & 0x3F ) ); } else { c = a[ ++i ] & 0xFF; d = a[ ++i ]; if ( ( c & 0xC0 ) != 0x80 || ( d & 0xC0 ) != 0x80 ) throw new IllegalStateException( "Malformed internal UTF-8 encoding" ); s[ j++ ] = (char)( ( ( b & 0x0F ) << 12 ) | ( ( c & 0x3F ) << 6 ) | ( ( d & 0x3F ) << 0 ) ); } } return s; }
/** Returns the element at the specified position in this front-coded list by storing it in a mutable string. * * @param index an index in the list. * @param s a mutable string that will contain the string at the specified position. */ public void get( final int index, final MutableString s ) { frontCodedStringList.get( permutation[ index ], s ); }
public int size() { return frontCodedStringList.size(); }
pl.itemsName = "strings"; pl.start("Reading strings..."); final FrontCodedStringList frontCodedStringList = new FrontCodedStringList(new LineIterator(new FastBufferedReader( new InputStreamReader(zipped ? new GZIPInputStream(System.in) : System.in, encoding), bufferSize), pl), ratio, utf8); pl.done();
@Override public MutableString previous() { return MutableString.wrap(utf8 ? byte2Char((byte[])i.previous(), null) :(char[])i.previous()); } @Override