org.abora.white.collection.arrays
Class PtrArray

java.lang.Object
  |
  +--org.abora.white.xpp.basic.Heaper
        |
        +--org.abora.white.collection.arrays.PrimArray
              |
              +--org.abora.white.collection.arrays.PtrArray
Direct Known Subclasses:
SharedPtrArray, WeakPtrArray

public class PtrArray
extends PrimArray


Field Summary
protected  Heaper[] storage
           
 
Constructor Summary
protected PtrArray(Heaper[] source)
           
protected PtrArray(int count)
           
protected PtrArray(int size, PrimArray from, int sourceOffset, int count, int destOffset)
           
 
Method Summary
 boolean contentsEQ(PtrArray other)
           
 boolean contentsEqual(PrimArray other)
          Whether the two ranges contain semantically the same values.
 int contentsHash()
          A hash of the entire contents of the array.
 void copyToBuffer(Heaper[] buffer, int count, int start)
           
 int count()
          Return the number of elements the array can hold.
 boolean elementsEQ(int here, PrimArray other)
           
 boolean elementsEQ(int here, PrimArray other, int there)
           
 boolean elementsEQ(int here, PrimArray other, int there, int count)
           
 boolean elementsEqual(int here, PrimArray other, int there, int count)
          Whether the two ranges contain the same values, using the criteria defined in contentsEqual
 int elementsHash(int count, int start)
          A hash of the range of values out of the array.
static PtrArray empty()
          create a zero size PtrArray
 Heaper fetch(int index)
          Retrieve a single element from the array.
 Heaper fetchValue(int index)
          Fetch a value; may be a Heaper, null, or a PrimValue as appropriate to PrimArray subclass.
 Heaper get(int index)
          Retrieve a single element from the array.
 int indexOf(Heaper value, int start, int nth)
          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 indexOfEQ(Heaper value)
           
 int indexOfEQ(Heaper value, int start)
           
 int indexOfEQ(Heaper value, int start, int nth)
           
 int indexOfEQOrNull(Heaper value)
           
 int indexOfEQOrNull(Heaper value, int start)
           
 int indexOfEQOrNull(Heaper value, int start, int nth)
           
 int indexPast(Heaper value, int start, int nth)
          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 indexPastEQ(Heaper value)
           
 int indexPastEQ(Heaper value, int start)
           
 int indexPastEQ(Heaper value, int start, int nth)
           
static PtrArray make(Heaper[] buffer)
          create a PtrArray filled with data from 'buffer'
static PtrArray make(int count)
          create a PtrArray filled with NULLs
static PtrArray make(int size, PrimArray from)
           
static PtrArray make(int size, PrimArray from, int sourceOffset)
           
static PtrArray make(int size, PrimArray from, int sourceOffset, int count)
           
static PtrArray make(int size, PrimArray from, int sourceOffset, int count, int destOffset)
          create a PtrArray filled with the indicated data in 'from'
protected  PrimArray makeNew(int size, PrimArray source, int sourceOffset, int count, int destOffset)
          Return a new array of the same type as this initialized with the elements of source specified by the index range, prepended by destOffset and postpended by null or 0 elements.
protected  void printElementOn(int index, java.io.PrintWriter oo)
          Print a representation of the element at the given index.
 PrimSpec spec()
          A description of the kinds of things which can be stored in this array
 void store(int index, Heaper pointer)
           
 void storeAll(Heaper value, int count, int start)
          Fill a consequitive range of elements with the supplied value.
 void storeValue(int index, Heaper value)
          Store a value; may be a Heaper, null, or a PrimValue as appropriate to PrimArray subclass.
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.PrimArray
copy, copy, copy, copy, copy, copyElements, copyGrow, elementsEqual, elementsEqual, elementsHash, elementsHash, getValue, indexOf, indexOf, indexOfElements, indexOfElements, indexOfElements, indexOfElements, indexOfElements, indexPast, indexPast, isEqual, printOn, storeAll, storeAll, storeMany, storeMany, storeMany, 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
 

Field Detail

storage

protected final Heaper[] storage
Constructor Detail

PtrArray

protected PtrArray(int count)

PtrArray

protected PtrArray(int size,
                   PrimArray from,
                   int sourceOffset,
                   int count,
                   int destOffset)

PtrArray

protected PtrArray(Heaper[] source)
Method Detail

make

public static PtrArray make(int count)
create a PtrArray filled with NULLs


make

public static PtrArray make(int size,
                            PrimArray from,
                            int sourceOffset,
                            int count,
                            int destOffset)
create a PtrArray filled with the indicated data in 'from'


make

public static PtrArray make(int size,
                            PrimArray from,
                            int sourceOffset,
                            int count)

make

public static PtrArray make(int size,
                            PrimArray from,
                            int sourceOffset)

make

public static PtrArray make(int size,
                            PrimArray from)

make

public static PtrArray make(Heaper[] buffer)
create a PtrArray filled with data from 'buffer'


empty

public static PtrArray empty()
create a zero size PtrArray


makeNew

protected PrimArray makeNew(int size,
                            PrimArray source,
                            int sourceOffset,
                            int count,
                            int destOffset)
Description copied from class: PrimArray
Return a new array of the same type as this initialized with the elements of source specified by the index range, prepended by destOffset and postpended by null or 0 elements.

Specified by:
makeNew in class PrimArray
Parameters:
size - size of new array.
source - source of elements to be initialized with in the new array.
sourceOffset - first index of the source array to be included in the range.
count - number of elements of source to include in the new array
destOffset - first index of new array to be initialized with source elements.
Returns:
the new array.

store

public void store(int index,
                  Heaper pointer)

get

public Heaper get(int index)
Retrieve a single element from the array. Does array bounds checking. BLAST if NULL


fetch

public Heaper fetch(int index)
Retrieve a single element from the array. Does array bounds checking. Non-pointer arrays box up the contents in a PrimValue object.


storeValue

public void storeValue(int index,
                       Heaper value)
Description copied from class: PrimArray
Store a value; may be a Heaper, null, or a PrimValue as appropriate to PrimArray subclass. An exception will be throw if the value is not compatible with the elements this can hold.

It is expected that most PrimArray clients will want to use less abstract access methods

Specified by:
storeValue in class PrimArray
Parameters:
index - index in array the element will be stored at.
value - heaper to store in this.

fetchValue

public Heaper fetchValue(int index)
Description copied from class: PrimArray
Fetch a value; may be a Heaper, null, or a PrimValue as appropriate to PrimArray subclass.

It is expected that most PrimArray clients will want to use less abstract access methods.

Specified by:
fetchValue in class PrimArray
Parameters:
index - index in array whose element will be returned
Returns:
the heaper at the specified index.

spec

public PrimSpec spec()
Description copied from class: PrimArray
A description of the kinds of things which can be stored in this array

Specified by:
spec in class PrimArray

count

public int count()
Description copied from class: PrimArray
Return the number of elements the array can hold.

Specified by:
count in class PrimArray

contentsEQ

public boolean contentsEQ(PtrArray other)

contentsEqual

public boolean contentsEqual(PrimArray other)
Description copied from class: PrimArray
Whether the two ranges contain semantically the same values. Two non-NULL pointers match iff the Heapers they point to are isEqual. Two integers match iff they have the same value, even though they may be represented as different sizes. Two floats likewise.

Specified by:
contentsEqual in class PrimArray

contentsHash

public int contentsHash()
Description copied from class: PrimArray
A hash of the entire contents of the array. If two arrays are contentsEqual, they will have the same contentsHash.

Overrides:
contentsHash in class PrimArray

elementsEQ

public boolean elementsEQ(int here,
                          PrimArray other,
                          int there,
                          int count)

elementsEQ

public boolean elementsEQ(int here,
                          PrimArray other,
                          int there)

elementsEQ

public boolean elementsEQ(int here,
                          PrimArray other)

elementsEqual

public boolean elementsEqual(int here,
                             PrimArray other,
                             int there,
                             int count)
Description copied from class: PrimArray
Whether the two ranges contain the same values, using the criteria defined in contentsEqual

Specified by:
elementsEqual in class PrimArray

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

indexOf

public int indexOf(Heaper value,
                   int start,
                   int nth)
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

indexPast

public int indexPast(Heaper value,
                     int start,
                     int nth)
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

indexOfEQ

public int indexOfEQ(Heaper value,
                     int start,
                     int nth)

indexOfEQ

public int indexOfEQ(Heaper value,
                     int start)

indexOfEQ

public int indexOfEQ(Heaper value)

indexOfEQOrNull

public int indexOfEQOrNull(Heaper value,
                           int start,
                           int nth)

indexOfEQOrNull

public int indexOfEQOrNull(Heaper value,
                           int start)

indexOfEQOrNull

public int indexOfEQOrNull(Heaper value)

indexPastEQ

public int indexPastEQ(Heaper value,
                       int start,
                       int nth)

indexPastEQ

public int indexPastEQ(Heaper value,
                       int start)

indexPastEQ

public int indexPastEQ(Heaper 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.

copyToBuffer

public void copyToBuffer(Heaper[] buffer,
                         int count,
                         int start)

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

printElementOn

protected void printElementOn(int index,
                              java.io.PrintWriter oo)
Description copied from class: PrimArray
Print a representation of the element at the given index.

Overrides:
printElementOn in class PrimArray
Parameters:
index - index of element to be printed.
oo - print stream to write element representation to.


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