Javolution 6.0.0 java
javolution.util.FastBitSet Class Reference
Inheritance diagram for javolution.util.FastBitSet:
[legend]
Collaboration diagram for javolution.util.FastBitSet:
[legend]

Public Member Functions

 FastBitSet ()
 
FastBitSet unmodifiable ()
 
FastBitSet shared ()
 
void and (FastBitSet that)
 
void andNot (FastBitSet that)
 
int cardinality ()
 
void clear ()
 
void clear (int bitIndex)
 
void clear (int fromIndex, int toIndex)
 
void flip (int bitIndex)
 
void flip (int fromIndex, int toIndex)
 
boolean get (int bitIndex)
 
FastBitSet get (int fromIndex, int toIndex)
 
boolean intersects (FastBitSet that)
 
int length ()
 
int nextClearBit (int fromIndex)
 
int nextSetBit (int fromIndex)
 
int previousClearBit (int fromIndex)
 
int previousSetBit (int fromIndex)
 
void or (FastBitSet that)
 
void set (int bitIndex)
 
void set (int bitIndex, boolean value)
 
void set (int fromIndex, int toIndex)
 
void set (int fromIndex, int toIndex, boolean value)
 
void xor (FastBitSet that)
 
FastBitSet addAll (Index... elements)
 
FastBitSet addAll (FastCollection<? extends Index > elements)
 
FastSet< E > atomic ()
 
FastSet< E > filtered (final Predicate<? super E > filter)
 
boolean isEmpty ()
 
int size ()
 
boolean contains (Object obj)
 
boolean remove (Object obj)
 
FastSet< E > addAll (E... elements)
 
FastSet< E > addAll (FastCollection<? extends E > that)
 

Protected Member Functions

 FastBitSet (BitSetService impl)
 
BitSetService service ()
 

Private Attributes

final BitSetService service
 

Static Private Attributes

static final long serialVersionUID = 0x600L
 

Detailed Description

A high-performance bitset with real-time behavior.

This class is integrated with the collection framework as a set of indices and obeys the collection semantic for methods such as size (cardinality) or equals (same set of indices).

Author
Jean-Marie Dautelle
Version
6.0, July 21, 2013

Definition at line 27 of file FastBitSet.java.

Constructor & Destructor Documentation

◆ FastBitSet() [1/2]

javolution.util.FastBitSet.FastBitSet ( )

Creates an empty bit set.

Definition at line 39 of file FastBitSet.java.

39  {
40  service = new BitSetServiceImpl();
41  }

References javolution.util.FastBitSet.service.

Referenced by javolution.util.FastBitSet.get().

Here is the caller graph for this function:

◆ FastBitSet() [2/2]

javolution.util.FastBitSet.FastBitSet ( BitSetService  impl)
protected

Creates a fast bit set based on the specified implementation.

Definition at line 46 of file FastBitSet.java.

46  {
47  this.service = impl;
48  }

Member Function Documentation

◆ addAll() [1/4]

FastSet<E> javolution.util.FastSet< E >.addAll ( E...  elements)
inherited

Returns this collection with the specified element added.

Parameters
elementsthe elements to be added.
Returns
this

Definition at line 133 of file FastSet.java.

133  {
134  return (FastSet<E>) super.addAll(elements);
135  }

◆ addAll() [2/4]

FastSet<E> javolution.util.FastSet< E >.addAll ( FastCollection<? extends E >  that)
inherited

Returns this collection with the specified collection's elements added in sequence.

Definition at line 138 of file FastSet.java.

138  {
139  return (FastSet<E>) super.addAll(that);
140  }

◆ addAll() [3/4]

FastBitSet javolution.util.FastBitSet.addAll ( FastCollection<? extends Index elements)

Definition at line 352 of file FastBitSet.java.

352  {
353  return (FastBitSet) super.addAll(elements);
354  }

References javolution.util.FastBitSet.addAll().

Here is the call graph for this function:

◆ addAll() [4/4]

FastBitSet javolution.util.FastBitSet.addAll ( Index...  elements)

Definition at line 347 of file FastBitSet.java.

347  {
348  return (FastBitSet) super.addAll(elements);
349  }

References javolution.util.FastBitSet.addAll().

Referenced by javolution.util.FastBitSet.addAll().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ and()

void javolution.util.FastBitSet.and ( FastBitSet  that)

Performs the logical AND operation on this bit set and the given bit set. This means it builds the intersection of the two sets. The result is stored into this bit set.

Parameters
thatthe second bit set.

Definition at line 76 of file FastBitSet.java.

76  {
77  service.and(that.service);
78  }

References javolution.util.service.BitSetService.and(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ andNot()

void javolution.util.FastBitSet.andNot ( FastBitSet  that)

Performs the logical AND operation on this bit set and the complement of the given bit set. This means it selects every element in the first set, that isn't in the second set. The result is stored into this bit set.

Parameters
thatthe second bit set

Definition at line 89 of file FastBitSet.java.

89  {
90  service.andNot(that.service);
91  }

References javolution.util.service.BitSetService.andNot(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ atomic()

FastSet<E> javolution.util.FastSet< E >.atomic
inherited

Returns an atomic view over this collection. All operations that write or access multiple elements in the collection (such as addAll(), retainAll()) are atomic. Iterators on atomic collections are thread-safe (no ConcurrentModificationException possible).

Definition at line 75 of file FastSet.java.

75  {
76  return new FastSet<E>(new AtomicSetImpl<E>(service()));
77  }

◆ cardinality()

int javolution.util.FastBitSet.cardinality ( )

Returns the number of bits set to

true

(or the size of this set).

Returns
the number of bits being set.

Definition at line 99 of file FastBitSet.java.

99  {
100  return service.cardinality();
101  }

References javolution.util.service.BitSetService.cardinality(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ clear() [1/3]

void javolution.util.FastBitSet.clear ( )

Sets all bits in the set to

false

(empty the set).

Definition at line 107 of file FastBitSet.java.

107  {
108  service.clear();
109  }

References javolution.util.service.BitSetService.clear(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ clear() [2/3]

void javolution.util.FastBitSet.clear ( int  bitIndex)

Removes the specified integer value from this set. That is the corresponding bit is cleared.

Parameters
bitIndexa non-negative integer.
Exceptions
IndexOutOfBoundsExceptionif
index < 0

Definition at line 118 of file FastBitSet.java.

118  {
119  service.clear(bitIndex);
120  }

References javolution.util.service.BitSetService.clear(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ clear() [3/3]

void javolution.util.FastBitSet.clear ( int  fromIndex,
int  toIndex 
)

Sets the bits from the specified

fromIndex

(inclusive) to the specified

toIndex

(exclusive) to

false

.

Parameters
fromIndexindex of the first bit to be cleared.
toIndexindex after the last bit to be cleared.
Exceptions
IndexOutOfBoundsExceptionif
(fromIndex < 0) | (toIndex < fromIndex)

Definition at line 132 of file FastBitSet.java.

132  {
133  service.clear(fromIndex, toIndex);
134  }

References javolution.util.service.BitSetService.clear(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ contains()

boolean javolution.util.FastSet< E >.contains ( Object  obj)
inherited

Indicates if this collection contains the specified element.

Definition at line 118 of file FastSet.java.

118  {
119  return service.contains(obj);
120  }

◆ filtered()

FastSet<E> javolution.util.FastSet< E >.filtered ( final Predicate<? super E >  filter)
inherited

Returns a view exposing only the elements matching the specified filter. Adding elements not matching the specified filter has no effect. If this collection is initially empty, using a filtered view to add new elements ensure that this collection has only elements satisfying the filter predicate.

Definition at line 80 of file FastSet.java.

80  {
81  return new FastSet<E>(new FilteredSetImpl<E>(service(), filter));
82  }

◆ flip() [1/2]

void javolution.util.FastBitSet.flip ( int  bitIndex)

Sets the bit at the index to the opposite value.

Parameters
bitIndexthe index of the bit.
Exceptions
IndexOutOfBoundsExceptionif
bitIndex < 0

Definition at line 142 of file FastBitSet.java.

142  {
143  service.flip(bitIndex);
144  }

References javolution.util.service.BitSetService.flip(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ flip() [2/2]

void javolution.util.FastBitSet.flip ( int  fromIndex,
int  toIndex 
)

Sets a range of bits to the opposite value.

Parameters
fromIndexthe low index (inclusive).
toIndexthe high index (exclusive).
Exceptions
IndexOutOfBoundsExceptionif
(fromIndex < 0) | (toIndex < fromIndex)

Definition at line 155 of file FastBitSet.java.

155  {
156  service.flip(fromIndex, toIndex);
157  }

References javolution.util.service.BitSetService.flip(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ get() [1/2]

boolean javolution.util.FastBitSet.get ( int  bitIndex)

Returns

true

if the specified integer is in this bit set;

false

otherwise.

Parameters
bitIndexa non-negative integer.
Returns
the value of the bit at the specified index.
Exceptions
IndexOutOfBoundsExceptionif
bitIndex < 0

Definition at line 167 of file FastBitSet.java.

167  {
168  return service.get(bitIndex);
169  }

References javolution.util.service.BitSetService.get(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ get() [2/2]

FastBitSet javolution.util.FastBitSet.get ( int  fromIndex,
int  toIndex 
)

Returns a new bit set composed of a range of bits from this one.

Parameters
fromIndexthe low index (inclusive).
toIndexthe high index (exclusive).
Returns
a context allocated bit set instance.
Exceptions
IndexOutOfBoundsExceptionif
(fromIndex < 0) | (toIndex < fromIndex)

Definition at line 181 of file FastBitSet.java.

181  {
182  return new FastBitSet(service.get(fromIndex, toIndex));
183  }

References javolution.util.FastBitSet.FastBitSet(), javolution.util.service.BitSetService.get(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ intersects()

boolean javolution.util.FastBitSet.intersects ( FastBitSet  that)

Returns

true

if this bit set shares at least one common bit with the specified bit set.

Parameters
thatthe bit set to check for intersection
Returns
true
if the sets intersect;
false
otherwise.

Definition at line 193 of file FastBitSet.java.

193  {
194  return service.intersects(that.service);
195  }

References javolution.util.service.BitSetService.intersects(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ isEmpty()

boolean javolution.util.FastSet< E >.isEmpty
inherited

Indicates if this collection is empty.

Definition at line 100 of file FastSet.java.

100  {
101  return size() == 0;
102  }

◆ length()

int javolution.util.FastBitSet.length ( )

Returns the logical number of bits actually used by this bit set. It returns the index of the highest set bit plus one.

Note: This method does not return the number of set bits which is returned by size

Returns
the index of the highest set bit plus one.

Definition at line 206 of file FastBitSet.java.

206  {
207  return service.length();
208  }

References javolution.util.service.BitSetService.length(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ nextClearBit()

int javolution.util.FastBitSet.nextClearBit ( int  fromIndex)

Returns the index of the next

false

bit, from the specified bit (inclusive).

Parameters
fromIndexthe start location.
Returns
the first
false
bit.
Exceptions
IndexOutOfBoundsExceptionif
fromIndex < 0

Definition at line 218 of file FastBitSet.java.

218  {
219  return service.nextClearBit(fromIndex);
220  }

References javolution.util.service.BitSetService.nextClearBit(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ nextSetBit()

int javolution.util.FastBitSet.nextSetBit ( int  fromIndex)

Returns the index of the next

true

bit, from the specified bit (inclusive). If there is none,

-1

is returned. The following code will iterates through the bit set:[code] for (int i=nextSetBit(0); i >= 0; i = nextSetBit(i+1)) { ... }[/code]

Parameters
fromIndexthe start location.
Returns
the first
false
bit.
Exceptions
IndexOutOfBoundsExceptionif
fromIndex < 0

Definition at line 234 of file FastBitSet.java.

234  {
235  return service.nextSetBit(fromIndex);
236  }

References javolution.util.service.BitSetService.nextSetBit(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ or()

void javolution.util.FastBitSet.or ( FastBitSet  that)

Performs the logical OR operation on this bit set and the one specified. In other words, builds the union of the two sets.
The result is stored into this bit set.

Parameters
thatthe second bit set.

Definition at line 274 of file FastBitSet.java.

274  {
275  service.or(that.service);
276  }

References javolution.util.service.BitSetService.or(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ previousClearBit()

int javolution.util.FastBitSet.previousClearBit ( int  fromIndex)

Returns the index of the previous

false

bit, from the specified bit (inclusive).

Parameters
fromIndexthe start location.
Returns
the first
false
bit.
Exceptions
IndexOutOfBoundsExceptionif
fromIndex < -1

Definition at line 246 of file FastBitSet.java.

246  {
247  return service.previousClearBit(fromIndex);
248  }

References javolution.util.service.BitSetService.previousClearBit(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ previousSetBit()

int javolution.util.FastBitSet.previousSetBit ( int  fromIndex)

Returns the index of the previous

true

bit, from the specified bit (inclusive). If there is none,

-1

is returned. The following code will iterates through the bit set:[code] for (int i = length(); (i = previousSetBit(i-1)) >= 0; ) { ... }[/code]

Parameters
fromIndexthe start location.
Returns
the first
false
bit.
Exceptions
IndexOutOfBoundsExceptionif
fromIndex < -1

Definition at line 262 of file FastBitSet.java.

262  {
263  return service.previousSetBit(fromIndex);
264  }

References javolution.util.service.BitSetService.previousSetBit(), and javolution.util.FastBitSet.service.

Here is the call graph for this function:

◆ remove()

boolean javolution.util.FastSet< E >.remove ( Object  obj)
inherited

Removes the specified element from this collection.

Definition at line 124 of file FastSet.java.

124  {
125  return service.remove(obj);
126  }

◆ service()

BitSetService javolution.util.FastBitSet.service ( )
protected

Definition at line 357 of file FastBitSet.java.

357  {
358  return service;
359  }

References javolution.util.FastBitSet.service.

◆ set() [1/4]

void javolution.util.FastBitSet.set ( int  bitIndex)

Adds the specified integer to this set (corresponding bit is set to

true

.

Parameters
bitIndexa non-negative integer.
Exceptions
IndexOutOfBoundsExceptionif
bitIndex < 0

Definition at line 285 of file FastBitSet.java.

285  {
286  service.set(bitIndex);
287  }

References javolution.util.FastBitSet.service, and javolution.util.service.BitSetService.set().

Here is the call graph for this function:

◆ set() [2/4]

void javolution.util.FastBitSet.set ( int  bitIndex,
boolean  value 
)

Sets the bit at the given index to the specified value.

Parameters
bitIndexthe position to set.
valuethe value to set it to.
Exceptions
IndexOutOfBoundsExceptionif
bitIndex < 0

Definition at line 296 of file FastBitSet.java.

296  {
297  service.set(bitIndex, value);
298  }

References javolution.util.FastBitSet.service, and javolution.util.service.BitSetService.set().

Here is the call graph for this function:

◆ set() [3/4]

void javolution.util.FastBitSet.set ( int  fromIndex,
int  toIndex 
)

Sets the bits from the specified

fromIndex

(inclusive) to the specified

toIndex

(exclusive) to

true

.

Parameters
fromIndexindex of the first bit to be set.
toIndexindex after the last bit to be set.
Exceptions
IndexOutOfBoundsExceptionif
(fromIndex < 0) | (toIndex < fromIndex)

Definition at line 310 of file FastBitSet.java.

310  {
311  if ((fromIndex < 0) || (toIndex < fromIndex)) throw new IndexOutOfBoundsException();
312  service.set(fromIndex, toIndex);
313  }

References javolution.util.FastBitSet.service, and javolution.util.service.BitSetService.set().

Here is the call graph for this function:

◆ set() [4/4]

void javolution.util.FastBitSet.set ( int  fromIndex,
int  toIndex,
boolean  value 
)

Sets the bits between from (inclusive) and to (exclusive) to the specified value.

Parameters
fromIndexthe start range (inclusive).
toIndexthe end range (exclusive).
valuethe value to set it to.
Exceptions
IndexOutOfBoundsExceptionif
bitIndex < 0

Definition at line 325 of file FastBitSet.java.

325  {
326  service.set(fromIndex, toIndex, value);
327  }

References javolution.util.FastBitSet.service, and javolution.util.service.BitSetService.set().

Here is the call graph for this function:

◆ shared()

FastBitSet javolution.util.FastBitSet.shared ( )

Definition at line 60 of file FastBitSet.java.

60  {
61  throw new UnsupportedOperationException("NOT DONE YET"); // TODO
62  }

◆ size()

int javolution.util.FastSet< E >.size
inherited

Returns the size of this collection.

Definition at line 106 of file FastSet.java.

106  {
107  return service.size();
108  }

◆ unmodifiable()

FastBitSet javolution.util.FastBitSet.unmodifiable ( )

Definition at line 55 of file FastBitSet.java.

55  {
56  throw new UnsupportedOperationException("NOT DONE YET"); // TODO
57  }

◆ xor()

void javolution.util.FastBitSet.xor ( FastBitSet  that)

Performs the logical XOR operation on this bit set and the one specified. In other words, builds the symmetric remainder of the two sets (the elements that are in one set, but not in the other).
The result is stored into this bit set.

Parameters
thatthe second bit set.

Definition at line 338 of file FastBitSet.java.

338  {
339  service.xor(that.service);
340  }

References javolution.util.FastBitSet.service, and javolution.util.service.BitSetService.xor().

Here is the call graph for this function:

Member Data Documentation

◆ serialVersionUID

final long javolution.util.FastBitSet.serialVersionUID = 0x600L
staticprivate

Definition at line 29 of file FastBitSet.java.

◆ service


The documentation for this class was generated from the following file:
javolution.util.service.BitSetService.previousSetBit
int previousSetBit(int fromIndex)
javolution.util.service.BitSetService.cardinality
int cardinality()
javolution.util.service.BitSetService.nextClearBit
int nextClearBit(int fromIndex)
javolution.util.service.BitSetService.get
boolean get(int bitIndex)
javolution.util.FastBitSet.service
final BitSetService service
Definition: FastBitSet.java:34
javolution.util.service.BitSetService.length
int length()
javolution.util.service.BitSetService.and
void and(BitSetService that)
javolution.util.service.BitSetService.set
void set(int bitIndex)
javolution.util.FastBitSet.FastBitSet
FastBitSet()
Definition: FastBitSet.java:39
javolution.util.service.BitSetService.andNot
void andNot(BitSetService that)
javolution.util.service.BitSetService.nextSetBit
int nextSetBit(int fromIndex)
javolution.util.service.BitSetService.or
void or(BitSetService that)
javolution.util.service.BitSetService.flip
void flip(int bitIndex)
javolution.util.service.BitSetService.previousClearBit
int previousClearBit(int fromIndex)
javolution.util.service.BitSetService.clear
void clear(int bitIndex)
javolution.util.FastSet< Index >::size
int size()
Definition: FastSet.java:106
javolution.util.FastSet< Index >::service
final SetService< E > service
Definition: FastSet.java:44
javolution.util.service.BitSetService.intersects
boolean intersects(BitSetService that)
javolution.util.service.BitSetService.xor
void xor(BitSetService that)