Class NonBlockingSetInt

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<Integer>
zombie.core.Collections.NonBlockingSetInt
All Implemented Interfaces:
Serializable, Iterable<Integer>, Collection<Integer>, Set<Integer>

public class NonBlockingSetInt extends AbstractSet<Integer> implements Serializable
A multi-threaded bit-vector set, implemented as an array of primitive longs. All operations are non-blocking and multi-threaded safe. contains(int) calls are roughly the same speed as a {load, mask} sequence. add(int) and remove(int) calls are a tad more expensive than a {load, mask, store} sequence because they must use a CAS. The bit-vector is auto-sizing.

General note of caution: The Set API allows the use of Integer with silent autoboxing - which can be very expensive if many calls are being made. Since autoboxing is silent you may not be aware that this is going on. The built-in API takes lower-case ints and is much more efficient.

Space: space is used in proportion to the largest element, as opposed to the number of elements (as is the case with hash-table based Set implementations). Space is approximately (largest_element/8 + 64) bytes. The implementation is a simple bit-vector using CAS for update.

Since:
1.5
See Also: