public interface Set extends Collection, Rollbackable
e1.equals(e2)
returns false. There
are additional stipulations on add
, equals
and hashCode
, as well as the requirements that constructors
do not permit duplicate elements. The Set interface is incompatible with
List; you cannot implement both simultaneously.
Note: Be careful about using mutable objects in sets. In particular, if a mutable object changes to become equal to another set element, you have violated the contract. As a special case of this, a Set is not allowed to be an element of itself, without risking undefined behavior.
Collection
,
List
,
SortedSet
,
HashSet
,
TreeSet
,
LinkedHashSet
,
AbstractSet
,
Collections.singleton(Object)
,
Collections.EMPTY_SET
Modifier and Type | Method and Description |
---|---|
void |
$COMMIT(long timestamp)
Commit changes up to the given timestamp, but not including changes
made at timestamp and afterward.
|
Checkpoint |
$GET$CHECKPOINT()
Get the checkpoint object that monitors this rollbackable object.
|
void |
$RESTORE(long timestamp,
boolean trim)
Restore a previous state to all the private fields of this rollbackable
object.
|
java.lang.Object |
$SET$CHECKPOINT(Checkpoint checkpoint)
Set the checkpoint object of this rollbackable object.
|
boolean |
add(java.lang.Object o)
Adds the specified element to the set if it is not already present
(optional operation).
|
boolean |
addAll(Collection c)
Adds all of the elements of the given collection to this set (optional
operation).
|
void |
clear()
Removes all elements from this set (optional operation).
|
boolean |
contains(java.lang.Object o)
Returns true if the set contains the specified element.
|
boolean |
containsAll(Collection c)
Returns true if this set contains all elements in the specified
collection.
|
boolean |
equals(java.lang.Object o)
Compares the specified object to this for equality.
|
int |
hashCode()
Returns the hash code for this set.
|
boolean |
isEmpty()
Returns true if the set contains no elements.
|
java.util.Iterator |
iterator()
Returns an iterator over the set.
|
boolean |
remove(java.lang.Object o)
Removes the specified element from this set (optional operation).
|
boolean |
removeAll(Collection c)
Removes from this set all elements contained in the specified collection
(optional operation).
|
boolean |
retainAll(Collection c)
Retains only the elements in this set that are also in the specified
collection (optional operation).
|
int |
size()
Returns the number of elements in the set.
|
java.lang.Object[] |
toArray()
Returns an array containing the elements of this set.
|
java.lang.Object[] |
toArray(java.lang.Object[] a)
Returns an array containing the elements of this set, of the same runtime
type of the argument.
|
boolean add(java.lang.Object o)
o == null ? e == null : o.equals(e)
. Sets need not permit
all values, and may document what exceptions will be thrown if
a value is not permitted.add
in interface Collection
o
- the object to addjava.lang.UnsupportedOperationException
- if this operation is not allowedjava.lang.ClassCastException
- if the class of o prevents it from being addedjava.lang.IllegalArgumentException
- if some aspect of o prevents it from
being addedjava.lang.NullPointerException
- if null is not permitted in this setboolean addAll(Collection c)
addAll
in interface Collection
c
- the collection to addjava.lang.UnsupportedOperationException
- if this operation is not allowedjava.lang.ClassCastException
- if the class of an element prevents it from
being addedjava.lang.IllegalArgumentException
- if something about an element prevents
it from being addedjava.lang.NullPointerException
- if null is not permitted in this set, or
if the argument c is nulladd(Object)
void clear()
clear
in interface Collection
java.lang.UnsupportedOperationException
- if this operation is not allowedboolean contains(java.lang.Object o)
o == null ? e == null : o.equals(e)
.contains
in interface Collection
o
- the object to look forjava.lang.ClassCastException
- if the type of o is not a valid type
for this set.java.lang.NullPointerException
- if o is null and this set doesn't
support null values.boolean containsAll(Collection c)
containsAll
in interface Collection
c
- the collection to check membership injava.lang.NullPointerException
- if c is nulljava.lang.ClassCastException
- if the type of any element in c is not
a valid type for this set.java.lang.NullPointerException
- if some element of c is null and this
set doesn't support null values.contains(Object)
boolean equals(java.lang.Object o)
equals
in interface Collection
equals
in class java.lang.Object
o
- the object to compare toint hashCode()
hashCode
in interface Collection
hashCode
in class java.lang.Object
equals(Object)
boolean isEmpty()
isEmpty
in interface Collection
java.util.Iterator iterator()
iterator
in interface Collection
boolean remove(java.lang.Object o)
o == null ? e == null : o.equals(e)
,
it is removed from the set.remove
in interface Collection
o
- the object to removejava.lang.UnsupportedOperationException
- if this operation is not allowedjava.lang.ClassCastException
- if the type of o is not a valid type
for this set.java.lang.NullPointerException
- if o is null and this set doesn't allow
the removal of a null value.boolean removeAll(Collection c)
removeAll
in interface Collection
c
- the collection to remove from this setjava.lang.UnsupportedOperationException
- if this operation is not allowedjava.lang.NullPointerException
- if c is nulljava.lang.ClassCastException
- if the type of any element in c is not
a valid type for this set.java.lang.NullPointerException
- if some element of c is null and this
set doesn't support removing null values.remove(Object)
boolean retainAll(Collection c)
retainAll
in interface Collection
c
- the collection to keepjava.lang.UnsupportedOperationException
- if this operation is not allowedjava.lang.NullPointerException
- if c is nulljava.lang.ClassCastException
- if the type of any element in c is not
a valid type for this set.java.lang.NullPointerException
- if some element of c is null and this
set doesn't support retaining null values.remove(Object)
int size()
size
in interface Collection
java.lang.Object[] toArray()
toArray
in interface Collection
toArray(Object[])
java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface Collection
a
- the array to determine the return type; if it is big enough
it is used and returnedjava.lang.ArrayStoreException
- if the runtime type of a is not a supertype
of all elements in the setjava.lang.NullPointerException
- if a is nulltoArray()
void $COMMIT(long timestamp)
Rollbackable
$COMMIT
in interface Collection
$COMMIT
in interface Rollbackable
timestamp
- The timestamp.void $RESTORE(long timestamp, boolean trim)
Rollbackable
$RESTORE
in interface Collection
$RESTORE
in interface Rollbackable
timestamp
- The timestamp taken at the time when the previous
state was recorded.trim
- Whether to delete the records used for the rollback.Checkpoint.rollback(long, boolean)
Checkpoint $GET$CHECKPOINT()
Rollbackable
$GET$CHECKPOINT
in interface Collection
$GET$CHECKPOINT
in interface Rollbackable
java.lang.Object $SET$CHECKPOINT(Checkpoint checkpoint)
Rollbackable
$SET$CHECKPOINT
in interface Collection
$SET$CHECKPOINT
in interface Rollbackable
checkpoint
- The new checkpoint object.Checkpoint.setCheckpoint(Checkpoint)