|
AlgART Home | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.algart.arrays.AbstractArray
net.algart.arrays.AbstractBitArray
net.algart.arrays.AbstractUpdatableBitArray
public abstract class AbstractUpdatableBitArray extends AbstractBitArray implements UpdatableBitArray
Implementation of almost all basic functions of UpdatableBitArray interface.
The only BitArray.getBit(long) and UpdatableBitArray.setBit(long, boolean) methods
are not defined in this class;
all other methods are implemented via calls of these 2 methods.
AlgART Laboratory 2007-2013
| Modifier and Type | Field and Description |
|---|
| Fields inherited from class net.algart.arrays.AbstractArray |
|---|
capacity, length, underlyingArrays |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractUpdatableBitArray(long initialCapacityAndLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
Equivalent to the constructor AbstractUpdatableBitArray(long, long, boolean, Array...),
where both initialCapacity and initialLength arguments are equal to
initialCapacityAndLength. |
protected |
AbstractUpdatableBitArray(long initialCapacity,
long initialLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
Creates an updatable array with the given initial capacity and length. |
| Modifier and Type | Method and Description |
|---|---|
UpdatableArray |
asCopyOnNextWrite()
This implementation returns updatableClone(Arrays.SMM). |
BitArray |
asImmutable()
This implementation returns an instance of the subclass of AbstractBitArray,
where the following method are overridden and call the same methods of this instance:
AbstractBitArray.getBit(long), AbstractBitArray.getData(long, Object, int, int),
AbstractBitArray.getData(long, Object),
AbstractBitArray.loadResources(ArrayContext, long, long),
AbstractBitArray.flushResources(ArrayContext, long, long, boolean) and
AbstractBitArray.freeResources(ArrayContext, long, long, boolean). |
UpdatableBitArray |
asUnresizable()
This implementation returns this object. |
void |
clearBit(long index)
Clears the bit #index to 0 (false). |
UpdatableArray |
copy(Array src)
This implementation calls defaultCopy(thisInstance, src). |
void |
copy(long destIndex,
long srcIndex)
This implementation calls setBit(destIndex, getBit(srcIndex)). |
void |
copy(long destIndex,
long srcIndex,
long count)
This implementation is based on a loop of calls of copy(long, long) method. |
UpdatableBitArray |
fill(boolean value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableBitArray |
fill(double value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableBitArray |
fill(long value)
This implementation just calls fill(0, thisArray.length(), value). |
UpdatableBitArray |
fill(long position,
long count,
boolean value)
This implementation does the following: subArr(position, count).copy(Arrays.nBitCopies(count, value)). |
UpdatableBitArray |
fill(long position,
long count,
double value)
This implementation just calls fill(position, count, (boolean)value). |
UpdatableBitArray |
fill(long position,
long count,
long value)
This implementation just calls fill(position, count, (boolean)value). |
boolean |
isImmutable()
This implementation returns false. |
void |
setBit(long index)
Sets the bit #index to 1 (true). |
abstract void |
setBit(long index,
boolean value)
Sets the element #index to specified value. |
UpdatableBitArray |
setBits(long arrayPos,
long[] srcArray,
long srcArrayOffset,
long count)
This implementation is based on a loop of calls of setBit(long, boolean) method. |
UpdatableArray |
setData(long arrayPos,
java.lang.Object srcArray)
This implementation calls setData(long, Object, int, int)
with corresponding arguments. |
UpdatableArray |
setData(long arrayPos,
java.lang.Object srcArray,
int srcArrayOffset,
int count)
This implementation is based on a loop of calls of setBit(long, boolean) method. |
void |
setDouble(long index,
double value)
Sets the element #index by convertion from double, as (xxx)value for numeric element type xxx (byte, short, int, long, float, double or char), or as value!=0.0 for boolean element type. |
void |
setElement(long index,
java.lang.Object value)
This implementation calls setBit(index, (Boolean)value).booleanValue()). |
void |
setInt(long index,
int value)
Equivalent to setLong(index, (long)value),
but may work little faster. |
void |
setLong(long index,
long value)
Sets the element #index by convertion from long, as (xxx)value for numeric element type xxx (byte, short, int, long, float, double or char), or as value!=0 for boolean element type. |
void |
setNonNew()
This implementation calls setNewStatus(false). |
UpdatableArray |
shallowClone()
This implementation returns (UpdatableArray)super. shallowClone(). |
UpdatableBitArray |
subArr(long position,
long count)
This implementation returns subArray(position, position + count). |
UpdatableBitArray |
subArray(long fromIndex,
long toIndex)
This implementation returns new instance of AbstractUpdatableBitArray with the same memory model
and underlying arrays, that were passed to the constructor of this instance,
and with overridden methods AbstractBitArray.getBit(long), setBit(long, boolean),
AbstractBitArray.getData(long, Object, int, int) and
setData(long, Object, int, int)
calling the same methods of this instance with corresponding corrections of the arguments. |
void |
swap(long firstIndex,
long secondIndex)
This implementation swaps two elements by AbstractBitArray.getBit(long)
and setBit(long, boolean) methods. |
void |
swap(long firstIndex,
long secondIndex,
long count)
This implementation is based on a loop of calls of swap(long, long) method. |
UpdatableArray |
swap(UpdatableArray another)
This implementation calls defaultSwap(thisInstance, another). |
java.lang.String |
toString()
Returns a brief string description of this object. |
| Methods inherited from class net.algart.arrays.AbstractBitArray |
|---|
asTrustedImmutable, bitsPerElement, buffer, buffer, buffer, buffer, checkUnallowedMutation, elementType, flushResources, flushResources, freeResources, freeResources, getBit, getBits, getData, getData, getDouble, getElement, getInt, getLong, indexOf, indexOf, indexOf, isCopyOnNextWrite, isUnresizable, lastIndexOf, lastIndexOf, lastIndexOf, loadResources, loadResources, maxPossibleValue, maxPossibleValue, minPossibleValue, minPossibleValue, mutableClone, mutableType, nextQuickPosition, type, updatableClone, updatableType |
| Methods inherited from class net.algart.arrays.AbstractArray |
|---|
byteOrder, capacity, checkCopyArguments, checkSubArrArguments, checkSubArrayArguments, checkSwapArguments, defaultAppend, defaultBuffer, defaultBufferCapacity, defaultCopy, defaultCopy, defaultSwap, equals, equals, flushResources, freeResources, hashCode, hashCode, isLazy, isNew, isNewReadOnlyView, isZeroFilled, length, newJavaArray, setNewReadOnlyViewStatus, setNewStatus, standardObjectClone |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.algart.arrays.BitArray |
|---|
asTrustedImmutable, buffer, buffer, buffer, buffer, getBit, getBits, indexOf, lastIndexOf, mutableClone, mutableType, nextQuickPosition, type, updatableClone, updatableType |
| Methods inherited from interface net.algart.arrays.PFixedArray |
|---|
getInt, getLong, indexOf, lastIndexOf, maxPossibleValue, minPossibleValue |
| Methods inherited from interface net.algart.arrays.PArray |
|---|
bitsPerElement, getDouble, indexOf, isZeroFilled, lastIndexOf, maxPossibleValue, minPossibleValue |
| Methods inherited from interface net.algart.arrays.Array |
|---|
byteOrder, capacity, checkUnallowedMutation, elementType, equals, flushResources, flushResources, freeResources, freeResources, getData, getData, getElement, hashCode, isCopyOnNextWrite, isLazy, isNew, isNewReadOnlyView, isUnresizable, length, loadResources, newJavaArray |
| Constructor Detail |
|---|
protected AbstractUpdatableBitArray(long initialCapacity,
long initialLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
This array is not new by default.
This is correct usually, because this class is often used
for creating a view of another data. However, if the instance
if this class does not depend on any other data sources,
you may call setNewStatus(true) in
the constructor of your subclass.
initialCapacity - initial capacity of the array.initialLength - initial length of the array.underlyingArraysAreParallel - see the same argument of
AbstractBitArray.AbstractBitArray(long, long, boolean, Array...).underlyingArrays - see the same argument of
AbstractArray.AbstractArray(long, long, Array...).java.lang.NullPointerException - if underlyingArrays argument or some of underlyingArrays[k]
elements is null.java.lang.IllegalArgumentException - if the initialCapacity or initialLength arguments
are illegal (negative, or capacity < length).SizeMismatchException - if underlyingArraysAreParallel=true,
underlyingArrays.length>1 and some of passed arrays
have different lengths.
protected AbstractUpdatableBitArray(long initialCapacityAndLength,
boolean underlyingArraysAreParallel,
Array... underlyingArrays)
AbstractUpdatableBitArray(long, long, boolean, Array...),
where both initialCapacity and initialLength arguments are equal to
initialCapacityAndLength.
initialCapacityAndLength - initial capacity and length of the array.underlyingArraysAreParallel - see AbstractUpdatableBitArray(long, long, boolean, Array...).underlyingArrays - see AbstractUpdatableBitArray(long, long, boolean, Array...)java.lang.IllegalArgumentException - if the passed argument are illegal (negative).| Method Detail |
|---|
public UpdatableBitArray subArray(long fromIndex,
long toIndex)
AbstractUpdatableBitArray with the same memory model
and underlying arrays, that were passed to the constructor of this instance,
and with overridden methods AbstractBitArray.getBit(long), setBit(long, boolean),
AbstractBitArray.getData(long, Object, int, int) and
setData(long, Object, int, int)
calling the same methods of this instance with corresponding corrections of the arguments.
The returned instance also have overridden methods AbstractBitArray.loadResources(ArrayContext, long, long),
AbstractBitArray.flushResources(ArrayContext, long, long, boolean) and
AbstractBitArray.freeResources(ArrayContext, long, long, boolean),
that also call the same methods of this instance with corresponding correction of their fromIndex
argument.
The returned instance also have overridden method AbstractArray.isLazy(),
that just calls the same methods of this instance with the same arguments.
subArray in interface ArraysubArray in interface UpdatableArraysubArray in interface UpdatableBitArraysubArray in interface UpdatablePArraysubArray in interface UpdatablePFixedArraysubArray in class AbstractBitArrayfromIndex - low endpoint (inclusive) of the subarray.toIndex - high endpoint (exclusive) of the subarray.java.lang.IndexOutOfBoundsException - for illegal fromIndex and toIndex
(fromIndex < 0 || toIndex > length() || fromIndex > toIndex).Array.subArr(long, long)
public UpdatableBitArray subArr(long position,
long count)
AbstractArraysubArray(position, position + count).
Please note that the exception message can be not fully correct for the very exotic case
position+count>Long.MAX_VALUE.
subArr in interface ArraysubArr in interface UpdatableArraysubArr in interface UpdatableBitArraysubArr in interface UpdatablePArraysubArr in interface UpdatablePFixedArraysubArr in class AbstractArrayposition - start position (inclusive) of the subarray.count - number of elements in the subarray.Array.subArray(long, long)
public void setDouble(long index,
double value)
UpdatablePArray
setDouble in interface UpdatablePArrayindex - index of element to replace.value - element to be stored at the specified position.PArray.getDouble(long)
public void setLong(long index,
long value)
UpdatablePArray
setLong in interface UpdatablePArrayindex - index of element to replace.value - element to be stored at the specified position.PFixedArray.getLong(long)
public void setInt(long index,
int value)
UpdatablePArraysetLong(index, (long)value),
but may work little faster.
setInt in interface UpdatablePArrayindex - index of element to replace.value - element to be stored at the specified position.PFixedArray.getInt(long)
public abstract void setBit(long index,
boolean value)
UpdatableBitArray
setBit in interface UpdatableBitArrayindex - index of element to replace.value - element to be stored at the specified position.public final UpdatableBitArray fill(double value)
fill(0, thisArray.length(), value).
fill in interface UpdatablePArrayvalue - the value to be stored in all elements of the array.UpdatablePArray.fill(long, long, double),
Arrays.zeroFill(UpdatableArray)
public UpdatableBitArray fill(long position,
long count,
double value)
fill(position, count, (boolean)value).
fill in interface UpdatablePArrayposition - start index (inclusive) to be filled.count - number of filled elements.value - the value to be stored in the elements of the array.java.lang.IndexOutOfBoundsException - for illegal position and count
(position < 0 || count < 0 || position + count > length()).UpdatablePArray.fill(double),
Arrays.zeroFill(UpdatableArray)public final UpdatableBitArray fill(long value)
fill(0, thisArray.length(), value).
fill in interface UpdatablePArrayvalue - the value to be stored in all elements of the array.UpdatablePArray.fill(long, long, long),
Arrays.zeroFill(UpdatableArray)
public UpdatableBitArray fill(long position,
long count,
long value)
fill(position, count, (boolean)value).
fill in interface UpdatablePArrayposition - start index (inclusive) to be filled.count - number of filled elements.value - the value to be stored in the elements of the array.java.lang.IndexOutOfBoundsException - for illegal position and count
(position < 0 || count < 0 || position + count > length()).UpdatablePArray.fill(long),
Arrays.zeroFill(UpdatableArray)public final UpdatableBitArray fill(boolean value)
fill(0, thisArray.length(), value).
fill in interface UpdatableBitArrayvalue - the value to be stored in all elements of the array.UpdatableBitArray.fill(long, long, boolean),
Arrays.zeroFill(UpdatableArray)
public UpdatableBitArray fill(long position,
long count,
boolean value)
subArr(position, count).copy(Arrays.nBitCopies(count, value)).
Please override this method if it's possible to perform the same task more efficiently.
fill in interface UpdatableBitArrayposition - start index (inclusive) to be filled.count - number of filled elements.value - the value to be stored in the elements of the array.java.lang.IndexOutOfBoundsException - for illegal position and count
(position < 0 || count < 0 || position + count > length()).UpdatableBitArray.fill(boolean),
Arrays.zeroFill(UpdatableArray)public boolean isImmutable()
isImmutable in interface ArrayisImmutable in class AbstractBitArrayArray.asImmutable()public BitArray asImmutable()
AbstractBitArray,
where the following method are overridden and call the same methods of this instance:
AbstractBitArray.getBit(long), AbstractBitArray.getData(long, Object, int, int),
AbstractBitArray.getData(long, Object),
AbstractBitArray.loadResources(ArrayContext, long, long),
AbstractBitArray.flushResources(ArrayContext, long, long, boolean) and
AbstractBitArray.freeResources(ArrayContext, long, long, boolean).
The returned instance also have overridden method AbstractArray.isLazy(),
that just calls the same methods of this instance with the same arguments.
asImmutable in interface ArrayasImmutable in interface BitArrayasImmutable in interface PArrayasImmutable in interface PFixedArrayasImmutable in class AbstractBitArrayArray.isImmutable(),
Array.asTrustedImmutable(),
Array.mutableClone(MemoryModel),
Array.updatableClone(MemoryModel),
UpdatableArray.asUnresizable()public UpdatableArray shallowClone()
shallowClone().
shallowClone in interface ArrayshallowClone in interface UpdatableArrayshallowClone in class AbstractArrayArray.length(),
Array.capacity(),
DirectAccessible.javaArrayOffset(),
Array.isCopyOnNextWrite()
public void setElement(long index,
java.lang.Object value)
setElement in interface UpdatableArrayindex - index of element to replace.value - element to be stored at the specified position.java.lang.IndexOutOfBoundsException - if index is out of range 0..length()-1.java.lang.NullPointerException - if value == null and it is an array of primitive elementsjava.lang.ClassCastException - if it is an array of primitive elements and value
is not a corresponding wrapped class
(Boolean, Integer, etc.)java.lang.ArrayStoreException - if it is an array of non-primitive elements and value
is not an instance of AbstractBitArray.elementType() class
public UpdatableArray setData(long arrayPos,
java.lang.Object srcArray,
int srcArrayOffset,
int count)
setBit(long, boolean) method.
Please override this method if it's possible to perform the same task more efficiently
than such a loop.
setData in interface UpdatableArrayarrayPos - starting position in this AlgART array.srcArray - the source Java array.srcArrayOffset - starting position in the source Java array.count - the number of elements to be copied.java.lang.NullPointerException - if srcArray argument is null.java.lang.IllegalArgumentException - if srcArray argument is not an array.java.lang.IndexOutOfBoundsException - if copying would cause access of data outside this array or source Java array.java.lang.ArrayStoreException - if destArray element type mismatches with this array
elementType().java.lang.ClassCastException - if destArray element type mismatches with this array
elementType()
(both this and ArrayStoreException are possible,
depending on implementation).DirectAccessible,
Array.getData(long, Object, int, int)
public UpdatableArray setData(long arrayPos,
java.lang.Object srcArray)
setData(long, Object, int, int)
with corresponding arguments.
setData in interface UpdatableArrayarrayPos - starting position in this AlgART array.srcArray - the source Java array.java.lang.NullPointerException - if srcArray argument is null.java.lang.IllegalArgumentException - if srcArray argument is not an array.java.lang.IndexOutOfBoundsException - if copying would cause access of data outside this array or source Java array.java.lang.ArrayStoreException - if destArray element type mismatches with this array
AbstractBitArray.elementType().java.lang.ClassCastException - if destArray element type mismatches with this array
AbstractBitArray.elementType()
(both this and ArrayStoreException are possible,
depending on implementation).DirectAccessible,
UpdatableArray.setData(long, Object, int, int),
Array.getData(long, Object),
UpdatableBitArray.setBits(long, long[], long, long)
public void copy(long destIndex,
long srcIndex)
copy in interface UpdatableArraydestIndex - index of element to replace.srcIndex - index of element to be copied.java.lang.IndexOutOfBoundsException - if one of indexes is out of range 0..length()-1.
public void copy(long destIndex,
long srcIndex,
long count)
copy(long, long) method.
copy in interface UpdatableArraydestIndex - starting index of element to replace.srcIndex - starting index of element to be copied.count - the number of elements to be copied.java.lang.IndexOutOfBoundsException - if one of indexes is out of range 0..length()-1.
public void swap(long firstIndex,
long secondIndex)
AbstractBitArray.getBit(long)
and setBit(long, boolean) methods.
swap in interface ArrayExchangerswap in interface UpdatableArrayfirstIndex - first index of element to exchange.secondIndex - second index of element to exchange.java.lang.IndexOutOfBoundsException - if one of indexes is out of range 0..length()-1.
public void swap(long firstIndex,
long secondIndex,
long count)
swap(long, long) method.
swap in interface UpdatableArrayfirstIndex - starting first index of element to exchange.secondIndex - starting second index of element to exchange.count - the number of elements to be exchanged.java.lang.IndexOutOfBoundsException - if one of indexes is out of range 0..length()-1.public UpdatableArray copy(Array src)
defaultCopy(thisInstance, src).
copy in interface UpdatableArraysrc - the source array.java.lang.NullPointerException - if src argument is null.java.lang.IllegalArgumentException - if the source and this element types do not match.Arrays.copy(ArrayContext, UpdatableArray, Array)public UpdatableArray swap(UpdatableArray another)
defaultSwap(thisInstance, another).
swap in interface UpdatableArrayanother - another array.java.lang.NullPointerException - if another argument is null.java.lang.IllegalArgumentException - if another and this element types do not match.public void setNonNew()
setNewStatus(false).
setNonNew in interface UpdatableArraypublic UpdatableArray asCopyOnNextWrite()
updatableClone(Arrays.SMM).
asCopyOnNextWrite in interface ArrayasCopyOnNextWrite in interface UpdatableArrayasCopyOnNextWrite in class AbstractBitArrayArray.isCopyOnNextWrite(),
MemoryModel.newLazyCopy(Array),
MemoryModel.newUnresizableLazyCopy(Array)public UpdatableBitArray asUnresizable()
asUnresizable in interface UpdatableArrayasUnresizable in interface UpdatableBitArrayasUnresizable in interface UpdatablePArrayasUnresizable in interface UpdatablePFixedArrayArray.isUnresizable()public java.lang.String toString()
ArrayThe result of this method may depend on implementation and usually contains a short description of the array length, capacity, element type.
Note: for character arrays, unlike CharSequence.toString(),
this method works as for all other array types.
If you need to convert a character array to a string,
containing all characters of the array, you may use
Arrays.toString(CharArray) method.
toString in interface ArraytoString in class AbstractBitArraypublic void setBit(long index)
UpdatableBitArray
setBit in interface UpdatableBitArrayindex - index of element to replace.public void clearBit(long index)
clearBit in interface UpdatableBitArrayindex - index of element to replace.java.lang.IndexOutOfBoundsException - if index out of range 0..length()-1.
public UpdatableBitArray setBits(long arrayPos,
long[] srcArray,
long srcArrayOffset,
long count)
setBit(long, boolean) method.
Please override this method if it's possible to perform the same task more efficiently
than such a loop.
setBits in interface UpdatableBitArrayarrayPos - starting position in this AlgART array.srcArray - the source packed bit array.srcArrayOffset - starting position in the source packed bit array.count - the number of bits to be copied.java.lang.NullPointerException - if srcArray argument is null.java.lang.IndexOutOfBoundsException - if copying would cause access of data outside this array or source Java array.Array.getData(long, Object, int, int),
BitArray.getBits(long, long[], long, long),
PackedBitArrays
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||