HashMap with primitive int key
- From: Andrew E <andrew@xxxxxxxxxx>
- Date: Mon, 28 Nov 2005 21:45:45 +0100
Dear All,
I have a class like this:
class CustomerOrder {
int globalID;
...
}
I have an array of these.
I'd like to store an index of globalIDs, so I can do:
CustomerOrder o = index.get(123)
I could modify my class to be:
class CustomerOrder {
Integer globalID;
...
}
Perhaps it is my C++ background, but the idea of allocating an object for every
ID when I can just use an int bothers me.
I figure a HashMap is the right tool of choice, e.g.:
HashMap<Integer, CustomerOrder> index = new ...
Has anyone out there already written a modified hashmap class that uses int as
the key?
Thanks for any tips :)
Andrew
.
- Follow-Ups:
- Re: HashMap with primitive int key
- From: Thomas Hawtin
- Re: HashMap with primitive int key
- Prev by Date: Capturing sound over SB (What you hear)
- Next by Date: Re: HashMap with primitive int key
- Previous by thread: Capturing sound over SB (What you hear)
- Next by thread: Re: HashMap with primitive int key
- Index(es):