Archived issue #0027571
Foundation Classes - bad implementation of NCollection_Sequence::Iterator in reversed mode
Description
Regression after #0024831 "Make iterators of NCollection classes STL-compatible".
When the Iterator is initialized for reverse iteration (isStart==False) then it is placed to empty position beyond the end of collection. The OCCT loop semantics requires that an iterator after creation should point to the first iterated item, as it was implemented before version 6.8.0
I propose to restore the original definition of method NCollection_BaseSequence::Iterator::Init() and then revise the STL methods of NCollection_Sequence, particularly now end() and cend() likely lead to crash.
When the Iterator is initialized for reverse iteration (isStart==False) then it is placed to empty position beyond the end of collection. The OCCT loop semantics requires that an iterator after creation should point to the first iterated item, as it was implemented before version 6.8.0
I propose to restore the original definition of method NCollection_BaseSequence::Iterator::Init() and then revise the STL methods of NCollection_Sequence, particularly now end() and cend() likely lead to crash.
Steps to reproduce
test bugs fclasses bug27571
Public activity
6 archived notes
Participants are labeled by their role within this record.
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: ski
Date: Wed Sep 28 17:13:47 2016 +0300
0027571: Bad implementation of NCollection_Sequence::Iterator
Reverse iterator after creation points to the first iterated item now (last item of sequence).
Test case was created.
[revision removed]
Detailed log of new commits:
Author: ski
Date: Wed Sep 28 17:13:47 2016 +0300
0027571: Bad implementation of NCollection_Sequence::Iterator
Reverse iterator after creation points to the first iterated item now (last item of sequence).
Test case was created.
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Dear abv,
all changes are located in branch CR27571.
When the Iterator is initialized for reverse iteration (isStart==False) then it
points to the first iterated item of reversed sequence.
For example:
sequence = 1 2 3 4 5
reversed sequence = 5 4 3 2 1
so, reversed iterator will point to the item 5 after initialization.
It is possible to use Next() with reversed iterator, it will set iterator to the next item 5 -> 4.
More() is also usable.
Previous() will reset iterator to the previous item 4 -> 5.
Methods rbegin()/rend(), increment / decrement operators can be used to work with reversed iterator too.
Test case bugs fclasses bug27571 was created.
Please, review.
all changes are located in branch CR27571.
When the Iterator is initialized for reverse iteration (isStart==False) then it
points to the first iterated item of reversed sequence.
For example:
sequence = 1 2 3 4 5
reversed sequence = 5 4 3 2 1
so, reversed iterator will point to the item 5 after initialization.
It is possible to use Next() with reversed iterator, it will set iterator to the next item 5 -> 4.
More() is also usable.
Previous() will reset iterator to the previous item 4 -> 5.
Methods rbegin()/rend(), increment / decrement operators can be used to work with reversed iterator too.
Test case bugs fclasses bug27571 was created.
Please, review.
Review it, please.
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Related records