diff --git a/Vector.h b/Vector.h index c77460e..44f86e6 100644 --- a/Vector.h +++ b/Vector.h @@ -53,7 +53,7 @@ class Vector { // Equals Operator: Returns true if the number of elements is identical and // each of these elements are equal - bool operator==(const Vector &other) { + bool operator==(const Vector &other) const { if (size() != other.size()) return false; for (unsigned int i = 0; i < size(); i++) { @@ -105,7 +105,7 @@ class Vector { } } - T *as_array() { + T *as_array() const { return data; } @@ -172,19 +172,19 @@ class Vector { // Return a sensible capacity for the given size (including some // padding). - unsigned int get_capacity_for_size(unsigned int size) { + unsigned int get_capacity_for_size(unsigned int size) const { return size * 2 + 5; } // Return true if the Vector is holding much more memory (capacity) than it // currently needs (element_count). - inline bool is_using_excessive_memory() { + inline bool is_using_excessive_memory() const { return 10 + element_count * 2 < capacity; } // Return true if the passed new_size would cause the Vector to exceed the // current capacity (meaning it must be expanded with `reallocate` first). - inline bool new_size_exceeds_capacity(unsigned int new_size) { + inline bool new_size_exceeds_capacity(unsigned int new_size) const { return new_size > capacity; }