|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jmlspecs.models.JMLListObjectNode
An implementation class used in various models. These are
singly-linked list nodes containing objects. The empty
list is represented by null, which makes dealing with these lists
tricky. Normal users should use JMLObjectSequence instead of this
type to avoid these difficulties.
This type uses "==" to compare elements. The cons method does not clone elements that are passed into the list.
JMLObjectSequence,
JMLObjectBag,
JMLObjectSet| Field Summary | |
JMLListObjectNode |
next
The next node in this list. |
Object |
val
An `equational' specification of lists, for use in the invariant. |
| Constructor Summary | |
JMLListObjectNode(Object item,
JMLListObjectNode nxt)
The type of the elements in this list. |
|
| Method Summary | |
JMLListObjectNode |
append(Object item)
Return a list that consists of this list and the given element. |
Object |
clone()
Return a clone of this object. |
JMLListObjectNode |
concat(JMLListObjectNode ls2)
Return a list that is the concatenation of this with the given lists. |
static JMLListObjectNode |
cons(Object hd,
JMLListObjectNode tl)
Return a JMLListObjectNode containing the given element followed by the given list. |
private static boolean |
elem_equals(Object item1,
Object item2)
Tell if the given elements are equal, taking null into account. |
boolean |
equals(Object ls2)
Test whether this object's value is equal to the given argument. |
Object |
getItem(Object item)
Return the zero-based index of the first occurrence of the given element in the list, if there is one |
boolean |
has(Object item)
Tells whether the given element is "==" to an element in the list. |
int |
hashCode()
Return a hash code for this object. |
Object |
head()
Return the first element in this list. |
boolean |
headEquals(Object item)
Tell if the head of the list is "==" to the given item. |
int |
indexOf(Object item)
Return the zero-based index of the first occurrence of the given element in the list, if there is one |
JMLListObjectNode |
insertBefore(int n,
Object item)
Return a list that is like this list but with the given item inserted before the given index. |
int |
int_length()
Tells the number of elements in the list; a synonym for size. |
int |
int_size()
Tells the number of elements in the sequence; a synonym for length Tells the number of elements in the sequence; a synonym for length Tells the number of elements in the list; a synonym for length. |
boolean |
isPrefixOf(JMLListObjectNode ls2)
Tells whether the elements of this list occur, in order, at the beginning of the given list, using "==" for comparisons. |
Object |
itemAt(int i)
Return the ith element of a list. |
Object |
last()
Return the last element in this list. |
JMLListObjectNode |
prefix(int n)
Return a list containing the first n elements in this list. |
JMLListObjectNode |
prepend(Object item)
Return a list that is like this, but with the given item at the front. |
JMLListObjectNode |
remove(Object item)
Return a list that is like this list but without the first occurrence of the given item. |
JMLListObjectNode |
removeItemAt(int n)
Return a list like this list, but without the element at the given zero-based index. |
JMLListObjectNode |
removeLast()
Return a list containing all but the last element in this. |
JMLListObjectNode |
removePrefix(int n)
Return a list containing all but the first n elements in this list. |
JMLListObjectNode |
replaceItemAt(int n,
Object item)
Return a list like this, but with item replacing the element at the given zero-based index. |
JMLListObjectNode |
reverse()
Return a list that is the reverse of this list. |
String |
toString()
Return a string representation for this list. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public final Object val
public final JMLListObjectNode next
| Constructor Detail |
public JMLListObjectNode(Object item,
JMLListObjectNode nxt)
item - the object to place at the head of this list.nxt - the _JMLListObjectNode to make the tail of this list.| Method Detail |
public static JMLListObjectNode cons(Object hd,
JMLListObjectNode tl)
hd - the object to place at the head of the result.tl - the JMLListObjectNode to make the tail of the result.public Object head()
public boolean headEquals(Object item)
has(Object)
private static boolean elem_equals(Object item1,
Object item2)
public Object itemAt(int i)
throws JMLListException
JMLListExceptionReturn the ith element of a list.,
#getItem(int)public int int_size()
public int int_length()
public boolean has(Object item)
public boolean isPrefixOf(JMLListObjectNode ls2)
public boolean equals(Object ls2)
equals in interface JMLTypeequals in class Objectpublic int hashCode()
hashCode in interface JMLTypehashCode in class Objectpublic int indexOf(Object item)
item - the Object sought in this.
public Object last()
public Object getItem(Object item)
throws JMLListException
item - the Object sought in this list.
JMLListException - if the item does not occur in this list.itemAt(int)public Object clone()
clone in interface JMLTypeclone in class Objectpublic JMLListObjectNode prefix(int n)
n - the number of elements to leave in the result.
public JMLListObjectNode removePrefix(int n)
n - the number of elements to remove
public JMLListObjectNode removeItemAt(int n)
n - the zero-based index into the list.
public JMLListObjectNode replaceItemAt(int n,
Object item)
n - the zero-based index into this list.item - the item to put at index index
Return a list like this, but with item replacing the element at the
given zero-based index.public JMLListObjectNode removeLast()
public JMLListObjectNode concat(JMLListObjectNode ls2)
ls2 - the list to place at the end of this list in the
result.
public JMLListObjectNode prepend(Object item)
item - the element to place at the front of the result.public JMLListObjectNode append(Object item)
public JMLListObjectNode reverse()
public JMLListObjectNode insertBefore(int n,
Object item)
throws JMLListException
JMLListExceptionpublic JMLListObjectNode remove(Object item)
public String toString()
toString in class Object
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||