You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/07/11 17:54:44 UTC
[32/34] commons-collections git commit: PR: COLLECTIONS-323
Submitted-By: Maarten Brak Allow to use an initial
capacity of 0 on certain maps.
PR: COLLECTIONS-323
Submitted-By: Maarten Brak <ma...@quinity.com>
Allow to use an initial capacity of 0 on certain maps.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/COLLECTIONS_3_2_BRANCH@1079602 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/a0603b15
Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/a0603b15
Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/a0603b15
Branch: refs/heads/COLLECTIONS_3_2_BRANCH
Commit: a0603b1547ca7ad946b8d2ca87cec7116158a4c1
Parents: ef4dd46
Author: Jochen Wiedmann <jo...@apache.org>
Authored: Tue Mar 8 23:37:01 2011 +0000
Committer: Jochen Wiedmann <jo...@apache.org>
Committed: Tue Mar 8 23:37:01 2011 +0000
----------------------------------------------------------------------
pom.xml | 5 ++++-
.../apache/commons/collections/map/AbstractHashedMap.java | 10 +++++-----
.../apache/commons/collections/map/AbstractLinkedMap.java | 4 ++--
.../commons/collections/map/CaseInsensitiveMap.java | 4 ++--
.../org/apache/commons/collections/map/HashedMap.java | 4 ++--
.../org/apache/commons/collections/map/IdentityMap.java | 4 ++--
.../org/apache/commons/collections/map/LinkedMap.java | 4 ++--
.../commons/collections/map/TestCaseInsensitiveMap.java | 8 ++++++++
.../org/apache/commons/collections/map/TestHashedMap.java | 8 ++++++++
.../apache/commons/collections/map/TestIdentityMap.java | 8 ++++++++
.../org/apache/commons/collections/map/TestLinkedMap.java | 8 ++++++++
11 files changed, 51 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5c4a6d8..d26330a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -148,12 +148,15 @@
<name>Janek Bogucki</name>
</contributor>
<contributor>
- <name>Chuck Burdick</name>
+ <name>Maarten Brak</name>
</contributor>
<contributor>
<name>Dave Bryson</name>
</contributor>
<contributor>
+ <name>Chuck Burdick</name>
+ </contributor>
+ <contributor>
<name>Julien Buret</name>
</contributor>
<contributor>
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/AbstractHashedMap.java b/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
index d1e1a61..739548d 100644
--- a/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
+++ b/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
@@ -123,7 +123,7 @@ public class AbstractHashedMap extends AbstractMap implements IterableMap {
* default load factor.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
protected AbstractHashedMap(int initialCapacity) {
this(initialCapacity, DEFAULT_LOAD_FACTOR);
@@ -135,13 +135,13 @@ public class AbstractHashedMap extends AbstractMap implements IterableMap {
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
- * @throws IllegalArgumentException if the load factor is less than or equal to zero
+ * @throws IlleagalArgumentException if the initial capacity is negative
+ * @throws IllegalArgumentException if the load factor is less than or equal to zero
*/
protected AbstractHashedMap(int initialCapacity, float loadFactor) {
super();
- if (initialCapacity < 1) {
- throw new IllegalArgumentException("Initial capacity must be greater than 0");
+ if (initialCapacity < 0) {
+ throw new IllegalArgumentException("Initial capacity must be a non negative number");
}
if (loadFactor <= 0.0f || Float.isNaN(loadFactor)) {
throw new IllegalArgumentException("Load factor must be greater than 0");
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java b/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
index a5cfbe7..8248727 100644
--- a/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
+++ b/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
@@ -90,7 +90,7 @@ public class AbstractLinkedMap extends AbstractHashedMap implements OrderedMap {
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
protected AbstractLinkedMap(int initialCapacity) {
super(initialCapacity);
@@ -102,7 +102,7 @@ public class AbstractLinkedMap extends AbstractHashedMap implements OrderedMap {
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
protected AbstractLinkedMap(int initialCapacity, float loadFactor) {
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java b/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
index 2674349..9690cd3 100644
--- a/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
+++ b/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
@@ -78,7 +78,7 @@ public class CaseInsensitiveMap extends AbstractHashedMap implements Serializabl
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
public CaseInsensitiveMap(int initialCapacity) {
super(initialCapacity);
@@ -90,7 +90,7 @@ public class CaseInsensitiveMap extends AbstractHashedMap implements Serializabl
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
public CaseInsensitiveMap(int initialCapacity, float loadFactor) {
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/java/org/apache/commons/collections/map/HashedMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/HashedMap.java b/src/java/org/apache/commons/collections/map/HashedMap.java
index f208b40..5300033 100644
--- a/src/java/org/apache/commons/collections/map/HashedMap.java
+++ b/src/java/org/apache/commons/collections/map/HashedMap.java
@@ -58,7 +58,7 @@ public class HashedMap
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
public HashedMap(int initialCapacity) {
super(initialCapacity);
@@ -70,7 +70,7 @@ public class HashedMap
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
public HashedMap(int initialCapacity, float loadFactor) {
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/java/org/apache/commons/collections/map/IdentityMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/IdentityMap.java b/src/java/org/apache/commons/collections/map/IdentityMap.java
index ee1fa3d..88979f5 100644
--- a/src/java/org/apache/commons/collections/map/IdentityMap.java
+++ b/src/java/org/apache/commons/collections/map/IdentityMap.java
@@ -60,7 +60,7 @@ public class IdentityMap
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
public IdentityMap(int initialCapacity) {
super(initialCapacity);
@@ -72,7 +72,7 @@ public class IdentityMap
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
public IdentityMap(int initialCapacity, float loadFactor) {
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/java/org/apache/commons/collections/map/LinkedMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/LinkedMap.java b/src/java/org/apache/commons/collections/map/LinkedMap.java
index 682f3dc..1b170e7 100644
--- a/src/java/org/apache/commons/collections/map/LinkedMap.java
+++ b/src/java/org/apache/commons/collections/map/LinkedMap.java
@@ -79,7 +79,7 @@ public class LinkedMap
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
public LinkedMap(int initialCapacity) {
super(initialCapacity);
@@ -91,7 +91,7 @@ public class LinkedMap
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
public LinkedMap(int initialCapacity, float loadFactor) {
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java b/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java
index b3f27a5..e4eb6bf 100644
--- a/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java
+++ b/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java
@@ -117,4 +117,12 @@ public class TestCaseInsensitiveMap extends AbstractTestIterableMap {
writeExternalFormToDisk((java.io.Serializable) map, "/home/phil/jakarta-commons/collections/data/test/CaseInsensitiveMap.fullCollection.version3.obj");
}
*/
+
+ /**
+ * Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>.
+ */
+ public void testInitialCapacityZero() {
+ final CaseInsensitiveMap map = new CaseInsensitiveMap(0);
+ assertEquals(1, map.data.length);
+ }
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/test/org/apache/commons/collections/map/TestHashedMap.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/map/TestHashedMap.java b/src/test/org/apache/commons/collections/map/TestHashedMap.java
index 49d2678..8eb7d81 100644
--- a/src/test/org/apache/commons/collections/map/TestHashedMap.java
+++ b/src/test/org/apache/commons/collections/map/TestHashedMap.java
@@ -75,4 +75,12 @@ public class TestHashedMap extends AbstractTestIterableMap {
// resetFull();
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/HashedMap.fullCollection.version3.obj");
// }
+
+ /**
+ * Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>.
+ */
+ public void testInitialCapacityZero() {
+ final HashedMap map = new HashedMap(0);
+ assertEquals(1, map.data.length);
+ }
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/test/org/apache/commons/collections/map/TestIdentityMap.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/map/TestIdentityMap.java b/src/test/org/apache/commons/collections/map/TestIdentityMap.java
index b1e6c4e..c668fb0 100644
--- a/src/test/org/apache/commons/collections/map/TestIdentityMap.java
+++ b/src/test/org/apache/commons/collections/map/TestIdentityMap.java
@@ -143,4 +143,12 @@ public class TestIdentityMap extends AbstractTestObject {
// map.put(I2A, I2B);
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/IdentityMap.fullCollection.version3.obj");
// }
+
+ /**
+ * Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>.
+ */
+ public void testInitialCapacityZero() {
+ final IdentityMap map = new IdentityMap(0);
+ assertEquals(1, map.data.length);
+ }
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a0603b15/src/test/org/apache/commons/collections/map/TestLinkedMap.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/map/TestLinkedMap.java b/src/test/org/apache/commons/collections/map/TestLinkedMap.java
index a1d1c16..20fd169 100644
--- a/src/test/org/apache/commons/collections/map/TestLinkedMap.java
+++ b/src/test/org/apache/commons/collections/map/TestLinkedMap.java
@@ -272,4 +272,12 @@ public class TestLinkedMap extends AbstractTestOrderedMap {
// resetFull();
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/LinkedMap.fullCollection.version3.obj");
// }
+
+ /**
+ * Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>.
+ */
+ public void testInitialCapacityZero() {
+ final LinkedMap map = new LinkedMap(0);
+ assertEquals(1, map.data.length);
+ }
}