it.unimi.dsi.sux4j.bits
Class TrivialBalancedParentheses

java.lang.Object
  extended by it.unimi.dsi.sux4j.bits.TrivialBalancedParentheses
All Implemented Interfaces:
BalancedParentheses, Serializable

public class TrivialBalancedParentheses
extends Object
implements BalancedParentheses

See Also:
Serialized Form

Constructor Summary
TrivialBalancedParentheses(BitVector v)
           
 
Method Summary
 BitVector bitVector()
          Returns the bit vector indexed by this structure.
 long enclose(long pos)
          Returns the position of the open parenthesis of the pair the most tightly encloses the given position (optional operation).
 long findClose(long pos)
          Returns the position of the matching closed parenthesis (optional operation).
 long findOpen(long pos)
          Returns the position of the matching open parenthesis (optional operation).
 long numBits()
          Returns the overall number of bits allocated by this structure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrivialBalancedParentheses

public TrivialBalancedParentheses(BitVector v)
Method Detail

bitVector

public BitVector bitVector()
Description copied from interface: BalancedParentheses
Returns the bit vector indexed by this structure.

Note that you are not supposed to modify the returned vector.

Specified by:
bitVector in interface BalancedParentheses
Returns:
the bit vector indexed by this structure.

enclose

public long enclose(long pos)
Description copied from interface: BalancedParentheses
Returns the position of the open parenthesis of the pair the most tightly encloses the given position (optional operation).

Specified by:
enclose in interface BalancedParentheses
Parameters:
pos - a position in the bit vector.
Returns:
the position of the open parenthesis of the pair the most tightly encloses the given position.

findClose

public long findClose(long pos)
Description copied from interface: BalancedParentheses
Returns the position of the matching closed parenthesis (optional operation).

Note that if you do not implement this method you must implement BalancedParentheses.findOpen(long).

Specified by:
findClose in interface BalancedParentheses
Parameters:
pos - a position in the bit vector containing an open parenthesis (a one).
Returns:
the position of the matching open parenthesis.

findOpen

public long findOpen(long pos)
Description copied from interface: BalancedParentheses
Returns the position of the matching open parenthesis (optional operation).

Note that if you do not implement this method you must implement BalancedParentheses.findClose(long).

Specified by:
findOpen in interface BalancedParentheses
Parameters:
pos - a position in the bit vector containing a closed parenthesis (a zero).
Returns:
the position of the matching open parenthesis.

numBits

public long numBits()
Description copied from interface: BalancedParentheses
Returns the overall number of bits allocated by this structure.

Specified by:
numBits in interface BalancedParentheses
Returns:
the overall number of bits allocated by this structure (not including the bits of the indexed vector).