|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<T>
com.scottlogic.util.PatchWorkArray<T>
com.scottlogic.util.AutoFixingPatchWorkArray<T>
T
- The type of element that this list should store.public class AutoFixingPatchWorkArray<T>
Subclass of the PatchWorkArray which automatically fixes itself if the number of alterations reaches some specified limit.
List
,
Collection
,
ArrayList
,
PatchWorkArray
,
Serialized FormField Summary | |
---|---|
static float |
DEFAULT_MAX_PERFORMANCE_HIT_FACTOR
The default maximum factor of the size of a list that the performance hit can reach before it automatically fixes itself. |
static int |
DEFAULT_MIN_PERFORMANCE_HIT_BEFORE_FIX
The default minimum performance factor at which a list will automatically fix itself. |
protected float |
maxPerformanceHitFactor
The maximum factor of the size of this list that the performance hit can reach before it automatically fixes itself. |
protected int |
minPerformanceHitBeforeFix
The minimum performance factor at which this list will automatically fix itself. |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
AutoFixingPatchWorkArray()
Default constructor which fixes after the default limits are breached. |
|
AutoFixingPatchWorkArray(int initialCapacity)
Constructor which fixes after the default limits are breached and the backing list has the given initial capacity. |
|
AutoFixingPatchWorkArray(int initialCapacity,
float maxPerformanceHitFactor,
int minPerformanceHitBeforeFix)
Constructor which allows the limits controlling the when this list auto-fixes. |
Method Summary | |
---|---|
void |
add(int index,
T obj)
Inserts the specified element at the specified position in this list. |
protected boolean |
isFixRequired()
Determines if this list needs to be fixed or not. |
T |
remove(int index)
Removes and returns the element at the given index in this list. |
Methods inherited from class com.scottlogic.util.PatchWorkArray |
---|
add, clear, fix, get, getPerformanceHit, iterator, size |
Methods inherited from class java.util.AbstractList |
---|
addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeRange, set, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Field Detail |
---|
public static final float DEFAULT_MAX_PERFORMANCE_HIT_FACTOR
public static final int DEFAULT_MIN_PERFORMANCE_HIT_BEFORE_FIX
protected final float maxPerformanceHitFactor
protected final int minPerformanceHitBeforeFix
Constructor Detail |
---|
public AutoFixingPatchWorkArray()
public AutoFixingPatchWorkArray(int initialCapacity)
initialCapacity
- the initial capacity of the backing list.public AutoFixingPatchWorkArray(int initialCapacity, float maxPerformanceHitFactor, int minPerformanceHitBeforeFix)
fix()
when the performance hit is greater than both
minPerformanceHitBeforeFix
and maxPerformanceHitFactor
* size()
.
initialCapacity
- the initial size of the backing list.maxPerformanceHitFactor
- the fraction of size of the list that the performance hit
must exceed in order for this list to fix itself. This value must be between 0 and 1 inclusive.minPerformanceHitBeforeFix
- the smallest value for the performance hit at which this
list will fix itself.
java.lang.IllegalArgumentException
- in the case that the maxPerformanceHitFactor
is smaller than
0 or larger than 1.Method Detail |
---|
public T remove(int index)
This method can potentially increase or decrease the number of alterations, and hence the
performance hit. If after removing the element at the given index the performance hit breaches the
auto-fixing limit, fix
is called.
remove
in interface java.util.List<T>
remove
in class PatchWorkArray<T>
index
- the index of the element to remove.
java.lang.IllegalArgumentException
- in the case that the index is not a valid index.public void add(int index, T obj)
This method can potentially increase or decrease the number of alterations, and hence the
performance hit. If after inserting the given element the performance hit breaches
the auto-fixing limit, fix
is called.
add
in interface java.util.List<T>
add
in class PatchWorkArray<T>
index
- at which the element should be added.obj
- the object to by inserted.
java.lang.IllegalArgumentException
- in the case that the given element is null.
java.lang.IndexOutOfBoundsException
- in the case that (0 <= index <= size()) does not hold.protected boolean isFixRequired()
This implementation returns true when the performance hit is at least
minPerformanceHitBeforeFix
and is more than maxPerformanceHitFactor
of the total size of the list.
true
if this list needs to be fixed and false
otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |