Class LazyBag<E>
java.lang.Object
org.eclipse.m2m.atl.emftvm.util.LazyCollection<E>
org.eclipse.m2m.atl.emftvm.util.LazyBag<E>
- Type Parameters:
E-
- All Implemented Interfaces:
Iterable<E>, Collection<E>
- Direct Known Subclasses:
LazyBag.IncludingBag, LazyBag.IntegerRangeBag, LazyBag.LongRangeBag, LazyBag.UnionBag, LazyBagOnCollection
Immutable
Collection that supports lazy evaluation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassLazyCollection.ReadOnlyIteratorthat returns only elements contained in both underlying collections, where the element occurs as often as in the collection with the least occurrences of the element.static classLazyBagthat implements the "including" operation.static classstatic classstatic classLazyBagthat implements the "union" operation.Nested classes/interfaces inherited from class LazyCollection
LazyCollection.AppendIterator, LazyCollection.CachingIterator, LazyCollection.CachingSetIterator, LazyCollection.CollectIterator<T>, LazyCollection.ExcludingIterator, LazyCollection.FilterIterator, LazyCollection.FlattenIterator, LazyCollection.FlattenSetIterator, LazyCollection.IntegerRangeListIterator, LazyCollection.IntersectionIterator, LazyCollection.IteratorToListIterator, LazyCollection.LongRangeListIterator, LazyCollection.ReadOnlyIterator<E>, LazyCollection.ReadOnlyListIterator<E>, LazyCollection.RejectIterator, LazyCollection.ReverseIterator, LazyCollection.ReverseListIterator, LazyCollection.SelectIterator, LazyCollection.SubListIterator, LazyCollection.SubListListIterator, LazyCollection.SubtractionIterator, LazyCollection.UnionIterator, LazyCollection.UnionSetIterator, LazyCollection.WrappedIterator, LazyCollection.WrappedListIterator -
Field Summary
Fields inherited from class LazyCollection
cache, dataSource, occurrences -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasBag()Returns a Bag identical to self.Evaluates the collection as an OCL String.<T> LazyBag<T> Collects the return values offunctionfor each of the elements of this collection.protected voidCreates the cache collections.booleanReturns the bag containing all elements of self apart from all occurrences ofobject.excludingAll(Collection<?> coll) Returns the collection containing all elements of self minuscoll.LazyBag<?> flatten()If the element type is not a collection type this results in the same self.inthashCode()Returns the bag containing all elements of self plusobject.Returns the collection containing all elements of self plusobject.includingAll(Collection<? extends E> coll) Returns the collection containing all elements of self pluscoll.includingAll(Collection<? extends E> coll, int index) Returns the collection containing all elements of self pluscoll.includingRange(E first, E last) Returns the bag containing all elements of self plus the bag offirstrunning tolast.intersection(LazyBag<E> bag) Returns the intersection of self andbag(i.e, the bag of all elements that are in both self ands, where the element occurs as often as in the bag with the least element occurrences).intersection(LazySet<E> set) Returns the intersection of self andset.Rejects all elements from this collection for which theconditionevaluates totrue.Selects all elements from this collection for which theconditionevaluates totrue.Results in the Collection containing all elements of the source collection.Returns the union of self andbag.Returns the union of self andset.Methods inherited from class LazyCollection
add, addAll, any, appendElements, asOrderedSet, asSequence, asSet, clear, contains, containsAll, containsAny, count, excludes, excludesAll, exists, exists2, forAll, forAll2, includes, includesAll, isEmpty, isUnique, iterate, iterator, mappedBy, mappedBySingle, max, min, notEmpty, one, product, remove, removeAll, retainAll, size, sum, toArray, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
LazyBag
public LazyBag()Creates an emptyLazyBag. -
LazyBag
-
-
Method Details
-
createCache
protected void createCache()Creates the cache collections.- Overrides:
createCachein classLazyCollection<E>
-
equals
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Overrides:
hashCodein classObject
-
asString
Evaluates the collection as an OCL String.- Specified by:
asStringin classLazyCollection<E>- Parameters:
env- the execution environment- Returns:
- the String representation of this
LazyCollection.
-
union
-
union
-
intersection
Returns the intersection of self andbag(i.e, the bag of all elements that are in both self ands, where the element occurs as often as in the bag with the least element occurrences).Lazy operation.
- Parameters:
bag- the collection to intersect with this- Returns:
- The intersection of self and
bag.
-
intersection
-
including
-
including
Returns the collection containing all elements of self plusobject.Lazy operation.
- Specified by:
includingin classLazyCollection<E>- Parameters:
object- the object to includeindex- the index at which to insertcoll(starting at 1)- Returns:
- The collection containing all elements of self plus
object.
-
includingAll
Returns the collection containing all elements of self pluscoll.Lazy operation.
- Specified by:
includingAllin classLazyCollection<E>- Parameters:
coll- the collection to include- Returns:
- The collection containing all elements of self plus
coll.
-
includingAll
Returns the collection containing all elements of self pluscoll.Lazy operation.
- Specified by:
includingAllin classLazyCollection<E>- Parameters:
coll- the collection to includeindex- the index at which to insertcoll(starting at 1)- Returns:
- The collection containing all elements of self plus
coll. - Throws:
UnsupportedOperationException
-
excluding
Returns the bag containing all elements of self apart from all occurrences ofobject.Lazy operation.
- Specified by:
excludingin classLazyCollection<E>- Parameters:
object- the object to exclude- Returns:
- The bag containing all elements of self apart from all occurrences of
object.
-
excludingAll
Returns the collection containing all elements of self minuscoll.Lazy operation.
- Specified by:
excludingAllin classLazyCollection<E>- Parameters:
coll- the collection to exclude- Returns:
- The collection containing all elements of self minus
coll.
-
flatten
If the element type is not a collection type this results in the same self. If the element type is a collection type, the result is the sequence containing all the elements of all the elements of self. The order of the elements is partial.Lazy operation.
- Returns:
- if self.type.elementType.oclIsKindOf(CollectionType) then
self->iterate(c; acc : Bag() = Bag{} |
acc->union(c->asBag() ) )
else
self
endif
-
asBag
Returns a Bag identical to self. This operation exists for convenience reasons.Lazy operation.
- Overrides:
asBagin classLazyCollection<E>- Returns:
- A Bag identical to self. This operation exists for convenience reasons.
-
includingRange
Returns the bag containing all elements of self plus the bag offirstrunning tolast.Lazy operation.
- Specified by:
includingRangein classLazyCollection<E>- Parameters:
first- the first object of the range to includelast- the last object of the range to include- Returns:
- The bag containing all elements of self plus the bag of
firstrunning tolast
-
select
-
reject
-
collect
-
sortedBy
Results in the Collection containing all elements of the source collection. The element for which body has the lowest value comes first, and so on. The type of the body expression must have the<operation defined. The<operation must return a Boolean value and must be transitive (i.e., ifa < bandb < cthena < c).- Specified by:
sortedByin classLazyCollection<E>- Parameters:
body- the function to evaluate on each element- Returns:
- the sorted collection
-