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

Classes

class  IteratorImpl
 

Public Member Functions

 ReversedCollectionImpl (CollectionService< E > target)
 
boolean add (E e)
 
void clear ()
 
Equality<? super E > comparator ()
 
boolean contains (Object obj)
 
boolean isEmpty ()
 
Iterator< E > iterator ()
 
boolean remove (Object obj)
 
int size ()
 
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 ()
 
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)
 
CollectionService< E > threadSafe ()
 
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 ()
 

Protected Member Functions

CollectionService< 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 Attributes

CollectionService< E > target
 

Static Private Attributes

static final long serialVersionUID = 0x600L
 

Detailed Description

A reversed view over a collection.

Definition at line 19 of file ReversedCollectionImpl.java.

Constructor & Destructor Documentation

◆ ReversedCollectionImpl()

Member Function Documentation

◆ add()

Adds the specified element to this collection

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

Definition at line 59 of file ReversedCollectionImpl.java.

59  {
60  return target().add(e);
61  }

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

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

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

Removes all elements from this collection.

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

Definition at line 64 of file ReversedCollectionImpl.java.

64  {
65  target().clear();
66  }

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

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

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 69 of file ReversedCollectionImpl.java.

69  {
70  return target().comparator();
71  }

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

◆ contains()

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

Indicates if this collection contains the specified element.

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

Definition at line 74 of file ReversedCollectionImpl.java.

74  {
75  return target().contains(obj);
76  }

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

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

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

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  }

◆ isEmpty()

Indicates if this collection is empty.

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

Definition at line 79 of file ReversedCollectionImpl.java.

79  {
80  return target().isEmpty();
81  }

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

◆ 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 84 of file ReversedCollectionImpl.java.

84  {
85  return new IteratorImpl();
86  }

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

boolean javolution.util.internal.collection.ReversedCollectionImpl< E >.remove ( Object  searched)

Removes the specified element from this collection.

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

Definition at line 89 of file ReversedCollectionImpl.java.

89  {
90  return target().remove(obj);
91  }

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

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

◆ 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 94 of file ReversedCollectionImpl.java.

94  {
95  return target().size();
96  }

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

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

◆ threadSafe()

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

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

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 >, javolution.util.internal.collection.UnmodifiableCollectionImpl< E >, javolution.util.internal.set.sorted.SharedSortedSetImpl< E >, javolution.util.internal.table.UnmodifiableTableImpl< E >, javolution.util.internal.table.sorted.SortedTableView< E >, javolution.util.internal.table.sorted.FastSortedTableImpl< E >, javolution.util.internal.set.sorted.UnmodifiableSortedSetImpl< E >, javolution.util.internal.set.sorted.AtomicSortedSetImpl< 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 >, javolution.util.internal.table.sorted.UnmodifiableSortedTableImpl< E >, javolution.util.internal.set.FilteredSetImpl< E >, javolution.util.internal.set.AtomicSetImpl< E >, javolution.util.internal.set.SharedSetImpl< E >, and javolution.util.internal.set.UnmodifiableSetImpl< E >.

Definition at line 237 of file CollectionView.java.

237  {
238  // We use shared collection as default (they can split).
239  return new SharedCollectionImpl<E>(this);
240  }

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

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

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:

Member Data Documentation

◆ serialVersionUID

final long javolution.util.internal.collection.ReversedCollectionImpl< E >.serialVersionUID = 0x600L
staticprivate

Definition at line 52 of file ReversedCollectionImpl.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().


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.collection.CollectionView.add
abstract boolean add(E element)
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.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.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.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.collection.ReversedCollectionImpl.comparator
Equality<? super E > comparator()
Definition: ReversedCollectionImpl.java:69
javolution.util.internal.collection.CollectionView.toArray
Object[] toArray()
Definition: CollectionView.java:243
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.collection.CollectionView.containsAll
boolean containsAll(Collection<?> c)
Definition: CollectionView.java:93