it.unimi.dsi.bits
Class TransformationStrategies

java.lang.Object
  extended by it.unimi.dsi.bits.TransformationStrategies

public class TransformationStrategies
extends Object

A class providing static methods and objects that do useful things with transformation strategies.

See Also:
TransformationStrategy

Constructor Summary
TransformationStrategies()
           
 
Method Summary
static
<T extends BitVector>
TransformationStrategy<T>
identity()
          A trivial transformation for data already in BitVector form.
static
<T extends CharSequence>
TransformationStrategy<T>
iso()
          A trivial transformation from strings to bit vectors that concatenates the lower eight bits of the UTF-16 representation.
static
<T extends BitVector>
TransformationStrategy<T>
prefixFree()
          A transformation from bit vectors to bit vectors that guarantees that its results are prefix free.
static
<T extends CharSequence>
TransformationStrategy<T>
prefixFreeIso()
          A trivial transformation from strings to bit vectors that concatenates the bits of the UTF-16 representation and completes the representation with an ASCII NUL to guarantee lexicographical ordering and prefix-freeness.
static
<T extends CharSequence>
TransformationStrategy<T>
prefixFreeUtf16()
          A trivial transformation from strings to bit vectors that concatenates the bits of the UTF-16 representation and completes the representation with an ASCII NUL to guarantee lexicographical ordering and prefix-freeness.
static
<T extends CharSequence>
TransformationStrategy<T>
utf16()
          A trivial transformation from strings to bit vectors that concatenates the bits of the UTF-16 representation.
static
<T> Iterable<BitVector>
wrap(Iterable<T> iterable, TransformationStrategy<? super T> transformationStrategy)
          Wraps a given iterable, returning an iterable that contains bit vectors.
static
<T> Iterator<BitVector>
wrap(Iterator<T> iterator, TransformationStrategy<? super T> transformationStrategy)
          Wraps a given iterator, returning an iterator that emits bit vectors.
static
<T> List<BitVector>
wrap(List<T> list, TransformationStrategy<? super T> transformationStrategy)
          Wraps a given list, returning a list that contains bit vectors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformationStrategies

public TransformationStrategies()
Method Detail

identity

public static <T extends BitVector> TransformationStrategy<T> identity()
A trivial transformation for data already in BitVector form.


utf16

public static <T extends CharSequence> TransformationStrategy<T> utf16()
A trivial transformation from strings to bit vectors that concatenates the bits of the UTF-16 representation. Warning: bit vectors returned by this strategy are adaptors around the original string. If the string changes while the bit vector is being accessed, the results will be unpredictable.


prefixFreeUtf16

public static <T extends CharSequence> TransformationStrategy<T> prefixFreeUtf16()
A trivial transformation from strings to bit vectors that concatenates the bits of the UTF-16 representation and completes the representation with an ASCII NUL to guarantee lexicographical ordering and prefix-freeness.

Note that strings provided to this strategy must not contain ASCII NULs. Warning: bit vectors returned by this strategy are adaptors around the original string. If the string changes while the bit vector is being accessed, the results will be unpredictable.


iso

public static <T extends CharSequence> TransformationStrategy<T> iso()
A trivial transformation from strings to bit vectors that concatenates the lower eight bits of the UTF-16 representation.

Note that this transformation is sensible only for strings that are known to be contain just characters in the ISO-8859-1 charset. Warning: bit vectors returned by this strategy are adaptors around the original string. If the string changes while the bit vector is being accessed, the results will be unpredictable.


prefixFreeIso

public static <T extends CharSequence> TransformationStrategy<T> prefixFreeIso()
A trivial transformation from strings to bit vectors that concatenates the bits of the UTF-16 representation and completes the representation with an ASCII NUL to guarantee lexicographical ordering and prefix-freeness.

Note that this transformation is sensible only for strings that are known to be contain just characters in the ISO-8859-1 charset, and that strings provided to this strategy must not contain ASCII NULs. Warning: bit vectors returned by this strategy are adaptors around the original string. If the string changes while the bit vector is being accessed, the results will be unpredictable.


wrap

public static <T> Iterator<BitVector> wrap(Iterator<T> iterator,
                                           TransformationStrategy<? super T> transformationStrategy)
Wraps a given iterator, returning an iterator that emits bit vectors.

Parameters:
iterator - an iterator.
transformationStrategy - a strategy to transform the object returned by iterator.
Returns:
an iterator that emits the content of iterator passed through transformationStrategy.

wrap

public static <T> Iterable<BitVector> wrap(Iterable<T> iterable,
                                           TransformationStrategy<? super T> transformationStrategy)
Wraps a given iterable, returning an iterable that contains bit vectors.

Parameters:
iterable - an iterable.
transformationStrategy - a strategy to transform the object contained in iterable.
Returns:
an iterable that has the content of iterable passed through transformationStrategy.

wrap

public static <T> List<BitVector> wrap(List<T> list,
                                       TransformationStrategy<? super T> transformationStrategy)
Wraps a given list, returning a list that contains bit vectors.

Parameters:
list - a list.
transformationStrategy - a strategy to transform the object contained in list.
Returns:
a list that has the content of list passed through transformationStrategy.

prefixFree

public static <T extends BitVector> TransformationStrategy<T> prefixFree()
A transformation from bit vectors to bit vectors that guarantees that its results are prefix free.

More in detail, we map 0 to 10, 1 to 11, and we add a 0 at the end of all strings.

Warning: bit vectors returned by this strategy are adaptors around the original string. If the string changes while the bit vector is being accessed, the results will be unpredictable.