org.eclipse.emf.common.util
Class ECollections

java.lang.Object
  extended byorg.eclipse.emf.common.util.ECollections

public class ECollections
extends Object

Support for empty and unmodifiable ELists.


Field Summary
static EList EMPTY_ELIST
          An unmodifiable empty list with an efficient reusable iterator.
static EMap EMPTY_EMAP
          An unmodifiable empty map with an efficient reusable iterator.
 
Method Summary
static int indexOf(List list, Object o, int fromIndex)
          Searches for the first occurence of the given argument in list starting from a specified index.
static Object move(List list, int targetIndex, int sourceIndex)
          Moves the object from the old position to the new position.
static void move(List list, int newPosition, Object object)
          Moves the object to the new position, if is in the list.
static void reverse(EList list)
          Reverses the order of the elements in the specified EList.
static void setEList(EList eList, List prototypeList)
          Sets the eList's contents and order to be exactly that of the prototype list.
static void sort(EList list)
          Sorts the specified list.
static void sort(EList list, Comparator comparator)
          Sorts the specified list based on the order defined by the specified comparator.
static EList unmodifiableEList(EList list)
          Returns an unmodifiable view of the list.
static EMap unmodifiableEMap(EMap map)
          Returns an unmodifiable view of the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ELIST

public static final EList EMPTY_ELIST
An unmodifiable empty list with an efficient reusable iterator.


EMPTY_EMAP

public static final EMap EMPTY_EMAP
An unmodifiable empty map with an efficient reusable iterator.

Method Detail

move

public static void move(List list,
                        int newPosition,
                        Object object)
Moves the object to the new position, if is in the list.

Parameters:
list -
newPosition - the position of the object after the move.
object - the object to move.

move

public static Object move(List list,
                          int targetIndex,
                          int sourceIndex)
Moves the object from the old position to the new position.

Parameters:
list -
targetIndex - the position of the object after the move.
sourceIndex - the position of the object before the move.

reverse

public static void reverse(EList list)
Reverses the order of the elements in the specified EList.


indexOf

public static int indexOf(List list,
                          Object o,
                          int fromIndex)
Searches for the first occurence of the given argument in list starting from a specified index. The equality is tested using the operator == and the equals method.

Parameters:
list -
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

public static void sort(EList list)
Sorts the specified list. Use this method instead of Collections.sort(java.util.List) to avoid errors when sorting unique lists.

Since:
2.1.0

sort

public static void sort(EList list,
                        Comparator comparator)
Sorts the specified list based on the order defined by the specified comparator. Use this method instead of Collections.sort(java.util.List, java.util.Comparator) to avoid errors when sorting unique lists.

Since:
2.1.0

setEList

public static void setEList(EList eList,
                            List prototypeList)
Sets the eList's contents and order to be exactly that of the prototype list. This implementation mimimizes 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. If eList's contents and order are already exactly that of the prototype list, no change will be made.

Parameters:
eList - the list to set.
prototypeList - the list representing the desired content and order.

unmodifiableEList

public static EList unmodifiableEList(EList list)
Returns an unmodifiable view of the list.

Returns:
an unmodifiable view of the list.

unmodifiableEMap

public static EMap unmodifiableEMap(EMap map)
Returns an unmodifiable view of the map.

Returns:
an unmodifiable view of the map.

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.