diff options
author | Bryce McKinlay <bryce@albatross.co.nz> | 2001-03-24 08:05:29 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2001-03-24 08:05:29 +0000 |
commit | f1cd4ab0037948a9800f33b0cbaef7140d467fd8 (patch) | |
tree | 2f56a669b80540246a89b55a478afadbac3e615c /libjava | |
parent | aff68f1cd99a1e3f98fbfea2638fdc4905a6ed4f (diff) | |
download | gcc-f1cd4ab0037948a9800f33b0cbaef7140d467fd8.zip gcc-f1cd4ab0037948a9800f33b0cbaef7140d467fd8.tar.gz gcc-f1cd4ab0037948a9800f33b0cbaef7140d467fd8.tar.bz2 |
HashMap.java (HashMap): If 0 is given for initialCapacity paramater, bump it to 1.
2001-03-24 Bryce McKinlay <bryce@albatross.co.nz>
* java/util/HashMap.java (HashMap): If 0 is given for initialCapacity
paramater, bump it to 1.
* java/util/Hashtable.java (Hashtable): Likewise.
From-SVN: r40812
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 6 | ||||
-rw-r--r-- | libjava/java/util/HashMap.java | 6 | ||||
-rw-r--r-- | libjava/java/util/Hashtable.java | 4 |
3 files changed, 13 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d68ec70..35218b3 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2001-03-24 Bryce McKinlay <bryce@albatross.co.nz> + + * java/util/HashMap.java (HashMap): If 0 is given for initialCapacity + paramater, bump it to 1. + * java/util/Hashtable.java (Hashtable): Likewise. + 2001-03-23 Per Bothner <per@bothner.com> * java/lang/natDouble.cc (parseDouble): Cannot use errno to diff --git a/libjava/java/util/HashMap.java b/libjava/java/util/HashMap.java index bf10e9e..4bc88b7 100644 --- a/libjava/java/util/HashMap.java +++ b/libjava/java/util/HashMap.java @@ -157,7 +157,7 @@ public class HashMap extends AbstractMap * @param loadFactor the load factor * * @throws IllegalArgumentException if (initialCapacity < 0) || - * (initialLoadFactor > 1.0) || + * (loadFactor <= 0) */ public HashMap(int initialCapacity, float loadFactor) throws IllegalArgumentException @@ -167,7 +167,9 @@ public class HashMap extends AbstractMap + initialCapacity); if (loadFactor <= 0) throw new IllegalArgumentException("Illegal Load Factor: " + loadFactor); - + + if (initialCapacity == 0) + initialCapacity = 1; buckets = new Entry[initialCapacity]; this.loadFactor = loadFactor; this.threshold = (int) (initialCapacity * loadFactor); diff --git a/libjava/java/util/Hashtable.java b/libjava/java/util/Hashtable.java index 4fd8167..4475785 100644 --- a/libjava/java/util/Hashtable.java +++ b/libjava/java/util/Hashtable.java @@ -179,7 +179,9 @@ public class Hashtable extends Dictionary + initialCapacity); if (loadFactor <= 0) throw new IllegalArgumentException("Illegal Load Factor: " + loadFactor); - + + if (initialCapacity == 0) + initialCapacity = 1; buckets = new Entry[initialCapacity]; this.loadFactor = loadFactor; this.threshold = (int) (initialCapacity * loadFactor); |