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

Public Member Functions

 BitSetServiceImpl ()
 
boolean add (Index index)
 
void and (BitSetService that)
 
void andNot (BitSetService that)
 
int cardinality ()
 
void clear ()
 
void clear (int bitIndex)
 
void clear (int fromIndex, int toIndex)
 
Equality<? super Indexcomparator ()
 
boolean contains (Object index)
 
void flip (int bitIndex)
 
void flip (int fromIndex, int toIndex)
 
boolean get (int bitIndex)
 
BitSetServiceImpl get (int fromIndex, int toIndex)
 
boolean getAndSet (int bitIndex, boolean value)
 
boolean intersects (BitSetService that)
 
Iterator< Indexiterator ()
 
int length ()
 
int nextClearBit (int fromIndex)
 
int nextSetBit (int fromIndex)
 
void or (BitSetService that)
 
int previousClearBit (int fromIndex)
 
int previousSetBit (int fromIndex)
 
boolean remove (Object index)
 
void set (int bitIndex)
 
void set (int bitIndex, boolean value)
 
void set (int fromIndex, int toIndex)
 
void set (int fromIndex, int toIndex, boolean value)
 
int size ()
 
long[] toLongArray ()
 
void xor (BitSetService that)
 
SetService< E > threadSafe ()
 
abstract boolean add (E element)
 
boolean addAll (Collection<? extends E > c)
 
FastCollection< E > addAll (E... elements)
 
FastCollection< E > addAll (FastCollection<? extends E > that)
 
CollectionView< E > clone ()
 
boolean containsAll (Collection<?> c)
 
boolean equals (Object o)
 
int hashCode ()
 
boolean isEmpty ()
 
void perform (Consumer< CollectionService< E >> action, CollectionService< E > view)
 
void perform (Consumer<? extends Collection< E >> action)
 
void perform (Consumer< T > action, T part)
 
boolean removeAll (Collection<?> c)
 
boolean retainAll (Collection<?> c)
 
CollectionService< E >[] split (int n)
 
Object[] toArray ()
 
void update (Consumer< CollectionService< E >> action, CollectionService< E > view)
 
void update (Consumer<? extends Collection< E >> action)
 
void update (Consumer< T > action, T part)
 
FastCollection< E > atomic ()
 
FastCollection< E > shared ()
 
FastCollection< E > parallel ()
 
FastCollection< E > sequential ()
 
FastCollection< E > unmodifiable ()
 
FastCollection< E > filtered (Predicate<? super E > filter)
 
FastCollection< E > sorted ()
 
FastCollection< E > sorted (Comparator<? super E > cmp)
 
FastCollection< E > reversed ()
 
FastCollection< E > distinct ()
 
void forEach (final Consumer<? super E > consumer)
 
boolean removeIf (final Predicate<? super E > filter)
 
reduce (Reducer< E > reducer)
 
min ()
 
max ()
 
String toString ()
 
SetService< E > threadSafe ()
 

Protected Member Functions

SetService< E > target ()
 
CollectionService< E > service ()
 

Static Protected Member Functions

static< E > CollectionService< E > serviceOf (FastCollection< E > collection)
 

Package Functions

public< T > T[] toArray (T[] a)
 
public< R > FastCollection< R > mapped (Function<? super E, ? extends R > function)
 
public< T extends E > T any (Class< T > type)
 
public< T extends Collection< E > > Immutable< T > toImmutable ()
 

Private Member Functions

void setLength (int newLength)
 
void trim ()
 

Private Attributes

long[] bits
 

Static Private Attributes

static final long serialVersionUID = 0x600L
 

Detailed Description

A table of indices implemented using packed bits (long[]).

Definition at line 24 of file BitSetServiceImpl.java.

Constructor & Destructor Documentation

◆ BitSetServiceImpl()

javolution.util.internal.bitset.BitSetServiceImpl.BitSetServiceImpl ( )

Creates a bit set (all bits are cleared).

Definition at line 32 of file BitSetServiceImpl.java.

32  {
33  super(null); // Root.
34  bits = new long[0];
35  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

Referenced by javolution.util.internal.bitset.BitSetServiceImpl.get(), javolution.util.internal.bitset.BitSetServiceImpl.or(), and javolution.util.internal.bitset.BitSetServiceImpl.xor().

Here is the caller graph for this function:

Member Function Documentation

◆ add() [1/2]

◆ add() [2/2]

boolean javolution.util.internal.bitset.BitSetServiceImpl.add ( Index  index)

Definition at line 38 of file BitSetServiceImpl.java.

38  {
39  return !getAndSet(index.intValue(), true);
40  }

References javolution.util.internal.bitset.BitSetServiceImpl.getAndSet(), and javolution.util.Index.intValue().

Here is the call graph for this function:

◆ addAll() [1/3]

boolean javolution.util.internal.collection.CollectionView< E >.addAll ( Collection<? extends E >  that)
inherited

Adds all the specified elements to this collection.

Reimplemented from javolution.util.FastCollection< E >.

Reimplemented in javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 46 of file CollectionView.java.

46  {
47  boolean changed = false;
48  Iterator<? extends E> it = c.iterator();
49  while (it.hasNext()) {
50  if (add(it.next())) changed = true;
51  }
52  return changed;
53  }

◆ addAll() [2/3]

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

Returns this collection with the specified element added.

Parameters
elementsthe elements to be added.
Returns
this

Reimplemented in javolution.util.FastTable< E >, javolution.util.FastSortedSet< E >, javolution.util.FastSet< E >, and javolution.util.FastSortedTable< E >.

Definition at line 552 of file FastCollection.java.

552  {
553  for (E e : elements) {
554  add(e);
555  }
556  return this;
557  }

◆ addAll() [3/3]

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

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

Reimplemented in javolution.util.FastTable< E >, javolution.util.FastSortedSet< E >, javolution.util.FastSet< E >, and javolution.util.FastSortedTable< E >.

Definition at line 564 of file FastCollection.java.

564  {
565  addAll((Collection<? extends E>) that);
566  return this;
567  }

◆ and()

void javolution.util.internal.bitset.BitSetServiceImpl.and ( BitSetService  that)

See FastBitSet#and(FastBitSet)

Implements javolution.util.service.BitSetService.

Definition at line 43 of file BitSetServiceImpl.java.

43  {
44  long[] thatBits = that.toLongArray();
45  int n = MathLib.min(this.bits.length, thatBits.length);
46  for (int i = 0; i < n; i++) {
47  this.bits[i] &= thatBits[i];
48  }
49  for (int i = n; i < bits.length; i++) {
50  this.bits[i] = 0L;
51  }
52  trim();
53  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, javolution.lang.MathLib.min(), javolution.util.service.BitSetService.toLongArray(), and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Here is the call graph for this function:

◆ andNot()

void javolution.util.internal.bitset.BitSetServiceImpl.andNot ( BitSetService  that)

See FastBitSet#andNot(FastBitSet)

Implements javolution.util.service.BitSetService.

Definition at line 56 of file BitSetServiceImpl.java.

56  {
57  long[] thatBits = that.toLongArray();
58  int n = MathLib.min(this.bits.length, thatBits.length);
59  for (int i = 0; i < n; i++) {
60  this.bits[i] &= ~thatBits[i];
61  }
62  trim();
63  }

References javolution.lang.MathLib.min(), javolution.util.service.BitSetService.toLongArray(), and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Here is the call graph for this function:

◆ any()

public<T extends E> T javolution.util.FastCollection< E >.any ( Class< T >  type)
packageinherited

Returns any non-null element of the specified type (convenience method).

Parameters
typethe element type searched for.
Returns
reduce(Reducers.any(type))
See also
Reducers::any

Definition at line 515 of file FastCollection.java.

515  {
516  return (T) reduce((Reducer<E>) Reducers.any(type));
517  }

References javolution.util.function.Reducers.any().

Here is the call graph for this function:

◆ atomic()

FastCollection<E> javolution.util.FastCollection< 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).

Reimplemented in javolution.util.FastTable< E >, javolution.util.FastSet< E >, javolution.util.FastSortedTable< E >, and javolution.util.FastSortedSet< E >.

Definition at line 187 of file FastCollection.java.

187  {
188  return new AtomicCollectionImpl<E>(service());
189  }

◆ cardinality()

int javolution.util.internal.bitset.BitSetServiceImpl.cardinality ( )

See FastBitSet#cardinality()

Implements javolution.util.service.BitSetService.

Definition at line 66 of file BitSetServiceImpl.java.

66  {
67  int sum = 0;
68  for (int i = 0; i < bits.length; i++) {
69  sum += MathLib.bitCount(bits[i]);
70  }
71  return sum;
72  }

References javolution.lang.MathLib.bitCount(), and javolution.util.internal.bitset.BitSetServiceImpl.bits.

Referenced by javolution.util.internal.bitset.BitSetServiceImpl.size().

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

◆ clear() [1/3]

void javolution.util.internal.bitset.BitSetServiceImpl.clear ( )

Removes all elements from this collection.

Reimplemented from javolution.util.internal.collection.CollectionView< E >.

Definition at line 75 of file BitSetServiceImpl.java.

75  {
76  bits = new long[0];
77  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

Referenced by javolution.util.internal.bitset.BitSetServiceImpl.get(), and javolution.util.internal.bitset.BitSetServiceImpl.set().

Here is the caller graph for this function:

◆ clear() [2/3]

void javolution.util.internal.bitset.BitSetServiceImpl.clear ( int  bitIndex)

See FastBitSet#clear(int)

Implements javolution.util.service.BitSetService.

Definition at line 80 of file BitSetServiceImpl.java.

80  {
81  int longIndex = bitIndex >> 6;
82  if (longIndex >= bits.length)
83  return;
84  bits[longIndex] &= ~(1L << bitIndex);
85  trim();
86  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Here is the call graph for this function:

◆ clear() [3/3]

void javolution.util.internal.bitset.BitSetServiceImpl.clear ( int  fromIndex,
int  toIndex 
)

See FastBitSet#clear(int, int)

Implements javolution.util.service.BitSetService.

Definition at line 89 of file BitSetServiceImpl.java.

89  {
90  if ((fromIndex < 0) || (toIndex < fromIndex))
91  throw new IndexOutOfBoundsException();
92  int i = fromIndex >>> 6;
93  if (i >= bits.length)
94  return; // Ensures that i < _length
95  int j = toIndex >>> 6;
96  if (i == j) {
97  bits[i] &= ((1L << fromIndex) - 1) | (-1L << toIndex);
98  return;
99  }
100  bits[i] &= (1L << fromIndex) - 1;
101  if (j < bits.length) {
102  bits[j] &= -1L << toIndex;
103  }
104  for (int k = i + 1; (k < j) && (k < bits.length); k++) {
105  bits[k] = 0;
106  }
107  trim();
108  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Here is the call graph for this function:

◆ clone()

Returns a copy of this collection; updates of the copy should not impact the original.

Implements javolution.util.service.CollectionService< E >.

Reimplemented in javolution.util.internal.table.FastTableImpl< E >, javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 66 of file CollectionView.java.

66  {
67  try {
68  CollectionView<E> copy = (CollectionView<E>) super.clone();
69  if (target != null) { // Not a root class.
70  copy.target = target.clone();
71  }
72  return copy;
73  } catch (CloneNotSupportedException e) {
74  throw new Error("Should not happen since target is cloneable");
75  }
76  }

Referenced by javolution.util.internal.collection.CollectionView< R >.clone(), and javolution.util.internal.collection.CollectionView< R >.split().

Here is the caller graph for this function:

◆ comparator()

Equality<? super Index> javolution.util.internal.bitset.BitSetServiceImpl.comparator ( )

Returns the comparator uses by this collection for equality and/or ordering if this collection is sorted.

Reimplemented from javolution.util.internal.collection.CollectionView< E >.

Definition at line 111 of file BitSetServiceImpl.java.

111  {
112  return Equalities.IDENTITY;
113  }

References javolution.util.function.Equalities.IDENTITY.

◆ contains()

boolean javolution.util.internal.bitset.BitSetServiceImpl.contains ( Object  searched)

Indicates if this collection contains the specified element.

Reimplemented from javolution.util.internal.set.SetView< E >.

Definition at line 116 of file BitSetServiceImpl.java.

116  {
117  return get(((Index)index).intValue());
118  }

◆ containsAll()

boolean javolution.util.internal.collection.CollectionView< E >.containsAll ( Collection<?>  that)
inherited

Indicates if this collection contains all the specified elements.

Reimplemented from javolution.util.FastCollection< E >.

Reimplemented in javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 93 of file CollectionView.java.

93  {
94  for (Object e : c) {
95  if (!contains(e)) return false;
96  }
97  return true;
98  }

Referenced by javolution.util.internal.collection.CollectionView< R >.equals().

Here is the caller graph for this function:

◆ distinct()

FastCollection<E> javolution.util.FastCollection< E >.distinct ( )
inherited

Returns a view exposing only distinct elements (it does not iterate twice over the same elements). Adding elements already in the collection through this view has no effect. If this collection is initially empty, using a distinct view to add new elements ensures that this collection has no duplicate.

Definition at line 293 of file FastCollection.java.

293  {
294  return new DistinctCollectionImpl<E>(service());
295  }

◆ equals()

boolean javolution.util.internal.collection.CollectionView< E >.equals ( Object  obj)
inherited

Compares the specified object with this collection for equality. This method follows the Collection#equals(Object) specification if this collection comparator is Equalities#STANDARD (default). Otherwise, only collections using the same comparator can be considered equals.

Parameters
objthe object to be compared for equality with this collection
Returns
true if both collections are considered equals; false otherwise.

Reimplemented from javolution.util.FastCollection< E >.

Reimplemented in javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 102 of file CollectionView.java.

102  {
103  // Follow Collection.equals specification if this comparator is standard.
104  if (this == o) return true;
105  // Check comparators consistency.
106  if (o instanceof CollectionService) {
107  if (!comparator().equals(((CollectionService<E>) o).comparator())) return false; // Different comparators.
108  } else {
109  if (!comparator().equals(Equalities.STANDARD)) return false;
110  }
111  // Collection.equals contract.
112  if (this instanceof Set) {
113  if (!(o instanceof Set)) return false;
114  Set<E> set = (Set<E>) o;
115  return (size() == set.size()) && containsAll(set);
116  } else if (this instanceof List) {
117  if (!(o instanceof List)) return false;
118  List<E> list = (List<E>) o;
119  if (size() != list.size()) return false; // Short-cut.
120  Equality<? super E> cmp = comparator();
121  Iterator<E> it1 = this.iterator();
122  Iterator<E> it2 = list.iterator();
123  while (it1.hasNext()) {
124  if (!it2.hasNext()) return false;
125  if (!cmp.areEqual(it1.next(), it2.next())) return false;
126  }
127  if (it2.hasNext()) return false;
128  return true;
129  } else {
130  return false;
131  }
132  }

Referenced by javolution.util.internal.collection.CollectionView< R >.equals().

Here is the caller graph for this function:

◆ filtered()

FastCollection<E> javolution.util.FastCollection< E >.filtered ( 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.

Reimplemented in javolution.util.FastSet< E >.

Definition at line 250 of file FastCollection.java.

250  {
251  return new FilteredCollectionImpl<E>(service(), filter);
252  }

◆ flip() [1/2]

void javolution.util.internal.bitset.BitSetServiceImpl.flip ( int  bitIndex)

See FastBitSet#flip(int)

Implements javolution.util.service.BitSetService.

Definition at line 121 of file BitSetServiceImpl.java.

121  {
122  int i = bitIndex >> 6;
123  setLength(i + 1);
124  bits[i] ^= 1L << bitIndex;
125  trim();
126  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, javolution.util.internal.bitset.BitSetServiceImpl.setLength(), and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Here is the call graph for this function:

◆ flip() [2/2]

void javolution.util.internal.bitset.BitSetServiceImpl.flip ( int  fromIndex,
int  toIndex 
)

See FastBitSet#flip(int, int)

Implements javolution.util.service.BitSetService.

Definition at line 129 of file BitSetServiceImpl.java.

129  {
130  if ((fromIndex < 0) || (toIndex < fromIndex))
131  throw new IndexOutOfBoundsException();
132  int i = fromIndex >>> 6;
133  int j = toIndex >>> 6;
134  setLength(j + 1);
135  if (i == j) {
136  bits[i] ^= (-1L << fromIndex) & ((1L << toIndex) - 1);
137  return;
138  }
139  bits[i] ^= -1L << fromIndex;
140  bits[j] ^= (1L << toIndex) - 1;
141  for (int k = i + 1; k < j; k++) {
142  bits[k] ^= -1;
143  }
144  trim();
145  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, javolution.util.internal.bitset.BitSetServiceImpl.setLength(), and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Here is the call graph for this function:

◆ forEach()

void javolution.util.FastCollection< E >.forEach ( final Consumer<? super E >  consumer)
inherited

Iterates over all this collection elements applying the specified consumer (convenience method). Iterations are performed concurrently if the collection is parallel.

Parameters
consumerthe functional consumer applied to the collection elements.

Definition at line 346 of file FastCollection.java.

346  {
347  perform(new Consumer<Collection<E>>() {
348  public void accept(Collection<E> view) {
349  Iterator<E> it = view.iterator();
350  while (it.hasNext()) {
351  consumer.accept(it.next());
352  }
353  }
354  });
355  }

References javolution.util.function.Consumer< T >.accept().

Here is the call graph for this function:

◆ get() [1/2]

boolean javolution.util.internal.bitset.BitSetServiceImpl.get ( int  bitIndex)

See FastBitSet#get(int)

Implements javolution.util.service.BitSetService.

Definition at line 148 of file BitSetServiceImpl.java.

148  {
149  int i = bitIndex >> 6;
150  return (i >= bits.length) ? false : (bits[i] & (1L << bitIndex)) != 0;
151  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

◆ get() [2/2]

BitSetServiceImpl javolution.util.internal.bitset.BitSetServiceImpl.get ( int  fromIndex,
int  toIndex 
)

See FastBitSet#get(int, int)

Implements javolution.util.service.BitSetService.

Definition at line 154 of file BitSetServiceImpl.java.

154  {
155  if (fromIndex < 0 || fromIndex > toIndex)
156  throw new IndexOutOfBoundsException();
157  BitSetServiceImpl bitSet = new BitSetServiceImpl();
158  int length = MathLib.min(bits.length, (toIndex >>> 6) + 1);
159  bitSet.bits = new long[length];
160  System.arraycopy(bits, 0, bitSet.bits, 0, length);
161  bitSet.clear(0, fromIndex);
162  bitSet.clear(toIndex, length << 6);
163  return bitSet;
164  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, javolution.util.internal.bitset.BitSetServiceImpl.BitSetServiceImpl(), javolution.util.internal.bitset.BitSetServiceImpl.clear(), javolution.util.internal.bitset.BitSetServiceImpl.length(), and javolution.lang.MathLib.min().

Here is the call graph for this function:

◆ getAndSet()

boolean javolution.util.internal.bitset.BitSetServiceImpl.getAndSet ( int  bitIndex,
boolean  value 
)

Sets the specified bit, returns true if previously set.

Implements javolution.util.service.BitSetService.

Definition at line 168 of file BitSetServiceImpl.java.

168  {
169  int i = bitIndex >> 6;
170  if (i >= bits.length) {
171  setLength(i + 1);
172  }
173  boolean previous = (bits[i] & (1L << bitIndex)) != 0;
174  if (value) {
175  bits[i] |= 1L << bitIndex;
176  } else {
177  bits[i] &= ~(1L << bitIndex);
178  }
179  trim();
180  return previous;
181  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, javolution.util.internal.bitset.BitSetServiceImpl.setLength(), and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Referenced by javolution.util.internal.bitset.BitSetServiceImpl.add(), and javolution.util.internal.bitset.BitSetServiceImpl.remove().

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

◆ hashCode()

int javolution.util.internal.collection.CollectionView< E >.hashCode ( )
inherited

Returns the hash code of this collection. This method follows the Collection#hashCode() specification if this collection comparator is Equalities#STANDARD.

Returns
this collection hash code.

Reimplemented from javolution.util.FastCollection< E >.

Reimplemented in javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 135 of file CollectionView.java.

135  {
136  // Follow Collection.equals specification if this comparator is standard.
137  Equality<? super E> cmp = comparator();
138  Iterator<E> it = this.iterator();
139  int hash = 0;
140  if (this instanceof Set) {
141  while (it.hasNext()) {
142  hash += cmp.hashCodeOf(it.next());
143  }
144  } else if (this instanceof List) {
145  while (it.hasNext()) {
146  hash += 31 * hash + cmp.hashCodeOf(it.next());
147  }
148  } else {
149  hash = super.hashCode();
150  }
151  return hash;
152  }

◆ intersects()

boolean javolution.util.internal.bitset.BitSetServiceImpl.intersects ( BitSetService  that)

See FastBitSet#intersects(FastBitSet)

Implements javolution.util.service.BitSetService.

Definition at line 184 of file BitSetServiceImpl.java.

184  {
185  long[] thatBits = that.toLongArray();
186  int i = MathLib.min(this.bits.length, thatBits.length);
187  while (--i >= 0) {
188  if ((bits[i] & thatBits[i]) != 0) return true;
189  }
190  return false;
191  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, javolution.lang.MathLib.min(), and javolution.util.service.BitSetService.toLongArray().

Here is the call graph for this function:

◆ isEmpty()

◆ iterator()

Iterator<Index> javolution.util.internal.bitset.BitSetServiceImpl.iterator ( )

Returns an iterator over this collection elements. For shared/atomic collections the iterator is immune to concurrent modifications. In other words the elements iterated over may or may not reflect the current state of the collection.

Reimplemented from javolution.util.internal.collection.CollectionView< E >.

Definition at line 194 of file BitSetServiceImpl.java.

194  {
195  return new BitSetIteratorImpl(this, 0);
196  }

◆ length()

int javolution.util.internal.bitset.BitSetServiceImpl.length ( )

See FastBitSet#length()

Implements javolution.util.service.BitSetService.

Definition at line 199 of file BitSetServiceImpl.java.

199  {
200  if (bits.length == 0) return 0;
201  return (bits.length << 6) - MathLib.numberOfLeadingZeros(bits[bits.length -1]);
202  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, and javolution.lang.MathLib.numberOfLeadingZeros().

Referenced by javolution.util.internal.bitset.BitSetServiceImpl.get().

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

◆ mapped()

public<R> FastCollection<R> javolution.util.FastCollection< E >.mapped ( Function<? super E, ? extends R >  function)
packageinherited

Returns a view exposing elements through the specified mapping function. The returned view does not allow new elements to be added.

Definition at line 258 of file FastCollection.java.

259  {
260  return new MappedCollectionImpl<E, R>(service(), function);
261  }

Referenced by javolution.xml.internal.stream.EntitiesImpl.setEntitiesMapping().

Here is the caller graph for this function:

◆ max()

E javolution.util.FastCollection< E >.max ( )
inherited

Returns the largest element of this collection using this collection comparator (convenience method). Returns

null

if this collection is empty.

Returns
reduce(Reducers.max(comparator()))
See also
Reducers::max

Definition at line 541 of file FastCollection.java.

541  {
542  return reduce(Reducers.max(comparator()));
543  }

References javolution.util.function.Reducers.max().

Here is the call graph for this function:

◆ min()

E javolution.util.FastCollection< E >.min ( )
inherited

Returns the smallest element of this collection using this collection comparator (convenience method). Returns

null

if this collection is empty.

Returns
reduce(Reducers.min(comparator()))
See also
Reducers::min

Definition at line 528 of file FastCollection.java.

528  {
529  return reduce(Reducers.min(comparator()));
530  }

References javolution.util.function.Reducers.min().

Here is the call graph for this function:

◆ nextClearBit()

int javolution.util.internal.bitset.BitSetServiceImpl.nextClearBit ( int  fromIndex)

See FastBitSet#nextClearBit(int)

Implements javolution.util.service.BitSetService.

Definition at line 205 of file BitSetServiceImpl.java.

205  {
206  int offset = fromIndex >> 6;
207  long mask = 1L << fromIndex;
208  while (offset < bits.length) {
209  long h = bits[offset];
210  do {
211  if ((h & mask) == 0) { return fromIndex; }
212  mask <<= 1;
213  fromIndex++;
214  } while (mask != 0);
215  mask = 1;
216  offset++;
217  }
218  return fromIndex;
219  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

◆ nextSetBit()

int javolution.util.internal.bitset.BitSetServiceImpl.nextSetBit ( int  fromIndex)

See FastBitSet#nextSetBit(int)

Implements javolution.util.service.BitSetService.

Definition at line 222 of file BitSetServiceImpl.java.

222  {
223  int offset = fromIndex >> 6;
224  long mask = 1L << fromIndex;
225  while (offset < bits.length) {
226  long h = bits[offset];
227  do {
228  if ((h & mask) != 0)
229  return fromIndex;
230  mask <<= 1;
231  fromIndex++;
232  } while (mask != 0);
233  mask = 1;
234  offset++;
235  }
236  return -1;
237  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

◆ or()

void javolution.util.internal.bitset.BitSetServiceImpl.or ( BitSetService  that)

See FastBitSet#or(FastBitSet)

Implements javolution.util.service.BitSetService.

Definition at line 240 of file BitSetServiceImpl.java.

240  {
241  long[] thatBits = (that instanceof BitSetServiceImpl) ? ((BitSetServiceImpl) that).bits
242  : that.toLongArray();
243  if (thatBits.length > this.bits.length) {
244  setLength(thatBits.length);
245  }
246  for (int i = thatBits.length; --i >= 0;) {
247  bits[i] |= thatBits[i];
248  }
249  trim();
250  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, javolution.util.internal.bitset.BitSetServiceImpl.BitSetServiceImpl(), javolution.util.internal.bitset.BitSetServiceImpl.setLength(), javolution.util.service.BitSetService.toLongArray(), and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Here is the call graph for this function:

◆ parallel()

FastCollection<E> javolution.util.FastCollection< E >.parallel ( )
inherited

Returns a parallel collection. Parallel collections affect only closure-based operations, all others operations behaving the same. Parallel actions are performed concurrently using Javolution ConcurrentContext. The number of parallel views is derived from the context concurrency (

number of parallel views = concurrency + 1

). Parallel views do not require this collection to be thread-safe (internal synchronization).

See also
#perform(Consumer)
#update(Consumer)
#forEach(Consumer)
#removeIf(Predicate)
#reduce(Reducer)

Definition at line 222 of file FastCollection.java.

222  {
223  return new ParallelCollectionImpl<E>(service());
224  }

◆ perform() [1/3]

void javolution.util.internal.collection.CollectionView< E >.perform ( Consumer< CollectionService< E >>  action,
CollectionService< E >  view 
)
inherited

Reimplemented in javolution.util.internal.collection.ParallelCollectionImpl< E >, javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.SequentialCollectionImpl< E >.

Definition at line 163 of file CollectionView.java.

163  {
164  if (target == null) {
165  action.accept(view);
166  } else {
167  target.perform(action, view);
168  }
169  }

◆ perform() [2/3]

void javolution.util.function.Splittable< T >.perform ( Consumer< T >  action,
part 
)
inherited

Executes a read-only action on the specified part of this object.

Parameters
actionthe read-only action.
partthis object or a part of it.
Exceptions
UnsupportedOperationExceptionif the action tries to update the specified part.

◆ perform() [3/3]

void javolution.util.FastCollection< E >.perform ( Consumer<? extends Collection< E >>  action)
inherited

Executes the specified read-only action on this collection. That logic may be performed concurrently on sub-collections if this collection is parallel.

Parameters
actionthe read-only action.
Exceptions
UnsupportedOperationExceptionif the action tries to update this collection and this collection is thread-safe.
ClassCastExceptionif the action type is not compatible with this collection (e.g. action on set and this is a list).
See also
#update(Consumer)

Definition at line 315 of file FastCollection.java.

315  {
316  service().perform((Consumer<CollectionService<E>>) action, service());
317  }

◆ previousClearBit()

int javolution.util.internal.bitset.BitSetServiceImpl.previousClearBit ( int  fromIndex)

See FastBitSet#previousClearBit(int)

Implements javolution.util.service.BitSetService.

Definition at line 253 of file BitSetServiceImpl.java.

253  {
254  int offset = fromIndex >> 6;
255  long mask = 1L << fromIndex;
256  while (offset >= 0) {
257  long h = bits[offset];
258  do {
259  if ((h & mask) == 0)
260  return fromIndex;
261  mask >>= 1;
262  fromIndex--;
263  } while (mask != 0);
264  mask = 1L << 63;
265  offset--;
266  }
267  return -1;
268  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

◆ previousSetBit()

int javolution.util.internal.bitset.BitSetServiceImpl.previousSetBit ( int  fromIndex)

See FastBitSet#previousSetBit(int)

Implements javolution.util.service.BitSetService.

Definition at line 271 of file BitSetServiceImpl.java.

271  {
272  int offset = fromIndex >> 6;
273  long mask = 1L << fromIndex;
274  while (offset >= 0) {
275  long h = bits[offset];
276  do {
277  if ((h & mask) != 0)
278  return fromIndex;
279  mask >>= 1;
280  fromIndex--;
281  } while (mask != 0);
282  mask = 1L << 63;
283  offset--;
284  }
285  return -1;
286  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

◆ reduce()

E javolution.util.FastCollection< E >.reduce ( Reducer< E >  reducer)
inherited

Performs a reduction of the elements of this collection using the specified reducer. This may not involve iterating over all the collection elements, for example the reducers: Reducers#any, Reducers#and and Reducers#or may stop iterating early. Reduction is performed concurrently if this collection is parallel.

Parameters
reducerthe collection reducer.
Returns
the reduction result.

Definition at line 396 of file FastCollection.java.

396  {
397  perform(reducer);
398  return reducer.get();
399  }

◆ remove()

boolean javolution.util.internal.bitset.BitSetServiceImpl.remove ( Object  searched)

Removes the specified element from this collection.

Reimplemented from javolution.util.internal.set.SetView< E >.

Definition at line 289 of file BitSetServiceImpl.java.

289  {
290  return getAndSet(((Index)index).intValue(), false);
291  }

References javolution.util.internal.bitset.BitSetServiceImpl.getAndSet().

Here is the call graph for this function:

◆ removeAll()

boolean javolution.util.internal.collection.CollectionView< E >.removeAll ( Collection<?>  that)
inherited

Removes all the specified element from this collection.

Reimplemented from javolution.util.FastCollection< E >.

Reimplemented in javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 186 of file CollectionView.java.

186  {
187  boolean changed = false;
188  Iterator<? extends E> it = iterator();
189  while (it.hasNext()) {
190  if (c.contains(it.next())) {
191  it.remove();
192  changed = true;
193  }
194  }
195  return changed;
196  }

◆ removeIf()

boolean javolution.util.FastCollection< E >.removeIf ( final Predicate<? super E >  filter)
inherited

Removes from this collection all the elements matching the specified functional predicate (convenience method). Removals are performed concurrently if this collection is parallel and atomically if this collection is atomic.

Parameters
filtera predicate returning
true
for elements to be removed.
Returns
true
if at least one element has been removed;
false
otherwise.

Definition at line 368 of file FastCollection.java.

368  {
369  final boolean[] removed = new boolean[1];
370  update(new Consumer<Collection<E>>() {
371  public void accept(Collection<E> view) {
372  Iterator<E> it = view.iterator();
373  while (it.hasNext()) {
374  if (filter.test(it.next())) {
375  it.remove(); // Ok mutable iteration.
376  removed[0] = true;
377  }
378  }
379  }
380  });
381  return removed[0];
382  }

◆ retainAll()

boolean javolution.util.internal.collection.CollectionView< E >.retainAll ( Collection<?>  that)
inherited

Removes all the elements except those in the specified collection.

Reimplemented from javolution.util.FastCollection< E >.

Reimplemented in javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 199 of file CollectionView.java.

199  {
200  boolean changed = false;
201  Iterator<? extends E> it = iterator();
202  while (it.hasNext()) {
203  if (!c.contains(it.next())) {
204  it.remove();
205  changed = true;
206  }
207  }
208  return changed;
209  }

◆ reversed()

FastCollection<E> javolution.util.FastCollection< E >.reversed ( )
inherited

Returns a view exposing elements in reverse iterative order.

Reimplemented in javolution.util.FastTable< E >.

Definition at line 282 of file FastCollection.java.

282  {
283  return new ReversedCollectionImpl<E>(service());
284  }

◆ sequential()

FastCollection<E> javolution.util.FastCollection< E >.sequential ( )
inherited

Returns a sequential view of this collection. Using this view, all closure-based iterations are performed sequentially.

Definition at line 230 of file FastCollection.java.

230  {
231  return new SequentialCollectionImpl<E>(service());
232  }

◆ service()

Returns the service implementation of this collection (for sub-classes).

Reimplemented from javolution.util.FastCollection< E >.

Definition at line 274 of file CollectionView.java.

274  {
275  return this;
276  }

◆ serviceOf()

static <E> CollectionService<E> javolution.util.FastCollection< E >.serviceOf ( FastCollection< E >  collection)
staticprotectedinherited

Returns the service implementation of any fast collection (for sub-classes).

Definition at line 647 of file FastCollection.java.

648  {
649  return collection.service();
650  }

References javolution.util.FastCollection< E >.service().

Here is the call graph for this function:

◆ set() [1/4]

void javolution.util.internal.bitset.BitSetServiceImpl.set ( int  bitIndex)

See FastBitSet#set(int)

Implements javolution.util.service.BitSetService.

Definition at line 294 of file BitSetServiceImpl.java.

294  {
295  int i = bitIndex >> 6;
296  if (i >= bits.length) {
297  setLength(i + 1);
298  }
299  bits[i] |= 1L << bitIndex;
300  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, and javolution.util.internal.bitset.BitSetServiceImpl.setLength().

Here is the call graph for this function:

◆ set() [2/4]

void javolution.util.internal.bitset.BitSetServiceImpl.set ( int  bitIndex,
boolean  value 
)

See FastBitSet#set(int, boolean)

Implements javolution.util.service.BitSetService.

Definition at line 303 of file BitSetServiceImpl.java.

303  {
304  if (value) {
305  set(bitIndex);
306  } else {
307  clear(bitIndex);
308  }
309  }

References javolution.util.internal.bitset.BitSetServiceImpl.clear().

Here is the call graph for this function:

◆ set() [3/4]

void javolution.util.internal.bitset.BitSetServiceImpl.set ( int  fromIndex,
int  toIndex 
)

See FastBitSet#set(int, int)

Implements javolution.util.service.BitSetService.

Definition at line 312 of file BitSetServiceImpl.java.

312  {
313  int i = fromIndex >>> 6;
314  int j = toIndex >>> 6;
315  setLength(j + 1);
316  if (i == j) {
317  bits[i] |= (-1L << fromIndex) & ((1L << toIndex) - 1);
318  return;
319  }
320  bits[i] |= -1L << fromIndex;
321  bits[j] |= (1L << toIndex) - 1;
322  for (int k = i + 1; k < j; k++) {
323  bits[k] = -1;
324  }
325  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, and javolution.util.internal.bitset.BitSetServiceImpl.setLength().

Here is the call graph for this function:

◆ set() [4/4]

void javolution.util.internal.bitset.BitSetServiceImpl.set ( int  fromIndex,
int  toIndex,
boolean  value 
)

See FastBitSet#set(int, int, boolean)

Implements javolution.util.service.BitSetService.

Definition at line 328 of file BitSetServiceImpl.java.

328  {
329  if (value) {
330  set(fromIndex, toIndex);
331  } else {
332  clear(fromIndex, toIndex);
333  }
334  }

References javolution.util.internal.bitset.BitSetServiceImpl.clear().

Here is the call graph for this function:

◆ setLength()

void javolution.util.internal.bitset.BitSetServiceImpl.setLength ( int  newLength)
private

Sets the new length of the bit set.

Definition at line 362 of file BitSetServiceImpl.java.

362  {
363  long[] tmp = new long[newLength];
364  if (newLength >= bits.length) {
365  System.arraycopy(bits, 0, tmp, 0, bits.length);
366  } else { // Truncates.
367  System.arraycopy(bits, 0, tmp, 0, newLength);
368  }
369  bits = tmp;
370  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

Referenced by javolution.util.internal.bitset.BitSetServiceImpl.flip(), javolution.util.internal.bitset.BitSetServiceImpl.getAndSet(), javolution.util.internal.bitset.BitSetServiceImpl.or(), javolution.util.internal.bitset.BitSetServiceImpl.set(), javolution.util.internal.bitset.BitSetServiceImpl.trim(), and javolution.util.internal.bitset.BitSetServiceImpl.xor().

Here is the caller graph for this function:

◆ shared()

FastCollection<E> javolution.util.FastCollection< E >.shared ( )
inherited

Returns a thread-safe view over this collection. The shared view allows for concurrent read as long as there is no writer. The default implementation is based on readers-writers locks giving priority to writers. Iterators on shared collections are thread-safe (no ConcurrentModificationException possible).

Reimplemented in javolution.util.FastTable< E >, javolution.util.FastSet< E >, javolution.util.FastSortedTable< E >, and javolution.util.FastSortedSet< E >.

Definition at line 201 of file FastCollection.java.

201  {
202  return new SharedCollectionImpl<E>(service());
203  }

◆ size()

int javolution.util.internal.bitset.BitSetServiceImpl.size ( )

Returns the size of this collection.

Reimplemented from javolution.util.internal.set.SetView< E >.

Definition at line 337 of file BitSetServiceImpl.java.

337  {
338  return cardinality();
339  }

References javolution.util.internal.bitset.BitSetServiceImpl.cardinality().

Here is the call graph for this function:

◆ sorted() [1/2]

FastCollection<E> javolution.util.FastCollection< E >.sorted ( )
inherited

Returns a view exposing elements sorted according to the collection order.

Definition at line 267 of file FastCollection.java.

267  {
268  return new SortedCollectionImpl<E>(service(), comparator());
269  }

Referenced by javolution.util.internal.collection.SortedCollectionImpl< E >.IteratorImpl.IteratorImpl().

Here is the caller graph for this function:

◆ sorted() [2/2]

FastCollection<E> javolution.util.FastCollection< E >.sorted ( Comparator<? super E >  cmp)
inherited

Returns a view exposing elements sorted according to the specified comparator.

Definition at line 275 of file FastCollection.java.

275  {
276  return new SortedCollectionImpl<E>(service(), cmp);
277  }

◆ split()

Returns

n

distinct parts of this object. This method may return an array of size less than

n

(e.g. an array of size one if this object cannot split).

Parameters
nthe number of parts.
Returns
the distinct parts (or views) for this object.
Exceptions
IllegalArgumentExceptionif
n <= 1

Implements javolution.util.function.Splittable< T >.

Reimplemented in javolution.util.internal.table.SharedTableImpl< E >, javolution.util.internal.table.TableView< E >, javolution.util.internal.collection.SharedCollectionImpl< E >, javolution.util.internal.table.AtomicTableImpl< E >, javolution.util.internal.collection.AtomicCollectionImpl< E >, and javolution.util.internal.map.MapView< K, V >.EntrySet.

Definition at line 224 of file CollectionView.java.

224  {
225  if (target == null) return new CollectionService[] { this }; // No split.
226  CollectionService<E>[] subTargets = target.split(n);
227  CollectionService<E>[] result = new CollectionService[subTargets.length];
228  for (int i = 0; i < subTargets.length; i++) {
229  CollectionView<E> copy = this.clone();
230  copy.target = subTargets[i];
231  result[i] = copy;
232  }
233  return result;
234  }

◆ target()

SetService<E> javolution.util.internal.set.SetView< E >.target ( )
protectedinherited

Returns the actual target

Reimplemented from javolution.util.internal.collection.CollectionView< E >.

Reimplemented in javolution.util.internal.set.sorted.SortedSetView< E >.

Definition at line 45 of file SetView.java.

45  {
46  return (SetService<E>) super.target();
47  }

Referenced by javolution.util.internal.set.SetView< Index >.SetView().

Here is the caller graph for this function:

◆ threadSafe() [1/2]

SetService<E> javolution.util.service.SetService< E >.threadSafe
inherited

Returns a thread-safe version of this service (used during parallel updates).

◆ threadSafe() [2/2]

SetService<E> javolution.util.internal.set.SetView< E >.threadSafe ( )
inherited

Returns a thread-safe version of this service (used during parallel updates).

Reimplemented from javolution.util.internal.collection.CollectionView< E >.

Reimplemented in javolution.util.internal.set.sorted.SortedSetView< E >.

Definition at line 39 of file SetView.java.

39  {
40  return new SharedSetImpl<E>(this);
41  }

◆ toArray() [1/2]

Object [] javolution.util.internal.collection.CollectionView< E >.toArray ( )
inherited

Returns an array holding this collection elements.

Reimplemented from javolution.util.FastCollection< E >.

Reimplemented in javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 243 of file CollectionView.java.

243  {
244  return toArray(new Object[size()]);
245  }

Referenced by javolution.util.internal.collection.CollectionView< R >.toArray().

Here is the caller graph for this function:

◆ toArray() [2/2]

public<T> T [] javolution.util.internal.collection.CollectionView< E >.toArray ( T[]  array)
packageinherited

Returns the specified array holding this collection elements if enough capacity.

Reimplemented from javolution.util.FastCollection< E >.

Reimplemented in javolution.util.internal.collection.SharedCollectionImpl< E >, and javolution.util.internal.collection.AtomicCollectionImpl< E >.

Definition at line 249 of file CollectionView.java.

249  {
250  final int size = size();
251  final T[] result = (size <= a.length) ? a
252  : (T[]) java.lang.reflect.Array.newInstance(a.getClass()
253  .getComponentType(), size);
254  int i = 0;
255  Iterator<E> it = iterator();
256  while (it.hasNext()) {
257  result[i++] = (T) it.next();
258  }
259  if (result.length > size) {
260  result[size] = null; // As per Collection contract.
261  }
262  return result;
263  }

◆ toImmutable()

public<T extends Collection<E> > Immutable<T> javolution.util.FastCollection< E >.toImmutable ( )
packageinherited

Returns an immutable reference over this collection. The immutable value is an unmodifiable view of this collection. The caller must guarantees that the original collection is never going to be updated (e.g. there is no reference left of the original collection).

Definition at line 585 of file FastCollection.java.

585  {
586  return new Immutable<T>() {
587  @SuppressWarnings("unchecked")
588  final T value = (T) unmodifiable();
589 
590  @Override
591  public T value() {
592  return value;
593  }
594 
595  };
596  }

◆ toLongArray()

long [] javolution.util.internal.bitset.BitSetServiceImpl.toLongArray ( )

Returns the minimal length long[] representation of this bitset.

Implements javolution.util.service.BitSetService.

Definition at line 342 of file BitSetServiceImpl.java.

342  {
343  return bits;
344  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits.

◆ toString()

String javolution.util.FastCollection< E >.toString ( )
inherited

Returns the string representation of this collection using its default format.

Definition at line 634 of file FastCollection.java.

634  {
635  return TextContext.getFormat(FastCollection.class).format(this);
636  }

References javolution.text.TextContext.getFormat().

Here is the call graph for this function:

◆ trim()

void javolution.util.internal.bitset.BitSetServiceImpl.trim ( )
private

Removes the tails words if cleared.

Definition at line 375 of file BitSetServiceImpl.java.

375  {
376  int n = bits.length;
377  while ((--n >= 0) && (bits[n] == 0L)) {}
378  if (++n < bits.length) setLength(n);
379  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, and javolution.util.internal.bitset.BitSetServiceImpl.setLength().

Referenced by javolution.util.internal.bitset.BitSetServiceImpl.and(), javolution.util.internal.bitset.BitSetServiceImpl.andNot(), javolution.util.internal.bitset.BitSetServiceImpl.clear(), javolution.util.internal.bitset.BitSetServiceImpl.flip(), javolution.util.internal.bitset.BitSetServiceImpl.getAndSet(), javolution.util.internal.bitset.BitSetServiceImpl.or(), and javolution.util.internal.bitset.BitSetServiceImpl.xor().

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

◆ unmodifiable()

FastCollection<E> javolution.util.FastCollection< E >.unmodifiable ( )
inherited

Returns an unmodifiable view over this collection. Any attempt to modify the collection through this view will result into a java.lang.UnsupportedOperationException being raised.

Reimplemented in javolution.util.FastTable< E >, javolution.util.FastSet< E >, javolution.util.FastSortedTable< E >, and javolution.util.FastSortedSet< E >.

Definition at line 239 of file FastCollection.java.

239  {
240  return new UnmodifiableCollectionImpl<E>(service());
241  }

◆ update() [1/3]

void javolution.util.internal.collection.CollectionView< E >.update ( Consumer< CollectionService< E >>  action,
CollectionService< E >  view 
)
inherited

Reimplemented in javolution.util.internal.collection.ParallelCollectionImpl< E >, javolution.util.internal.collection.AtomicCollectionImpl< E >, and javolution.util.internal.collection.SequentialCollectionImpl< E >.

Definition at line 266 of file CollectionView.java.

266  {
267  if (target == null) {
268  action.accept(view);
269  } else {
270  target.perform(action, view);
271  }
272  }

◆ update() [2/3]

void javolution.util.function.Splittable< T >.update ( Consumer< T >  action,
part 
)
inherited

Executes an update action on the specified part of this object. Any change to the part is reflected in the whole (this object).

Parameters
actionthe action authorized to update this object part.
partthis object or a part of it.

◆ update() [3/3]

void javolution.util.FastCollection< E >.update ( Consumer<? extends Collection< E >>  action)
inherited

Executes the specified update action on this collection. That logic may be performed concurrently on sub-collections if this collection is parallel. For atomic collections the update is atomic (either concurrent readers see the full result of the action or nothing).

Parameters
actionthe update action.
Exceptions
ClassCastExceptionif the action type is not compatible with this collection (e.g. action on set and this is a list).
See also
#perform(Consumer)

Definition at line 334 of file FastCollection.java.

334  {
335  service().update((Consumer<CollectionService<E>>) action, service());
336  }

Referenced by javolution.util.FastTable< javolution.xml.internal.stream.XMLStreamReaderImpl >.sort().

Here is the caller graph for this function:

◆ xor()

void javolution.util.internal.bitset.BitSetServiceImpl.xor ( BitSetService  that)

See FastBitSet#xor(FastBitSet)

Implements javolution.util.service.BitSetService.

Definition at line 347 of file BitSetServiceImpl.java.

347  {
348  long[] thatBits = (that instanceof BitSetServiceImpl) ? ((BitSetServiceImpl) that).bits
349  : that.toLongArray();
350  if (thatBits.length > this.bits.length) {
351  setLength(thatBits.length);
352  }
353  for (int i = thatBits.length; --i >= 0;) {
354  bits[i] ^= thatBits[i];
355  }
356  trim();
357  }

References javolution.util.internal.bitset.BitSetServiceImpl.bits, javolution.util.internal.bitset.BitSetServiceImpl.BitSetServiceImpl(), javolution.util.internal.bitset.BitSetServiceImpl.setLength(), javolution.util.service.BitSetService.toLongArray(), and javolution.util.internal.bitset.BitSetServiceImpl.trim().

Here is the call graph for this function:

Member Data Documentation

◆ bits

◆ serialVersionUID

final long javolution.util.internal.bitset.BitSetServiceImpl.serialVersionUID = 0x600L
staticprivate

Definition at line 26 of file BitSetServiceImpl.java.


The documentation for this class was generated from the following file:
javolution.util.FastCollection.comparator
Equality<? super E > comparator()
Definition: FastCollection.java:574
javolution.util.FastCollection.update
void update(Consumer<? extends Collection< E >> action)
Definition: FastCollection.java:334
javolution.util.internal.bitset.BitSetServiceImpl.cardinality
int cardinality()
Definition: BitSetServiceImpl.java:66
javolution.util.internal.collection.CollectionView.add
abstract boolean add(E element)
javolution.util.FastCollection.reduce
E reduce(Reducer< E > reducer)
Definition: FastCollection.java:396
javolution.util.internal.bitset.BitSetServiceImpl.comparator
Equality<? super Index > comparator()
Definition: BitSetServiceImpl.java:111
javolution.util.internal.bitset.BitSetServiceImpl.length
int length()
Definition: BitSetServiceImpl.java:199
javolution.util.internal.bitset.BitSetServiceImpl.clear
void clear()
Definition: BitSetServiceImpl.java:75
javolution.util.FastCollection.service
abstract CollectionService< E > service()
javolution.util.internal.collection.CollectionView.contains
boolean contains(Object obj)
Definition: CollectionView.java:83
javolution.util.internal.collection.CollectionView.comparator
abstract Equality<? super E > comparator()
javolution.util.internal.collection.CollectionView.size
int size()
Definition: CollectionView.java:212
javolution.util.internal.bitset.BitSetServiceImpl.setLength
void setLength(int newLength)
Definition: BitSetServiceImpl.java:362
javolution.util.internal.collection.CollectionView.target
CollectionService< E > target
Definition: CollectionView.java:33
javolution.util.internal.collection.CollectionView.iterator
abstract Iterator< E > iterator()
javolution.util.FastCollection.addAll
boolean addAll(final Collection<? extends E > that)
Definition: FastCollection.java:462
javolution.util.internal.collection.CollectionView.equals
boolean equals(Object o)
Definition: CollectionView.java:102
javolution.util.internal.bitset.BitSetServiceImpl.getAndSet
boolean getAndSet(int bitIndex, boolean value)
Definition: BitSetServiceImpl.java:168
javolution.util.FastCollection.unmodifiable
FastCollection< E > unmodifiable()
Definition: FastCollection.java:239
javolution.util.FastCollection.add
boolean add(E element)
Definition: FastCollection.java:408
javolution.util.FastCollection.parallel
FastCollection< E > parallel()
Definition: FastCollection.java:222
javolution.util.FastCollection.FastCollection
FastCollection()
Definition: FastCollection.java:173
javolution.util.internal.bitset.BitSetServiceImpl.trim
void trim()
Definition: BitSetServiceImpl.java:375
javolution.util.internal.collection.CollectionView.toArray
Object[] toArray()
Definition: CollectionView.java:243
javolution.util.internal.bitset.BitSetServiceImpl.BitSetServiceImpl
BitSetServiceImpl()
Definition: BitSetServiceImpl.java:32
javolution.util.FastCollection.perform
void perform(Consumer<? extends Collection< E >> action)
Definition: FastCollection.java:315
javolution.util.internal.collection.CollectionView.clone
CollectionView< E > clone()
Definition: CollectionView.java:66
javolution.util.internal.bitset.BitSetServiceImpl.bits
long[] bits
Definition: BitSetServiceImpl.java:29
javolution.util.internal.collection.CollectionView.containsAll
boolean containsAll(Collection<?> c)
Definition: CollectionView.java:93