#8 Add class based JCF compatible factory methods

closed-rejected
None
5
2004-07-27
2004-02-06
Curt Cox
No

Hi,

I'm looking at using PCJ instead of HashMap and
ArrayList solely for memory efficiency. I have lots of
homogenous Lists and Maps with types that are
determined at runtime, so I use factory methods that
produce type enforcing instances. Factory methods like
the ones I'm using now would be really handy. For example:

// Create a new java.util.List backed by int primitives
List list = Lists.newList(Integer.class);

// Create a new java.util.Map backed by int and float
primitives
Map map = Maps.newMap(Integer.class,Float.class);

Of course, I could write these myself, but they seem
generally useful.

Thanks,
Curt

Discussion

  • Søren Bak

    Søren Bak - 2004-07-27
    • assigned_to: nobody --> bak
    • status: open --> closed-rejected
     
  • Søren Bak

    Søren Bak - 2004-07-27

    Logged In: YES
    user_id=43402

    Hi Curt,

    Thanks for your suggestions. You can achieve a somewhat
    similar effect by using the adapter classes. Here is how:

    // Create a new java.util.List backed by int primitives
    //List list = Lists.newList(Integer.class);
    List list = Adapter.asObjects(new IntArrayList());

    // Create a new java.util.Map backed by int and float
    primitives
    //Map map = Maps.newMap(Integer.class,Float.class);
    Map map = Adapter.asObjects(new IntKeyFloatOpenHashMap
    ());

    I think that tclib (by Dennis Sosnoski) employs your strategy.
    Maybe you should have a look at that.

    Sren

     

Log in to post a comment.