Javolution 6.0.0 java
javolution.util.internal.set.AtomicSetImpl< E > Class Template Reference
Inheritance diagram for javolution.util.internal.set.AtomicSetImpl< E >:
[legend]
Collaboration diagram for javolution.util.internal.set.AtomicSetImpl< E >:
[legend]

Public Member Functions

 AtomicSetImpl (SetService< E > target)
 
SetService< E > threadSafe ()
 
synchronized boolean add (E element)
 
synchronized boolean addAll (Collection<? extends E > c)
 
FastCollection< E > addAll (E... elements)
 
FastCollection< E > addAll (FastCollection<? extends E > that)
 
synchronized void clear ()
 
synchronized AtomicCollectionImpl< E > clone ()
 
Equality<? super E > comparator ()
 
boolean contains (Object o)
 
boolean containsAll (Collection<?> c)
 
boolean equals (Object o)
 
int hashCode ()
 
boolean isEmpty ()
 
Iterator< E > iterator ()
 
synchronized boolean remove (Object o)
 
synchronized boolean removeAll (Collection<?> c)
 
synchronized boolean retainAll (Collection<?> c)
 
int size ()
 
CollectionService< E >[] split (int n)
 
Object[] toArray ()
 
synchronized void update (Consumer< CollectionService< E >> action, CollectionService< E > view)
 
void update (Consumer<? extends Collection< E >> action)
 
void update (Consumer< T > action, T part)
 
void perform (Consumer< CollectionService< E >> action, CollectionService< E > view)
 
void perform (Consumer<? extends Collection< E >> action)
 
void perform (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 ()
 

Protected Member Functions

CollectionService< E > targetView ()
 
CollectionService< E > cloneTarget ()
 
final boolean updateInProgress ()
 
CollectionService< E > target ()
 
CollectionService< E > service ()
 

Static Protected Member Functions

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

Protected Attributes

volatile CollectionService< E > immutable
 
transient Thread updatingThread
 

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 Attributes

CollectionService< E > target
 

Static Private Attributes

static final long serialVersionUID = 0x600L
 

Detailed Description

An atomic view over a set allowing concurrent access and sequential updates.

Definition at line 17 of file AtomicSetImpl.java.

Constructor & Destructor Documentation

◆ AtomicSetImpl()

Member Function Documentation

◆ add()

synchronized boolean javolution.util.internal.collection.AtomicCollectionImpl< E >.add ( element)
inherited

Adds the specified element to this collection

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

Definition at line 61 of file AtomicCollectionImpl.java.

61  {
62  boolean changed = target().add(element);
63  if (changed && !updateInProgress()) immutable = cloneTarget();
64  return changed;
65  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable, javolution.util.internal.collection.CollectionView< E >.target, and javolution.util.internal.collection.AtomicCollectionImpl< E >.updateInProgress().

Here is the call graph for this function:

◆ addAll() [1/3]

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

Adds all the specified elements to this collection.

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

Definition at line 68 of file AtomicCollectionImpl.java.

68  {
69  boolean changed = target().addAll(c);
70  if (changed && !updateInProgress()) immutable = cloneTarget();
71  return changed;
72  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable, javolution.util.internal.collection.CollectionView< E >.target, and javolution.util.internal.collection.AtomicCollectionImpl< E >.updateInProgress().

Here is the call graph for this function:

◆ 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  }

◆ 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  }

◆ clear()

synchronized void javolution.util.internal.collection.AtomicCollectionImpl< E >.clear ( )
inherited

Removes all elements from this collection.

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

Definition at line 75 of file AtomicCollectionImpl.java.

75  {
76  clear();
77  if (!updateInProgress()) {
79  }
80  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable, and javolution.util.internal.collection.AtomicCollectionImpl< E >.updateInProgress().

Here is the call graph for this function:

◆ clone()

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

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

Definition at line 83 of file AtomicCollectionImpl.java.

83  { // Synchronized required since working with real target.
84  AtomicCollectionImpl<E> copy = (AtomicCollectionImpl<E>) super.clone();
85  copy.updatingThread = null;
86  return copy;
87  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.clone(), and javolution.util.internal.collection.AtomicCollectionImpl< E >.updatingThread.

Referenced by javolution.util.internal.collection.AtomicCollectionImpl< E >.clone().

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

◆ cloneTarget()

Returns a clone copy of target.

Definition at line 191 of file AtomicCollectionImpl.java.

191  {
192  try {
193  return target().clone();
194  } catch (CloneNotSupportedException e) {
195  throw new Error("Cannot happen since target is Cloneable.");
196  }
197  }

References javolution.util.internal.collection.CollectionView< E >.target.

Referenced by javolution.util.internal.table.AtomicTableImpl< E >.add(), javolution.util.internal.collection.AtomicCollectionImpl< E >.add(), javolution.util.internal.table.AtomicTableImpl< E >.addAll(), javolution.util.internal.collection.AtomicCollectionImpl< E >.addAll(), javolution.util.internal.table.AtomicTableImpl< E >.addFirst(), javolution.util.internal.table.sorted.AtomicSortedTableImpl< E >.addIfAbsent(), javolution.util.internal.table.AtomicTableImpl< E >.addLast(), javolution.util.internal.collection.AtomicCollectionImpl< E >.AtomicCollectionImpl(), javolution.util.internal.collection.AtomicCollectionImpl< E >.clear(), javolution.util.internal.table.AtomicTableImpl< E >.offerFirst(), javolution.util.internal.table.AtomicTableImpl< E >.offerLast(), javolution.util.internal.table.AtomicTableImpl< E >.pollFirst(), javolution.util.internal.table.AtomicTableImpl< E >.pollLast(), javolution.util.internal.collection.AtomicCollectionImpl< E >.remove(), javolution.util.internal.table.AtomicTableImpl< E >.remove(), javolution.util.internal.collection.AtomicCollectionImpl< E >.removeAll(), javolution.util.internal.table.AtomicTableImpl< E >.removeFirst(), javolution.util.internal.table.AtomicTableImpl< E >.removeFirstOccurrence(), javolution.util.internal.table.AtomicTableImpl< E >.removeLast(), javolution.util.internal.table.AtomicTableImpl< E >.removeLastOccurrence(), javolution.util.internal.collection.AtomicCollectionImpl< E >.retainAll(), javolution.util.internal.table.AtomicTableImpl< E >.set(), and javolution.util.internal.collection.AtomicCollectionImpl< E >.update().

Here is the caller graph for this function:

◆ comparator()

Equality<? super E> javolution.util.internal.collection.AtomicCollectionImpl< E >.comparator ( )
inherited

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 90 of file AtomicCollectionImpl.java.

90  {
91  return immutable.comparator();
92  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable.

◆ contains()

boolean javolution.util.internal.collection.AtomicCollectionImpl< E >.contains ( Object  searched)
inherited

Indicates if this collection contains the specified element.

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

Definition at line 95 of file AtomicCollectionImpl.java.

95  {
96  return targetView().contains(o);
97  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView().

Here is the call graph for this function:

◆ containsAll()

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

Indicates if this collection contains all the specified elements.

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

Definition at line 100 of file AtomicCollectionImpl.java.

100  {
101  return targetView().containsAll(c);
102  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView().

Here is the call 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.AtomicCollectionImpl< 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.internal.collection.CollectionView< E >.

Definition at line 105 of file AtomicCollectionImpl.java.

105  {
106  return targetView().equals(o);
107  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView().

Here is the call 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  }

◆ 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:

◆ hashCode()

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.internal.collection.CollectionView< E >.

Definition at line 110 of file AtomicCollectionImpl.java.

110  {
111  return targetView().hashCode();
112  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView().

Here is the call graph for this function:

◆ isEmpty()

Indicates if this collection is empty.

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

Definition at line 115 of file AtomicCollectionImpl.java.

115  {
116  return targetView().isEmpty();
117  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView().

Here is the call graph for this function:

◆ iterator()

Iterator<E> javolution.util.internal.collection.AtomicCollectionImpl< E >.iterator ( )
inherited

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 >.

Reimplemented in javolution.util.internal.table.AtomicTableImpl< E >.

Definition at line 120 of file AtomicCollectionImpl.java.

120  {
121  return new IteratorImpl();
122  }

◆ 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:

◆ 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  }

◆ 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()

synchronized boolean javolution.util.internal.collection.AtomicCollectionImpl< E >.remove ( Object  searched)
inherited

Removes the specified element from this collection.

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

Definition at line 125 of file AtomicCollectionImpl.java.

125  {
126  boolean changed = target().remove(o);
127  if (changed && !updateInProgress()) immutable = cloneTarget();
128  return changed;
129  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable, javolution.util.internal.collection.CollectionView< E >.target, and javolution.util.internal.collection.AtomicCollectionImpl< E >.updateInProgress().

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

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

◆ removeAll()

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

Removes all the specified element from this collection.

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

Definition at line 132 of file AtomicCollectionImpl.java.

132  {
133  boolean changed = target().removeAll(c);
134  if (changed && !updateInProgress()) immutable = cloneTarget();
135  return changed;
136  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable, javolution.util.internal.collection.CollectionView< E >.target, and javolution.util.internal.collection.AtomicCollectionImpl< E >.updateInProgress().

Here is the call graph for this function:

◆ 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()

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

Removes all the elements except those in the specified collection.

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

Definition at line 139 of file AtomicCollectionImpl.java.

139  {
140  boolean changed = target().retainAll(c);
141  if (changed && !updateInProgress()) immutable = cloneTarget();
142  return changed;
143  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable, javolution.util.internal.collection.CollectionView< E >.target, and javolution.util.internal.collection.AtomicCollectionImpl< E >.updateInProgress().

Here is the call graph for this function:

◆ 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:

◆ 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()

Returns the size of this collection.

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

Definition at line 146 of file AtomicCollectionImpl.java.

146  {
147  return targetView().size();
148  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView().

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

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

Reimplemented in javolution.util.internal.table.AtomicTableImpl< E >.

Definition at line 152 of file AtomicCollectionImpl.java.

152  { // Split not supported.
153  return new CollectionService[] { this };
154  }

◆ target()

◆ targetView()

◆ threadSafe()

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

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

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

Definition at line 27 of file AtomicSetImpl.java.

27  {
28  return this;
29  }

◆ toArray() [1/2]

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

Returns an array holding this collection elements.

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

Definition at line 162 of file AtomicCollectionImpl.java.

162  {
163  return targetView().toArray();
164  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView().

Here is the call graph for this function:

◆ toArray() [2/2]

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

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

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

Definition at line 167 of file AtomicCollectionImpl.java.

167  {
168  return targetView().toArray(a);
169  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView().

Here is the call graph for this function:

◆ 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  }

◆ 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:

◆ 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]

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

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

Definition at line 172 of file AtomicCollectionImpl.java.

173  {
174  updatingThread = Thread.currentThread(); // Update in progress.
175  try {
176  target().update(action, view); // No copy performed.
177  } finally {
178  updatingThread = null;
179  immutable = cloneTarget(); // One single copy !
180  }
181  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable, javolution.util.internal.collection.CollectionView< E >.target, and javolution.util.internal.collection.AtomicCollectionImpl< E >.updatingThread.

Here is the call graph for this function:

◆ 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:

◆ updateInProgress()

final boolean javolution.util.internal.collection.AtomicCollectionImpl< E >.updateInProgress ( )
protectedinherited

Indicates if the current thread is doing an atomic update.

Definition at line 200 of file AtomicCollectionImpl.java.

200  {
201  return updatingThread == Thread.currentThread();
202 
203  }

References javolution.util.internal.collection.AtomicCollectionImpl< E >.updatingThread.

Referenced by javolution.util.internal.table.AtomicTableImpl< E >.add(), javolution.util.internal.collection.AtomicCollectionImpl< E >.add(), javolution.util.internal.table.AtomicTableImpl< E >.addAll(), javolution.util.internal.collection.AtomicCollectionImpl< E >.addAll(), javolution.util.internal.table.AtomicTableImpl< E >.addFirst(), javolution.util.internal.table.sorted.AtomicSortedTableImpl< E >.addIfAbsent(), javolution.util.internal.table.AtomicTableImpl< E >.addLast(), javolution.util.internal.collection.AtomicCollectionImpl< E >.clear(), javolution.util.internal.table.AtomicTableImpl< E >.offerFirst(), javolution.util.internal.table.AtomicTableImpl< E >.offerLast(), javolution.util.internal.table.AtomicTableImpl< E >.pollFirst(), javolution.util.internal.table.AtomicTableImpl< E >.pollLast(), javolution.util.internal.collection.AtomicCollectionImpl< E >.remove(), javolution.util.internal.table.AtomicTableImpl< E >.remove(), javolution.util.internal.collection.AtomicCollectionImpl< E >.removeAll(), javolution.util.internal.table.AtomicTableImpl< E >.removeFirst(), javolution.util.internal.table.AtomicTableImpl< E >.removeFirstOccurrence(), javolution.util.internal.table.AtomicTableImpl< E >.removeLast(), javolution.util.internal.table.AtomicTableImpl< E >.removeLastOccurrence(), javolution.util.internal.collection.AtomicCollectionImpl< E >.retainAll(), and javolution.util.internal.table.AtomicTableImpl< E >.set().

Here is the caller graph for this function:

Member Data Documentation

◆ immutable

volatile CollectionService<E> javolution.util.internal.collection.AtomicCollectionImpl< E >.immutable
protectedinherited

Definition at line 52 of file AtomicCollectionImpl.java.

Referenced by javolution.util.internal.table.AtomicTableImpl< E >.add(), javolution.util.internal.collection.AtomicCollectionImpl< E >.add(), javolution.util.internal.table.AtomicTableImpl< E >.addAll(), javolution.util.internal.collection.AtomicCollectionImpl< E >.addAll(), javolution.util.internal.table.AtomicTableImpl< E >.addFirst(), javolution.util.internal.table.sorted.AtomicSortedTableImpl< E >.addIfAbsent(), javolution.util.internal.table.AtomicTableImpl< E >.addLast(), javolution.util.internal.collection.AtomicCollectionImpl< E >.clear(), javolution.util.internal.collection.AtomicCollectionImpl< E >.comparator(), javolution.util.internal.table.AtomicTableImpl< E >.offerFirst(), javolution.util.internal.table.AtomicTableImpl< E >.offerLast(), javolution.util.internal.table.AtomicTableImpl< E >.pollFirst(), javolution.util.internal.table.AtomicTableImpl< E >.pollLast(), javolution.util.internal.collection.AtomicCollectionImpl< E >.remove(), javolution.util.internal.table.AtomicTableImpl< E >.remove(), javolution.util.internal.collection.AtomicCollectionImpl< E >.removeAll(), javolution.util.internal.table.AtomicTableImpl< E >.removeFirst(), javolution.util.internal.table.AtomicTableImpl< E >.removeFirstOccurrence(), javolution.util.internal.table.AtomicTableImpl< E >.removeLast(), javolution.util.internal.table.AtomicTableImpl< E >.removeLastOccurrence(), javolution.util.internal.collection.AtomicCollectionImpl< E >.retainAll(), javolution.util.internal.table.AtomicTableImpl< E >.set(), javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView(), and javolution.util.internal.collection.AtomicCollectionImpl< E >.update().

◆ serialVersionUID

final long javolution.util.internal.set.AtomicSetImpl< E >.serialVersionUID = 0x600L
staticprivate

Definition at line 20 of file AtomicSetImpl.java.

◆ target

Reimplemented in javolution.util.internal.table.SharedTableImpl< E >, javolution.util.internal.table.TableView< E >, javolution.util.internal.table.AtomicTableImpl< E >, javolution.util.internal.set.sorted.SharedSortedSetImpl< E >, javolution.util.internal.table.sorted.SortedTableView< E >, javolution.util.internal.set.sorted.UnmodifiableSortedSetImpl< E >, javolution.util.internal.set.sorted.SortedSetView< E >, javolution.util.internal.table.sorted.SharedSortedTableImpl< E >, javolution.util.internal.table.sorted.AtomicSortedTableImpl< E >, javolution.util.internal.set.SetView< E >, and javolution.util.internal.table.sorted.UnmodifiableSortedTableImpl< E >.

Definition at line 33 of file CollectionView.java.

Referenced by javolution.util.internal.collection.SequentialCollectionImpl< E >.add(), javolution.util.internal.collection.ParallelCollectionImpl< E >.add(), javolution.util.internal.collection.ReversedCollectionImpl< E >.add(), javolution.util.internal.collection.AtomicCollectionImpl< E >.add(), javolution.util.internal.collection.DistinctCollectionImpl< E >.add(), javolution.util.internal.collection.SortedCollectionImpl< E >.add(), javolution.util.internal.collection.SharedCollectionImpl< E >.add(), javolution.util.internal.collection.FilteredCollectionImpl< E >.add(), javolution.util.internal.collection.AtomicCollectionImpl< E >.addAll(), javolution.util.internal.collection.SharedCollectionImpl< E >.addAll(), javolution.util.internal.collection.AtomicCollectionImpl< E >.AtomicCollectionImpl(), javolution.util.internal.set.AtomicSetImpl< E >.AtomicSetImpl(), javolution.util.internal.set.sorted.AtomicSortedSetImpl< E >.AtomicSortedSetImpl(), javolution.util.internal.collection.SequentialCollectionImpl< E >.clear(), javolution.util.internal.collection.ParallelCollectionImpl< E >.clear(), javolution.util.internal.collection.ReversedCollectionImpl< E >.clear(), javolution.util.internal.collection.DistinctCollectionImpl< E >.clear(), javolution.util.internal.collection.SortedCollectionImpl< E >.clear(), javolution.util.internal.collection.SharedCollectionImpl< E >.clear(), javolution.util.internal.collection.CollectionView< R >.clone(), javolution.util.internal.collection.AtomicCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.SharedCollectionImpl< E >.cloneTarget(), javolution.util.internal.collection.CollectionView< R >.CollectionView(), javolution.util.internal.collection.SequentialCollectionImpl< E >.comparator(), javolution.util.internal.collection.ParallelCollectionImpl< E >.comparator(), javolution.util.internal.collection.UnmodifiableCollectionImpl< E >.comparator(), javolution.util.internal.collection.ReversedCollectionImpl< E >.comparator(), javolution.util.internal.collection.DistinctCollectionImpl< E >.comparator(), javolution.util.internal.collection.FilteredCollectionImpl< E >.comparator(), javolution.util.internal.collection.SharedCollectionImpl< E >.comparator(), javolution.util.internal.collection.SequentialCollectionImpl< E >.contains(), javolution.util.internal.collection.ParallelCollectionImpl< E >.contains(), javolution.util.internal.collection.UnmodifiableCollectionImpl< E >.contains(), javolution.util.internal.collection.ReversedCollectionImpl< E >.contains(), javolution.util.internal.collection.DistinctCollectionImpl< E >.contains(), javolution.util.internal.collection.FilteredCollectionImpl< E >.contains(), javolution.util.internal.collection.SortedCollectionImpl< E >.contains(), javolution.util.internal.collection.SharedCollectionImpl< E >.contains(), javolution.util.internal.collection.SharedCollectionImpl< E >.containsAll(), javolution.util.internal.collection.DistinctCollectionImpl< E >.DistinctCollectionImpl(), javolution.util.internal.collection.SharedCollectionImpl< E >.equals(), javolution.util.internal.collection.FilteredCollectionImpl< E >.FilteredCollectionImpl(), javolution.util.internal.set.FilteredSetImpl< E >.FilteredSetImpl(), javolution.util.internal.collection.SharedCollectionImpl< E >.hashCode(), javolution.util.internal.collection.SequentialCollectionImpl< E >.isEmpty(), javolution.util.internal.collection.ParallelCollectionImpl< E >.isEmpty(), javolution.util.internal.collection.UnmodifiableCollectionImpl< E >.isEmpty(), javolution.util.internal.collection.ReversedCollectionImpl< E >.isEmpty(), javolution.util.internal.collection.DistinctCollectionImpl< E >.isEmpty(), javolution.util.internal.collection.SortedCollectionImpl< E >.isEmpty(), javolution.util.internal.collection.SharedCollectionImpl< E >.isEmpty(), javolution.util.internal.collection.SequentialCollectionImpl< E >.iterator(), javolution.util.internal.collection.ParallelCollectionImpl< E >.iterator(), javolution.util.internal.collection.ReversedCollectionImpl< E >.IteratorImpl.IteratorImpl(), javolution.util.internal.collection.SortedCollectionImpl< E >.IteratorImpl.IteratorImpl(), javolution.util.internal.collection.FilteredCollectionImpl< E >.IteratorImpl.IteratorImpl(), javolution.util.internal.collection.ParallelCollectionImpl< E >.ParallelCollectionImpl(), javolution.util.internal.collection.ParallelCollectionImpl< E >.perform(), javolution.util.internal.collection.CollectionView< R >.perform(), javolution.util.internal.collection.SharedCollectionImpl< E >.perform(), javolution.util.internal.collection.ReversedCollectionImpl< E >.IteratorImpl.remove(), javolution.util.internal.collection.SortedCollectionImpl< E >.IteratorImpl.remove(), javolution.util.internal.collection.SequentialCollectionImpl< E >.remove(), javolution.util.internal.collection.ParallelCollectionImpl< E >.remove(), javolution.util.internal.collection.ReversedCollectionImpl< E >.remove(), javolution.util.internal.collection.FilteredCollectionImpl< E >.remove(), javolution.util.internal.collection.SortedCollectionImpl< E >.remove(), javolution.util.internal.collection.AtomicCollectionImpl< E >.remove(), javolution.util.internal.collection.SharedCollectionImpl< E >.remove(), javolution.util.internal.collection.AtomicCollectionImpl< E >.removeAll(), javolution.util.internal.collection.SharedCollectionImpl< E >.removeAll(), javolution.util.internal.collection.AtomicCollectionImpl< E >.retainAll(), javolution.util.internal.collection.SharedCollectionImpl< E >.retainAll(), javolution.util.internal.collection.ReversedCollectionImpl< E >.ReversedCollectionImpl(), javolution.util.internal.collection.SequentialCollectionImpl< E >.SequentialCollectionImpl(), javolution.util.internal.collection.SharedCollectionImpl< E >.SharedCollectionImpl(), javolution.util.internal.set.SharedSetImpl< E >.SharedSetImpl(), javolution.util.internal.collection.SequentialCollectionImpl< E >.size(), javolution.util.internal.collection.UnmodifiableCollectionImpl< E >.size(), javolution.util.internal.collection.ParallelCollectionImpl< E >.size(), javolution.util.internal.collection.ReversedCollectionImpl< E >.size(), javolution.util.internal.collection.SortedCollectionImpl< E >.size(), javolution.util.internal.collection.SharedCollectionImpl< E >.size(), javolution.util.internal.collection.SortedCollectionImpl< E >.SortedCollectionImpl(), javolution.util.internal.collection.CollectionView< R >.split(), javolution.util.internal.collection.SharedCollectionImpl< E >.split(), javolution.util.internal.collection.CollectionView< R >.target(), javolution.util.internal.collection.AtomicCollectionImpl< E >.targetView(), javolution.util.internal.collection.SharedCollectionImpl< E >.toArray(), javolution.util.internal.collection.UnmodifiableCollectionImpl< E >.UnmodifiableCollectionImpl(), javolution.util.internal.set.UnmodifiableSetImpl< E >.UnmodifiableSetImpl(), javolution.util.internal.collection.ParallelCollectionImpl< E >.update(), javolution.util.internal.collection.AtomicCollectionImpl< E >.update(), and javolution.util.internal.collection.CollectionView< R >.update().

◆ updatingThread


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.internal.collection.AtomicCollectionImpl.updateInProgress
final boolean updateInProgress()
Definition: AtomicCollectionImpl.java:200
javolution.util.FastCollection.update
void update(Consumer<? extends Collection< E >> action)
Definition: FastCollection.java:334
javolution.util.internal.collection.AtomicCollectionImpl.cloneTarget
CollectionService< E > cloneTarget()
Definition: AtomicCollectionImpl.java:191
javolution.util.FastCollection.reduce
E reduce(Reducer< E > reducer)
Definition: FastCollection.java:396
javolution.util.FastCollection.service
abstract CollectionService< E > service()
javolution.util.internal.collection.AtomicCollectionImpl.updatingThread
transient Thread updatingThread
Definition: AtomicCollectionImpl.java:53
javolution.util.internal.collection.CollectionView.target
CollectionService< E > target
Definition: CollectionView.java:33
javolution.util.FastCollection.addAll
boolean addAll(final Collection<? extends E > that)
Definition: FastCollection.java:462
javolution.util.internal.collection.AtomicCollectionImpl.clear
synchronized void clear()
Definition: AtomicCollectionImpl.java:75
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.FastCollection.perform
void perform(Consumer<? extends Collection< E >> action)
Definition: FastCollection.java:315
Thread
javolution.util.internal.collection.AtomicCollectionImpl.comparator
Equality<? super E > comparator()
Definition: AtomicCollectionImpl.java:90
javolution.util.internal.collection.AtomicCollectionImpl.targetView
CollectionService< E > targetView()
Definition: AtomicCollectionImpl.java:185
javolution.util.internal.collection.AtomicCollectionImpl.immutable
volatile CollectionService< E > immutable
Definition: AtomicCollectionImpl.java:52