Package org.eclipse.m2m.atl.emftvm.util
Class LazyList<E>
java.lang.Object
org.eclipse.m2m.atl.emftvm.util.LazyCollection<E>
org.eclipse.m2m.atl.emftvm.util.LazyList<E>
- Type Parameters:
E
- the collection element type
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
,org.eclipse.emf.common.util.EList<E>
- Direct Known Subclasses:
EnumConversionList
,LazyList.CollectList
,LazyList.IntegerRangeList
,LazyList.LongRangeList
,LazyList.NonCachingList
,LazyListOnCollection
,ModelImpl.InstanceOfList
,OCLOperations.ResolveList
Immutable
EList
that supports lazy evaluation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
LazyList
that implements thecollect(CodeBlock)
function.static class
LazyList
that inserts an element it a given index in the underlying collection.static class
static class
static class
static class
static class
LazyList
that reverses the order of the underlying list.static class
LazyList
that presents a sub-range of the underlying list.static class
class
ListIterator
that returns first the elements of the underlying collection, then the elements of the other collection.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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Unsupported.boolean
addAll
(int index, Collection<? extends E> c) Unsupported.Returns the sequence of elements, consisting of all elements of self, followed byobject
.Returns the Sequence identical to the object itself.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.protected void
Creates the cache collections.boolean
Returns the sequence containing all elements of self apart from all occurrences ofobject
.excludingAll
(Collection<?> coll) Returns the collection containing all elements of self minuscoll
.first()
Returns the first element in self.LazyList<?>
flatten()
If the element type is not a collection type this results in the same self.get
(int index) int
hashCode()
Returns the sequence containing all elements of self plusobject
added as the last element.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 sequence containing all elements of self plus the sequence offirst
running tolast
added as the last elements.int
int
Returns the index of objectobj
in the sequence.Returns the sequence consisting of self withobject
inserted at positionindex
.last()
Returns the last element in self.int
int
lastIndexOf2
(Object obj) Returns the last index of objectobj
in the sequence.listIterator
(int index) move
(int newPosition, int oldPosition) Unsupported in this implementation.void
Unsupported in this implementation.Returns the sequence 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 sequence containing the 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-list of this list starting at numberlower
, up to and including element numberupper
.Returns the sequence consisting of all elements in self, followed by all elements ins
.Returns the sequence consisting of all elements in self, with all elements ins
inserted atindex
.Methods inherited from class org.eclipse.m2m.atl.emftvm.util.LazyCollection
add, addAll, any, appendElements, asBag, asOrderedSet, 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, 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
-
Method Details
-
createCache
protected void createCache()Creates the cache collections.- Overrides:
createCache
in classLazyCollection<E>
-
add
Unsupported.- Specified by:
add
in interfaceList<E>
- Parameters:
index
- the index at which to addelement
- the element 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)
. -
move
Unsupported in this implementation.- Specified by:
move
in interfaceorg.eclipse.emf.common.util.EList<E>
- Throws:
UnsupportedOperationException
-
move
Unsupported in this implementation.- Specified by:
move
in interfaceorg.eclipse.emf.common.util.EList<E>
- Throws:
UnsupportedOperationException
-
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
.
-
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 to look for- 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 to look for- 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 sequence consisting of all elements in self, followed by all elements ins
.Lazy operation.
- Parameters:
s
- the list to union with this- Returns:
- The sequence consisting of all elements in self, followed by all elements in
s
.
-
union
Returns the sequence consisting of all elements in self, with all elements ins
inserted atindex
.Lazy operation.
- Parameters:
s
- the list to union with thisindex
- the insertion index (starting at 1)- Returns:
- The sequence consisting of all elements in self, with all elements in
s
inserted atindex
-
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 : Sequence() = Sequence{} |
acc->union(c->asSequence() ) )
else
self
endif
-
append
Returns the sequence of elements, consisting of all elements of self, followed byobject
.Lazy operation.
- Parameters:
object
- the object to append- Returns:
- The sequence of elements, consisting of all elements of self, followed by
object
.
-
prepend
Returns the sequence consisting ofobject
, followed by all elements in self.Lazy operation.
- Parameters:
object
- the object to prepend- Returns:
- The sequence consisting of
object
, followed by all elements in self.
-
insertAt
Returns the sequence consisting of self withobject
inserted at positionindex
. List index starts at 1.Lazy operation.
- Parameters:
index
- the index at which to insertobject
- the object to insert- Returns:
- The sequence consisting of self with
object
inserted at positionindex
.
-
subSequence
Returns the sub-list of this list starting at numberlower
, up to and including element numberupper
. List index starts at 1.Lazy operation.
- Parameters:
lower
- the sub-list lower bound, inclusiveupper
- the sub-list upper bound, inclusive- Returns:
- the sub-list of this list.
-
including
Returns the sequence containing all elements of self plusobject
added as the last element.Lazy operation.
- Specified by:
including
in classLazyCollection<E>
- Parameters:
object
- the object to include- Returns:
- The sequence containing all elements of self plus
object
added as the last element.
-
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 sequence containing all elements of self apart from all occurrences ofobject
.Lazy operation.
- Specified by:
excluding
in classLazyCollection<E>
- Parameters:
object
- the object to exclude- Returns:
- The sequence 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:
excludingAll
in classLazyCollection<E>
- Parameters:
coll
- the collection to exclude- Returns:
- The collection containing all elements of self minus
coll
.
-
reverse
Returns the sequence containing the same elements but with the opposite order.Lazy operation.
- Returns:
- The sequence containing the same elements but with the opposite order.
-
asSequence
Returns the Sequence identical to the object itself. This operation exists for convenience reasons.Lazy operation.
- Overrides:
asSequence
in classLazyCollection<E>
- Returns:
- The Sequence identical to the object itself. This operation exists for convenience reasons.
-
includingRange
Returns the sequence containing all elements of self plus the sequence 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 sequence containing all elements of self plus the sequence 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 list 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 list 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
-