Everybody hi.
I need to swap elements of my std::vector container.
For example, i have vector with values from 1 to 5;
and i need to swap 2 with 3 (only nearby elements), that in result i'll have 1,3,2,4,5.
In real world i don't have std::vector filled with numbers - it filled with struct objects;
crioto
0
Newbie Poster
Recommended Answers
Jump to PostDo a routine swap manually or use the swap() method from STL algorithm header file. The routine swap involves identifying the two items you want to swap, declaring a third item of desired type and doing this:
temp = B;
B = A;
A = temp;Be sure …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.