I thought since @ReplacedBy was both @Documented and @Inherited, that it would
show up on HashIntMap when I added it to IntMap. Not so. Apparently it only works for superclasses, no implemented interfaces, and it may also not apply to non-runtime annotations. So: add @ReplacedBy to these IntMap-related classes. I've not yet used @ReplacedBy on IntSet, and I guess some people still really like their ArrayIntSet, but the memory gain is minimal and it's actually usually a loss in terms of performance. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2769 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -31,12 +31,17 @@ import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import com.samskivert.annotation.ReplacedBy;
|
||||
|
||||
/**
|
||||
* An int map is like a regular map, but with integers as keys. We avoid
|
||||
* the annoyance of having to create integer objects every time we want to
|
||||
* lookup or insert values. The hash int map is an int map that uses a
|
||||
* hashtable mechanism to store its key/value mappings.
|
||||
*/
|
||||
@ReplacedBy(value="java.util.Map",
|
||||
reason="Boxing shouldn't be a major concern. It's probably better to stick to " +
|
||||
"standard classes rather than worry about a tiny memory or performance gain.")
|
||||
public class HashIntMap<V> extends AbstractMap<Integer,V>
|
||||
implements IntMap<V>, Cloneable, Serializable
|
||||
{
|
||||
|
||||
@@ -32,8 +32,9 @@ import com.samskivert.annotation.ReplacedBy;
|
||||
* and therefore provides all of the standard accessors (for which
|
||||
* <code>Integer</code> objects should be supplied as keys).
|
||||
*/
|
||||
@ReplacedBy(value="java.util.Map", reason="Boxing shouldn't be a major concern. " +
|
||||
"The performance gain from using an IntMap probably isn't worth trouble.")
|
||||
@ReplacedBy(value="java.util.Map",
|
||||
reason="Boxing shouldn't be a major concern. It's probably better to stick to " +
|
||||
"standard classes rather than worry about a tiny memory or performance gain.")
|
||||
public interface IntMap<V> extends Map<Integer,V>
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
package com.samskivert.util;
|
||||
|
||||
import com.samskivert.annotation.ReplacedBy;
|
||||
|
||||
/**
|
||||
* Provides static methods for creating mutable {@code IntMap} instances easily.
|
||||
* You can replace code like:
|
||||
@@ -30,6 +32,10 @@ package com.samskivert.util;
|
||||
*
|
||||
* <p>{@code IntMap<String> map = IntMaps.newHashIntMap();}
|
||||
*/
|
||||
@ReplacedBy(value="com.google.common.collect.Maps",
|
||||
reason="Boxing shouldn't be a major concern. It's probably better to stick to " +
|
||||
"standard classes rather than worry about a tiny memory or performance gain.")
|
||||
|
||||
public class IntMaps
|
||||
{
|
||||
/**
|
||||
@@ -37,6 +43,7 @@ public class IntMaps
|
||||
*
|
||||
* @return a newly-created, initially-empty {@code HashIntMap}
|
||||
*/
|
||||
@ReplacedBy(value="com.google.common.collect.Maps#newHashMap()")
|
||||
public static <V> HashIntMap<V> newHashIntMap()
|
||||
{
|
||||
return new HashIntMap<V>();
|
||||
|
||||
Reference in New Issue
Block a user