org.erights.e.elib.tables
Class FlexListImpl

java.lang.Object
  |
  +--org.erights.e.elib.tables.EList
        |
        +--org.erights.e.elib.tables.FlexList
              |
              +--org.erights.e.elib.tables.FlexListImpl
All Implemented Interfaces:
ArrayedList, EPrintable, Iteratable, Marker, PassByProxy, Persistent, Serializable

class FlexListImpl
extends FlexList
implements ArrayedList

FlexList extends EList with mutation operations.

Author:
Mark S. Miller

Field Summary
private  int mySize
          mySize <= myVals.length
private  Object myVals
          myVals is an array
(package private) static long serialVersionUID
           
 
Fields inherited from interface org.erights.e.elib.serial.PassByProxy
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.Persistent
HONORARY, HONORED_NAMES
 
Constructor Summary
(package private) FlexListImpl(int capacity)
           
(package private) FlexListImpl(Object vals, int size)
          The caller is *trusted* not to modify vals after handing it in.
 
Method Summary
 Object get(int index)
          Enabled: What value does 'index' map to?
 Object getSecretArray()
          The caller is *trusted* not to modify the returned array.
 void put(int index, Object value)
          Places value at this index.
private static void qsort(Object[] a, int start, int bound, CompFunc func)
           
 void replace(int start, int bound, EList other, int lstart, int lbound)
          Replace from start..!bound in this list with lstart..!lbound in other.
 void setSize(int newSize)
          Make this list be exactly 'newSize', truncating or extending as necessary.
 int size()
          How many entries are in the table?
 ConstList snapshot()
          Enabled: Returns a ConstList whose state is a snapshot of the state of this list at the time of the snapshot() request.
(package private)  void sortInPlace(CompFunc func)
          Reorders the list in place into ascending order according to func
 Class valueType()
          All values in this table must be of this type
private  void zero(int start, int bound)
          Overwrites this run with the zero element for my valueType().
 
Methods inherited from class org.erights.e.elib.tables.FlexList
__optUncall, __printOn, append, ensureSize, fromType, fromType, insert, make, make, pop, push, readOnly, removeRun, removeRun, setRun, setRun
 
Methods inherited from class org.erights.e.elib.tables.EList
add, asKeys, asMap, asSet, contains, diverge, diverge, getArray, getArray, getArray, includes, indexOf1, indexOf1, iterate, last, lastIndexOf1, lastIndexOf1, lastStartOf, lastStartOf, multiply, printOn, run, run, sort, sort, startOf, startOf, toString, with, with
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID

myVals

private Object myVals
myVals is an array


mySize

private int mySize
mySize <= myVals.length

Constructor Detail

FlexListImpl

FlexListImpl(Object vals,
             int size)
The caller is *trusted* not to modify vals after handing it in.


FlexListImpl

FlexListImpl(int capacity)
Method Detail

getSecretArray

public Object getSecretArray()
The caller is *trusted* not to modify the returned array. Even though this is declared 'public', it is believed (and required) to be package scope, since all declarations are only in package scoped classes or interfaces.

Specified by:
getSecretArray in interface ArrayedList

snapshot

public ConstList snapshot()
Description copied from class: EList
Enabled: Returns a ConstList whose state is a snapshot of the state of this list at the time of the snapshot() request. A ConstList returns itself.

Specified by:
snapshot in class EList

get

public Object get(int index)
           throws IndexOutOfBoundsException
Description copied from class: EList
Enabled: What value does 'index' map to?

Specified by:
get in class EList
Returns:
nullOk; the value at index may be null.
Throws:
IndexOutOfBoundsException - if index isn't in 0..!size.

size

public int size()
How many entries are in the table?

Specified by:
size in class EList

valueType

public Class valueType()
All values in this table must be of this type

Specified by:
valueType in class EList

put

public void put(int index,
                Object value)
         throws IndexOutOfBoundsException
Places value at this index. If index is the current size of the list, the list is extended with this element. Otherwise, if the index is out of range, throws IndexOutOfBoundsException

Specified by:
put in class FlexList
Throws:
IndexOutOfBoundsException - if index isn't in 0..size

sortInPlace

void sortInPlace(CompFunc func)
Reorders the list in place into ascending order according to func

Specified by:
sortInPlace in class FlexList

qsort

private static void qsort(Object[] a,
                          int start,
                          int bound,
                          CompFunc func)

zero

private void zero(int start,
                  int bound)
Overwrites this run with the zero element for my valueType(). May be called on runs exceeding my size but within my capacity. That's why it's private.


setSize

public void setSize(int newSize)
Make this list be exactly 'newSize', truncating or extending as necessary. If this list is extended, what is it filled with? If it is of a scalar valueType(), it is filled with the zero element for that scalar. Otherwise, it is filled with nulls.

Specified by:
setSize in class FlexList

replace

public void replace(int start,
                    int bound,
                    EList other,
                    int lstart,
                    int lbound)
Replace from start..!bound in this list with lstart..!lbound in other.

Specified by:
replace in class FlexList


comments?