TIntIntIterator does not work

Issue #18 invalid
Christoph Sturm created an issue

here is a failing testcase:

<pre>

public void testIntIntHashMapIterator() {
    TIntIntHashMap map = new TIntIntHashMap(2);
    map.put(1,1);
    map.put(2,2);
    TIntIntIterator it = map.iterator();
    assertEquals(1, it.key());
    assertEquals(1, it.value());
    assertTrue(it.hasNext());
    it.advance();
    assertTrue(it.hasNext());
}

</pre>

Comments (2)

  1. Christoph Sturm reporter

    ok i understand now that I have to call advance before reading the first element. is that explained somewhere?

  2. Rob Eden

    It's on the Javadocs for the iterator classes. I can look at putting it on the FAQ also.

    The other problem you'll have with your unit test is that ordering is not guaranteed with hash maps. So, you're check to make sure "1" comes out first is a risky one and wouldn't hold if you had more elements.

  3. Log in to comment