bloritsch 02/02/27 08:07:23
Modified: src/java/org/apache/avalon/excalibur/collections
BucketMap.java
src/test/org/apache/avalon/excalibur/collections/test
BucketMapTestCase.java
Log:
Apply patch from Vadim Gritsenko--Good work
Revision Changes Path
1.11 +5 -5
jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/collections/BucketMap.java
Index: BucketMap.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/collections/BucketMap.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- BucketMap.java 27 Feb 2002 13:31:40 -0000 1.10
+++ BucketMap.java 27 Feb 2002 16:07:23 -0000 1.11
@@ -19,7 +19,7 @@
*
* @author <a href="[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="[EMAIL PROTECTED]">Gerhard Froehlich</a>
- * @version CVS $Revision: 1.10 $ $Date: 2002/02/27 13:31:40 $
+ * @version CVS $Revision: 1.11 $ $Date: 2002/02/27 16:07:23 $
* @since 4.0
*/
public final class BucketMap implements Map
@@ -115,7 +115,7 @@
}
/**
- * Add an object into the buffer.
+ * Put a reference in the Map.
*
* @throws BufferOverflowException if adding this element exceeds the
* buffer's capacity.
@@ -142,16 +142,16 @@
return value;
}
- while ( n.next != null )
+ for ( Node next = n; next != null; next = next.next )
{
+ n = next;
+
if ( n.key.equals(key) )
{
Object returnVal = n.value;
n.value = value;
return returnVal;
}
-
- n = n.next;
}
Node newNode = new Node();
1.2 +46 -0
jakarta-avalon-excalibur/src/test/org/apache/avalon/excalibur/collections/test/BucketMapTestCase.java
Index: BucketMapTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/test/org/apache/avalon/excalibur/collections/test/BucketMapTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BucketMapTestCase.java 27 Feb 2002 13:31:40 -0000 1.1
+++ BucketMapTestCase.java 27 Feb 2002 16:07:23 -0000 1.2
@@ -127,4 +127,50 @@
assertTrue( map.size() == 4 );
assertTrue( map.get( VAL4 ) == null );
}
+
+ public void testReplace1()
+ {
+ final BucketMap map = new BucketMap();
+
+ map.put( VAL1, VAL1 );
+ map.put( VAL1, VAL2 );
+ assertTrue( map.size() == 1 );
+ assertTrue( map.get( VAL1 ) == VAL2 );
+ }
+
+ public void testReplace2()
+ {
+ final BucketMap map = new BucketMap();
+
+ map.put( VAL1, VAL1 );
+ map.put( VAL2, VAL2 );
+ map.put( VAL1, VAL3 );
+ assertTrue( map.size() == 2 );
+ assertTrue( map.get( VAL1 ) == VAL3 );
+ }
+
+ public void testReplace3()
+ {
+ final BucketMap map = new BucketMap();
+
+ map.put( VAL1, VAL1 );
+ map.put( VAL2, VAL2 );
+ map.put( VAL3, VAL3 );
+ map.put( VAL3, VAL4 );
+ assertTrue( map.size() == 3 );
+ assertTrue( map.get( VAL3 ) == VAL4 );
+ }
+
+ public void testReplace4()
+ {
+ final BucketMap map = new BucketMap();
+
+ map.put( VAL1, VAL1 );
+ map.put( VAL2, VAL2 );
+ map.put( VAL3, VAL3 );
+ map.put( VAL4, VAL4 );
+ map.put( VAL3, VAL5 );
+ assertTrue( map.size() == 4 );
+ assertTrue( map.get( VAL3 ) == VAL5 );
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>