Package org.eclipse.m2m.atl.emftvm.util
Class LazyOrderedSet<E>
java.lang.Object
org.eclipse.m2m.atl.emftvm.util.LazyCollection<E>
org.eclipse.m2m.atl.emftvm.util.LazyOrderedSet<E>
- Type Parameters:
E
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
,Set<E>
- Direct Known Subclasses:
LazyOrderedSet.IntegerRangeOrderedSet
,LazyOrderedSet.LongRangeOrderedSet
,LazyOrderedSet.NonCachingOrderedSet
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
LazyOrderedSet
that appends an element to the underlyingLazyOrderedSet
, except when it already occurs in the underlyingLazyOrderedSet
.static class
LazyOrderedSet
that excludes an element from the underlyingLazyOrderedSet
.static class
LazyOrderedSet
that inserts an object into the underlyingLazyOrderedSet
, except when it already occurs in the underlyingLazyOrderedSet
.static class
LazyOrderedSet
that represents a range running from a first to lastInteger
.static class
LazyOrderedSet
that represents a range running from a first to lastLong
.static class
LazyOrderedSet
that disables caching of the underlyingLazyOrderedSet
.static class
LazyOrderedSet
that prepends an element to the underlyingLazyOrderedSet
, except when it already occurs in the underlyingLazyOrderedSet
.static class
LazyOrderedSet
in reverse order.static class
LazyOrderedSet
that represents a sub-range of the underlyingLazyOrderedSet
.Nested 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
ConstructorDescriptionCreates an emptyLazyOrderedSet
.LazyOrderedSet
(Iterable<E> dataSource) Creates aLazyOrderedSet
arounddataSource
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Unsupported.boolean
addAll
(int index, Collection<? extends E> c) Unsupported.Returns the set of elements, consisting of all elements of self, followed byobject
.Returns an OrderedSet identical to self.Evaluates the collection as an OCL String.at
(int i) Returns thei
-th element of this list.<T> LazyList<T>
Collects the return values offunction
for each of the elements of this collection.int
Returns the number of occurrences ofobject
in self.
post: result <= 1
protected void
Creates the cache collections.boolean
Returns the set containing all elements of self withoutobject
.excludingAll
(Collection<?> coll) Returns the collection containing all elements of self minuscoll
.first()
Returns the first element in self.flatten()
If the element type is not a collection type this results in the same self.get
(int index) int
hashCode()
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 OrderedSet containing all elements of self plus the OrderedSet offirst
running tolast
added as the last elements.int
int
Returns the index of objectobj
in the sequence.Returns the OrderedSet consisting of self withobject
inserted at positionindex
.intersection
(LazyBag<E> s) Returns the intersection of self ands
(i.e, the set of all elements that are in both self ands
).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()
last()
Returns the last element in self.int
int
lastIndexOf2
(Object obj) Returns the last index of objectobj
in the sequence.listIterator
(int index) Returns the OrderedSet consisting ofobject
, followed by all elements in self.Rejects all elements from this collection for which thecondition
evaluates totrue
.remove
(int index) Unsupported.reverse()
Returns the ordered set of elements with same elements but with the opposite order.Selects all elements from this collection for which thecondition
evaluates totrue
.Unsupported.Results in the Collection containing all elements of the source collection.subList
(int fromIndex, int toIndex) Lazy implementation ofList.subList(int, int)
.subSequence
(int lower, int upper) Returns the sub-set of self starting at numberlower
, up to and including element numberupper
.subtract
(LazyOrderedSet<E> s) Returns the elements of self, which are not ins
.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
.union
(LazyOrderedSet<? extends E> s) Returns the union of self ands
, where elements of self are returned before elements of s.union
(LazyOrderedSet<? extends E> s, int index) Returns the ordered set consisting of all elements in self, with all elements ins
inserted atindex
.Returns the union of self ands
.Methods inherited from class org.eclipse.m2m.atl.emftvm.util.LazyCollection
add, addAll, any, appendElements, asBag, asSequence, asSet, 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, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
LazyOrderedSet
public LazyOrderedSet()Creates an emptyLazyOrderedSet
. -
LazyOrderedSet
Creates aLazyOrderedSet
arounddataSource
.- Parameters:
dataSource
- the underlying collection
-
-
Method Details
-
createCache
protected void createCache()Creates the cache collections.- Overrides:
createCache
in classLazyCollection<E>
-
iterator
-
add
Unsupported.- Specified by:
add
in interfaceList<E>
- Parameters:
index
- the index at which to addelement
- the object to add- Throws:
UnsupportedOperationException
-
addAll
Unsupported.- Specified by:
addAll
in interfaceList<E>
- Parameters:
index
- the index at which to addc
- the collection to add- Returns:
- nothing
- Throws:
UnsupportedOperationException
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
remove
Unsupported.- Specified by:
remove
in interfaceList<E>
- Parameters:
index
- the index at which to remove- Returns:
- nothing
- Throws:
UnsupportedOperationException
-
set
Unsupported.- Specified by:
set
in interfaceList<E>
- Parameters:
index
- the index at which to setelement
- the element to set- Returns:
- nothing
- Throws:
UnsupportedOperationException
-
subList
Lazy implementation of
List.subList(int, int)
. -
equals
-
hashCode
public int hashCode() -
asString
Evaluates the collection as an OCL String.- Specified by:
asString
in classLazyCollection<E>
- Parameters:
env
- the execution environment- Returns:
- the String representation of this
LazyCollection
.
-
count
Returns the number of occurrences ofobject
in self.
post: result <= 1
- Overrides:
count
in classLazyCollection<E>
- Parameters:
o
- the object to count- Returns:
- The number of occurrences of
object
in self.
-
at
Returns thei
-th element of this list. List index starts at 1.- Parameters:
i
- the element index- Returns:
- The
i
-th element of this list.
-
indexOf2
Returns the index of objectobj
in the sequence. List index starts at 1.
pre :self->includes(obj)
post :self->at(i) = obj
- Parameters:
obj
- the object- Returns:
- The index of object
obj
in the sequence. - Throws:
IndexOutOfBoundsException
- ifobj
is not contained in this list.
-
lastIndexOf2
Returns the last index of objectobj
in the sequence. List index starts at 1.
pre :self->includes(obj)
post :self->at(i) = obj
- Parameters:
obj
- the object- Returns:
- The last index of object
obj
in the sequence. - Throws:
IndexOutOfBoundsException
- ifobj
is not contained in this list.
-
first
Returns the first element in self.- Returns:
- The first element in self.
-
last
Returns the last element in self.- Returns:
- The last element in self.
-
union
Returns the union of self ands
, where elements of self are returned before elements of s.Lazy operation.
- Parameters:
s
- the collection to union with self- Returns:
- The union of self and
s
.
-
union
Returns the ordered set consisting of all elements in self, with all elements ins
inserted atindex
.Lazy operation.
- Parameters:
s
- the ordered set to union with thisindex
- the insertion index (starting at 1)- Returns:
- The ordered set consisting of all elements in self, with all elements in
s
inserted atindex
-
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
).
-
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
.
-
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:
including
in classLazyCollection<E>
- Parameters:
object
- the element 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:
including
in 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:
includingAll
in 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:
includingAll
in 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
.
-
excluding
Returns the set containing all elements of self withoutobject
.Lazy operation.
- Specified by:
excluding
in classLazyCollection<E>
- Parameters:
object
- the element 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:
excludingAll
in 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 : OrderedSet() = OrderedSet{} |
acc->union(c->asOrderedSet() ) )
else
self
endif
-
append
Returns the set of elements, consisting of all elements of self, followed byobject
.Lazy operation.
- Parameters:
object
- the element to append- Returns:
- The set of elements, consisting of all elements of self, followed by
object
.
-
prepend
Returns the OrderedSet consisting ofobject
, followed by all elements in self.Lazy operation.
- Parameters:
object
- the element to prepend- Returns:
- The OrderedSet consisting of
object
, followed by all elements in self.
-
insertAt
Returns the OrderedSet consisting of self withobject
inserted at positionindex
. List index starts at 1.Lazy operation.
- Parameters:
index
- the index at which to insertobject
- the element to insert- Returns:
- The OrderedSet consisting of self with
object
inserted at positionindex
.
-
subSequence
Returns the sub-set of self starting at numberlower
, up to and including element numberupper
. List index starts at 1.Lazy operation.
- Parameters:
lower
- the sub-range lower bound, inclusiveupper
- the sub-range upper bound, inclusive- Returns:
- The sub-set of self starting at number
lower
, up to and including element numberupper
.
-
reverse
Returns the ordered set of elements with same elements but with the opposite order.- Returns:
- The ordered set of elements with same elements but with the opposite order.
-
asOrderedSet
Returns an OrderedSet identical to self. This operation exists for convenience reasons.Lazy operation.
- Overrides:
asOrderedSet
in classLazyCollection<E>
- Returns:
- An OrderedSet identical to self. This operation exists for convenience reasons.
-
includingRange
Returns the OrderedSet containing all elements of self plus the OrderedSet offirst
running tolast
added as the last elements.Lazy operation.
- Specified by:
includingRange
in classLazyCollection<E>
- Parameters:
first
- the first object of the range to includelast
- the last object of the range to include- Returns:
- The OrderedSet containing all elements of self plus the OrderedSet of
first
running tolast
added as the last elements
-
select
Selects all elements from this collection for which thecondition
evaluates totrue
.- Parameters:
condition
- the condition function- Returns:
- a new lazy ordered set with only the selected elements.
-
reject
Rejects all elements from this collection for which thecondition
evaluates totrue
.- Parameters:
condition
- the condition function- Returns:
- a new lazy ordered set without the rejected elements.
-
collect
Collects the return values offunction
for each of the elements of this collection.- Type Parameters:
T
- the element type- Parameters:
function
- the return value function- Returns:
- a new lazy list with the
function
return 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 < b
andb < c
thena < c
).- Specified by:
sortedBy
in classLazyCollection<E>
- Parameters:
body
- the function to evaluate on each element- Returns:
- the sorted collection
-