public final class StyledFragmentsList
extends java.lang.Object
StyledFragmentsList
is just a list of StyledFragments that we can re-use without having to constantly reallocate arrays and StyledFragment objects. This should help overall performance by reducing the amount of object allocation going on. We can do this because the current usage is to build up a list of StyledFragments for a range of lines, then iterate through them one by one to paint them.
The methods on this class are a subset of the List interface based on the needs of this package. Note that this is an unsynchronized class, and the StyledFragment returned by get() is just a cached member of the list - this means that multiple readers should not be using the list at the same time. This is generally not a problem as a given list will be used only by one renderer at a time.
Constructor and Description |
---|
StyledFragmentsList()
Constructs a new StyledFragmentList with an initial size of the default (100).
|
StyledFragmentsList(int preferredSize)
Constructs a new StyledFragmentList with the given preferred size.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String styleName, int startOffset, int endOffset)
Adds the given fragment to the end of the list.
|
void |
clear()
Discards all fragments from the list.
|
StyledFragment |
get(int index)
Get the fragment at the specified index.
|
int |
size()
Returns the size of the list (number of fragments.)
|
public StyledFragmentsList()
public StyledFragmentsList(int preferredSize)
preferredSize
- requested perferred sizepublic void add(java.lang.String styleName, int startOffset, int endOffset)
styleName
- the name of the style of the fragment to addstartOffset
- the start offset of the fragmentendOffset
- the end offset of the fragmentpublic void clear()
public int size()
public StyledFragment get(int index)
index
- the index of the fragment to retrieve