Skip to main content

Can I post Bug here? Error with java.util.Map (Mustang & eclipse)

No replies
gingalala
Offline
Joined: 2005-06-30

Hi,

I am using Fedora Core 5 on 800MHz PIII.
Using Eclipse 3.2 m5a built

JDK Env:
java version "1.6.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59g)
Java HotSpot(TM) Client VM (build 1.6.0-beta-b59g, mixed mode, sharing)

I was debugging a problem when I got some funny feedback.
I don't know if the issue is because of Eclipse of Mustang, but here it goes.

If you do a break-point on:

(Integer) map.get(value)) and add the value to WATCH in eclipse debug mode. I noticed that the "watch" keeps looping through. i.e. the value is the same but the entire console window flicks trying to refresh the value again and again.

Hope these details are enough. File attached below:

package gen;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Listy {

//private E s;
private List e;
private Map map;

public Listy() {
e = new ArrayList();
map = new HashMap();
}

/**
* Add an element to the listy.
* If element already exits, increment the count.
* @param value
*/
public void add(E value){
if (e != null && e.size() >0){
for (E val : e)
if (val.equals(value)){
map.put(value, ((Integer) map.get(value)) + 1 );
return;
}
}
e.add(value); // Add the element to the List
map.put(value, new Integer(1)); // Enter the 1st element in the Map.
}

/**
* Remove an element from the Listy
* @param value
*/
public void remove(E value){
for (E iVal : e){
if(iVal.equals(value)){
if (((Integer) map.get(value)).intValue() >1)
map.put(value, ((Integer) map.get(value)) - 1 );
else
e.remove(iVal);
return;
}
}
System.out.println("Value :" + value + " not found.");
}

/**
* Print Listy
*/

public String toString() {
return e.toString();
}

/**
* Print the map with values
* @return
*/
public String showMap(){
return map.toString();
}

/**
* Check if two Listy's are equal. i.e. contain the same set of elements.
* @param value
* @return
*/
public boolean equals(Listy value ){

boolean bResult = true;
for (E src : this.e){
boolean bOk=false;

for (E dst : value.e ){
if (dst.equals(src))
bOk=true;
}
bResult=bResult && bOk;
}
return bResult;
}

/**
* Check if a value exists in the given Listy
* @param value
* @return
*/
public boolean isExists(E value){
for (E srs : e)
if (srs.equals(value))
return true;
return false;
}

}