|
JADE v6.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.dautelle.realtime.RealtimeObject
com.dautelle.util.FastSet
This class represents a Set
backed by a FastMap
instance.
Instances of this class can directly be allocated from the current
thread stack using the newInstance(int)
factory method
(e.g. for throw-away set to avoid the creation cost).
FastSet
has a predictable iteration order, which is the order
in which the element were added to the set. The set iterator
is also real-time compliant (allocated on the stack when running
in a pool context).
Nested Class Summary |
Nested classes inherited from class com.dautelle.realtime.RealtimeObject |
RealtimeObject.Factory |
Constructor Summary | |
FastSet()
Creates a FastSet with a default capacity. |
|
FastSet(int capacity)
Creates a FastSet with the specified capacity. |
|
FastSet(java.util.Set set)
Creates a FastSet , copy of the specified Set . |
Method Summary | |
boolean |
add(java.lang.Object o)
Adds the specified element to this set if it is not already present. |
boolean |
addAll(java.util.Collection c)
Adds all of the elements in the specified collection to this set if they're not already present. |
void |
clear()
Removes all of the elements from this set. |
java.lang.Object |
clone()
Returns a shallow copy of this FastSet . |
boolean |
contains(java.lang.Object o)
Returns true if this set contains the specified element. |
boolean |
containsAll(java.util.Collection c)
Returns true if this set contains all of the elements of the
specified collection. |
boolean |
equals(java.lang.Object obj)
Compares the specified object with this FastSet for equality. |
java.lang.Object |
export()
Exports this object out of the current pool context. |
int |
hashCode()
Returns the hash code value for this FastSet . |
boolean |
isEmpty()
Returns true if this set contains no elements. |
java.util.Iterator |
iterator()
Returns an iterator over the elements in this set (allocated from the "stack" when executing in a PoolContext ). |
static FastSet |
newInstance(int capacity)
Returns a FastSet allocated from the current
stack (or the heap if not in a pool context). |
boolean |
remove(java.lang.Object o)
Removes the specified element from this set if it is present. |
boolean |
removeAll(java.util.Collection c)
Removes from this set all of its elements that are contained in the specified collection. |
boolean |
retainAll(java.util.Collection c)
Retains only the elements in this set that are contained in the specified collection. |
int |
size()
Returns the number of elements in this set (its cardinality). |
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this set. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. |
java.lang.Object |
toHeap()
Moves this object to the heap. |
java.lang.String |
toString()
Returns a String representation of this set. |
Methods inherited from class com.dautelle.realtime.RealtimeObject |
isLocalObject, isPoolObject, recycle |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public FastSet()
FastSet
with a default capacity.
public FastSet(java.util.Set set)
FastSet
, copy of the specified Set
.
The newly created set has a capacity set to the specified set's size.
The copy has the same order as the original, regardless of the original
set's implementation.
set
- the set whose elements are to be placed in this set.public FastSet(int capacity)
FastSet
with the specified capacity. Unless the
capacity is exceeded, operations on this set do not allocate memory.
For optimum performance, the capacity should be of the same order
of magnitude or larger than the expected set's size.
capacity
- the initial capacity of the backing map.Method Detail |
public static FastSet newInstance(int capacity)
FastSet
allocated from the current
stack (or the heap if not in a pool context).
capacity
- the minimum capacity for the set to return.
public int size()
size
in interface java.util.Set
public boolean isEmpty()
true
if this set contains no elements.
isEmpty
in interface java.util.Set
true
if this set contains no elements.public boolean contains(java.lang.Object o)
true
if this set contains the specified element.
contains
in interface java.util.Set
o
- element whose presence in this set is to be tested.
true
if this set contains the specified element.public java.util.Iterator iterator()
PoolContext
).
The elements are returned in is the order in which they were inserted
into the map.
iterator
in interface java.util.Set
public boolean add(java.lang.Object o)
add
in interface java.util.Set
o
- element to be added to this set.
true
if this set did not already contain the
specified element.public boolean remove(java.lang.Object o)
remove
in interface java.util.Set
o
- object to be removed from this set, if present.
public void clear()
clear
in interface java.util.Set
public java.lang.Object clone()
FastSet
. The keys and
the values themselves are not cloned but moved to the heap as well.
clone
in class RealtimeObject
public boolean equals(java.lang.Object obj)
FastSet
for equality.
Returns true
if the given object is also a set and the two
set represent the collection (regardless of collection iteration
order).
equals
in interface java.util.Set
obj
- the object to be compared for equality with this set.
true
if the specified object is equal to this set;
false
otherwise.public int hashCode()
FastSet
.
hashCode
in interface java.util.Set
public boolean addAll(java.util.Collection c)
addAll
in interface java.util.Set
c
- collection whose elements are to be added to this set.
true
if this set changed as a result of the call.public boolean containsAll(java.util.Collection c)
true
if this set contains all of the elements of the
specified collection. If the specified collection is also a set, this
method returns true
if it is a subset of this set.
containsAll
in interface java.util.Set
c
- collection to be checked for containment in this set.
true
if this set contains all of the elements of the
specified collection.public boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Set
c
- collection that defines which elements will be removed from
this set.
true
if this set changed as a result of the call.public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Set
c
- collection that defines which elements this set will retain.
true
if this collection changed as a result of the
call.public java.lang.Object[] toArray()
toArray
in interface java.util.Set
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Set
a
- the array into which the elements of this set are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
public java.lang.String toString()
String
representation of this set.
public java.lang.Object export()
Realtime
Realtime
members are exported as well (recursion).
This method affects only objects belonging to the current pool context.
To avoid pool depletion, a "free" object from the outer pool
is moved to replace the object being exported.
export
in interface Realtime
export
in class RealtimeObject
public java.lang.Object toHeap()
Realtime
Realtime
members are moved to the heap as well (recursion).
This method affects only objects belonging to a pool context
(current or not).
toHeap
in interface Realtime
toHeap
in class RealtimeObject
|
JADE v6.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |