|
HTML Parser Home Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.htmlparser.lexer.PageIndex
public class PageIndex
A sorted array of integers, the positions of the first characters of each line.
To facilitate processing the first element should be maintained at position 0.
Facilities to add, remove, search and determine row and column are provided.
This class provides similar functionality to a Vector but
does not incur the overhead of an Integer
object per element.
Field Summary | |
---|---|
protected int |
mCount
The number of valid elements. |
protected int |
mIncrement
Increment for allocations. |
protected int[] |
mIndices
The elements. |
protected Page |
mPage
The page associated with this index. |
protected static int |
mStartIncrement
Starting increment for allocations. |
Constructor Summary | |
---|---|
PageIndex(Page page)
Create an empty index. |
|
PageIndex(Page page,
int cursor)
Create an index with the one element given. |
|
PageIndex(Page page,
int[] cursors)
Create an index with the elements given. |
Method Summary | |
---|---|
int |
add(Cursor cursor)
Add an element to the list |
int |
add(int cursor)
Add an element to the list |
protected int |
bsearch(int cursor)
Binary search for the element. |
protected int |
bsearch(int cursor,
int first,
int last)
Binary search for the element. |
int |
capacity()
Get the capacity for elements without reallocation. |
int |
column(Cursor cursor)
Get the column number for a cursor. |
int |
column(int cursor)
Get the column number for a position. |
int |
elementAt(int index)
Get an element from the list. |
Ordered |
fetch(int index,
Ordered reuse)
Fetch the object at the given index. |
int |
first()
Returns the first index of the Sortable. |
int[] |
get()
Get the elements as an array of int. |
Page |
getPage()
Get this index's page. |
protected void |
insertElementAt(int cursor,
int index)
Inserts an element into the list. |
int |
last()
Returns the last index of the Sortable. |
void |
remove(Cursor cursor)
Remove an element from the list |
void |
remove(int cursor)
Remove an element from the list |
protected void |
removeElementAt(int index)
Remove an element from the list. |
int |
row(Cursor cursor)
Get the line number for a cursor. |
int |
row(int cursor)
Get the line number for a position. |
int |
size()
Get the count of elements. |
void |
swap(int i,
int j)
Swaps the elements at the given indicies. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int mStartIncrement
protected int mIncrement
protected int mCount
protected int[] mIndices
protected Page mPage
Constructor Detail |
---|
public PageIndex(Page page)
page
- The page associated with this index.public PageIndex(Page page, int cursor)
page
- The page associated with this index.cursor
- The single element for the new index.public PageIndex(Page page, int[] cursors)
page
- The page associated with this index.cursors
- The initial elements of the index.
NOTE: The list must be sorted in ascending order.Method Detail |
---|
public Page getPage()
public int size()
public int capacity()
public int add(Cursor cursor)
cursor
- The element to add.
public int add(int cursor)
cursor
- The element to add.
public void remove(Cursor cursor)
cursor
- The element to remove.public void remove(int cursor)
cursor
- The element to remove.public int elementAt(int index)
index
- The index of the element to get.
public int row(Cursor cursor)
cursor
- The character offset into the page.
public int row(int cursor)
cursor
- The character offset into the page.
public int column(Cursor cursor)
cursor
- The character offset into the page.
public int column(int cursor)
cursor
- The character offset into the page.
public int[] get()
protected int bsearch(int cursor)
cursor
- The element to search for.
protected int bsearch(int cursor, int first, int last)
cursor
- The element to search for.first
- The index to start at.last
- The index to stop at.
protected void insertElementAt(int cursor, int index)
cursor
- The element to insert.index
- The index in the list to insert it at.protected void removeElementAt(int index)
index
- The index of the item to remove.public int first()
first
in interface Sortable
public int last()
last
in interface Sortable
public Ordered fetch(int index, Ordered reuse)
fetch
in interface Sortable
index
- The item number to get.reuse
- If this argument is not null, it is an object
acquired from a previous fetch that is no longer needed and
may be returned as the result if it makes mores sense to alter
and return it than to fetch or create a new element. That is, the
reuse object is garbage and may be used to avoid allocating a new
object if that would normally be the strategy.
public void swap(int i, int j)
swap
in interface Sortable
i
- One index.j
- The other index.
|
© 2006 Derrick Oswald Sep 17, 2006
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
HTML Parser is an open source library released under Common Public License. |