java.io.Serializable
JacobsonBalancedParentheses
public interface BalancedParentheses
extends java.io.Serializable
A bit array of viewed by implementations of this class as a string of open (=one) and closed
(=zero) parentheses, which must be nested correctly. All operations are optional, but by contract
at least one of findOpen(long)
and findClose(long)
must be
provided.
Modifier and Type | Method | Description |
---|---|---|
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.
|
long findOpen(long pos)
Note that if you do not implement this method you must
implement findClose(long)
.
pos
- a position in the bit vector containing a closed parenthesis (a zero).long findClose(long pos)
Note that if you do not implement this method you must
implement findOpen(long)
.
pos
- a position in the bit vector containing an open parenthesis (a one).long enclose(long pos)
pos
- a position in the bit vector.BitVector bitVector()
Note that you are not supposed to modify the returned vector.
long numBits()