public abstract class AbstractList extends PersistentObject
int
, float
, etc.
First see the package summary and javadoc
tree view to get the broad picture.
Note that this implementation is not synchronized.
ArrayList
,
Vector
,
Arrays
,
Serialized FormConstructor and Description |
---|
AbstractList() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
beforeInsertDummies(int index,
int length)
Inserts length dummy elements before the specified position into the receiver.
|
protected static void |
checkRange(int index,
int theSize)
Checks if the given index is in range.
|
protected static void |
checkRangeFromTo(int from,
int to,
int theSize)
Checks if the given range is within the contained array's bounds.
|
void |
clear()
Removes all elements from the receiver.
|
boolean |
isEmpty() |
void |
mergeSort()
Sorts the receiver into ascending order.
|
abstract void |
mergeSortFromTo(int from,
int to)
Sorts the receiver into ascending order.
|
void |
quickSort()
Sorts the receiver into ascending order.
|
abstract void |
quickSortFromTo(int from,
int to)
Sorts the specified range of the receiver into ascending order.
|
void |
remove(int index)
Removes the element at the specified position from the receiver.
|
abstract void |
removeFromTo(int fromIndex,
int toIndex)
Removes from the receiver all elements whose index is between
from , inclusive and to ,
inclusive. |
abstract void |
reverse()
Reverses the elements of the receiver.
|
void |
setSize(int newSize)
Sets the size of the receiver.
|
abstract int |
size() |
void |
sort()
Sorts the receiver into ascending order.
|
void |
sortFromTo(int from,
int to)
Sorts the specified range of the receiver into ascending order.
|
void |
trimToSize()
Trims the capacity of the receiver to be the receiver's current size.
|
clone
public abstract int size()
public boolean isEmpty()
protected abstract void beforeInsertDummies(int index, int length)
index
- index before which to insert dummy elements (must be in [0,size])..length
- number of dummy elements to be inserted.IndexOutOfBoundsException
- if index < 0 || index > size().protected static void checkRange(int index, int theSize)
protected static void checkRangeFromTo(int from, int to, int theSize)
IndexOutOfBoundsException
- if to!=from-1 || from<0 || from>to || to>=size().public void clear()
public final void mergeSort()
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set. It is generally better to call sort() or sortFromTo(...) instead, because those methods automatically choose the best sorting algorithm.
public abstract void mergeSortFromTo(int from, int to)
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists.
You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set. It is generally better to call sort() or sortFromTo(...) instead, because those methods automatically choose the best sorting algorithm.
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (inclusive) to be sorted.IndexOutOfBoundsException
- if (from<0 || from>to || to>=size()) && to!=from-1.public final void quickSort()
You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set. It is generally better to call sort() or sortFromTo(...) instead, because those methods automatically choose the best sorting algorithm.
public abstract void quickSortFromTo(int from, int to)
You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set. It is generally better to call sort() or sortFromTo(...) instead, because those methods automatically choose the best sorting algorithm.
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (inclusive) to be sorted.IndexOutOfBoundsException
- if (from<0 || from>to || to>=size()) && to!=from-1.public void remove(int index)
index
- the index of the element to removed.IndexOutOfBoundsException
- if index < 0 || index >= size().public abstract void removeFromTo(int fromIndex, int toIndex)
from
, inclusive and to
,
inclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the list by
(to - from + 1) elements.fromIndex
- index of first element to be removed.toIndex
- index of last element to be removed.IndexOutOfBoundsException
- if (from<0 || from>to || to>=size()) && to!=from-1.public abstract void reverse()
public void setSize(int newSize)
newSize
- the new size of the receiver.IndexOutOfBoundsException
- if newSize < 0.public final void sort()
public void sortFromTo(int from, int to)
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (inclusive) to be sorted.IndexOutOfBoundsException
- if (from<0 || from>to || to>=size()) && to!=from-1.public void trimToSize()
This default implementation does nothing. Override this method in space efficient implementations.
Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.