|
|
вернуться в форумI accepted 0.39(5kb). I use template veckor class(C++) to store list of employees. But I don't know how make my program faster :( Edited by author 30.09.2008 14:40 Edited by author 30.09.2008 14:51 Don't use vectors - these are VERY slow structures (as, by the way, all STL components). Rewrite with usual arrays - and, I think, speed of your code will increase several times... i use vector too, i think if i got use array memory limit have exceeded. Don't use vectors - these are VERY slow structures (as, by the way, all STL components). Rewrite with usual arrays - and, I think, speed of your code will increase several times... This statement is just wrong. In which part? For any STL component I can write much faster analog. Well, I was refering only to vectors. Of course you can make sets/maps/other stuff faster. But the underlying structure of a vector is the same array. E.g. vector<int> is just a {array pointer, size, reserved mem}. I've heard this myth about vectors being slow several times, that's exactly why I've done some real testing of it - absolutely no difference, especially if you give the size beforehand (which you have to do in case of arrays). Actually, if you use an iterator to iterate through your vector, it can sometimes actually be faster for different reasons. The only difference may come from using multidimensional (i.e. nested) vectors - in that case, indeed, there can be some performance differences, but still, saying "VERY slow structures" is an extreme exaggeration... remember, you said "increase several times" :). Edited by author 02.04.2011 02:12 |
|
|