From: Bryce McKinlay Date: Sat, 24 Mar 2001 08:05:29 +0000 (+0000) Subject: HashMap.java (HashMap): If 0 is given for initialCapacity paramater, bump it to 1. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f1cd4ab0037948a9800f33b0cbaef7140d467fd8;p=gcc.git HashMap.java (HashMap): If 0 is given for initialCapacity paramater, bump it to 1. 2001-03-24 Bryce McKinlay * 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 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d68ec70734a..35218b36318 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2001-03-24 Bryce McKinlay + + * 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 * java/lang/natDouble.cc (parseDouble): Cannot use errno to diff --git a/libjava/java/util/HashMap.java b/libjava/java/util/HashMap.java index bf10e9ef00a..4bc88b75570 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 4fd8167d60c..4475785bbbb 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);