jfun.parsec

Class DefaultPositionMap

public class DefaultPositionMap extends Object implements PositionMap, Serializable

This default implementation of PositionMap.

This class internally keeps a cache of the positions of all the line break characters scanned so far, therefore repeated position lookup can be done in amortized log(n) time.

Author: Ben Yu Dec 12, 2004

Constructor Summary
DefaultPositionMap(CharSequence src, int lno, int cno, char line_break)
Create a DefaultPositionMap object.
DefaultPositionMap(CharSequence src, int lno, int cno)
Create a DefaultPositionMap object.
Method Summary
PosgetPos(int n)

Constructor Detail

DefaultPositionMap

public DefaultPositionMap(CharSequence src, int lno, int cno, char line_break)
Create a DefaultPositionMap object.

Parameters: src the source. lno the starting line number. cno the starting column number. line_break the line break character.

DefaultPositionMap

public DefaultPositionMap(CharSequence src, int lno, int cno)
Create a DefaultPositionMap object.

Parameters: src the source. lno the starting line number. cno the starting column number.

Method Detail

getPos

public Pos getPos(int n)