我在我的代码中使用了位集:
std::bitset<MAX_INSTRUMENTS_NUMBER_IN_SYSTEM> updatedInstruments;
通常我只需要迭代“设置”的(或者“未设置”的)值,以下是我的做法:
for (int instrumentId = 0; instrumentId < MAX_INSTRUMENTS_NUMBER_IN_SYSTEM; instrumentId++) {
if (!updatedInstruments[instrumentId]) {
continue;
}
// work
}
这个迭代可以通过优化来使其更易读,也可能更快吗?
std::bitset
甚至没有迭代器!所以我想我的观点完全无效了... - Matteo Italia