[program-java] Re: Java: Redimensioning my existing array.

  • From: Willem <dwillemv@xxxxxxxxx>
  • To: program-java@xxxxxxxxxxxxx
  • Date: Fri, 03 Sep 2010 16:07:20 +0200

As a sidenote, in general here is a few guidelines to choosing datastructures.


LinkedLists: if you don't need indexes this is the way to go. No resizing is needed, but the pointer management could be tricky if you write your own. If you use the built in linkedList, remembor that indexing is possible in a roundabout way, though it takes longer to find the item. Arrays: Just as memory efficient as linkedLists, just has indexes and resizing is needed. If you double the size when resizing, inserting is done in amortized time. uses a small bit less memory and a bit more processing time. Hashmap: Quick insertion, though there is some processing for calculating the hash, but searching is easy.
hth.
On 9/3/2010 3:40 PM, Corbett, James wrote:
Hello all:
I have an array of type double....
Double[][] myDoubleArray = new double[2][13];
...I now need to add an additional field.... Should I redimension the array like double[2][13][5] or should I invest in either an arrayList or HashMap?
Jim
James M. Corbett
Programmer / Analyst |
Canada Revenue Agency | Agence du revenue du Canada
875 Heron Rd.
Ottawa, On.
K1A0L5
James.Corbett@xxxxxxxxxxxxx
Telephone | Téléphone: (613) 941-1338
Facsimile | Télécopieur: (613) 941-2261
Government of Canada | Gouvernement du Canada

Other related posts: