JML

java.util
Class LinkedList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.AbstractSequentialList
              extended byjava.util.LinkedList
All Implemented Interfaces:
Cloneable, Collection, List, Serializable

public class LinkedList
extends AbstractSequentialList
implements List, Cloneable, Serializable

JML's specification of java.util.LinkedList.

Author:
Katie Becker, Gary T. Leavens

Class Specifications

Specifications inherited from class AbstractList
protected initially this.modCount == 0;

Specifications inherited from class Object
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT;
public represents _getClass <- \typeof(this);

Specifications inherited from interface List
instance public represents theCollection <- this.theList.toBag();

Specifications inherited from interface Collection
instance public invariant this.elementType == this.theCollection.elementType;
instance public invariant this.containsNull == this.theCollection.containsNull;
instance public invariant !this.nullElementsSupported ==> !this.containsNull;

Model Field Summary
 
Model fields inherited from class java.lang.Object
_getClass, objectState, theString
 
Model fields inherited from interface java.util.List
theList
 
Model fields inherited from interface java.util.Collection
addOperationSupported, elementState, nullElementsSupported, removeOperationSupported, theCollection
 
Ghost Field Summary
 
Ghost fields inherited from class java.lang.Object
objectTimesFinalized, owner
 
Ghost fields inherited from interface java.util.Collection
containsNull, elementType
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LinkedList()
           
LinkedList(Collection c)
           
 
Model Method Summary
 
Model methods inherited from class java.lang.Object
hashValue
 
Model methods inherited from interface java.util.Collection
hashValue
 
Method Summary
 void add(int index, Object element)
           
 boolean add(nullable Object o)
           
 boolean addAll(int index, Collection c)
           
 boolean addAll(Collection c)
           
 void addFirst(Object o)
           
 void addLast(Object o)
           
 void clear()
           
 Object clone()
           
 boolean contains(nullable Object o)
           
 Object get(int index)
           
 Object getFirst()
           
 Object getLast()
           
 int indexOf(Object o)
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator(int index)
           
 Object remove(int index)
           
 boolean remove(nullable Object o)
           
 Object removeFirst()
           
 Object removeLast()
           
 Object set(int index, Object element)
           
 int size()
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

LinkedList

public LinkedList()
Specifications:
public normal_behavior
assignable theCollection;
ensures this.theList != null&&this.theList.isEmpty();

LinkedList

public LinkedList(Collection c)
Specifications:
public normal_behavior
requires c != null;
assignable theCollection;
ensures this.theList != null;
ensures org.jmlspecs.models.JMLEqualsSequence.convertFrom(c).equals(this.theList);
     also
public exceptional_behavior
requires c == null;
assignable theCollection;
signals_only java.lang.NullPointerException;
Method Detail

getFirst

public Object getFirst()
Specifications: pure
public normal_behavior
requires !this.theList.isEmpty();
ensures (\result == null)||\typeof(\result ) <: this.elementType;
ensures \result .equals(this.theList.itemAt(0));
     also
public exceptional_behavior
requires this.theList.isEmpty();
signals_only java.util.NoSuchElementException;

getLast

public Object getLast()
Specifications: pure
public normal_behavior
requires !this.theList.isEmpty();
ensures (\result == null)||\typeof(\result ) <: this.elementType;
ensures \result .equals(this.theList.itemAt((int)(this.theList.int_size()-1)));
     also
public exceptional_behavior
requires this.theList.isEmpty();
signals_only java.util.NoSuchElementException;

removeFirst

public Object removeFirst()
Specifications:
public normal_behavior
requires !this.theList.isEmpty();
assignable theCollection;
ensures \result .equals(\old(this.theList.itemAt(0)));
ensures this.theList.equals(\old(this.theList).removeItemAt(0));
ensures ((\result == null)||\typeof(\result ) <: this.elementType);
     also
public exceptional_behavior
requires this.theList.isEmpty();
assignable \nothing;
signals_only java.util.NoSuchElementException;

removeLast

public Object removeLast()
Specifications:
public behavior
requires !this.theList.isEmpty();
assignable theCollection;
ensures \result .equals(\old(this.theList.itemAt((int)(this.theList.int_size()-1))));
ensures this.theList.equals(\old(this.theList.removeItemAt((int)(this.theList.int_size()-1))));
ensures ((\result == null)||\typeof(\result ) <: this.elementType);
     also
public exceptional_behavior
requires this.theList.isEmpty();
assignable \nothing;
signals_only java.util.NoSuchElementException;

addFirst

public void addFirst(Object o)
Specifications:
public normal_behavior
assignable theCollection;
ensures this.theList.equals(\old(this.theList.insertFront(o)));
ensures_redundantly this.theList.itemAt(0).equals(o);

addLast

public void addLast(Object o)
Specifications:
public normal_behavior
assignable theCollection;
ensures this.theList.equals(\old(this.theList.insertBack(o)));
ensures_redundantly this.theList.itemAt((int)(this.theList.int_size()-1)).equals(o);

contains

public boolean contains(nullable Object o)
Specified by:
contains in interface List
Overrides:
contains in class AbstractCollection
Specifications: pure
Specifications inherited from overridden method in class AbstractCollection:
       pure
Specifications inherited from overridden method in interface List:
       pure
Specifications inherited from overridden method contains(Object o) in interface Collection:
       pure
public behavior
assignable \nothing;
ensures !this.containsNull&&o == null ==> !\result ;
ensures (o == null)||\typeof(o) <: this.elementType||!\result ;
ensures \result <==> this.theCollection.has(o);
signals_only java.lang.ClassCastException, java.lang.NullPointerException;
signals (java.lang.ClassCastException) (* \typeof(o) is incompatible with the elementType of this collection *);
signals (java.lang.NullPointerException) o == null;

size

public int size()
Specified by:
size in interface List
Specifications: pure
Specifications inherited from overridden method in class AbstractCollection:
       pure
Specifications inherited from overridden method in interface List:
       pure
Specifications inherited from overridden method in interface Collection:
       pure
public normal_behavior
assignable \nothing;
ensures \result == this.theCollection.int_size();
ensures \result >= 0;

add

public boolean add(nullable Object o)
Specified by:
add in interface List
Overrides:
add in class AbstractList
Specifications inherited from overridden method add(Object o) in class AbstractList:
     also
protected model_program { ... }
Specifications inherited from overridden method in class AbstractCollection:
      --- None ---
Specifications inherited from overridden method add(Object o) in interface List:
     also
public behavior
assignable theCollection;
ensures \result &&this.theList.equals(\old(this.theList).insertBack(o));
Specifications inherited from overridden method add(Object o) in interface Collection:
public behavior
requires !this.containsNull ==> o != null;
requires (o == null)||\typeof(o) <: this.elementType;
assignable theCollection;
ensures \result ==> this.theCollection.equals(\old(this.theCollection.insert(o)));
ensures \result &&\old(this.size() < 2147483647) ==> this.size() == \old(this.size()+1);
ensures !\result ==> this.size() == \old(this.size());
ensures !\result ==> \not_modified(theCollection);
ensures this.contains(o);
ensures_redundantly !\result ==> \old(this.contains(o));
signals_only java.lang.UnsupportedOperationException, java.lang.NullPointerException, java.lang.ClassCastException, java.lang.IllegalArgumentException;
signals (java.lang.UnsupportedOperationException) (* this does not support add *);
signals (java.lang.NullPointerException) (* not allowed to add null *);
signals (java.lang.ClassCastException) (* class of specified element prevents it from being added to this *);
signals (java.lang.IllegalArgumentException) (* some aspect of this element prevents it from being added to this *);

remove

public boolean remove(nullable Object o)
Specified by:
remove in interface List
Overrides:
remove in class AbstractCollection
Specifications inherited from overridden method in class AbstractCollection:
      --- None ---
Specifications inherited from overridden method remove(Object o) in interface List:
     also
public behavior
assignable theCollection;
ensures \result ==> this.theList.equals(\old(this.theList.removeItemAt(this.theList.indexOf(o))));
Specifications inherited from overridden method remove(Object o) in interface Collection:
public behavior
requires !this.containsNull ==> o != null;
requires (o == null)||\typeof(o) <: this.elementType;
assignable theCollection;
ensures \result ==> this.theCollection.equals(\old(this.theCollection.remove(o)));
ensures \result &&\old(this.size() <= 2147483647) ==> this.size() == \old(this.size()-1)&&this.size() < 2147483647&&this.size() >= 0;
ensures !\result ||\old(this.size() == 2147483647) ==> this.size() == \old(this.size());
signals_only java.lang.UnsupportedOperationException, java.lang.ClassCastException;
signals (java.lang.UnsupportedOperationException) (* this does not support remove *);
signals (java.lang.ClassCastException) (* the type of this element is not compatible with this *);

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface List
Overrides:
addAll in class AbstractCollection
Specifications inherited from overridden method in class AbstractCollection:
      --- None ---
Specifications inherited from overridden method in interface List:
      --- None ---
Specifications inherited from overridden method addAll(Collection c) in interface Collection:
public behavior
requires c != null;
requires c.elementType <: this.elementType;
requires !this.containsNull ==> !c.containsNull;
assignable theCollection;
ensures this.theCollection.equals(\old(this.theCollection).union(c.theCollection));
signals_only java.lang.UnsupportedOperationException, java.lang.ClassCastException, java.lang.IllegalArgumentException, java.lang.NullPointerException;
signals (java.lang.UnsupportedOperationException) (* this does not support addAll *);
signals (java.lang.ClassCastException) (* class of specified element prevents it from being added to this *);
signals (java.lang.IllegalArgumentException) (* some aspect of this element prevents it from being added to this *);
signals (java.lang.NullPointerException) (* argument contains null elements and this does not support null elements *);
     also
public exceptional_behavior
requires c == null;
assignable \nothing;
signals_only java.lang.NullPointerException;

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List
Overrides:
addAll in class AbstractSequentialList
Specifications inherited from overridden method in class AbstractSequentialList:
      --- None ---
Specifications inherited from overridden method in class AbstractList:
      --- None ---
Specifications inherited from overridden method addAll(int index, Collection c) in interface List:
public behavior
requires c != null;
requires 0 <= index&&index <= this.size();
requires c.elementType <: this.elementType;
requires !this.containsNull ==> !c.containsNull;
assignable theCollection;
ensures \result ==> this.theList.equals(\old(this.theList.subsequence(0,index)).concat(org.jmlspecs.models.JMLEqualsSequence.convertFrom(c)).concat(\old(this.theList.subsequence(index,this.size()))));
signals_only java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException;
signals (java.lang.UnsupportedOperationException) (* if this operation is not supported *);
signals (java.lang.IllegalArgumentException) (* if some aspect of c prevents its elements from being added to the list *);
     also
public exceptional_behavior
requires c == null||!(0 <= index&&index <= this.size())||!(c.elementType <: this.elementType)||(!this.containsNull&&c.containsNull);
assignable \nothing;
signals_only java.lang.UnsupportedOperationException, java.lang.ClassCastException, java.lang.NullPointerException, java.lang.IndexOutOfBoundsException;
signals (java.lang.ClassCastException) c != null&&!(c.elementType <: this.elementType);
signals (java.lang.NullPointerException) c == null;
signals (java.lang.IndexOutOfBoundsException) !(0 <= index&&index <= this.size());

clear

public void clear()
Specified by:
clear in interface List
Overrides:
clear in class AbstractList
Specifications inherited from overridden method in class AbstractList:
     also
protected model_program { ... }
Specifications inherited from overridden method in class AbstractCollection:
      --- None ---
Specifications inherited from overridden method in interface List:
      --- None ---
Specifications inherited from overridden method in interface Collection:
public behavior
assignable theCollection;
ensures this.theCollection.isEmpty();
ensures_redundantly this.size() == 0;
signals_only java.lang.UnsupportedOperationException;
signals (java.lang.UnsupportedOperationException) (* clear is not supported by this *);

get

public Object get(int index)
Specified by:
get in interface List
Overrides:
get in class AbstractSequentialList
Specifications: pure
Specifications inherited from overridden method in class AbstractSequentialList:
      --- None ---
Specifications inherited from overridden method in class AbstractList:
       pure
Specifications inherited from overridden method get(int index) in interface List:
       pure
public normal_behavior
requires 0 <= index&&index < this.size();
assignable \nothing;
ensures \result == this.theList.get(index);
     also
public exceptional_behavior
requires !(0 <= index&&index < this.size());
assignable \nothing;
signals_only java.lang.IndexOutOfBoundsException;
    implies_that
public normal_behavior
requires index >= 0;
ensures (\result == null)||\typeof(\result ) <: this.elementType;
ensures !this.containsNull ==> \result != null;

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List
Overrides:
set in class AbstractSequentialList
Specifications inherited from overridden method in class AbstractSequentialList:
      --- None ---
Specifications inherited from overridden method set(int index, Object element) in class AbstractList:
     also
protected exceptional_behavior
requires \typeof(this) == \type(java.util.AbstractList);
assignable \nothing;
signals_only java.lang.UnsupportedOperationException;
Specifications inherited from overridden method set(int index, Object element) in interface List:
public behavior
requires !this.containsNull ==> element != null;
requires (element == null)||\typeof(element) <: this.elementType;
{|
requires 0 <= index&&index < this.size();
assignable theCollection;
ensures \result == (\old(this.theList.get(index)));
ensures this.theList.equals(\old(this.theList.subsequence(0,index)).insertBack(element).concat(\old(this.theList.subsequence(index+1,this.size()))));
signals_only java.lang.UnsupportedOperationException, java.lang.ClassCastException, java.lang.NullPointerException, java.lang.IllegalArgumentException;
signals (java.lang.UnsupportedOperationException) (* set method not supported by list *);
signals (java.lang.ClassCastException) (* class of specified element prevents it from being added to this *);
signals (java.lang.NullPointerException) (* element is null and null elements not supported by this *);
signals (java.lang.IllegalArgumentException) (* some aspect of element prevents it from being added to this *);
also
requires !(0 <= index&&index < this.size());
assignable \nothing;
ensures false;
signals_only java.lang.UnsupportedOperationException, java.lang.IndexOutOfBoundsException;
|}

add

public void add(int index,
                Object element)
Specified by:
add in interface List
Overrides:
add in class AbstractSequentialList
Specifications inherited from overridden method in class AbstractSequentialList:
      --- None ---
Specifications inherited from overridden method add(int index, Object element) in class AbstractList:
     also
protected exceptional_behavior
requires \typeof(this) == \type(java.util.AbstractList);
assignable \nothing;
signals_only java.lang.UnsupportedOperationException;
Specifications inherited from overridden method add(int index, Object element) in interface List:
public behavior
requires !this.containsNull ==> element != null;
requires (element == null)||\typeof(element) <: this.elementType;
{|
requires 0 <= index&&index <= this.size();
assignable theCollection;
ensures (element == null&&this.theList.get(index) == null)||(this.theList.get(index).equals(element))&&( \forall int i; 0 <= i&&i < index; (this.theList.get(i) == null&&\old(this.theList).get(i) == null)||this.theList.get(i).equals(\old(this.theList.get(i))))&&( \forall int i; index <= i&&i < \old(this.size()); (this.theList.get((int)(i+1)) == null&&\old(this.theList).get(i) == null)||this.theList.get((int)(i+1)).equals(\old(this.theList.get(i))));
signals_only java.lang.UnsupportedOperationException, java.lang.ClassCastException, java.lang.NullPointerException, java.lang.IllegalArgumentException;
signals (java.lang.UnsupportedOperationException) (* add method not supported by list *);
signals (java.lang.ClassCastException) (* class of specified element prevents it from being added to this *);
signals (java.lang.NullPointerException) (* element is null and null elements are not supported by this *);
signals (java.lang.IllegalArgumentException) (* some aspect of element prevents it from being added to this *);
also
requires !(0 <= index&&index <= this.size());
assignable \nothing;
ensures false;
signals_only java.lang.UnsupportedOperationException, java.lang.IndexOutOfBoundsException;
|}

remove

public Object remove(int index)
Specified by:
remove in interface List
Overrides:
remove in class AbstractSequentialList
Specifications inherited from overridden method in class AbstractSequentialList:
      --- None ---
Specifications inherited from overridden method remove(int index) in class AbstractList:
     also
protected exceptional_behavior
requires \typeof(this) == \type(java.util.AbstractList);
assignable \nothing;
signals_only java.lang.UnsupportedOperationException;
Specifications inherited from overridden method remove(int index) in interface List:
public behavior
{|
requires 0 <= index&&index < this.size();
assignable theCollection;
ensures \result == (\old(this.theList.get(index)));
ensures ( \forall int i; 0 <= i&&i < index; (this.theList.get(i) == null&&\old(this.theList).get(i) == null)||this.theList.get(i) == (\old(this.theList.get(i))))&&( \forall \bigint i; index <= i&&i < (\old(this.size()-1)); (this.theList.get((int)i) == null&&\old(this.theList).get((int)(i+1)) == null)||this.theList.get((int)i) == (\old(this.theList.get((int)(i+1)))));
signals_only java.lang.UnsupportedOperationException;
signals (java.lang.UnsupportedOperationException) (* remove method not supported by list *);
also
requires 0 <= index&&index < this.size();
assignable theCollection;
ensures (\result == null)||\typeof(\result ) <: this.elementType;
ensures !this.containsNull ==> \result != null;
also
requires !(0 <= index&&index < this.size());
assignable \nothing;
ensures false;
signals_only java.lang.UnsupportedOperationException, java.lang.IndexOutOfBoundsException;
|}

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List
Overrides:
indexOf in class AbstractList
Specifications: pure
Specifications inherited from overridden method in class AbstractList:
       pure
Specifications inherited from overridden method indexOf(Object o) in interface List:
       pure
public behavior
requires !this.containsNull ==> o != null;
requires (o == null)||\typeof(o) <: this.elementType;
assignable \nothing;
ensures \result != -1&&this.theList.get(\result ) == null ==> o == null;
ensures \result != -1&&this.theList.get(\result ) != null ==> this.theList.get(\result ).equals(o)&&this.theList.indexOf(o) == \result ;
ensures \result == -1&&!this.contains(o);
signals_only java.lang.ClassCastException, java.lang.NullPointerException;
signals (java.lang.ClassCastException) (* class of specified element is incompatible with this *);
signals (java.lang.NullPointerException) (* element is null and null elements are not supported by this *);
    implies_that
ensures \result != -1 ==> ( \forall int i; 0 <= i&&i < \result ; (this.theList.get(i) == null&&o != null)||(this.theList.get(i) != null&&!this.theList.get(i).equals(o)));

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List
Overrides:
lastIndexOf in class AbstractList
Specifications: pure
Specifications inherited from overridden method in class AbstractList:
       pure
Specifications inherited from overridden method lastIndexOf(Object o) in interface List:
       pure
public behavior
requires !this.containsNull ==> o != null;
requires (o == null)||\typeof(o) <: this.elementType;
assignable \nothing;
ensures \result != -1&&this.theList.get(\result ) == null ==> o == null;
ensures \result != -1&&this.theList.get(\result ) != null ==> this.theList.get(\result ).equals(o)&&this.theList.reverse().indexOf(o) == this.theList.int_size()-(\result +1);
signals_only java.lang.ClassCastException, java.lang.NullPointerException;
signals (java.lang.ClassCastException) (* class of specified element is incompatible with this *);
signals (java.lang.NullPointerException) (* element is null and null elements are not supported by this *);
    implies_that
ensures \result != -1 ==> ( \forall int i; \result < i&&i < this.theList.int_size(); (this.theList.get(i) == null&&o != null)||(this.theList.get(i) != null&&!this.theList.get(i).equals(o)));

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List
Specified by:
listIterator in class AbstractSequentialList
Specifications: pure
Specifications inherited from overridden method in class AbstractSequentialList:
      --- None ---
Specifications inherited from overridden method in class AbstractList:
       pure
Specifications inherited from overridden method listIterator(int index) in interface List:
       pure non_null
public normal_behavior
requires 0 <= index&&index < this.size();
assignable \nothing;
ensures \result != null&&this.size() < 2147483647 ==> ( \forall int i; index <= i&&i < this.size(); \result .hasNext(i)&&\result .nthNextElement(i) == this.toArray()[i]);
     also
public exceptional_behavior
requires index < 0&&this.size() <= index;
signals_only java.lang.IndexOutOfBoundsException;
    implies_that
ensures \result .elementType == this.elementType;
ensures this.containsNull == \result .returnsNull;

clone

public Object clone()
Overrides:
clone in class Object
Specifications: pure
     also
public normal_behavior
ensures \result instanceof java.util.LinkedList&&\fresh(\result )&&((java.util.LinkedList)\result ).equals(this);
ensures_redundantly \result != this;
Specifications inherited from overridden method in class Object:
       non_null
protected normal_behavior
requires this instanceof java.lang.Cloneable;
assignable \nothing;
ensures \result != null;
ensures \typeof(\result ) == \typeof(this);
ensures (* \result is a clone of this *);
     also
protected normal_behavior
requires this.getClass().isArray();
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((java.lang.Object[])\result ).length == ((java.lang.Object[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((java.lang.Object[])this).length; ((java.lang.Object[])\result )[i] == ((java.lang.Object[])this)[i]);
     also
requires this.getClass().isArray();
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures java.lang.reflect.Array.getLength(\result ) == java.lang.reflect.Array.getLength(this);
ensures ( \forall int i; 0 <= i&&i < java.lang.reflect.Array.getLength(this); ( \exists java.lang.Object result_i; result_i == java.lang.reflect.Array.get(\result ,i); (result_i == null&&java.lang.reflect.Array.get(this,i) == null)||(result_i != null&&result_i.equals(java.lang.reflect.Array.get(this,i)))));
     also
protected exceptional_behavior
requires !(this instanceof java.lang.Cloneable);
assignable \nothing;
signals_only java.lang.CloneNotSupportedException;
     also
protected normal_behavior
requires \elemtype(\typeof(this)) <: \type(java.lang.Object);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((java.lang.Object[])\result ).length == ((java.lang.Object[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((java.lang.Object[])this).length; ((java.lang.Object[])\result )[i] == ((java.lang.Object[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(int);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((int[])\result ).length == ((int[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((int[])this).length; ((int[])\result )[i] == ((int[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(byte);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((byte[])\result ).length == ((byte[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((byte[])this).length; ((byte[])\result )[i] == ((byte[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(char);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((char[])\result ).length == ((char[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((char[])this).length; ((char[])\result )[i] == ((char[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(long);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((long[])\result ).length == ((long[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((long[])this).length; ((long[])\result )[i] == ((long[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(short);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((short[])\result ).length == ((short[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((short[])this).length; ((short[])\result )[i] == ((short[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(boolean);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((boolean[])\result ).length == ((boolean[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((boolean[])this).length; ((boolean[])\result )[i] == ((boolean[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(float);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((float[])\result ).length == ((float[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((float[])this).length; (java.lang.Float.isNaN(((float[])\result )[i])&&java.lang.Float.isNaN(((float[])this)[i]))||((float[])\result )[i] == ((float[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(double);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((double[])\result ).length == ((double[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((double[])this).length; (java.lang.Double.isNaN(((double[])\result )[i])&&java.lang.Double.isNaN(((double[])this)[i]))||((double[])\result )[i] == ((double[])this)[i]);

toArray

public Object[] toArray()
Specified by:
toArray in interface List
Overrides:
toArray in class AbstractCollection
Specifications: pure
Specifications inherited from overridden method in class AbstractCollection:
       pure
Specifications inherited from overridden method in interface List:
       pure
     also
public normal_behavior
requires this.size() < 2147483647;
assignable \nothing;
ensures \result != null;
ensures \result .length == this.size();
ensures ( \forall int i; 0 <= i&&i < this.size(); \result [i].equals(this.theList.get(i)));
Specifications inherited from overridden method in interface Collection:
       pure non_null
public normal_behavior
requires this.size() < 2147483647;
assignable \nothing;
ensures \result != null;
ensures this.containsNull||\nonnullelements(\result );
ensures \result .length == this.size();
     also
public normal_behavior
ensures ( \forall int i; 0 <= i&&i < this.size(); this.theCollection.count(\result [i]) == org.jmlspecs.models.JMLArrayOps.valueEqualsCount(\result ,\result [i]));

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface List
Overrides:
toArray in class AbstractCollection
Specifications inherited from overridden method in class AbstractCollection:
      --- None ---
Specifications inherited from overridden method toArray(Object[] a) in interface List:
     also
public normal_behavior
old int colSize = this.theCollection.int_size();
old int arrSize = a.length;
requires a != null&&colSize < 2147483647;
requires this.elementType <: \elemtype(\typeof(a));
requires ( \forall java.lang.Object o; this.contains(o); \typeof(o) <: \elemtype(\typeof(a)));
{|
requires colSize <= arrSize;
assignable a[*];
ensures \result == a;
ensures ( \forall int k; 0 <= k&&k < colSize; this.theList.get(k) == \result [k]);
ensures ( \forall int i; colSize <= i&&i < arrSize; \result [i] == null);
also
requires colSize > arrSize;
assignable \nothing;
ensures \fresh(\result )&&\result .length == colSize;
ensures ( \forall int k; 0 <= k&&k < colSize; this.theList.get(k) == \result [k]);
|}
Specifications inherited from overridden method toArray(Object[] a) in interface Collection:
       non_null
public normal_behavior
old int colSize = this.theCollection.int_size();
old int arrSize = a.length;
requires a != null&&colSize < 2147483647;
requires this.elementType <: \elemtype(\typeof(a));
requires ( \forall java.lang.Object o; this.contains(o); \typeof(o) <: \elemtype(\typeof(a)));
{|
requires colSize <= arrSize;
assignable a[*];
ensures \result == a;
ensures ( \forall int k; 0 <= k&&k < colSize; this.theCollection.count(\result [k]) == org.jmlspecs.models.JMLArrayOps.valueEqualsCount(\result ,\result [k],colSize));
ensures ( \forall int i; colSize <= i&&i < arrSize; \result [i] == null);
ensures_redundantly \typeof(\result ) == \typeof(a);
also
requires colSize > arrSize;
assignable \nothing;
ensures \fresh(\result )&&\result .length == colSize;
ensures ( \forall int k; 0 <= k&&k < colSize; this.theCollection.count(\result [k]) == org.jmlspecs.models.JMLArrayOps.valueEqualsCount(\result ,\result [k],colSize));
ensures ( \forall int k; 0 <= k&&k < colSize; \result [k] == null||\typeof(\result [k]) <: \elemtype(\typeof(\result )));
ensures \typeof(\result ) == \typeof(a);
|}
     also
public exceptional_behavior
requires a == null;
assignable \nothing;
signals_only java.lang.NullPointerException;
     also
public behavior
requires a != null;
requires !( \forall java.lang.Object o; o != null&&this.contains(o); \typeof(o) <: \elemtype(\typeof(a)));
assignable a[*];
signals_only java.lang.ArrayStoreException;

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.