Forum Replies Created
-
AuthorPosts
-
24. November 2022 at 15:46 in reply to: Remove duplications from vector but keep the given order #112810::
Watching the presentation “105 STL Algorithms in Less Than an Hour” by Jonathan Boccara, I came to the idea to implement the same function but this time using the algorithm std::stable_partition: https://godbolt.org/z/GEdcWxWa9
And this time no copy is needed.
::Thanx Rainer.
But the video link of the lesson ” Parallel Algorithms -> Details” is also broken: https://www.modernescpp.org/topics/details-82/
Thanx!
12. November 2022 at 23:51 in reply to: Remove duplications from vector but keep the given order #108073::Hi Imran,
I modified your solution a little bit: https://godbolt.org/z/1j5cvrazbBy checking if a key appears twice i.e., this is a duplication and I print it only once.
12. November 2022 at 23:20 in reply to: Remove duplications from vector but keep the given order #10807111. November 2022 at 20:49 in reply to: Remove duplications from vector but keep the given order #107817::Thanx for your answers, but:
- I cannot use std::unique because: “It eliminates all except the first element from every consecutive group of equivalent elements from the range [first, last) and …”
For example:
std::vector<int> v{1, 2, 1, 1, 3, 3, 3, 4, 5, 4};
auto last = std::unique(v.begin(), v.end());
// v now holds {1 2 1 3 4 5 4 x x x}, where ‘x’ is indeterminate
v.erase(last, v.end());
now v contains only: 1 2 1 3 4 5 4 => still duplications available
- std::stable_sort also sorts somehow: “A sequence is sorted with respect to a comparator comp ….”.
I want to keep the order as it is without any sorting at all.
I think the solution would be to write a function which does the stuff.
::Ok, but according to the CppReference the push_back() supports the move semantic.
When does this move semantic kick-in?
::But, if it always does the copy of the element, when is used the move semantic by adding new element std::vector?
According to the CppReference the push_back() supports the move semantic.
::Hi Kevin,
are both dlls being used within the same process or not?
Maybe you can consider these two other possibilities:
- If you can extend the interface of the second component with a new function (which you must export as well), and then the first component can use this new function to inform the second component for any changes detected in the directory, or
- Maybe you can establish a TCP/IP connection (Server-Cilent model) between those two components.
Best Regards,
Driton20. September 2022 at 13:16 in reply to: Video on week 17 template specialization – introspection #87521::Try this link: https://www.modernescpp.org/
When you want to add a link, then use the menu Insert (on top) and select “Link”.
Then, by the last option “Target” pick “New Window”.
::Maybe that WordPress issue blocked also my comment for Diana on this topic https://www.modernescpp.org/forums/topic/opening-external-links-on-a-different-tab/
I think, it had two links inside.
- I cannot use std::unique because: “It eliminates all except the first element from every consecutive group of equivalent elements from the range [first, last) and …”
-
AuthorPosts