Package eu.bandm.tools.ops
Class RtArraySet2<D>
java.lang.Object
java.util.AbstractCollection<D>
java.util.AbstractSet<D>
eu.bandm.tools.ops.RtArraySet2<D>
- All Implemented Interfaces:
Iterable<D>,Collection<D>,Set<D>
A set implementation for real-time application.
Based on an array of references.
"Lock-Free" variant of a "Real-Time Array Set".
DISCUSS: not yet clear whether the old dynamic form for "size()" is more efficient, -- it needs one "atomic" variable less. (!?)
ATTENTION: This class restricts the contract of "Iterator": Once "
DISCUSS: not yet clear whether the old dynamic form for "size()" is more efficient, -- it needs one "atomic" variable less. (!?)
ATTENTION: This class restricts the contract of "Iterator": Once "
hasNext()==false" has returned, all following behaviour
is unspecified and further usage forbidden. (The Iterator object will be recycled.)-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanany()Get one arbitrarily chosen element and remove it.intcapacity()voidclear()booleanDelegate directly to superclass.voidApply code to all elements.inthashCode()Delegate directly to superclass.iterator()booleanintsize()ATTENTION however implemented, there is always a race condition between the result of "size()" and the following number of contained elements, unless ADDITIONALLY enclosed in some "critical section", or sim.Methods inherited from class java.util.AbstractSet
removeAllMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
addAll, contains, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
-
Constructor Details
-
RtArraySet2
public RtArraySet2(int capacity) -
RtArraySet2
public RtArraySet2(int capacity, int iterators)
-
-
Method Details
-
equals
Delegate directly to superclass. Only semantics shall be subject to equals(), not the implementation.- Specified by:
equalsin interfaceCollection<D>- Specified by:
equalsin interfaceSet<D>- Overrides:
equalsin classAbstractSet<D>
-
hashCode
public int hashCode()Delegate directly to superclass. @see #equals(Object)- Specified by:
hashCodein interfaceCollection<D>- Specified by:
hashCodein interfaceSet<D>- Overrides:
hashCodein classAbstractSet<D>
-
add
- Specified by:
addin interfaceCollection<D>- Specified by:
addin interfaceSet<D>- Overrides:
addin classAbstractCollection<D>
-
capacity
public int capacity() -
size
public int size()ATTENTION however implemented, there is always a race condition between the result of "size()" and the following number of contained elements, unless ADDITIONALLY enclosed in some "critical section", or sim.- Specified by:
sizein interfaceCollection<D>- Specified by:
sizein interfaceSet<D>- Specified by:
sizein classAbstractCollection<D>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<D>- Specified by:
clearin interfaceSet<D>- Overrides:
clearin classAbstractCollection<D>
-
iterator
-
remove
- Specified by:
removein interfaceCollection<D>- Specified by:
removein interfaceSet<D>- Overrides:
removein classAbstractCollection<D>
-
any
Get one arbitrarily chosen element and remove it.
(This is an dditional method not in the "java.util.Set" interface.) -
forEach
Apply code to all elements.
-