Class JacobsonBalancedParentheses
java.lang.Object
it.unimi.dsi.sux4j.bits.JacobsonBalancedParentheses
- All Implemented Interfaces:
BalancedParentheses, Serializable
An implementation of Jacobson's balanced parentheses data structure.
Warning: this class is a stub implementing just those method needed by a
HollowTrieMonotoneMinimalPerfectHashFunction.- Author:
- Sebastiano Vigna
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final it.unimi.dsi.bits.BitVectorstatic final longstatic final longstatic final longstatic final long -
Constructor Summary
ConstructorsConstructorDescriptionJacobsonBalancedParentheses(long[] bits, long length) JacobsonBalancedParentheses(it.unimi.dsi.bits.BitVector bv) JacobsonBalancedParentheses(it.unimi.dsi.bits.BitVector bitVector, boolean findOpen, boolean findClose, boolean enclose) -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringbinary(long l, boolean reverse) it.unimi.dsi.bits.BitVectorReturns the bit vector indexed by this structure.static final intcountFarClose(long word, int l) static final intcountFarOpen(long word, int l) longenclose(long pos) Returns the position of the open parenthesis of the pair the most tightly encloses the given position (optional operation).longfindClose(long pos) Returns the position of the matching closed parenthesis (optional operation).static final intfindFarClose(long word, int k) static final intfindFarClose2(long word, int k) static final intfindFarOpen(long word, int l, int k) static final intfindNearClose(long word) static final intfindNearClose2(long word) static final intfindNearCloseAlt(long word) longfindOpen(long pos) Returns the position of the matching open parenthesis (optional operation).longnumBits()Returns the overall number of bits allocated by this structure.
-
Field Details
-
bitVector
protected final it.unimi.dsi.bits.BitVector bitVector -
ONES_STEP_4
public static final long ONES_STEP_4- See Also:
-
MSBS_STEP_4
public static final long MSBS_STEP_4- See Also:
-
ONES_STEP_8
public static final long ONES_STEP_8- See Also:
-
MSBS_STEP_8
public static final long MSBS_STEP_8- See Also:
-
-
Constructor Details
-
JacobsonBalancedParentheses
public JacobsonBalancedParentheses(it.unimi.dsi.bits.BitVector bv) -
JacobsonBalancedParentheses
public JacobsonBalancedParentheses(long[] bits, long length) -
JacobsonBalancedParentheses
public JacobsonBalancedParentheses(it.unimi.dsi.bits.BitVector bitVector, boolean findOpen, boolean findClose, boolean enclose)
-
-
Method Details
-
binary
-
countFarOpen
public static final int countFarOpen(long word, int l) -
findFarOpen
public static final int findFarOpen(long word, int l, int k) -
countFarClose
public static final int countFarClose(long word, int l) -
findFarClose2
public static final int findFarClose2(long word, int k) -
findFarClose
public static final int findFarClose(long word, int k) -
findNearClose2
public static final int findNearClose2(long word) -
findNearClose
public static final int findNearClose(long word) -
findNearCloseAlt
public static final int findNearCloseAlt(long word) -
enclose
public long enclose(long pos) Description copied from interface:BalancedParenthesesReturns the position of the open parenthesis of the pair the most tightly encloses the given position (optional operation).- Specified by:
enclosein interfaceBalancedParentheses- 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:BalancedParenthesesReturns 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:
findClosein interfaceBalancedParentheses- 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:BalancedParenthesesReturns 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:
findOpenin interfaceBalancedParentheses- 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:BalancedParenthesesReturns the overall number of bits allocated by this structure.- Specified by:
numBitsin interfaceBalancedParentheses- Returns:
- the overall number of bits allocated by this structure (not including the bits of the indexed vector).
-
bitVector
public it.unimi.dsi.bits.BitVector bitVector()Description copied from interface:BalancedParenthesesReturns the bit vector indexed by this structure.Note that you are not supposed to modify the returned vector.
- Specified by:
bitVectorin interfaceBalancedParentheses- Returns:
- the bit vector indexed by this structure.
-