Anonymous
lol
Lele fer lola
数学の恋人
You think that's funny?
Anonymous
No
数学の恋人
then stop doing that
Anonymous
Okay sorry. I thought u are chinese. Again sorry.
Pavel
What is a good way to remove elements from a vector in positions given in another vector (std::vector<size_t> indexesToRemove)?
数学の恋人
What is a good way to remove elements from a vector in positions given in another vector (std::vector<size_t> indexesToRemove)?
naive approach I can think just now is, iterate through the index vector and remove with std::vector::erase
Pavel
naive approach I can think just now is, iterate through the index vector and remove with std::vector::erase
Yep, but it's probably not very efficient because we will move elemens on the right in each iteration.
Pavel
Maybe iterating in reverse and erase should be better 🤔
数学の恋人
what about iterating over the original vector and use std::find to find the current index in indexesToRemove vector?
数学の恋人
Pavel
Hm, indexesToRemove is rather big, so the original vector, but it may worth it to convert it to unordered_map for example. Not sure, probably need to get more sleep :)
Anonymous
数学の恋人
Why???
is it bad?
Anonymous
Pavel
I don't think that will make any difference
Well, in case of reverse iterating we will move less elements (won't move elements that going to be removed anyway), but yes, that's a minor win
数学の恋人
Yes
I don't think that makes any difference there, pass by value or pass by reference does it really matter that much?
Cengizhan
Yes
Why?
Pavel
so the vector is sorted, am I right?
Ah, well, no, I thought it sorted but now when you asked I understood that it's not.
数学の恋人
Pavel
Yes. OK, I guess I will go with just iterate and erase and will think about it later. Thanks :)
数学の恋人
Please do tell us if you find anything efficient.
Pavel
No, but I can sort it :)
Pavel
Why?
Types like int can be passed using registers or stack. That's more efficient than passing a reference to it. And there's another issue (I forgot how it called): The compiler can be forced to generate code that reads variable from memory more often in case it can't be sure the variable you passed isn't changed inside your function. Here is an example of such problem in a bad case. https://en.m.wikipedia.org/wiki/Load-Hit-Store
数学の恋人
basically extra space
Pavel
That sounds like a very good solution (can't think if it could be done more efficient than this one), thanks
数学の恋人
oh right just reread the whole thing
数学の恋人
Yes
Thanks for the suggestion I corrected/recfactored it
Anonymous
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-in @maths_lover @cngzhnp
数学の恋人
gone in my saved messages
数学の恋人
is this okay to do? int someFunc(const int, int*) { } // Then calling like int num = 0; num = someFunc(num, &somePointerAddr);
Alex
yes
数学の恋人
or should I do like, int num; const int tempNum = 0; num = someFunc(num, &someAddr);
Alex
first option is ok
数学の恋人
ok thanks
Wisenky
Guys , I want to build an rpg multiplayer cross-platform game with using cpp , I look at sdl sfml and unreal engine . Should I learn using a software like sdl for building it or an engine . Im so confused , would you lead me guys ?
Asdew
Do you want to make an engine and a game or just a game?
Asdew
Then you want to use a game engine.
Wisenky
Then you want to use a game engine.
Is it a must thing using engine for making a game ?
Wisenky
Oh sad :(
klimi
I mean you could make your own game engine but... You would still use one
Asdew
Well, if you don't use a game engine that was not made specifically for your game, then you'll develop it along the way.
klimi
Exactly
Asdew
Well, not really hard.
Wisenky
Do you mean that I should use an engine that made before
Wisenky
Or making a new one specifically for mine
数学の恋人
Or making a new one specifically for mine
I guess first you can try making your game with an engine and learn how engine works in gneral then you might as well make one engine yourselves
数学の恋人
Which one should I choose
any should be fine, though I think you can go for unreal
Wisenky
Thanks for your opinions guys
Asdew
Godot is better.
Dima
UE:)
Tokin
Thanks for your opinions guys
Just make an engine dude.. Might take years if you are asking the questions... But fun process.. You'll learn a lot..
Anonymous
Hi guys this may be off topic but then I would appreciate. Does anyone know of a framework or api I can embed in a c# desktop app to track its analystics the way playstore tracks our Android apps.
Anonymous
Is it a must thing using engine for making a game ?
https://www.youtube.com/c/TheChernoProject If you're interested in making game engine, watch the channel
数学の恋人
Lol banned quietly
@unchanted
gets, getchar, puts, putchar, getch, putch... When, where and how to use them what is the difference in all these? Which compiler understand which keyword...
@unchanted
Read the docs
Can you share me the document?
Anonymous
Artöm
All of them are in standard library, none of them are keywords
Anonymous
And which compiler understand which keyword?
These are not keywords Your question doesn't make sense
Artöm
Yes
Artöm
The link https://en.cppreference.com/w/c/io