The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ambs (22) [Avatar] Offline
#1
I think the idea is to show how stable-partition works, applying it partially to the array, the first three elements with 'is_not_selected' and then with 'is_selected'.

Namely, calling the point in the middle 'destination' and then using it in different position as argument on stable-partition, makes it hard to understand. In fact, it takes a range (as a start and end iterator) and divides the elements accordingly with the predicate, making the ones that satisfy the criteria to be the first ones.

(just my humble opinion smilie)
JonKalb (2) [Avatar] Offline
#2
I don't see the figure as not easy to understand, but perhaps because I'm familiar with the concept.

The algorithm is called gather and the Boost library uses the term pivot for what is destination in this figure.

http://www.boost.org/doc/libs/1_62_0/libs/algorithm/doc/html/the_boost_algorithm_library/Misc/gather.html


I have a suggestion that isn't directly relevant to this figure or to gather, but I think enhances the discussion of partition. The last paragraph on page 34 contains a sentence stating with "The algorithm returns an iterator…" I think the ideal next sentences would point out that "The returned iterator can be paired with the first iterator of the original collection to provide a collection of all elements for which the predicate is true or paired with the end iterator of the original collection to provide a collection of all elements for which the predicate is false. This is true even if any of these collections are empty."


Also, I think the word her is missing in the sentence containing "note that in the figure2.10 we have used std::partition and Rose ended up in front of Martha even if she was after in the original list)." I think though is better than if here. I feel that this reads better as "even though she was after her in the original list." (Emphasis for illustration, not for production.)
Ivan Cukic (104) [Avatar] Offline
#3
I'm going a bit through the earlier chapters, so I'm now processing the comments for them.

@ambs

I'm not sure what you proposed to change in the figure. Could you be a bit more specific so that I can see what the problem is?

@Jon

Thanks for the suggestion - it will be in the next version of chapter 2 smilie