|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.erights.e.elib.tables.EList
Safe: A EList is a sequence of values.
'EList' is a query-only interface that's agnostic about whether the data can change and whether a EList can be cast to an object by which to change it. 'EList' is also agnostic about the basis for equality between tables. Subtypes do pin these issues down:
ConstList guarantees immutability, uses value-based equality, and can be transparently passed-by-copy over the network.
FlexList extends EList with mutation operations.
org.erights.e.elib.tables.ConstList
,
org.erights.e.elib.tables.FlexList
,
Serialized FormField Summary | |
private static long |
serialVersionUID
|
Fields inherited from interface org.erights.e.elib.serial.Persistent |
HONORARY, HONORED_NAMES |
Constructor Summary | |
(package private) |
EList()
Only subclasses within the package |
Method Summary | |
ConstList |
add(Object other)
Enabled: Concatenates (snapshots of) this list and other. |
ConstMap |
asKeys()
Enabled: Turns [a, b, ...] into [a => null, b => null, ...] |
ConstMap |
asMap()
Enabled: Turns [a, b, ...] into [0 => a, 1 => b, ...] |
ConstSet |
asSet()
Enabled: Returns a set whose elements are the values in this list |
boolean |
contains(Object candidate)
Enabled: Does the candidate appear as a value in this list? |
FlexList |
diverge()
Enabled: 'valueType' defaults to Object.class |
FlexList |
diverge(Class valueType)
Enabled: Returns a FlexList whose initial state is a snapshot of the state of this list at the time of the diverge() request. |
abstract Object |
get(int index)
Enabled: What value does 'index' map to? |
Object |
getArray()
Enabled: type defaults to valueType() and start,bound defaults to everything (0,size()). |
Object |
getArray(Class type)
Enabled: start,bound defaults to everything (0,size()). |
Object |
getArray(Class type,
int start,
int bound)
Enabled: Returns a divergent array of type. |
boolean |
includes(EList candidate)
Enabled: Does this list include candidate as a sub-list? |
int |
indexOf1(Object candidate)
Enabled: The first index at which 'candidate' appears in this list, or -1 if none. |
int |
indexOf1(Object candidate,
int start)
Enabled: The first index >= 'start' at which 'candidate' appears in this list, or -1 if none. |
void |
iterate(AssocFunc func)
Enabled: Call 'func' with each index-value pair in the table in order. |
Object |
last()
Enabled: 'a.last()' is equivalent to 'a[a.size()-1]'. |
int |
lastIndexOf1(Object candidate)
Enabled: The last index at which 'candidate' appears in this list, or -1 if none. |
int |
lastIndexOf1(Object candidate,
int start)
Enabled: The last index <= 'start' at which 'candidate' appears in this list, or -1 if none. |
int |
lastStartOf(EList candidate)
Enabled: The last index at which 'candidate' begins as a sub-list of this list, or -1 if none. |
int |
lastStartOf(EList candidate,
int start)
Enabled: The last index <= start at which 'candidate' appears as a sub-list of this list, or -1 if none. |
ConstList |
multiply(int n)
Enabled: Return the result of concatenating n snapshots of this list |
void |
printOn(String left,
String sep,
String right,
TextWriter out)
Enabled: Prints 'left', the values separated by 'sep', and 'right'. |
abstract EList |
readOnly()
Enabled: Returns a read-only facet on this list. |
ConstList |
run(int start,
int bound)
Enabled: Returns a snapshot of the sublist from 'start' (inclusive) to 'bound' (exclusive). |
ConstList |
run(Object intReg)
Enabled: Returns a snapshot of the run at intReg. |
abstract int |
size()
Enabled: How many entries are in the list? |
abstract ConstList |
snapshot()
Enabled: Returns a ConstList whose state is a snapshot of the state of this list at the time of the snapshot() request. |
ConstList |
sort()
Enabled: A snapshot of the list sorted into ascending order |
ConstList |
sort(CompFunc func)
Enabled: A snapshot of the list sorted into ascending order according to func |
int |
startOf(EList candidate)
Enabled: The first index at which 'candidate' begins as a sub-list of this list, or -1 if none. |
int |
startOf(EList candidate,
int start)
Enabled: The first index >= start at which 'candidate' begins as a sub-list of this list, or -1 if none. |
String |
toString()
Suppressed: |
abstract Class |
valueType()
Enabled: All values in this table must be of this type |
ConstList |
with(int index,
Object value)
Enabled: Return a ConstList just like this list except that the element at index is value. |
ConstList |
with(Object value)
Enabled: A ConstList equivalent to 'this snapshot() + [value]' |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.erights.e.elib.oldeio.EPrintable |
__printOn |
Field Detail |
private static final long serialVersionUID
Constructor Detail |
EList()
Method Detail |
public abstract ConstList snapshot()
public abstract EList readOnly()
public FlexList diverge(Class valueType)
Further changes to the original and/or the new list are independent -- they diverge.
The new list is constrained to only hold values of 'valueType'. XXX valueType should be of type ValueGuard rather than Class.
public FlexList diverge()
public ConstList sort()
public ConstList sort(CompFunc func)
public Object getArray(Class type, int start, int bound)
XXX Should 'type' be of type ValueGuard rather than Class?
public Object getArray(Class type)
public Object getArray()
public abstract Object get(int index) throws IndexOutOfBoundsException
IndexOutOfBoundsException
- if index isn't in 0..!size.public Object last() throws IndexOutOfBoundsException
IndexOutOfBoundsException
- if this list is empty.public boolean contains(Object candidate)
public abstract int size()
public void iterate(AssocFunc func)
iterate
in interface Iteratable
public abstract Class valueType()
XXX Should this return a ValueGuard rather than a Class?
public ConstList add(Object other)
XXX If they have a common class, we should use it.
The default implementation here insists that other coerces to an EList, but this is overridden in the Twine subclass.
public ConstList with(Object value)
public ConstList with(int index, Object value)
To do the side-effect-free operation corresponding to the conventional
foo[index] := valuedo
foo with= (index, value)Unlike the conventional assignment, this doesn't change the list, but rather assigns to the foo variable a new list derived from the original list by the with/2 operation. This expands to
foo := foo.with(index, value)
public ConstList multiply(int n)
public ConstMap asMap()
public ConstMap asKeys()
public ConstSet asSet()
public boolean includes(EList candidate)
public ConstList run(Object intReg)
public ConstList run(int start, int bound)
public int indexOf1(Object candidate)
public int indexOf1(Object candidate, int start)
public int lastIndexOf1(Object candidate)
Note that choosing '-1' leads to a programming pun that's too tempting to avoid (though it should be documented). If you want the index of, for example, the beginning of the last dot-separated substring of a string, you can say "lastIndexOf1('.')+1". If there is no dot, this returns 0, which is the correct answer for this case.
public int lastIndexOf1(Object candidate, int start)
public int startOf(EList candidate)
public int startOf(EList candidate, int start)
public int lastStartOf(EList candidate)
public int lastStartOf(EList candidate, int start)
public void printOn(String left, String sep, String right, TextWriter out) throws IOException
'left' value0 'sep' ... 'right'
IOException
public String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |