|
||||||||||
| PREV CLASS SOURCE NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.eclipse.emf.common.util.BasicEMap
A highly extensible map implementation.
| Inner Class Summary | |
|---|---|
protected class |
BasicEMap.BasicEMapIterator
An iterator over the map entry data. |
protected class |
BasicEMap.BasicEMapKeyIterator
An iterator over the map key data. |
protected class |
BasicEMap.BasicEMapValueIterator
An iterator over the map value data. |
protected class |
BasicEMap.DelegatingMap
|
static interface |
BasicEMap.Entry
An extended implementation interface for caching hash values and for upating an entry that may be manufactured as a uninitialized instance by a factory. |
protected class |
BasicEMap.EntryImpl
A simple and obvious entry implementation. |
protected static class |
BasicEMap.View
An implementation class to hold the views. |
| Field Summary | |
|---|---|
protected EList |
delegateEList
The underlying list of entries. |
protected BasicEList[] |
entryData
The array of entry lists into which the hash codes are indexed. |
protected int |
modCount
The modification indicator used to ensure iterator integrity. |
protected int |
size
The size of the map. |
protected BasicEMap.View |
view
The various alternative views of the map. |
| Constructor Summary | |
|---|---|
BasicEMap()
Creates an empty instance. |
|
BasicEMap(int initialCapacity)
Creates an empty instance with the given capacity. |
|
BasicEMap(java.util.Map map)
Creates an instance that is a copy of the map. |
|
| Method Summary | |
|---|---|
void |
add(int index,
java.lang.Object object)
Delegates to delegateEList. |
boolean |
add(java.lang.Object object)
Delegates to delegateEList. |
boolean |
addAll(java.util.Collection collection)
Delegates to delegateEList. |
boolean |
addAll(int index,
java.util.Collection collection)
Delegates to delegateEList. |
void |
clear()
Delegates to delegateEList. |
java.lang.Object |
clone()
Returns a shallow copy of this map. |
boolean |
contains(java.lang.Object object)
Delegates to delegateEList. |
boolean |
containsAll(java.util.Collection collection)
Delegates to delegateEList. |
boolean |
containsKey(java.lang.Object key)
Returns whether the key is associated with a value. |
boolean |
containsValue(java.lang.Object value)
Returns whether the value is associated with a key. |
protected void |
didAdd(BasicEMap.Entry entry)
Called to indicate that the entry has been added. |
protected void |
didClear(BasicEList[] oldEntryData)
Called to indicate that the map has been cleared. |
protected void |
didModify(BasicEMap.Entry entry,
java.lang.Object oldValue)
Called to indicate that the entry has an updated value. |
protected void |
didRemove(BasicEMap.Entry entry)
Called to indicate that the entry has been removed. |
protected void |
doClear()
Clears the map. |
protected void |
doMove(BasicEMap.Entry entry)
Increments the modification count. |
protected void |
doPut(BasicEMap.Entry entry)
Adds the new entry to the map. |
protected void |
doRemove(BasicEMap.Entry entry)
Removes the entry from the map. |
protected void |
ensureEntryDataExists()
Ensures that the entry data is created and is populated with contents of the delegate list. |
protected BasicEMap.Entry |
entryForKey(int index,
int hash,
java.lang.Object key)
Called to return the entry given the index, the hash, and the key. |
protected int |
entryIndexForKey(int index,
int hash,
java.lang.Object key)
Called to return the entry list index given the index, the hash, and the key. |
java.util.Set |
entrySet()
Returns a set view of the entries. |
boolean |
equals(java.lang.Object object)
|
java.lang.Object |
get(int index)
Delegates to delegateEList. |
java.lang.Object |
get(java.lang.Object key)
Returns the value associated with the key. |
protected boolean |
grow(int minimumCapacity)
Grows the capacity of the map to ensure that no additional growth is needed until the size exceeds the specified minimun capacity. |
int |
hashCode()
|
protected int |
hashOf(java.lang.Object key)
Called to return the hash code of the key. |
protected int |
indexOf(int hash)
Called to return the entry data index corresponding to the hash code. |
int |
indexOf(java.lang.Object object)
Delegates to delegateEList. |
int |
indexOfKey(java.lang.Object key)
Returns the index in the list of the entry with the given key, or -1, if there is no such entry. |
protected void |
initializeDelegateEList()
Initializes the delegateEList. |
boolean |
isEmpty()
Returns whether the map has zero size. |
java.util.Iterator |
iterator()
Delegates to delegateEList. |
java.util.Set |
keySet()
Returns a set view of the keys of the entries. |
int |
lastIndexOf(java.lang.Object object)
Delegates to delegateEList. |
java.util.ListIterator |
listIterator()
Delegates to delegateEList. |
java.util.ListIterator |
listIterator(int index)
Delegates to delegateEList. |
java.util.Map |
map()
Returns a map view. |
java.lang.Object |
move(int targetIndex,
int sourceIndex)
Delegates to delegateEList. |
void |
move(int index,
java.lang.Object object)
Delegates to delegateEList. |
protected BasicEMap.Entry |
newEntry(int hash,
java.lang.Object key,
java.lang.Object value)
Returns a new entry. |
protected BasicEList[] |
newEntryData(int capacity)
Returns new allocated entry data storage. |
protected BasicEList |
newList()
Returns a new allocated list of entries. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the key with the value and returns the value previously associated with the key, or null. |
void |
putAll(java.util.Map map)
Puts each Map.Entry of the given map into this one. |
protected java.lang.Object |
putEntry(BasicEMap.Entry entry,
java.lang.Object value)
Sets the value of the entry, and returns the former value. |
java.lang.Object |
remove(int index)
Delegates to delegateEList. |
boolean |
remove(java.lang.Object object)
Delegates to delegateEList. |
boolean |
removeAll(java.util.Collection collection)
Delegates to delegateEList. |
protected java.lang.Object |
removeEntry(int index,
int entryIndex)
Removes the fully indexed entry from the map and returns it's value. |
java.lang.Object |
removeKey(java.lang.Object key)
Disassociates the key from its value, and returns the value formerly associated with the key. |
protected java.lang.Object |
resolve(java.lang.Object key,
java.lang.Object value)
Resolves the value associated with the key and returns the result. |
boolean |
retainAll(java.util.Collection collection)
Delegates to delegateEList. |
java.lang.Object |
set(int index,
java.lang.Object object)
Delegates to delegateEList. |
int |
size()
Returns the number of entries in the map. |
java.util.List |
subList(int start,
int end)
Delegates to delegateEList. |
java.lang.Object[] |
toArray()
Delegates to delegateEList. |
java.lang.Object[] |
toArray(java.lang.Object[] array)
Delegates to delegateEList. |
java.lang.String |
toString()
Delegates to delegateEList. |
protected boolean |
useEqualsForKey()
Returns whether equals rather than == should be used to compare keys. |
protected boolean |
useEqualsForValue()
Returns whether equals rather than == should be used to compare values. |
protected void |
validateKey(java.lang.Object key)
Validates a new key. |
protected void |
validateValue(java.lang.Object value)
Validates a new key. |
java.util.Collection |
values()
Returns a collection view the values of the entries. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected transient EList delegateEList
protected int size
protected transient BasicEList[] entryData
protected transient int modCount
protected transient BasicEMap.View view
| Constructor Detail |
public BasicEMap()
public BasicEMap(int initialCapacity)
initialCapacity - the initial capacity of the map before it must grow.java.lang.IllegalArgumentException - if the initialCapacity is negative.public BasicEMap(java.util.Map map)
map - the initial contents of the map.| Method Detail |
protected void initializeDelegateEList()
delegateEList.
This implementation illustrates the precise pattern that is used to
delegate a list implementation's callback methods to the map implementation.protected BasicEList[] newEntryData(int capacity)
capacity - the capacity of storage needed.protected void ensureEntryDataExists()
protected BasicEList newList()
newEntry.newEntry(int, Object, Object)
protected BasicEMap.Entry newEntry(int hash,
java.lang.Object key,
java.lang.Object value)
validated and the value is validated.
Clients may override this to create typed storage.
The type must be kept in synch with newEntry.hash - the cached hash code of the key.key - the key.value - the value.newList()
protected java.lang.Object putEntry(BasicEMap.Entry entry,
java.lang.Object value)
validated.entry - the entry.value - the value.null.protected boolean useEqualsForKey()
equals rather than == should be used to compare keys.
The default is to return true but clients can optimize performance by returning false.
The performance difference is highly significant.equals rather than == should be used to compare keys.protected boolean useEqualsForValue()
equals rather than == should be used to compare values.
The default is to return true but clients can optimize performance by returning false.
The performance difference is highly significant.equals rather than == should be used to compare values.
protected java.lang.Object resolve(java.lang.Object key,
java.lang.Object value)
value;
clients can use this to transform objects as they are fetched.key - the key of an entry.value - the value of an entry.protected void validateKey(java.lang.Object key)
key - the new key.java.lang.IllegalArgumentException - if a constraint prevents the object from being added.protected void validateValue(java.lang.Object value)
value - the new value.java.lang.IllegalArgumentException - if a constraint prevents the object from being added.protected void didAdd(BasicEMap.Entry entry)
entry - the added entry.
protected void didModify(BasicEMap.Entry entry,
java.lang.Object oldValue)
entry - the new entry.protected void didRemove(BasicEMap.Entry entry)
entry - the removed entry.protected void didClear(BasicEList[] oldEntryData)
didRemove for each entry;
clients can use this to monitor clearing of the map.entry - the removed entry.public int size()
size in interface java.util.Listpublic boolean isEmpty()
isEmpty in interface java.util.Listpublic int indexOfKey(java.lang.Object key)
EMap-1, if there is no such entry.indexOfKey in interface EMaporg.eclipse.emf.common.util.EMapkey - a key.public boolean containsKey(java.lang.Object key)
EMapcontainsKey in interface EMaporg.eclipse.emf.common.util.EMapkey - a key associated with a value.public boolean containsValue(java.lang.Object value)
EMapcontainsValue in interface EMaporg.eclipse.emf.common.util.EMapvalue - a value associated with a key.public java.lang.Object get(java.lang.Object key)
EMapnull.get in interface EMaporg.eclipse.emf.common.util.EMapkey - the key of the value.
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
EMapnull.
The key, the value, or both may be null.
Either the existing entry is updated,
or a new entry is added to the end of the list.put in interface EMaporg.eclipse.emf.common.util.EMapkey - the key of the value.value - the value associated with the key.null.protected void doPut(BasicEMap.Entry entry)
entry - the new entry.public java.lang.Object removeKey(java.lang.Object key)
EMapremoveKey in interface EMaporg.eclipse.emf.common.util.EMapkey - the key of a value.protected void doRemove(BasicEMap.Entry entry)
entry - an entry in the map.
protected java.lang.Object removeEntry(int index,
int entryIndex)
index - the index in the entry dataentry - the index in the list of entries.public void putAll(java.util.Map map)
EMapMap.Entry of the given map into this one.putAll in interface EMaporg.eclipse.emf.common.util.EMapmap - the map of entries.EMap.put(java.lang.Object, java.lang.Object)protected void doClear()
protected void doMove(BasicEMap.Entry entry)
public java.lang.Object clone()
clone in class java.lang.Objectpublic java.util.Map map()
EMapmap in interface EMaporg.eclipse.emf.common.util.EMappublic java.util.Set keySet()
EMapkeySet in interface EMaporg.eclipse.emf.common.util.EMappublic java.util.Collection values()
EMapvalues in interface EMaporg.eclipse.emf.common.util.EMappublic java.util.Set entrySet()
EMapentrySet in interface EMaporg.eclipse.emf.common.util.EMapprotected int hashOf(java.lang.Object key)
key - the key.protected int indexOf(int hash)
hash - the hash code.
protected BasicEMap.Entry entryForKey(int index,
int hash,
java.lang.Object key)
index - the entry data index of the key.hash - the hash code of the key.key - the key.
protected int entryIndexForKey(int index,
int hash,
java.lang.Object key)
index - the entry data index of the key.hash - the hash code of the key.key - the key.protected boolean grow(int minimumCapacity)
public boolean contains(java.lang.Object object)
delegateEList.contains in interface java.util.Listpublic boolean containsAll(java.util.Collection collection)
delegateEList.containsAll in interface java.util.Listpublic int indexOf(java.lang.Object object)
delegateEList.indexOf in interface java.util.Listpublic int lastIndexOf(java.lang.Object object)
delegateEList.lastIndexOf in interface java.util.Listpublic java.lang.Object[] toArray()
delegateEList.toArray in interface java.util.Listpublic java.lang.Object[] toArray(java.lang.Object[] array)
delegateEList.toArray in interface java.util.Listpublic java.lang.Object get(int index)
delegateEList.get in interface java.util.List
public java.lang.Object set(int index,
java.lang.Object object)
delegateEList.set in interface java.util.Listpublic boolean add(java.lang.Object object)
delegateEList.add in interface java.util.List
public void add(int index,
java.lang.Object object)
delegateEList.add in interface java.util.Listpublic boolean addAll(java.util.Collection collection)
delegateEList.addAll in interface java.util.List
public boolean addAll(int index,
java.util.Collection collection)
delegateEList.addAll in interface java.util.Listpublic boolean remove(java.lang.Object object)
delegateEList.remove in interface java.util.Listpublic boolean removeAll(java.util.Collection collection)
delegateEList.removeAll in interface java.util.Listpublic java.lang.Object remove(int index)
delegateEList.remove in interface java.util.Listpublic boolean retainAll(java.util.Collection collection)
delegateEList.retainAll in interface java.util.Listpublic void clear()
delegateEList.clear in interface java.util.List
public void move(int index,
java.lang.Object object)
delegateEList.move in interface EListorg.eclipse.emf.common.util.EListnewPosition - the position of the object after the move.object - the object to move.
public java.lang.Object move(int targetIndex,
int sourceIndex)
delegateEList.move in interface EListorg.eclipse.emf.common.util.EListnewPosition - the position of the object after the move.oldPosition - the position of the object before the move.public java.util.Iterator iterator()
delegateEList.iterator in interface java.util.Listpublic java.util.ListIterator listIterator()
delegateEList.listIterator in interface java.util.Listpublic java.util.ListIterator listIterator(int index)
delegateEList.listIterator in interface java.util.List
public java.util.List subList(int start,
int end)
delegateEList.subList in interface java.util.Listpublic int hashCode()
hashCode in interface java.util.ListhashCode in class java.lang.Objectpublic boolean equals(java.lang.Object object)
equals in interface java.util.Listequals in class java.lang.Objectpublic java.lang.String toString()
delegateEList.toString in class java.lang.Object
|
Copyright 2001-2003 IBM Corporation and others. All Rights Reserved. |
|||||||||
| PREV CLASS SOURCE NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||