harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spark Shen <smallsmallor...@gmail.com>
Subject Re: [classlib][luni] A problem about behavior of EnumMap
Date Wed, 30 Aug 2006 01:33:07 GMT
Spark Shen 写道:
> I guess on RI, the returned iterator maintains a reference to current 
> entry and returns this reference in iter.next() method.
> I do not think RI's behavior makes sense here. So I suggest not to 
> follow RI on the behavior.
I want to adopt the behavior described below because it seems more 
The previous Entry should not point to the next Entry when the 
iterator's next() is invoked. And then the methods of the Class Entry, 
such as getKey(), getValue() ,setValue() etc,
will act on the different objects.
Based on my implement,I expect the following test cases pass on 
Harmony.(Some of them will fail on RI.)

enum Size {
Small, Middle, Big {
public void test_entrySet() {
EnumMap enumSizeMap = new EnumMap(Size.class);
enumSizeMap.put(Size.Middle, 1);
enumSizeMap.put(Size.Big, null);

Set set = enumSizeMap.entrySet();
Iterator iter = set.iterator();
Map.Entry entry1 = (Map.Entry) iter.next();
Map.Entry entry2 = (Map.Entry) iter.next();
assertEquals(Size.Middle, entry1.getKey());
assertEquals(1, entry1.getValue());
try {
fail("Should throw IllegalStateException"); //$NON-NLS-1$
} catch (IllegalStateException e) {
// Expected
assertEquals(1, set.size());
assertEquals(Size.Big, entry2.getKey());
assertEquals(2, entry2.getValue());
> Best regards

Spark Shen
China Software Development Lab, IBM

Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

View raw message