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

Diff of /classpath/java/util/LinkedHashMap.java

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

revision 1.2 by bryce, Tue Oct 16 05:24:14 2001 UTC revision 1.3 by ericb, Thu Oct 25 07:34:19 2001 UTC
# Line 28  executable file might be covered by the Line 28  executable file might be covered by the
28    
29  package java.util;  package java.util;
30    
 import java.io.IOException;  
 import java.io.Serializable;  
 import java.io.ObjectInputStream;  
 import java.io.ObjectOutputStream;  
   
31  /**  /**
32   * This class provides a hashtable-backed implementation of the   * This class provides a hashtable-backed implementation of the
33   * Map interface, with predictable traversal order.   * Map interface, with predictable traversal order.
# Line 89  import java.io.ObjectOutputStream; Line 84  import java.io.ObjectOutputStream;
84   * @see TreeMap   * @see TreeMap
85   * @see Hashtable   * @see Hashtable
86   * @since 1.4   * @since 1.4
87     * @status updated to 1.4
88   */   */
89  public class LinkedHashMap extends HashMap  public class LinkedHashMap extends HashMap
90  {  {
# Line 218  public class LinkedHashMap extends HashM Line 214  public class LinkedHashMap extends HashM
214     * Construct a new insertion-ordered LinkedHashMap with a specific     * Construct a new insertion-ordered LinkedHashMap with a specific
215     * inital capacity and default load factor of 0.75.     * inital capacity and default load factor of 0.75.
216     *     *
217     * @param initialCapacity the initial capacity of this HashMap (>=0)     * @param initialCapacity the initial capacity of this HashMap (>= 0)
218     * @throws IllegalArgumentException if (initialCapacity < 0)     * @throws IllegalArgumentException if (initialCapacity &lt; 0)
219     */     */
220    public LinkedHashMap(int initialCapacity)    public LinkedHashMap(int initialCapacity)
221    {    {
# Line 231  public class LinkedHashMap extends HashM Line 227  public class LinkedHashMap extends HashM
227     * Construct a new insertion-orderd LinkedHashMap with a specific     * Construct a new insertion-orderd LinkedHashMap with a specific
228     * inital capacity and load factor.     * inital capacity and load factor.
229     *     *
230     * @param initialCapacity the initial capacity (>=0)     * @param initialCapacity the initial capacity (&gt;= 0)
231     * @param loadFactor the load factor (>0, not NaN)     * @param loadFactor the load factor (&gt; 0, not NaN)
232     * @throws IllegalArgumentException if (initialCapacity < 0) ||     * @throws IllegalArgumentException if (initialCapacity &lt; 0) ||
233     *                                     ! (loadFactor > 0.0)     *                                     ! (loadFactor &gt; 0.0)
234     */     */
235    public LinkedHashMap(int initialCapacity, float loadFactor)    public LinkedHashMap(int initialCapacity, float loadFactor)
236    {    {
# Line 281  public class LinkedHashMap extends HashM Line 277  public class LinkedHashMap extends HashM
277      LinkedHashEntry e = head;      LinkedHashEntry e = head;
278      while (e != null)      while (e != null)
279        {        {
280          if (value == null ? e.value == null : value.equals(e.value))          if (equals(value, e.value))
281            return true;            return true;
282          e = e.succ;          e = e.succ;
283        }        }
# Line 307  public class LinkedHashMap extends HashM Line 303  public class LinkedHashMap extends HashM
303      HashEntry e = buckets[idx];      HashEntry e = buckets[idx];
304      while (e != null)      while (e != null)
305        {        {
306          if (key == null ? e.key == null : key.equals(e.key))          if (equals(key, e.key))
307            {            {
308              if (accessOrder)              if (accessOrder)
309                {                {
# Line 376  public class LinkedHashMap extends HashM Line 372  public class LinkedHashMap extends HashM
372      return false;      return false;
373    }    }
374    
375    /** Helper method called by <code>put</code>, which creates and adds a    /**
376       * Helper method called by <code>put</code>, which creates and adds a
377     * new Entry, followed by performing bookkeeping (like removeEldestEntry).     * new Entry, followed by performing bookkeeping (like removeEldestEntry).
378     *     *
379     * @param key the key of the new Entry     * @param key the key of the new Entry
380     * @param value the value     * @param value the value
381     * @param idx the index in buckets where the new Entry belongs     * @param idx the index in buckets where the new Entry belongs
382     * @param callRemove Whether to call the removeEldestEntry method.     * @param callRemove whether to call the removeEldestEntry method
383     * @see #put(Object, Object)     * @see #put(Object, Object)
384     * @see #removeEldestEntry(Map.Entry)     * @see #removeEldestEntry(Map.Entry)
385     */     */
# Line 397  public class LinkedHashMap extends HashM Line 394  public class LinkedHashMap extends HashM
394        remove(head);        remove(head);
395    }    }
396    
397      /**
398       * Helper method, called by clone() to reset the doubly-linked list.
399       * @param m the map to add entries from
400       * @see #clone()
401       */
402    void putAllInternal(Map m)    void putAllInternal(Map m)
403    {    {
404      head = null;      head = null;
# Line 466  public class LinkedHashMap extends HashM Line 468  public class LinkedHashMap extends HashM
468            throw new IllegalStateException();            throw new IllegalStateException();
469    
470          LinkedHashMap.this.remove(last.key);          LinkedHashMap.this.remove(last.key);
         knownMod++;  
471          last = null;          last = null;
472            knownMod++;
473        }        }
474      };      };
475    }    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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