From 5b1a6404336ed4d03a714a47d566ece26f8e8b3f Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Mon, 5 Apr 2010 18:31:29 +0000 Subject: [PATCH] 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 --- src/java/com/samskivert/util/HashIntMap.java | 5 +++++ src/java/com/samskivert/util/IntMap.java | 5 +++-- src/java/com/samskivert/util/IntMaps.java | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/java/com/samskivert/util/HashIntMap.java b/src/java/com/samskivert/util/HashIntMap.java index cae9f288..edbb9fb8 100644 --- a/src/java/com/samskivert/util/HashIntMap.java +++ b/src/java/com/samskivert/util/HashIntMap.java @@ -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 extends AbstractMap implements IntMap, Cloneable, Serializable { diff --git a/src/java/com/samskivert/util/IntMap.java b/src/java/com/samskivert/util/IntMap.java index d34089e2..4e9b6a6b 100644 --- a/src/java/com/samskivert/util/IntMap.java +++ b/src/java/com/samskivert/util/IntMap.java @@ -32,8 +32,9 @@ import com.samskivert.annotation.ReplacedBy; * and therefore provides all of the standard accessors (for which * Integer 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 extends Map { /** diff --git a/src/java/com/samskivert/util/IntMaps.java b/src/java/com/samskivert/util/IntMaps.java index 0d44e45d..95891247 100644 --- a/src/java/com/samskivert/util/IntMaps.java +++ b/src/java/com/samskivert/util/IntMaps.java @@ -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; * *

{@code IntMap 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 HashIntMap newHashIntMap() { return new HashIntMap();