Package org.eclipse.m2m.atl.emftvm.util
Class LazySet<E>
java.lang.Object
org.eclipse.m2m.atl.emftvm.util.LazyCollection<E>
org.eclipse.m2m.atl.emftvm.util.LazySet<E>
- Type Parameters:
E- the collection element type
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
- Direct Known Subclasses:
EnumConversionSetOnSet,LazySet.IntegerRangeSet,LazySet.LongRangeSet,LazySet.NonCachingSet,LazySetOnSet
Immutable
Set that supports lazy evaluation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classNested classes/interfaces inherited from class org.eclipse.m2m.atl.emftvm.util.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 org.eclipse.m2m.atl.emftvm.util.LazyCollection
cache, dataSource, occurrences -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasSet()Returns a Set 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.intReturns the number of occurrences ofobjectin self.
post: result <= 1protected voidCreates the cache collections.booleanReturns the set containing all elements of self withoutobject.excludingAll(Collection<?> coll) Returns the collection containing all elements of self minuscoll.LazySet<?> flatten()If the element type is not a collection type this results in the same self.inthashCode()Returns the set 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 Set containing all elements of self plus the Set offirstrunning tolast.intersection(LazyBag<E> s) Returns the intersection of self ands(i.e, the set of all elements that are in both self ands).intersection(LazySet<E> s) Returns the intersection of self ands(i.e, the set of all elements that are in both self ands).iterator()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 elements of self, which are not ins.Returns the set containing all the elements that are in self ors, but not in both.Returns the union of self andbag.Returns the union of self ands.Methods inherited from class org.eclipse.m2m.atl.emftvm.util.LazyCollection
add, addAll, any, appendElements, asBag, asOrderedSet, asSequence, clear, contains, containsAll, containsAny, excludes, excludesAll, exists, exists2, forAll, forAll2, includes, includesAll, isEmpty, isUnique, iterate, mappedBy, mappedBySingle, max, min, notEmpty, one, product, remove, removeAll, retainAll, size, sum, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
Method Details
-
createCache
protected void createCache()Creates the cache collections.- Overrides:
createCachein classLazyCollection<E>
-
iterator
-
equals
-
hashCode
public int hashCode() -
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.
-
count
Returns the number of occurrences ofobjectin self.
post: result <= 1- Overrides:
countin classLazyCollection<E>- Parameters:
o- the object to count- Returns:
- The number of occurrences of
objectin self.
-
union
Returns the union of self ands.Lazy operation.
- Parameters:
s- the collection to union with self- Returns:
- The union of self and
s.
-
union
Returns the union of self andbag.Lazy operation.
- Parameters:
bag- the collection to union with self- Returns:
- The union of self and
bag.
-
intersection
Returns the intersection of self ands(i.e, the set of all elements that are in both self ands).Lazy operation.
- Parameters:
s- the collection to intersect with self- Returns:
- The intersection of self and
s(i.e, the set of all elements that are in both self ands).
-
intersection
Returns the intersection of self ands(i.e, the set of all elements that are in both self ands).Lazy operation.
- Parameters:
s- the collection to intersect with self- Returns:
- The intersection of self and
s(i.e, the set of all elements that are in both self ands).
-
subtract
Returns the elements of self, which are not ins.Lazy operation.
- Parameters:
s- the collection to subtract from self- Returns:
- The elements of self, which are not in
s.
-
including
Returns the set containing all elements of self plusobject.Lazy operation.
- Specified by:
includingin classLazyCollection<E>- Parameters:
object- the object to include- Returns:
- The set containing all elements of self plus
object
-
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 set containing all elements of self withoutobject.Lazy operation.
- Specified by:
excludingin classLazyCollection<E>- Parameters:
object- the object to exclude- Returns:
- The set containing all elements of self without
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.
-
symmetricDifference
Returns the set containing all the elements that are in self ors, but not in both.Lazy operation.
- Parameters:
s- the collection to perform the symmetric difference with- Returns:
- The set containing all the elements that are in self or
s, but not in both.
-
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 set containing all the elements of all the elements of self.Lazy operation.
- Returns:
- if self.type.elementType.oclIsKindOf(CollectionType) then
self->iterate(c; acc : Set() = Set{} |
acc->union(c->asSet() ) )
else
self
endif
-
asSet
Returns a Set identical to self. This operation exists for convenience reasons.Lazy operation.
- Overrides:
asSetin classLazyCollection<E>- Returns:
- A Set identical to self. This operation exists for convenience reasons.
-
includingRange
Returns the Set containing all elements of self plus the Set 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 Set containing all elements of self plus the Set of
firstrunning tolast
-
select
Selects all elements from this collection for which theconditionevaluates totrue.- Parameters:
condition- the condition function- Returns:
- a new lazy set with only the selected elements.
-
reject
Rejects all elements from this collection for which theconditionevaluates totrue.- Parameters:
condition- the condition function- Returns:
- a new lazy set without the rejected elements.
-
collect
Collects the return values offunctionfor each of the elements of this collection.- Type Parameters:
T- the element type- Parameters:
function- the return value function- Returns:
- a new lazy bag with the
functionreturn values.
-
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
-