站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

CompactMap (Editor Utilities) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.util/1 1.17

org.netbeans.lib.editor.util
Class CompactMap<K,V>

java.lang.Object
  extended by org.netbeans.lib.editor.util.CompactMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class CompactMap<K,V>
extends Object
implements Map<K,V>

Map implementation that allows to define the class that implements the Map.Entry.
The present implementation does not allow null to be used as a key in the map. The client may use NULL_KEY masking on its own side if it wants to use null keys (see java.util.HashMap impl).
The load factor is fixed to 1.0 but if the approximate map size is known there is a constructor that allows to pass the initial capacity.
There are no additional attempts to generally improve hashing for poor hashing functions like those in HashMap.hash().
The iterators produced by this map are not fail-fast - they will continue iteration and their behavior is generally undefined after the modification. The caller should ensure that there will be no pending iterators during modification of this map.
When iterating through entries in a bucket the Object.equals() is used for comparison.


Nested Class Summary
static class CompactMap.DefaultMapEntry<K,V>
          Default implementation of the map entry similar to e.g.
static class CompactMap.MapEntry<K,V>
          Abstract implementation of the map entry.
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
CompactMap()
           
CompactMap(int initialCapacity)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           
 CompactMap.MapEntry<K,V> getFirstEntry(int hashCode)
          Get an entry from a bucket that corresponds to the given hash code.
 boolean isEmpty()
           
 Set<K> keySet()
           
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> map)
           
 CompactMap.MapEntry<K,V> putEntry(CompactMap.MapEntry<K,V> entry)
          Put the given entry into the map.
 V remove(Object key)
           
 CompactMap.MapEntry<K,V> removeEntry(CompactMap.MapEntry<K,V> entry)
          Remove the given entry from the map.
 int size()
           
 String toString()
           
 Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CompactMap

public CompactMap()

CompactMap

public CompactMap(int initialCapacity)
Method Detail

get

public V get(Object key)
Specified by:
get in interface Map<K,V>

getFirstEntry

public CompactMap.MapEntry<K,V> getFirstEntry(int hashCode)
Get an entry from a bucket that corresponds to the given hash code.
This may be useful if the hash code can be computed without creating an actual object being stored in the map. The target object should provide some method for comparing itself to the passed arguments that represent the contained data.

Parameters:
hashCode - computed hash code.
Returns:
first entry in the particular bucket or null if there are no entries for the given hash code. The caller may need to iterate through the linked list of the entries to find the right entry.

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,V>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,V>

putEntry

public CompactMap.MapEntry<K,V> putEntry(CompactMap.MapEntry<K,V> entry)
Put the given entry into the map.
The given entry should only be added to one compact map instance.
Adding a single entry into multiple compact maps will break internal consistency of all the intended maps!
If there will be an existing entry with a key that equals to the key in the entry parameter then the original entry will be replaced by the given entry.


put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>

putAll

public void putAll(Map<? extends K,? extends V> map)
Specified by:
putAll in interface Map<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>

removeEntry

public CompactMap.MapEntry<K,V> removeEntry(CompactMap.MapEntry<K,V> entry)
Remove the given entry from the map.
This method will search for the entry instance (not its key) so the given entry must be physically used in the map otherwise this method will not do anything.


clear

public void clear()
Specified by:
clear in interface Map<K,V>

size

public final int size()
Specified by:
size in interface Map<K,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>

toString

public String toString()
Overrides:
toString in class Object

org.netbeans.modules.editor.util/1 1.17

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.