Package org.eclipse.emf.common.util
Class ECollections
java.lang.Object
org.eclipse.emf.common.util.ECollections
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> EList<T> Returns an EList view of the specified list.static <T> EList<T> asEList(T... elements) Returns a mutable, fixed-size, random access EList backed by the given array.static <K,V> EMap <K, V> Returns a mutable EMap view of the specified map.static <T> EList<T> Returns an empty unmodifiable list.static <K,V> EMap <K, V> Returns an empty unmodifiable map.static intSearches for the first occurrence of the given argument in list starting from a specified index.static <T> TMoves the object from the old position to the new position.static <T> voidMoves the object to the new position, if is in the list.static <T> BasicEList<T> Creates an empty mutableBasicEList.static <T> BasicEList<T> newBasicEList(Iterable<? extends T> iterable) Creates a mutableBasicEListcontaining the given elements.static <T> BasicEList<T> newBasicEList(Iterator<? extends T> iterator) Creates a mutableBasicEListcontaining the given elements.static <T> BasicEList<T> newBasicEList(T... elements) Creates a mutableBasicEListcontaining the given elements.static <T> BasicEList<T> newBasicEListWithCapacity(int capacity) Creates an empty mutableBasicEListwith the given capacity.static <T> BasicEList<T> newBasicEListWithExpectedSize(int estimatedSize) Creates an empty mutableBasicEListwith a capacity large enough to hold a bit more than the estimated number of elements.static voidReverses the order of the elements in the specified EList.static <T> voidSets theeList's contents and order to be exactly that of theprototypelist.static <T> EList<T> singletonEList(T o) Returns an immutable list containing just the one object.static <K,V> EMap <K, V> singletonEMap(K key, V value) Returns an immutable map containing just the one key/value mapping.static voidSorts the specified list.static <T> voidsort(EList<T> list, Comparator<? super T> comparator) Sorts the specified list based on the order defined by the specified comparator.static <T> InterningSet<T> synchronizedInterningSet(InterningSet<T> set) Returns a synchronized, i.e., thread-safe view of the interning set.static <T> EList<T> Returns a list containing the elements of the given iterable.static <T> EList<T> Returns a mutable list containing the elements of the given iterator.static <T> EList<T> unmodifiableEList(List<? extends T> list) Returns an unmodifiable view of the list.static <T> EList<T> unmodifiableEList(EList<? extends T> list) Returns an unmodifiable view of the list.static <K,V> EMap <K, V> unmodifiableEMap(EMap<? extends K, ? extends V> map) Returns an unmodifiable view of the map.
-
Field Details
-
EMPTY_ELIST
An unmodifiable empty list with an efficient reusable iterator. -
EMPTY_EMAP
An unmodifiable empty map with an efficient reusable iterator.
-
-
Method Details
-
move
Moves the object to the new position, if is in the list.- Parameters:
newPosition- the position of the object after the move.object- the object to move.
-
move
Moves the object from the old position to the new position.- Parameters:
targetIndex- the position of the object after the move.sourceIndex- the position of the object before the move.- Returns:
- the moved object
-
reverse
Reverses the order of the elements in the specified EList. -
indexOf
Searches for the first occurrence of the given argument in list starting from a specified index. The equality is tested using the operator == and the equals method.- Parameters:
o- an object (can be null)fromIndex-- Returns:
- the index of the first occurrence of the argument in this list (where index>=fromIndex); returns -1 if the object is not found.
- Since:
- 2.1.0
-
sort
Sorts the specified list. Use this method instead ofCollections.sort(java.util.List)to avoid errors when sorting unique lists.- Since:
- 2.1.0
-
sort
Sorts the specified list based on the order defined by the specified comparator. Use this method instead ofCollections.sort(java.util.List, java.util.Comparator)to avoid errors when sorting unique lists.- Since:
- 2.1.0
-
setEList
Sets theeList's contents and order to be exactly that of theprototypelist. This implementation minimizes the number of notifications the operation will produce. Objects already in the list will be moved, missing objects will be added, and extra objects will be removed. IfeList's contents and order are already exactly that of theprototypelist, no change will be made.- Parameters:
eList- the list to set.prototypeList- the list representing the desired content and order.
-
unmodifiableEList
Returns an unmodifiable view of the list.- Returns:
- an unmodifiable view of the list.
-
unmodifiableEMap
Returns an unmodifiable view of the map.- Returns:
- an unmodifiable view of the map.
-
emptyEList
Returns an empty unmodifiable list.- Returns:
- an empty unmodifiable list.
-
emptyEMap
Returns an empty unmodifiable map.- Returns:
- an empty unmodifiable map.
-
singletonEList
Returns an immutable list containing just the one object.- Returns:
- an immutable list containing just the one object.
- Since:
- 2.7
-
singletonEMap
Returns an immutable map containing just the one key/value mapping.- Returns:
- an immutable map containing just the one key/value mapping.
- Since:
- 2.7
-
toEList
Returns a mutable list containing the elements of the given iterator.- Returns:
- a mutable list containing the same elements as the given iterator.
- Since:
- 2.9
-
toEList
Returns a list containing the elements of the given iterable. If the iterable is of typeEList, that list itself is returned. If the iterable is of typeList, aviewof that list is returned; all changes to view are reflected in the underlying list and all changes to the underlying list are reflected in the view. In all other cases, the result is acopyof the iterable.- Returns:
- a list containing the same elements as the given iterable.
- Since:
- 2.9
-
asEMap
Returns a mutable EMap view of the specified map.EList.move(int, int),EList.move(int, Object),List.add(int, Object), andList.addAll(int, Collection), i.e., the methods that expect to control the exact order of entries in the map's entry set, are not supported and throwUnsupportedOperationException. All other changes to the EMap write through to the underlying map.- Parameters:
map- the map to which the EMap delegates.- Returns:
- an EMap view of the specified map.
- Since:
- 2.9
-
asEList
Returns an EList view of the specified list. All changes to the EList write through to the underlying list.- Parameters:
list- the list to which the EList delegates.- Returns:
- an EList view of the specified list.
- Since:
- 2.9
-
asEList
Returns a mutable, fixed-size, random access EList backed by the given array. Changes to the list, i.e., set and move, write through to the array. All other list modifying operations throwUnsupportedOperationException. This is analogous toArrays.asList(Object...)with the advantage that you canmoveobjects; hence you cansortwithout usingList.add(int, Object)andList.remove(int).- Parameters:
elements- the array to which the EList delegates.- Returns:
- an EList view of the specified array.
- Since:
- 2.9
-
unmodifiableEList
Returns an unmodifiable view of the list.- Returns:
- an unmodifiable view of the list.
- Since:
- 2.9
-
newBasicEList
Creates an empty mutableBasicEList.- Returns:
- an empty mutable
BasicEList. - Since:
- 2.9
-
newBasicEListWithCapacity
Creates an empty mutableBasicEListwith the given capacity.- Returns:
- an empty mutable
BasicEList. - Since:
- 2.9
-
newBasicEListWithExpectedSize
Creates an empty mutableBasicEListwith a capacity large enough to hold a bit more than the estimated number of elements. If you know the exact size, usenewBasicEListWithCapacity(int)instead.- Returns:
- an empty mutable
BasicEList. - Since:
- 2.9
-
newBasicEList
Creates a mutableBasicEListcontaining the given elements.- Returns:
- a mutable
BasicEListcontaining the given elements. - Since:
- 2.9
-
newBasicEList
Creates a mutableBasicEListcontaining the given elements.- Returns:
- a mutable
BasicEListcontaining the given elements. - Since:
- 2.9
-
newBasicEList
Creates a mutableBasicEListcontaining the given elements.- Returns:
- a mutable
BasicEListcontaining the given elements. - Since:
- 2.9
-
synchronizedInterningSet
Returns a synchronized, i.e., thread-safe view of the interning set. The result is serializeable if the argument is serializeable.- Parameters:
set- the interning set to which this interning set delegates.- Returns:
- a synchronized view of the interning set.
- Since:
- 2.9
-