summaryrefslogtreecommitdiff
path: root/src/memory_heap.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-02-16 21:36:24 +0100
committerAndré Nusser <andre.nusser@googlemail.com>2020-02-23 13:45:25 +0100
commit43da08a1e3620cc296d27ef5cdf387693b063c68 (patch)
tree74f75cafd661c0748f3c5856697cec12acdb39e1 /src/memory_heap.h
parentcdc96aae4393f0cba0e274efcccc95bc25c5bbdd (diff)
Fix style, minor code fixes, and add review comments.
Diffstat (limited to 'src/memory_heap.h')
-rw-r--r--src/memory_heap.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/memory_heap.h b/src/memory_heap.h
index e2901b8..d90c50c 100644
--- a/src/memory_heap.h
+++ b/src/memory_heap.h
@@ -51,9 +51,9 @@ public:
template <typename... Args>
Index emplace(Args&&... args);
- Index add(T const& element);
+ Index add(const T& element);
T& get(Index index);
- T const& get(Index index) const;
+ const T& get(Index index) const;
void remove(Index index);
private:
@@ -62,7 +62,7 @@ private:
};
template <typename T>
-auto MemoryHeap<T>::add(T const& element) -> Index
+auto MemoryHeap<T>::add(const T& element) -> Index
{
if (free_indices.empty())
{
@@ -92,6 +92,8 @@ auto MemoryHeap<T>::emplace(Args&&... args) -> Index
return free_index;
}
+// Note: MemoryHeap never really deletes anything -- it just overwrites, so
+// old indices will always return a valid item wrt. memory.
template <typename T>
T& MemoryHeap<T>::get(Index index)
{
@@ -100,7 +102,7 @@ T& MemoryHeap<T>::get(Index index)
}
template <typename T>
-T const& MemoryHeap<T>::get(Index index) const
+const T& MemoryHeap<T>::get(Index index) const
{
assert(index < memory.size());
return memory[index];