Move Flat3Map to map subpackage
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
92450f8141
commit
473cba8ee3
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/Attic/Flat3Map.java,v 1.3 2003/11/14 22:58:27 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/map/Flat3Map.java,v 1.1 2003/11/18 23:23:05 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -55,7 +55,7 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.commons.collections;
|
||||
package org.apache.commons.collections.map;
|
||||
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.AbstractSet;
|
||||
|
@ -66,6 +66,7 @@ import java.util.Map;
|
|||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.IteratorUtils;
|
||||
import org.apache.commons.collections.iterators.EntrySetMapIterator;
|
||||
import org.apache.commons.collections.iterators.MapIterator;
|
||||
import org.apache.commons.collections.iterators.ResettableIterator;
|
||||
|
@ -86,18 +87,19 @@ import org.apache.commons.collections.iterators.ResettableIterator;
|
|||
* The design uses two distinct modes of operation - flat and delegate.
|
||||
* While the map is size 3 or less, operations map straight onto fields using
|
||||
* switch statements. Once size 4 is reached, the map switches to delegate mode
|
||||
* and never switches back. In delegate mode, all operations are forwarded
|
||||
* straight to a HashMap resulting in the 5% performance loss.
|
||||
* and only switches back when cleared. In delegate mode, all operations are
|
||||
* forwarded straight to a HashMap resulting in the 5% performance loss.
|
||||
* <p>
|
||||
* The performance gains on puts are due to not needing to create a Map Entry
|
||||
* object. This is a large saving not only in performance but in garbage collection.
|
||||
* <p>
|
||||
* Whilst in flat mode this map is also easy for the garbage collector to dispatch.
|
||||
* This is because it contains no complex objects or arrays which slow the progress.
|
||||
* (Note that the impact of this has not actually been tested!)
|
||||
* <p>
|
||||
* Do not use <code>Flat3Map</code> if the size is likely to grow beyond 3.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.3 $ $Date: 2003/11/14 22:58:27 $
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/18 23:23:05 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
|
@ -556,11 +558,14 @@ public class Flat3Map implements Map {
|
|||
*/
|
||||
public void clear() {
|
||||
if (iMap != null) {
|
||||
iMap.clear();
|
||||
}
|
||||
iMap.clear(); // should aid gc
|
||||
iMap = null; // switch back to flat mode
|
||||
} else {
|
||||
iSize = 0;
|
||||
iHash1 = iHash2 = iHash3 = 0;
|
||||
iKey1 = iKey2 = iKey3 = iValue1 = iValue2 = iValue3 = null;
|
||||
iKey1 = iKey2 = iKey3 = null;
|
||||
iValue1 = iValue2 = iValue3 = null;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
|
@ -16,6 +16,7 @@ The following implementations are provided in the package:
|
|||
<li>FixedSize - ensures that the size of the map cannot change
|
||||
<li>Lazy - creates objects in the map on demand
|
||||
<li>ListOrdered - ensures that insertion order is retained
|
||||
<li>Flat3 - designed for good performance at size 3 or less
|
||||
</ul>
|
||||
</pre>
|
||||
</BODY>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/MapPerformance.java,v 1.1 2003/11/02 23:43:00 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/MapPerformance.java,v 1.2 2003/11/18 23:23:05 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -65,6 +65,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.collections.map.Flat3Map;
|
||||
|
||||
/**
|
||||
* <code>TestMapPerformance</code> is designed to perform basic Map performance tests.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/map/TestAll.java,v 1.1 2003/11/16 00:05:46 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/map/TestAll.java,v 1.2 2003/11/18 23:23:05 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -65,7 +65,7 @@ import junit.framework.TestSuite;
|
|||
* Entry point for tests.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:46 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/11/18 23:23:05 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
|
@ -85,6 +85,7 @@ public class TestAll extends TestCase {
|
|||
|
||||
suite.addTest(TestFixedSizeMap.suite());
|
||||
suite.addTest(TestFixedSizeSortedMap.suite());
|
||||
suite.addTest(TestFlat3Map.suite());
|
||||
suite.addTest(TestLazyMap.suite());
|
||||
suite.addTest(TestLazySortedMap.suite());
|
||||
suite.addTest(TestListOrderedMap.suite());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestFlat3Map.java,v 1.4 2003/11/18 22:37:16 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/map/TestFlat3Map.java,v 1.1 2003/11/18 23:23:05 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -55,21 +55,21 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.commons.collections;
|
||||
package org.apache.commons.collections.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.textui.TestRunner;
|
||||
|
||||
import org.apache.commons.collections.BulkTest;
|
||||
import org.apache.commons.collections.iterators.AbstractTestMapIterator;
|
||||
import org.apache.commons.collections.iterators.MapIterator;
|
||||
import org.apache.commons.collections.map.AbstractTestMap;
|
||||
|
||||
/**
|
||||
* JUnit tests.
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2003/11/18 22:37:16 $
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/18 23:23:05 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
Loading…
Reference in New Issue