public class SizeSequence extends Object
Constructor and Description |
---|
SizeSequence()
Creates a new empty
SizeSequence instance. |
SizeSequence(int numEntries)
Creates a new
SizeSequence instance with the specified number
of elements, each having a size of 0. |
SizeSequence(int[] sizes)
Creates a new
SizeSequence instance using the specified
element sizes. |
SizeSequence(int numEntries,
int value)
Creates a new
SizeSequence instance with the specified number
of elements all having the same size (value ). |
Modifier and Type | Method and Description |
---|---|
int |
getIndex(int position)
Returns the index of the element that contains the specified position.
|
int |
getPosition(int index)
Returns the position of the specified element.
|
int |
getSize(int index)
Returns the size of the specified element, or 0 if the element index is
outside the defined range.
|
int[] |
getSizes()
Returns an array containing the sizes for all the elements in the sequence.
|
void |
insertEntries(int start,
int length,
int value)
Inserts new entries into the sequence at the
start position. |
void |
removeEntries(int start,
int length)
Removes the element(s) at index
start (the number of elements
removed is length ). |
void |
setSize(int index,
int size)
Sets the size of the element at the specified index.
|
void |
setSizes(int[] sizes)
Sets the sizes for the elements in the sequence.
|
public SizeSequence()
SizeSequence
instance.public SizeSequence(int numEntries)
SizeSequence
instance with the specified number
of elements, each having a size of 0.numEntries
- the number of elements.public SizeSequence(int numEntries, int value)
SizeSequence
instance with the specified number
of elements all having the same size (value
).numEntries
- the number of elements.value
- the value for each element.public SizeSequence(int[] sizes)
SizeSequence
instance using the specified
element sizes.sizes
- the element sizes (null
not permitted).public void setSize(int index, int size)
index
- the index.size
- the size.public int getIndex(int position)
position
- the position.public int getSize(int index)
index
- the element index.public void setSizes(int[] sizes)
sizes
- the element sizes (null
not permitted).public int[] getSizes()
public int getPosition(int index)
index
- the element index.public void insertEntries(int start, int length, int value)
start
position.
There are length
new entries each having the specified
value
.start
- the start element.length
- the number of elements to insert.value
- the size for each of the new elements.public void removeEntries(int start, int length)
start
(the number of elements
removed is length
).start
- the index of the first element to remove.length
- the number of elements to remove.