diff --git a/TurboList.hpp b/TurboList.hpp index 323c547..7bd6bbd 100644 --- a/TurboList.hpp +++ b/TurboList.hpp @@ -60,6 +60,18 @@ public: return (i < mid) ? old[i] : nex[i]; } + /** This is much faster than operator[] if you do small amounts of work per access */ + inline void iterate(void(callback)(T&)) noexcept { + // old + for(uint32_t i = 0; i < mid; ++i) { + callback(old[i]); + } + // nex + for(uint32_t i = mid; i < end; ++i) { + callback(nex[i]); + } + } + inline void insert(T elem) noexcept { if(TL_LIKELY(end < capacity)) {