org.abora.white.collection.arrays
Class PrimIntegerArray

java.lang.Object
  |
  +--org.abora.white.xpp.basic.Heaper
        |
        +--org.abora.white.collection.arrays.PrimArray
              |
              +--org.abora.white.collection.arrays.PrimArithmeticArray
                    |
                    +--org.abora.white.collection.arrays.PrimIntegerArray
Direct Known Subclasses:
IntegerVarArray, PrimIntArray

public abstract class PrimIntegerArray
extends PrimArithmeticArray

A common superclass for primitive arrays of integer types; this is the point to add bulk operations for Boolean operations, etc if we ever want them


Constructor Summary
protected PrimIntegerArray()
           
 
Method Summary
protected  void addData(int start, PrimArithmeticArray other, int otherStart, int count)
          Arithmetic addition of the respective elements of other to this over the specified index range.
protected  int compareData(int here, PrimArithmeticArray other, int there, int count)
          Over given range, returns - if this < other; 0 if this == other; + if this > other.
 int elementsHash(int count, int start)
          A hash of the range of values out of the array.
 PrimIntegerArray hold(int index, IntegerValue value)
           
 PrimIntegerArray hold(int index, IntegerValue value, boolean canModify)
          Store an integer value at the specified index.
 int indexOf(Heaper value, int start, int n)
          Return the index of the nth occurrence of the given value at or after (before if nth is negative) the given index, or -1 if there is none.
 int indexOfInteger(IntegerValue value)
           
 int indexOfInteger(IntegerValue value, int start)
           
 int indexOfInteger(IntegerValue value, int start, int nth)
           
 int indexPast(Heaper value, int start, int n)
          Return the index of the nth occurrence of anything but the given value at or after (before if nth is negative) the given index, or -1 if there is none.
 int indexPastInteger(IntegerValue value)
           
 int indexPastInteger(IntegerValue value, int start)
           
 int indexPastInteger(IntegerValue value, int start, int nth)
           
abstract  IntegerValue integerAt(int index)
          Fetch an integer value at the specified index.
 void storeAll(Heaper value, int count, int start)
          Fill a consequitive range of elements with the supplied value.
abstract  void storeInteger(int index, IntegerValue value)
          Store an integer value at the specified index.
protected  void subtractData(int start, PrimArithmeticArray other, int otherStart, int count)
          Subtract the respective elements of other from this over the given index range.
protected  Heaper zeroElement()
          Return a suitable immutable zero element for this type of array; either 0 or null.
 
Methods inherited from class org.abora.white.collection.arrays.PrimArithmeticArray
addElements, addElements, addElements, compare, compare, compare, compare, contentsEqual, elementsEqual, signOfNonZeroAfter, subtractElements, subtractElements, subtractElements
 
Methods inherited from class org.abora.white.collection.arrays.PrimArray
contentsHash, copy, copy, copy, copy, copy, copyElements, copyGrow, count, elementsEqual, elementsEqual, elementsHash, elementsHash, fetchValue, getValue, indexOf, indexOf, indexOfElements, indexOfElements, indexOfElements, indexOfElements, indexOfElements, indexPast, indexPast, isEqual, makeNew, printElementOn, printOn, spec, storeAll, storeAll, storeMany, storeMany, storeMany, storeValue, zeroElements, zeroElements, zeroElements
 
Methods inherited from class org.abora.white.xpp.basic.Heaper
actualHashForEqual, destroy, destruct, equals, hashForEqual, printContentsOn, sendSelfTo, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrimIntegerArray

protected PrimIntegerArray()
Method Detail

storeInteger

public abstract void storeInteger(int index,
                                  IntegerValue value)
Store an integer value at the specified index.

Parameters:
index - index in array the element will be stored at.
value - integer to store in this.
Throws:
java.lang.IllegalArgumentException - if value can not be held by array

integerAt

public abstract IntegerValue integerAt(int index)
Fetch an integer value at the specified index.

Parameters:
index - index in array whose element will be returned
Returns:
the integer at the specified index.

hold

public PrimIntegerArray hold(int index,
                             IntegerValue value,
                             boolean canModify)
Store an integer value at the specified index. If index is past the end of the current array, then return a copy of the array that has been extended to include the specified index. Fill new intervening elements with zero. If value can not be held by the current array, then return a copy of the array of a kind that can hold the value. If canModify and the value can be stored in the current array then modify this array, otherwise in all other cases return a copy of the this array.

Parameters:
index - index in array the element will be stored at.
value - integer to store in array
canModify - true if the the value can be stored in this array, if possible, otherwise always return a copy of this array.
Returns:
array holding value, may be this array or a copy.

hold

public PrimIntegerArray hold(int index,
                             IntegerValue value)

indexOf

public int indexOf(Heaper value,
                   int start,
                   int n)
Description copied from class: PrimArray
Return the index of the nth occurrence of the given value at or after (before if nth is negative) the given index, or -1 if there is none.

Specified by:
indexOf in class PrimArray
Parameters:
value - element that is to be matched
start - index to start the search. If positive start from that index, if negative start from relatie to end of array
Returns:
index of element matched or -1 if there is none

indexOfInteger

public int indexOfInteger(IntegerValue value,
                          int start,
                          int nth)

indexOfInteger

public int indexOfInteger(IntegerValue value,
                          int start)

indexOfInteger

public int indexOfInteger(IntegerValue value)

indexPast

public int indexPast(Heaper value,
                     int start,
                     int n)
Description copied from class: PrimArray
Return the index of the nth occurrence of anything but the given value at or after (before if nth is negative) the given index, or -1 if there is none.

Specified by:
indexPast in class PrimArray
Parameters:
value - anything except this element that is to be matched
start - index to start the search. If positive start from that index, if negative start from relatie to end of array
Returns:
index of element matched or -1 if there is none

indexPastInteger

public int indexPastInteger(IntegerValue value,
                            int start,
                            int nth)

indexPastInteger

public int indexPastInteger(IntegerValue value,
                            int start)

indexPastInteger

public int indexPastInteger(IntegerValue value)

storeAll

public void storeAll(Heaper value,
                     int count,
                     int start)
Description copied from class: PrimArray
Fill a consequitive range of elements with the supplied value.

Specified by:
storeAll in class PrimArray
Parameters:
value - to store within range or 0.0 if null.
count - number of consequentive elements in range or all elements from start if -1.
start - index of first element in range.

compareData

protected int compareData(int here,
                          PrimArithmeticArray other,
                          int there,
                          int count)
Description copied from class: PrimArithmeticArray
Over given range, returns - if this < other; 0 if this == other; + if this > other.

Overrides:
compareData in class PrimArithmeticArray

elementsHash

public int elementsHash(int count,
                        int start)
Description copied from class: PrimArray
A hash of the range of values out of the array. If two ranges are elementsEqual, they will have the same hash. For data values, additional zeros on the end make no difference to the hash.

Specified by:
elementsHash in class PrimArray

zeroElement

protected Heaper zeroElement()
Description copied from class: PrimArray
Return a suitable immutable zero element for this type of array; either 0 or null.

Specified by:
zeroElement in class PrimArray
Returns:
zero element for this type of array

addData

protected void addData(int start,
                       PrimArithmeticArray other,
                       int otherStart,
                       int count)
Description copied from class: PrimArithmeticArray
Arithmetic addition of the respective elements of other to this over the specified index range.

Note that arithmetic overflows aren't faulted.

Subclasses should override.

Overrides:
addData in class PrimArithmeticArray

subtractData

protected void subtractData(int start,
                            PrimArithmeticArray other,
                            int otherStart,
                            int count)
Description copied from class: PrimArithmeticArray
Subtract the respective elements of other from this over the given index range.

Note that arithmetic overflows aren't faulted.

Subclasses should override.

Overrides:
subtractData in class PrimArithmeticArray


Copyright © 2003 David G Jones. All Rights Reserved.
Original Udanax-Gold - Copyright © 1979-1999 Udanax.com. All rights reserved.