java.util
Class TreeSet
java.lang.Object
java.util.AbstractCollection
java.util.AbstractSet
java.util.TreeSet
- All Implemented Interfaces:
- Cloneable, Collection, Serializable, Set, SortedSet
- public class TreeSet
- extends AbstractSet
- implements SortedSet, Cloneable, Serializable
JML's specification of java.util.TreeSet.
- Version:
- $Revision: 1.11 $
- Author:
- Katie Becker, Gary T. Leavens
Specifications inherited from class Object |
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT;
public represents _getClass <- \typeof(this); |
Specifications inherited from interface Set |
instance public represents theCollection <- this.theSet.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 fields inherited from interface java.util.Set |
theSet |
TreeSet
public TreeSet()
- Specifications:
-
public normal_behavior
assignable theSet;
ensures this.theSet != null&&this.theSet.isEmpty();
TreeSet
public TreeSet(Comparator c)
- Specifications:
-
public normal_behavior
assignable theSet;
ensures this.theSet != null&&this.theSet.isEmpty();
TreeSet
public TreeSet(Collection c)
- Specifications:
-
public normal_behavior
assignable theSet;
ensures this.theSet != null&&this.theSet.equals(org.jmlspecs.models.JMLEqualsSet.convertFrom(c));
TreeSet
public TreeSet(SortedSet s)
- Specifications:
-
public normal_behavior
requires s != null;
assignable theSet;
ensures this.theSet != null&&this.theSet.equals(s.theSet);
- also
-
public exceptional_behavior
requires s == null;
assignable theSet;
signals_only java.lang.NullPointerException;
iterator
public Iterator iterator()
- Specified by:
iterator
in interface Set
- Specifications: pure
- Specifications inherited from overridden method in class AbstractCollection:
pure- Specifications inherited from overridden method in interface Set:
pure- Specifications inherited from overridden method in interface Collection:
pure non_null -
public normal_behavior
assignable \nothing;
ensures \result != null;
ensures \result .elementType == this.elementType;
ensures this.containsNull == \result .returnsNull;
- also
-
public normal_behavior
ensures ( \forall int i; 0 <= i&&i < this.size(); this.theCollection.has(\result .nthNextElement(i)));
ensures ( \forall java.lang.Object o; ; this.theCollection.has(o) ==> ( \exists int i; 0 <= i&&i < this.size(); o.equals(\result .nthNextElement(i))));
ensures this.size() > 0 ==> \result .hasNext((int)(this.size()-1));
ensures !\result .hasNext((int)(this.size()));
ensures_redundantly ( \forall int i; 0 <= i&&i < this.size(); this.contains(\result .nthNextElement(i)));
ensures_redundantly this.size() != 0 ==> \result .moreElements;
size
public int size()
- Specified by:
size
in interface Set
- Specifications: pure
- Specifications inherited from overridden method in class AbstractCollection:
pure- Specifications inherited from overridden method in interface Set:
pure- Specifications inherited from overridden method in interface Collection:
pure -
public normal_behavior
assignable \nothing;
ensures \result == this.theCollection.int_size();
ensures \result >= 0;
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface Set
- Overrides:
isEmpty
in class AbstractCollection
- Specifications: pure
- Specifications inherited from overridden method in class AbstractCollection:
pure- Specifications inherited from overridden method in interface Set:
pure- Specifications inherited from overridden method in interface Collection:
pure -
public normal_behavior
assignable \nothing;
ensures \result <==> this.theCollection.isEmpty();
- also
-
public normal_behavior
ensures \result == (this.size() == 0);
contains
public boolean contains(nullable Object o)
- Specified by:
contains
in interface Set
- Overrides:
contains
in class AbstractCollection
- Specifications: pure
- Specifications inherited from overridden method in class AbstractCollection:
pure- Specifications inherited from overridden method in interface Set:
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;
add
public boolean add(nullable Object o)
- Specified by:
add
in interface Set
- Overrides:
add
in class AbstractCollection
- Specifications inherited from overridden method in class AbstractCollection:
--- None ---
- Specifications inherited from overridden method add(Object o) in interface Set:
- also
-
public behavior
assignable theCollection;
ensures \result <==> !\old(this.theSet.has(o));
ensures this.theSet.equals(\old(this.theSet.insert(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 Set
- Overrides:
remove
in class AbstractCollection
- Specifications inherited from overridden method in class AbstractCollection:
--- None ---
- Specifications inherited from overridden method remove(Object o) in interface Set:
- implies_that
-
public behavior
assignable theCollection;
assignable_redundantly theSet;
ensures !this.theSet.has(o);
ensures_redundantly !this.theCollection.has(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 *);
clear
public void clear()
- Specified by:
clear
in interface Set
- Overrides:
clear
in class AbstractCollection
- Specifications inherited from overridden method in class AbstractCollection:
--- None ---
- Specifications inherited from overridden method in interface Set:
--- 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 *);
addAll
public boolean addAll(Collection c)
- Specified by:
addAll
in interface Set
- Overrides:
addAll
in class AbstractCollection
- Specifications inherited from overridden method in class AbstractCollection:
--- None ---
- Specifications inherited from overridden method addAll(Collection c) in interface Set:
- also
-
public behavior
assignable theCollection;
ensures this.theSet.equals(\old(this.theSet).union(org.jmlspecs.models.JMLEqualsSet.convertFrom(c)))&&(\result ==> !this.theSet.equals(\old(this.theSet)));
- 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;
subSet
public SortedSet subSet(Object fromElement,
Object toElement)
- Specified by:
subSet
in interface SortedSet
- Specifications: (inherited)pure
- Specifications inherited from overridden method subSet(Object fromElement, Object toElement) in interface SortedSet:
(class)pure -
public behavior
ensures \result != null;
signals_only java.lang.ClassCastException, java.lang.IllegalArgumentException, java.lang.NullPointerException;
signals (java.lang.ClassCastException) (* \typeof(fromElement) or \typeof(toElement) is incompatible with this set's comparator *);
signals (java.lang.IllegalArgumentException) (* fromElement > toElement || fromElement or toElement is not within the domain of the SortedSet *);
signals (java.lang.NullPointerException) (fromElement == null||toElement == null)&&!this.containsNull;
headSet
public SortedSet headSet(Object toElement)
- Specified by:
headSet
in interface SortedSet
- Specifications: (inherited)pure
- Specifications inherited from overridden method headSet(Object toElement) in interface SortedSet:
(class)pure -
public behavior
ensures (\result .firstElement.equals(this.firstElement));
ensures \result != null;
signals_only java.lang.ClassCastException, java.lang.IllegalArgumentException, java.lang.NullPointerException;
signals (java.lang.ClassCastException) (* \typeof(toElement) is incompatible with with this set's comparator *);
signals (java.lang.IllegalArgumentException) (* toElement is not within the domain of the SortedSet *);
signals (java.lang.NullPointerException) toElement == null&&!this.containsNull;
tailSet
public SortedSet tailSet(Object fromElement)
- Specified by:
tailSet
in interface SortedSet
- Specifications: (inherited)pure
- Specifications inherited from overridden method tailSet(Object fromElement) in interface SortedSet:
(class)pure -
public behavior
ensures \result != null;
signals_only java.lang.ClassCastException, java.lang.IllegalArgumentException, java.lang.NullPointerException;
signals (java.lang.ClassCastException) (* \typeof(fromElement) is incompatible with this set's comparator *);
signals (java.lang.IllegalArgumentException) (* fromKey is not within the domain of the SortedSet *);
signals (java.lang.NullPointerException) fromElement == null&&!this.containsNull;
comparator
public Comparator comparator()
- Specified by:
comparator
in interface SortedSet
- Specifications: (inherited)pure
- Specifications inherited from overridden method in interface SortedSet:
pure -
public normal_behavior
ensures true;
first
public Object first()
- Specified by:
first
in interface SortedSet
- Specifications: (inherited)pure
- Specifications inherited from overridden method in interface SortedSet:
(class)pure -
public behavior
ensures \result .equals(this.firstElement);
signals_only java.util.NoSuchElementException;
signals (java.util.NoSuchElementException) this.theSet.isEmpty();
last
public Object last()
- Specified by:
last
in interface SortedSet
- Specifications: (inherited)pure
- Specifications inherited from overridden method in interface SortedSet:
(class)pure -
public behavior
ensures \result .equals(this.lastElement);
signals_only java.util.NoSuchElementException;
signals (java.util.NoSuchElementException) this.theSet.isEmpty();
clone
public Object clone()
- Overrides:
clone
in class Object
- Specifications: pure
- also
-
public normal_behavior
ensures \result instanceof java.util.TreeSet&&\fresh(\result )&&((java.util.TreeSet)\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]);
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.