comments
This commit is contained in:
@ -23,10 +23,12 @@ private:
|
|||||||
static constexpr const std::size_t min_cap = 5; // Slots to allocate extra when array full
|
static constexpr const std::size_t min_cap = 5; // Slots to allocate extra when array full
|
||||||
|
|
||||||
std::unique_ptr<Type[]> buf; // Heap allocated as size needs to change during runtime
|
std::unique_ptr<Type[]> buf; // Heap allocated as size needs to change during runtime
|
||||||
// Can't use Array for same reason so we use a C Style array
|
// Can't use Array for the same reason so we use a C Style array
|
||||||
// NOTE: Because unique_ptr to an array doesn't implement operator*
|
// NOTE: Normally I wouldn't use smart pointers for low level data structers
|
||||||
// I used *buf.get() everywhere, I think it's probably not supposed
|
// but in this case it's ok as buf doesn't change often
|
||||||
// to be used for something like this?
|
// and the unique_ptr basically has no overhead.
|
||||||
|
// At least I didn't have to write any of the 3 deletes that would
|
||||||
|
// be necessary otherwise ¯\_(ツ)_/¯
|
||||||
std::size_t buf_pos = 0;
|
std::size_t buf_pos = 0;
|
||||||
std::size_t buf_cap = 0;
|
std::size_t buf_cap = 0;
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,7 @@ public:
|
|||||||
|
|
||||||
LinkedListIterator(Type* ptr) : Iterator<T>(ptr) {}
|
LinkedListIterator(Type* ptr) : Iterator<T>(ptr) {}
|
||||||
|
|
||||||
|
// Allow the iterator to traverse the links
|
||||||
LinkedListIterator& operator++() override {
|
LinkedListIterator& operator++() override {
|
||||||
// ptr is of type Wrapper<T>*
|
// ptr is of type Wrapper<T>*
|
||||||
this->ptr = this->ptr->next;
|
this->ptr = this->ptr->next;
|
||||||
|
|||||||
Reference in New Issue
Block a user