/[classpath]/classpath/java/util/HashMap.java
ViewVC logotype

Diff of /classpath/java/util/HashMap.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28.2.3 by tromey, Mon Nov 1 15:57:08 2004 UTC revision 1.28.2.4 by tromey, Wed Jan 12 01:12:48 2005 UTC
# Line 256  public class HashMap<K, V> extends Abstr Line 256  public class HashMap<K, V> extends Abstr
256    
257      if (initialCapacity == 0)      if (initialCapacity == 0)
258        initialCapacity = 1;        initialCapacity = 1;
259      buckets = new HashEntry<K, V>[initialCapacity];      buckets = (HashEntry<K, V>[]) new HashEntry[initialCapacity];
260      this.loadFactor = loadFactor;      this.loadFactor = loadFactor;
261      threshold = (int) (initialCapacity * loadFactor);      threshold = (int) (initialCapacity * loadFactor);
262    }    }
# Line 386  public class HashMap<K, V> extends Abstr Line 386  public class HashMap<K, V> extends Abstr
386        {        {
387          Map.Entry<? extends K, ? extends V> e = itr.next();          Map.Entry<? extends K, ? extends V> e = itr.next();
388          // Optimize in case the Entry is one of our own.          // Optimize in case the Entry is one of our own.
389          if (e instanceof AbstractMap.BasicMapEntry<K, V>)          if (e instanceof AbstractMap.BasicMapEntry)
390            {            {
391              AbstractMap.BasicMapEntry<? extends K, ? extends V> entry              AbstractMap.BasicMapEntry<? extends K, ? extends V> entry
392                = (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e;                = (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e;
# Line 485  public class HashMap<K, V> extends Abstr Line 485  public class HashMap<K, V> extends Abstr
485        {        {
486          // This is impossible.          // This is impossible.
487        }        }
488      copy.buckets = new HashEntry<K, V>[buckets.length];      copy.buckets = (HashEntry<K, V>[]) new HashEntry[buckets.length];
489      copy.putAllInternal(this);      copy.putAllInternal(this);
490      // Clear the entry cache. AbstractMap.clone() does the others.      // Clear the entry cache. AbstractMap.clone() does the others.
491      copy.entries = null;      copy.entries = null;
# Line 661  public class HashMap<K, V> extends Abstr Line 661  public class HashMap<K, V> extends Abstr
661    // Package visible, for use in nested classes.    // Package visible, for use in nested classes.
662    final HashEntry<K, V> getEntry(Object o)    final HashEntry<K, V> getEntry(Object o)
663    {    {
664      if (! (o instanceof Map.Entry<K, V>))      if (! (o instanceof Map.Entry))
665        return null;        return null;
666      Map.Entry<K, V> me = (Map.Entry<K, V>) o;      Map.Entry<K, V> me = (Map.Entry<K, V>) o;
667      K key = me.getKey();      K key = me.getKey();
# Line 716  public class HashMap<K, V> extends Abstr Line 716  public class HashMap<K, V> extends Abstr
716      while (itr.hasNext())      while (itr.hasNext())
717        {        {
718          size++;          size++;
719          Map.Entry<K, V> e = itr.next();          Map.Entry<? extends K, ? extends V> e = itr.next();
720          K key = e.getKey();          K key = e.getKey();
721          int idx = hash(key);          int idx = hash(key);
722          addEntry(key, e.getValue(), idx, false);          addEntry(key, e.getValue(), idx, false);
# Line 738  public class HashMap<K, V> extends Abstr Line 738  public class HashMap<K, V> extends Abstr
738    
739      int newcapacity = (buckets.length * 2) + 1;      int newcapacity = (buckets.length * 2) + 1;
740      threshold = (int) (newcapacity * loadFactor);      threshold = (int) (newcapacity * loadFactor);
741      buckets = new HashEntry<K, V>[newcapacity];      buckets = (HashEntry<K, V>[]) new HashEntry[newcapacity];
742    
743      for (int i = oldBuckets.length - 1; i >= 0; i--)      for (int i = oldBuckets.length - 1; i >= 0; i--)
744        {        {
# Line 800  public class HashMap<K, V> extends Abstr Line 800  public class HashMap<K, V> extends Abstr
800      s.defaultReadObject();      s.defaultReadObject();
801    
802      // Read and use capacity, followed by key/value pairs.      // Read and use capacity, followed by key/value pairs.
803      buckets = new HashEntry<K, V>[s.readInt()];      buckets = (HashEntry<K, V>[]) new HashEntry[s.readInt()];
804      int len = s.readInt();      int len = s.readInt();
805      size = len;      size = len;
806      while (len-- > 0)      while (len-- > 0)
# Line 868  public class HashMap<K, V> extends Abstr Line 868  public class HashMap<K, V> extends Abstr
868       * @throws ConcurrentModificationException if the HashMap was modified       * @throws ConcurrentModificationException if the HashMap was modified
869       * @throws NoSuchElementException if there is none       * @throws NoSuchElementException if there is none
870       */       */
871      public Object next()      public T next()
872      {      {
873        if (knownMod != modCount)        if (knownMod != modCount)
874          throw new ConcurrentModificationException();          throw new ConcurrentModificationException();
# Line 883  public class HashMap<K, V> extends Abstr Line 883  public class HashMap<K, V> extends Abstr
883        next = e.next;        next = e.next;
884        last = e;        last = e;
885        if (type == VALUES)        if (type == VALUES)
886          return e.value;          return (T) e.value;
887        if (type == KEYS)        if (type == KEYS)
888          return e.key;          return (T) e.key;
889        return e;        return (T) e;
890      }      }
891    
892      /**      /**

Legend:
Removed from v.1.28.2.3  
changed lines
  Added in v.1.28.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26