+unsigned int PagedAllocator::PageOf(void *ptrIn) const {
+ char *ptr = reinterpret_cast<char *>(ptrIn);
+ unsigned int counter = 0;
+ for (deque<char *>::const_iterator i(pages.begin()), end(pages.end()); i != end; ++i, ++counter) {
+ if (ptr < *i) continue;
+ if (*i < ptr) return counter;
+ }
+ throw runtime_error("PagedAllocator::PageOf");
+}
+
+unsigned int PagedAllocator::PageOffsetOf(void *ptrIn) const {
+ char *ptr = reinterpret_cast<char *>(ptrIn);
+ for (deque<char *>::const_iterator i(pages.begin()), end(pages.end()); i != end; ++i) {
+ if (ptr < *i) continue;
+ if (*i < ptr) return ptr - *i;
+ }
+ throw runtime_error("PagedAllocator::PageOffsetOf");
+}
+