Commit 0691ecc0 authored by Max Kellermann's avatar Max Kellermann

queue/IdTable: add "noexcept"

parent d917f44b
...@@ -37,21 +37,22 @@ class IdTable { ...@@ -37,21 +37,22 @@ class IdTable {
int *data; int *data;
public: public:
IdTable(unsigned _size):size(_size), next(1), data(new int[size]) { IdTable(unsigned _size) noexcept
:size(_size), next(1), data(new int[size]) {
std::fill_n(data, size, -1); std::fill_n(data, size, -1);
} }
~IdTable() { ~IdTable() noexcept {
delete[] data; delete[] data;
} }
int IdToPosition(unsigned id) const { int IdToPosition(unsigned id) const noexcept {
return id < size return id < size
? data[id] ? data[id]
: -1; : -1;
} }
unsigned GenerateId() { unsigned GenerateId() noexcept {
assert(next > 0); assert(next > 0);
assert(next < size); assert(next < size);
...@@ -67,20 +68,20 @@ public: ...@@ -67,20 +68,20 @@ public:
} }
} }
unsigned Insert(unsigned position) { unsigned Insert(unsigned position) noexcept {
unsigned id = GenerateId(); unsigned id = GenerateId();
data[id] = position; data[id] = position;
return id; return id;
} }
void Move(unsigned id, unsigned position) { void Move(unsigned id, unsigned position) noexcept {
assert(id < size); assert(id < size);
assert(data[id] >= 0); assert(data[id] >= 0);
data[id] = position; data[id] = position;
} }
void Erase(unsigned id) { void Erase(unsigned id) noexcept {
assert(id < size); assert(id < size);
assert(data[id] >= 0); assert(data[id] >= 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment