diff --git a/Spatial_searching/benchmark/Spatial_searching/deque.cpp b/Spatial_searching/benchmark/Spatial_searching/deque.cpp index a0a3e40d975..71bd8ca2f48 100644 --- a/Spatial_searching/benchmark/Spatial_searching/deque.cpp +++ b/Spatial_searching/benchmark/Spatial_searching/deque.cpp @@ -4,35 +4,49 @@ #include #include #include +#include +#if 1 // +// leaf struct X { - double a,b,c,d,e,f,g,h,i,j,k,l; + bool b; + int i; + double d1; }; - +#else +// internal +struct X { + bool b; + int i; + double d1, d2, d3, d4,d5; +}; +#endif int main() { CGAL::Memory_sizer ms; CGAL::Timer t; - char c; t.start(); #if 0 - + std::cout <<"blocklist"<< std::endl; CGAL::Block_list de; -#elif 1 +#elif 0 + std::cout <<"boost::container::deque"<< std::endl; + boost::container::deque de; +#elif 0 + std::cout <<"std::deque"<< std::endl; std::deque de; #else + std::cout <<"vector"<< std::endl; std::vector de; - de.reserve(100000000); + // de.reserve(100000000); #endif - for(int i=0; i < 100000000; i++){ + for(int i=0; i < 10000000; i++){ de.push_back(X()); } t.stop(); std::cout << t.time() << "sec"<< std::endl; std::cout << ms.virtual_size() << " " << ms.resident_size() << std::endl; - std::cout << "cont>" << std::endl; - std::cin >> c; return 0; } diff --git a/Spatial_searching/include/CGAL/Block_list.h b/Spatial_searching/include/CGAL/Block_list.h index a0b215175aa..8e6fa95a825 100644 --- a/Spatial_searching/include/CGAL/Block_list.h +++ b/Spatial_searching/include/CGAL/Block_list.h @@ -12,12 +12,20 @@ namespace CGAL { typedef CGAL::cpp11::array Block; int index; std::list blocks; + typedef typename std::list::iterator List_iterator; + typedef typename Block::iterator Block_iterator; public: Block_list() : index(N) {} + std::size_t size() const + { + return (index == N)? (blocks.size()*N) : ((blocks.size()-1)*N+index); + } + + T* push_back(const T& t) { if(index==N){ @@ -32,6 +40,8 @@ namespace CGAL { return ptr; } + + void clear() { blocks.clear();