|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jmlspecs.models.JMLObjectSequence
Sequences of objects. This type uses "==" to compare elements, and does not clone elements that are passed into and returned from the sequence's methods.
The informal model for a JMLObjectSequence is a finite
mathematical sequence of elements (of type Object). In
some examples, we will write
<a,b,c> for a mathematical
sequence of length 3, containing elements a, b,
and c. Elements of sequences are "indexed" from 0, so the
length of a sequence is always 1 more than the index of the last
element in the sequence.
JMLCollection,
JMLType,
JMLValueSequence,
JMLObjectSequenceEnumerator| Field Summary | |
protected BigInteger |
_length
This sequence's length. |
static JMLObjectSequence |
EMPTY
The empty JMLObjectSequence. |
private static String |
IS_NOT_FOUND
|
private static String |
ITEM_PREFIX
|
protected JMLListObjectNode |
theSeq
An equational specification of the properties of sequences. |
private static String |
TOO_BIG_TO_INSERT
|
| Constructor Summary | |
|
JMLObjectSequence()
Initialize this to be the empty sequence. |
|
JMLObjectSequence(Object e)
Initialize this to be the sequence containing just the given element. |
protected |
JMLObjectSequence(JMLListObjectNode ls,
int len)
Initialize this sequence based on the given representation. |
| Method Summary | |
Object |
clone()
Return a clone of this object. |
JMLObjectSequence |
concat(JMLObjectSequence s2)
Return a sequence that is the concatenation of this with the given sequence. |
boolean |
containsAll(Collection c)
Tell whether, for each element in the given collection, there is a "==" element in this sequence. |
static JMLObjectSequence |
convertFrom(Object[] a)
Return the sequence containing all the elements in the given array in the same order as the elements appear in the array. |
static JMLObjectSequence |
convertFrom(Object[] a,
int size)
Return the sequence containing the first 'size' elements in the given array in the same order as the elements appear in the array. |
static JMLObjectSequence |
convertFrom(Collection c)
Return the sequence containing all the object in the given collection in the same order as the elements appear in the collection. |
static JMLObjectSequence |
convertFrom(JMLCollection c)
Return the sequence containing all the object in the given JMLCollection in the same order as the elements appear in the collection. |
int |
count(Object item)
Tells the number of times a given element occurs in the sequence. |
JMLObjectSequenceEnumerator |
elements()
Return a enumerator for this. |
boolean |
equals(Object obj)
Test whether this object's value is equal to the given argument. |
Object |
first()
Return the first element in this sequence. |
Object |
get(int i)
Return the element at the given zero-based index; a synonym for itemAt(int). |
boolean |
has(Object elem)
Tells whether the given element is "==" to an element in the sequence. |
int |
hashCode()
Return a hash code for this object. |
JMLObjectSequence |
header()
Return a sequence containing all but the last element in this. |
int |
indexOf(Object item)
Return the zero-based index of the first occurrence of the given element in the sequence, if there is one |
JMLObjectSequence |
insertAfterIndex(int afterThisOne,
Object item)
Return a sequence like this, but with item put immediately after the given index. |
JMLObjectSequence |
insertBack(Object item)
Return a sequence like this, but with the given item put an the end. |
JMLObjectSequence |
insertBeforeIndex(int beforeThisOne,
Object item)
Return a sequence like this, but with item put immediately before the given index. |
JMLObjectSequence |
insertFront(Object item)
Return a sequence like this, but with the given item put an the front. |
int |
int_length()
Tells the number of elements in the sequence; a synonym for #size. |
int |
int_size()
Tells the number of elements in the sequence; a synonym for #length. |
boolean |
isDeletionFrom(JMLObjectSequence s2,
Object elem)
Tells whether this sequence is the result of deleting the given element once from the given sequence. |
boolean |
isEmpty()
Tells whether this sequence is empty. |
boolean |
isInsertionInto(JMLObjectSequence s2,
Object elem)
Tells whether this sequence is the result of inserting the given element once into the given sequence. |
boolean |
isPrefix(JMLObjectSequence s2)
Tells whether the elements of the this sequence occur, in order, at the beginning of the given sequence, using "==" for comparisons. |
boolean |
isProperPrefix(JMLObjectSequence s2)
Tells whether this sequence is shorter than the given sequence, and also if the elements of this sequence occur, in order, at the beginning of the given sequence, using "==" for comparisons. |
boolean |
isProperSubsequence(JMLObjectSequence s2)
Tells whether this sequence is strictly shorter than the given sequence and a subsequence of it. |
boolean |
isProperSuffix(JMLObjectSequence s2)
Tells whether the this sequence is shorter than the given object, and also if the elements of this sequence occur, in order, at the end of the given sequence, using "==" for comparisons. |
boolean |
isProperSupersequence(JMLObjectSequence s2)
Tells whether the given sequence is both longer than and a supersequence of this sequence. |
boolean |
isSubsequence(JMLObjectSequence s2)
Tells whether this sequence is a subsequence of the given sequence. |
boolean |
isSuffix(JMLObjectSequence s2)
Tells whether the elements of this sequence occur, in order, at the end of the given sequence, using "==" for comparisons. |
boolean |
isSupersequence(JMLObjectSequence s2)
Tells whether the given sequence is a supersequence of this sequence. |
Object |
itemAt(int i)
Return the element at the given zero-based index. |
JMLIterator |
iterator()
Returns an iterator over this sequence. |
Object |
last()
Return the last element in this sequence. |
JMLObjectSequence |
prefix(int n)
Return a sequence containing the first n elements in this sequence. |
JMLObjectSequence |
removeItemAt(int index)
Return a sequence like this, but without the element at the given zero-based index. |
JMLObjectSequence |
removePrefix(int n)
Return a sequence containing all but the first n elements in this. |
JMLObjectSequence |
replaceItemAt(int index,
Object item)
Return a sequence like this, but with item replacing the element at the given zero-based index. |
JMLObjectSequence |
reverse()
Return a sequence that is the reverse of this sequence. |
static JMLObjectSequence |
singleton(Object e)
Return the singleton sequence containing the given element. |
JMLObjectSequence |
subsequence(int from,
int to)
Returns a subsequence of this containing the elements beginning with index from (inclusive) and ending with index to (exclusive). |
Object[] |
toArray()
Return a new array containing all the elements of this in order. |
JMLObjectBag |
toBag()
Return a new JMLObjectBag containing all the elements of this. |
JMLObjectSet |
toSet()
Return a new JMLObjectSet containing all the elements of this. |
String |
toString()
Return a string representation of this object. |
JMLObjectSequence |
trailer()
Return a sequence containing all but the first element in this. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected final JMLListObjectNode theSeq
protected final BigInteger _length
public static final JMLObjectSequence EMPTY
JMLObjectSequence()private static final String ITEM_PREFIX
private static final String IS_NOT_FOUND
private static final String TOO_BIG_TO_INSERT
| Constructor Detail |
public JMLObjectSequence()
EMPTYpublic JMLObjectSequence(Object e)
e - the element that is the first element in this sequence.singleton(java.lang.Object)
protected JMLObjectSequence(JMLListObjectNode ls,
int len)
| Method Detail |
public static JMLObjectSequence singleton(Object e)
JMLObjectSequence(Object)public static JMLObjectSequence convertFrom(Object[] a)
public static JMLObjectSequence convertFrom(Object[] a,
int size)
public static JMLObjectSequence convertFrom(Collection c)
throws ClassCastException
ClassCastException - if some element in c is not an instance of
Object.containsAll(java.util.Collection)
public static JMLObjectSequence convertFrom(JMLCollection c)
throws ClassCastException
ClassCastException - if some element in c is not an instance of
Object.
public Object itemAt(int i)
throws JMLSequenceException
i - the zero-based index into the sequence.
JMLSequenceException - if the index oBiI is out of range.
JMLSequenceException - if the index i is out of range.get(int),
has(Object),
Return the element at the given zero-based index.,
get(int),
has(Object),
count(Object),
#itemAt(\bigint)
public Object get(int i)
throws IndexOutOfBoundsException
itemAt(int).
i - the zero-based index into the sequence.
IndexOutOfBoundsException - if the index i is out of range.
IndexOutOfBoundsException - if the index i is out of range.Return the element at the given zero-based index; a synonym
for {@link #itemAt}.,
itemAt(int)public int int_size()
#length.
int_size in interface JMLCollection#length(),
Tells the number of elements in the sequence; a synonym for
{@link #length}.,
#size(),
Tells the number of elements in the sequence; a synonym for
{@link #length}.,
#length(),
isEmpty()public int int_length()
#size.
int_size()public int count(Object item)
has(Object),
Tells the number of times a given element occurs in the sequence.,
has(Object),
itemAt(int)public boolean has(Object elem)
has in interface JMLCollectioncount(Object)public boolean containsAll(Collection c)
c - the collection whose elements are sought.public boolean isPrefix(JMLObjectSequence s2)
isProperPrefix(org.jmlspecs.models.JMLObjectSequence),
isSuffix(org.jmlspecs.models.JMLObjectSequence)public boolean isProperPrefix(JMLObjectSequence s2)
isPrefix(org.jmlspecs.models.JMLObjectSequence),
isProperSuffix(org.jmlspecs.models.JMLObjectSequence)public boolean isSuffix(JMLObjectSequence s2)
isProperSuffix(org.jmlspecs.models.JMLObjectSequence),
isPrefix(org.jmlspecs.models.JMLObjectSequence)public boolean isProperSuffix(JMLObjectSequence s2)
isSuffix(org.jmlspecs.models.JMLObjectSequence),
isProperPrefix(org.jmlspecs.models.JMLObjectSequence)public boolean equals(Object obj)
equals in interface JMLTypeequals in class ObjectisSuffix(org.jmlspecs.models.JMLObjectSequence),
int_size()public int hashCode()
hashCode in interface JMLTypehashCode in class Objectpublic boolean isEmpty()
int_size(),
int_length()
public int indexOf(Object item)
throws JMLSequenceException
item - the Object sought in this.
JMLSequenceException - if item is not a member of the sequence.
JMLSequenceException - if item is not a member of the sequence.Return the zero-based index of the first occurrence of the given
element in the sequence, if there is one,
itemAt(int)
public Object first()
throws JMLSequenceException
JMLSequenceException - if the sequence is empty.itemAt(int),
last(),
trailer(),
header()
public Object last()
throws JMLSequenceException
JMLSequenceException - if the sequence is empty.itemAt(int),
first(),
header(),
trailer()public boolean isSubsequence(JMLObjectSequence s2)
s2 - the sequence to search for within this sequence.
isProperSubsequence(org.jmlspecs.models.JMLObjectSequence),
isSupersequence(org.jmlspecs.models.JMLObjectSequence)public boolean isProperSubsequence(JMLObjectSequence s2)
s2 - the sequence to search for within this sequence.
isSubsequence(org.jmlspecs.models.JMLObjectSequence),
isProperSupersequence(org.jmlspecs.models.JMLObjectSequence)public boolean isSupersequence(JMLObjectSequence s2)
s2 - the sequence to search within for this sequence.
isProperSubsequence(org.jmlspecs.models.JMLObjectSequence),
isSubsequence(org.jmlspecs.models.JMLObjectSequence)public boolean isProperSupersequence(JMLObjectSequence s2)
s2 - the sequence to search within for this sequence.
isSupersequence(org.jmlspecs.models.JMLObjectSequence),
isProperSubsequence(org.jmlspecs.models.JMLObjectSequence)
public boolean isInsertionInto(JMLObjectSequence s2,
Object elem)
s2 - the shorter sequence, which we see if the elem is
inserted intoelem - the given element
isDeletionFrom(org.jmlspecs.models.JMLObjectSequence, java.lang.Object),
isProperSupersequence(org.jmlspecs.models.JMLObjectSequence),
isProperSubsequence(org.jmlspecs.models.JMLObjectSequence),
subsequence(int, int)
public boolean isDeletionFrom(JMLObjectSequence s2,
Object elem)
s2 - the longer sequence, in which we see if the elem is
deleted fromelem - the given element
isInsertionInto(org.jmlspecs.models.JMLObjectSequence, java.lang.Object),
isProperSupersequence(org.jmlspecs.models.JMLObjectSequence),
isProperSubsequence(org.jmlspecs.models.JMLObjectSequence),
subsequence(int, int)public Object clone()
clone in interface JMLTypeclone in class Object
public JMLObjectSequence prefix(int n)
throws JMLSequenceException
n - the number of elements in the result.
JMLSequenceException - if n is negative or greater than
the length of the sequence.
JMLSequenceException - if n is negative or greater than
the length of the sequence.trailer(),
removePrefix(int),
Return a sequence containing the first n elements in this sequence.,
trailer(),
removePrefix(int),
subsequence(int, int)
public JMLObjectSequence removePrefix(int n)
throws JMLSequenceException
n - the number of elements to remove
JMLSequenceException - if n is negative or greater than
the length of the sequence.
JMLSequenceException - if n is negative or greater than
the length of the sequence.header(),
prefix(int),
Return a sequence containing all but the first n elements in this.,
header(),
prefix(int),
subsequence(int, int)public JMLObjectSequence concat(JMLObjectSequence s2)
s2 - the sequence to place at the end of this sequence in
the result.
public JMLObjectSequence reverse()
public JMLObjectSequence removeItemAt(int index)
throws JMLSequenceException
index - the zero-based index into the sequence.
JMLSequenceException - if the index is out of range.
JMLSequenceException - if the index is out of range.itemAt(int),
removeItemAt(int),
prefix(int),
removePrefix(int),
subsequence(int, int),
Return a sequence like this, but without the element at the
given zero-based index.,
itemAt(int),
removeItemAt(int),
prefix(int),
removePrefix(int),
subsequence(int, int),
concat(org.jmlspecs.models.JMLObjectSequence)
public JMLObjectSequence replaceItemAt(int index,
Object item)
throws JMLSequenceException
index - the zero-based index into the sequence.item - the item to put at index index
JMLSequenceException - if the index is out of range.
JMLSequenceException - if the index is out of range.itemAt(int),
Return a sequence like this, but with item replacing the element at the
given zero-based index.,
itemAt(int),
replaceItemAt(int, java.lang.Object)
public JMLObjectSequence header()
throws JMLSequenceException
JMLSequenceException - if this is empty.prefix(int),
first(),
last(),
trailer(),
subsequence(int, int)
public JMLObjectSequence trailer()
throws JMLSequenceException
JMLSequenceException - if this is empty.removePrefix(int),
last(),
first(),
header(),
subsequence(int, int)
public JMLObjectSequence insertAfterIndex(int afterThisOne,
Object item)
throws JMLSequenceException,
IllegalStateException
afterThisOne - a zero-based index into the sequence, or -1.item - the item to put after index afterThisOne
JMLSequenceException - if the index is out of range.
JMLSequenceException - if the index is out of range.
IllegalStateExceptioninsertBeforeIndex(int, java.lang.Object),
insertFront(java.lang.Object),
insertBack(java.lang.Object),
Return a sequence like this, but with item put immediately after
the given index.,
insertBeforeIndex(int, java.lang.Object),
insertFront(java.lang.Object),
insertBack(java.lang.Object),
removeItemAt(int)
public JMLObjectSequence insertBeforeIndex(int beforeThisOne,
Object item)
throws JMLSequenceException,
IllegalStateException
beforeThisOne - a zero-based index into the sequence,
or the length of this.item - the item to put before index beforeThisOne
JMLSequenceException - if the index is out of range.
JMLSequenceException - if the index is out of range.
IllegalStateExceptioninsertAfterIndex(int, java.lang.Object),
insertFront(java.lang.Object),
insertBack(java.lang.Object),
Return a sequence like this, but with item put immediately
before the given index.,
insertAfterIndex(int, java.lang.Object),
insertFront(java.lang.Object),
insertBack(java.lang.Object),
removeItemAt(int)
public JMLObjectSequence insertBack(Object item)
throws IllegalStateException
item - the item to put at the end of the result.
IllegalStateExceptioninsertAfterIndex(int, java.lang.Object),
insertBeforeIndex(int, java.lang.Object),
insertFront(java.lang.Object),
removeItemAt(int),
header(),
last()
public JMLObjectSequence insertFront(Object item)
throws IllegalStateException
item - the item to put at the front of the result.
IllegalStateExceptioninsertAfterIndex(int, java.lang.Object),
insertBeforeIndex(int, java.lang.Object),
insertBack(java.lang.Object),
removeItemAt(int),
trailer(),
first()
public JMLObjectSequence subsequence(int from,
int to)
throws JMLSequenceException
from - the inclusive, zero-based element of the first
element in the subsequence.to - the zero-based element of the first element that
should not be in the subsequence.
JMLSequenceException - if (from < 0 or from > to
or to > length of this.
JMLSequenceException - if (from < 0 or from > to
or to > length of this.prefix(int),
removePrefix(int),
header(),
trailer(),
Returns a subsequence of this containing the elements beginning
with index from (inclusive) and ending with index to (exclusive).,
prefix(int),
removePrefix(int),
header(),
trailer(),
concat(org.jmlspecs.models.JMLObjectSequence)public JMLObjectBag toBag()
toSet(),
toArray()public JMLObjectSet toSet()
toBag(),
toArray()public Object[] toArray()
toSet(),
toBag()public JMLObjectSequenceEnumerator elements()
iterator(),
#itemAt()public JMLIterator iterator()
iterator in interface JMLCollectionelements()public String toString()
toString in class Object
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||