|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface BalancedParentheses
A data structure providing primitives for balanced parentheses represented in a bit array.
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.
| 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. |
| Method Detail |
|---|
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()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||