HashMap (or similar) with size greater than 124?

I'm trying to create a collision checking method for my game. I have decided that the best way to do this is to use a map of some sort to store blocked pixels, but I found (the hard way) that hashmaps can only store 124 entries. The problem is, I need to be storingthousands (at least) of entries to the map. My error at this point (from the program's output) is this:

==Quote==

WARNING: A new instance of Collision has been made!

Adding 3100 pixels to the restricted pixel list for object button1.

Finished adding pixels to restricted pixel list for object button1.

Size of map now is 124

==End Quote==

So a single object is using 3100 entries but the 4% of the entries retained (for me at least) isn't quite enough :P

Is there some other method of data storage (with something similar to [boolean] containsKey) that I can use for this?

[903 byte] By [timothyb89_a] at [2007-11-27 1:15:13]
# 1
> but I found (the hard way) that hashmaps can only store 124 entries. How did you found that?
Ruly-o_Oa at 2007-7-11 23:50:33 > top of Java-index,Java Essentials,Java Programming...
# 2
> but I found (the hard way) that hashmaps can only> store 124 entries. Incorrect. HashMaps can hold millions of entries without any problems. You have a coding error.
sabre150a at 2007-7-11 23:50:33 > top of Java-index,Java Essentials,Java Programming...
# 3
> > but I found (the hard way) that hashmaps can only> store 124 entries. > > How did you found that?Er, the hard way.
DrLaszloJamfa at 2007-7-11 23:50:33 > top of Java-index,Java Essentials,Java Programming...
# 4
:-)
sabre150a at 2007-7-11 23:50:33 > top of Java-index,Java Essentials,Java Programming...
# 5
> > > but I found (the hard way) that hashmaps can> only> > store 124 entries. > > > > How did you found that?> > Er, the hard way.I wonder why didn't he try by the simpler way. :sconf:
Ruly-o_Oa at 2007-7-11 23:50:33 > top of Java-index,Java Essentials,Java Programming...
# 6

> I'm trying to create a collision checking method for

> my game. I have decided that the best way to do this

> is to use a map of some sort to store blocked pixels,

> but I found (the hard way) that hashmaps can only

> store 124 entries.

Incorrect. The theoretical limit is probably Integer.MAX_VALUE, or perhaps that squared, but the available memory of your computer will likely impose a much smaller limit (but far bigger than 124, unless your objects are monstrously huge).

jverda at 2007-7-11 23:50:33 > top of Java-index,Java Essentials,Java Programming...
# 7

Oh, yes it is a programming error. I overlooks my addition method so thats my problem. So...

I know that the code I'm using is supposed to go line after line and add each pixel to the hashmap, but it obviously isn't.

This is the code I'm using, but I still don't know why it doesn't want to do what it should:

//the CollsionStorage instance

CollisionStorage cs = new CollisionStorage();

/**

* Adds a restricted area.

*

*@param x The x location of the object (in pixels)

*@param y The y location of the object (in pixels)

*@param height The height of the object in pixels.

*@param width The width of the object in pixels.

*@param identifier A unique name to identifiy the object for logs.

*/

public void addRestrictedArea(int x, int y, int height, int width, String identifier) {

//The number of times to repeat = height * width (r=hw), so:

int repeat = height * width;

//the counters

int hcounter = 0;

int wcounter = 0;

// The loop adds EVERY pixel defined by the args; the amount is determined by the repeat var.

// Print some info

System.out.println("Adding " + repeat + " pixels to the restricted pixel list for object " + identifier + ".");

// The loop!

for (int i = 0; hcounter <= height; i++) {

if (wcounter == width) { // if the counter is = to the width, we are finished with the line and can move down one

//reset counter

wcounter = 0;

// add to height counter

hcounter++;

//add the collision to storage

cs.add(x, hcounter + y);

// raises the counter

wcounter++;

} else {

// We know that we haven't finished the row because we got through the if, so we can keep going

cs.add(wcounter+x, hcounter+y);

wcounter++;

}

}

//done- print message

System.out.println("Finished adding pixels to restricted pixel list for object " + identifier + ".");

System.out.println("Size of CS now is " + cs.badMoves.size());

}

Now all I'm wondering is why it isn't going through all of the pixels as methodicly as I had hoped...

The code for CollisionStorage is at http://mazerunner.svn.sourceforge.net/viewvc/*checkout*/mazerunner/src/maps/utils/CollisionStorage.java

All I'm storing in the map are 3 digit ints so I shouldn't have to worry about memory issues.

timothyb89_a at 2007-7-11 23:50:33 > top of Java-index,Java Essentials,Java Programming...