KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
It's really a simple problem : I'm programming a Go program. Should I represent the board with a QVector<int> or a QVector<Player> where enum Player { EMPTY = 0, BLACK = 1, WHITE = 2 }; I guess that of course, using Player instead of integers will be slower. But I wonder how much more, because I believe that using enum is better coding. I've done a few tests regarding assigning and comparing Players (as opposed to int ) QVector<int> vec; vec.resize(10000000); int size = vec.size(); for(int i =0; i<size; ++i) { vec[i] = 0; } for(int i =0; i<size; ++i) { bool b = (vec[i] == 1); } QVector<Player> vec2; vec2.resize(10000000); int size = vec2.size(); for(int i =0; i<size; ++i) { vec2[i] = EMPTY; } for(int i =0; i<size; ++i) { bool b = (vec2[i] == BLACK); } Basically, it's only 10% slower. Is there anything else I should know before continuing? Thanks! Edit : The 10% difference is not a figment of my imagination, it seems to be specific to Qt and QVector. When I use std::vector, the speed is the same
Tags (comma-separated)
Save Edits
Cancel