When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
45 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
i can use vector if it will work
An array of what?
Making an array that large on the stack will almost certainly segfault yes, the stack is small
Either put it in static storage (global) or put it on the heap, vectors are a good idea
would vector with this big size work?
of structs
try it and see 
ok
bruh
memmove is not working the same for
vectors
memmove(parts + 1, parts, p * sizeof(parts[0])); //shift right by 1 snake parts pos
how to make it work for vector?
Thank you and let us know if you have any more questions!
its so slow...
do u know way to make it faster??? maybe to use something instead of vector?? something that can insert something at beginning in faster way?
@fluid hill rethink your approach, why do you need to insert stuff at the beginning
Populate in the opposite direction?
Use a linked list?
snake game simulation but on 1m scale
insertion in a linked list is faster
that's the only reason why you'd ever want to use std::set 
Consider linked lists, dequeues, and circular buffers
No its slower, thats why I recommended it as a alternative to meet your speed requirements
but yeah, in general data this big isn't ideal
Linked lists are almost always slower than alternatives
But if you really must insert at the beginning of a list of a million items it may very well be faster
ok, i need something even faster, it needs to end program in 32 seconds on 2GHz cpu...

Preallocate a huge buffer at the beginning of your program and use it
Did you consider other stuff might be eating up your cpu time
Luke Stackwalker shows