Ticket #14 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Problem with Iterator in mango.containers.HashMap

Reported by: jcomellas Assigned to:
Priority: major Milestone:
Component: mango.containers Version: SVN HEAD
Keywords: HashMap Iterator Cc:

Description (Last modified by jcomellas)

There is a bug in the HashMap? Iterators that causes them to miss elements. This means that if I insert, for example, 5 elements into the HashMap?, when iterating over it by using an Iterator I will not get these 5 elements if I call iter.next() successively. You can see this using the attached program. Here's the output:

* Insertion
  Item  0: 01234
  Item  1: 12345
  Item  2: 23456
  Item  3: 34567
  Item  4: 45678

* Index-based iteration
  Item 0: 01234
  Item 1: 12345
  Item 2: 23456
  Item 3: 34567
  Item 4: 45678

* Iterator-based iteration
  Item  0: 45678
  Item  1: 12345
  Item  2: 34567
  Item  3: 01234

Attachments

test_hashmap.d (0.9 kB) - added by jcomellas on 02/24/06 11:34:20.
Test program for HashMap? iterator
test_hashmap.brf (44 bytes) - added by jcomellas on 02/24/06 11:35:14.
Build file for test program

Change History

02/24/06 11:34:20 changed by jcomellas

  • attachment test_hashmap.d added.

Test program for HashMap? iterator

02/24/06 11:35:14 changed by jcomellas

  • attachment test_hashmap.brf added.

Build file for test program

02/24/06 11:36:10 changed by jcomellas

  • version set to SVN HEAD.

This program was only tested on Linux.

02/24/06 11:47:47 changed by jcomellas

  • description changed.

02/24/06 12:06:29 changed by jcomellas

  • description changed.

02/24/06 12:39:02 changed by teqdruid

  • status changed from new to closed.
  • resolution set to fixed.

02/24/06 13:13:20 changed by jcomellas

I know the test case was a little contrived. I just wanted to show the problem and I. The index was just to show the amount of elements.

The containers are comfortable to use so far. I'm only using HashMap? and several iterators, so I can't tell you much yet.

BTW, is there any Map container that is implemented over a tree? Is there any reason why the Maps don't have support for foreach?