Opened 14 years ago

Closed 14 years ago

#408 closed defect (fixed)

Bug in DictionaryIterator

Reported by: m.kaluzny@… Owned by: Tom Trenka
Priority: high Milestone:
Component: Core Version: 0.2
Keywords: Cc:
Blocked By: Blocking:

Description

There is an error in DictionaryIterator?. It doesn't work for one element collections. For example at line:

37 	        this.atEnd = (position>=arr.length-1);

if we pass array with one element in it then this.atEnd = (0 >= 1-1) and iterator will never iterate trough this one element.

If you have 2 elements in collection then iterator will iterate through only one element as so on.

Attachments (2)

Collections.js (1.9 KB) - added by m.kaluzny@… 14 years ago.
Fixed version of Iterator and DictionaryIterator?
Collections.diff (370 bytes) - added by m.kaluzny@… 14 years ago.
Patch in diff format. Sorry for spamming.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 14 years ago by m.kaluzny@…

Sorry, my mistake. Error only occurs when there is only one element in collection. For two elements and more it works fine.

Changed 14 years ago by m.kaluzny@…

Attachment: Collections.js added

Fixed version of Iterator and DictionaryIterator?

comment:2 Changed 14 years ago by m.kaluzny@…

Resolution: worksforme
Status: newclosed

I've added attachment with fixed version of Collections.js. There were bugs in Iterator and DictionaryIterator? classes. this.atEnd had wrong value for one element collections. I've also fixed errors in this.reset() methods. There was this.atEnd=false; which is wrong for empty collections. This version works fine for me, i've made some tests but i did not do test case in test_Dictionary.html, but I think it will pass it.

Changed 14 years ago by m.kaluzny@…

Attachment: Collections.diff added

Patch in diff format. Sorry for spamming.

comment:3 Changed 14 years ago by anonymous

Resolution: worksforme
Status: closedreopened

comment:4 Changed 14 years ago by m.kaluzny@…

Owner: changed from anonymous to Tom Trenka
Status: reopenednew

comment:5 Changed 14 years ago by Tom Trenka

Resolution: fixed
Status: newclosed

Revision 3589 has the initial check-in for this bug; the Iterator API is reworked and tested against the Dictionary class. Operates on 0 element, 1 element and N element collections correctly, including an error if using do...while against a 0 element collection.

Still doing testing but this seems very stable, so I'm closing the bug.

Note: See TracTickets for help on using tickets.