If you search the web with above keywords, you’ll get lots of misleading responses.
Very often though, List<> is suggested and the thread ends with a thanks.
What I hope is for someone to produce a definitive confirmation that vector is not part of managed C++ (so I can give up my search and move on). A reference would be nice.
The reason I insist on vectors is the random_shuffle() function.
1 2
|
srand(unsigned(time(NULL));
random_shuffle(cards.begin(), cards.end());
|
Does only vector have the random_shuffle function?
It’s so-ooo fast that it must’ve been optimized in assembly code. How else could they have achieved such superluminal speed?
You can write a custom Fisher-Yates shuffle algorithm that swaps elements of the array, but there will be a frustrating speed/performance penalty.
If you run the simulation in the range of 100 million and into a billion, then the lagging shuffle time becomes a deal-breaker.
I’m pretty sure that vector isn’t part of C#, and although List is C#’s equivalent of vector, List doesn’t have the shuffle function. Correct?
Another great C++ function is this:
accumulate(first, last, init, binary_op)
I don’t really care about the explanation as to why it’s so fast (optimized in assembly code?). I just want to use it.
Is accumulate part of managed C++? If not, is there an equivalent function in managed C++ (or C#)?
Will I have to settle with a disorganized mix of managed and unmanaged C++ codes?,...