diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 8fa4def7b3c..4409b2ebfe3 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -23,16 +23,16 @@ namespace CGAL { template class Concurrent_compact_container; - template + template class Combinatorial_map_storage_1; - template + template class Generalized_map_storage_1; - template + template class CMap_linear_cell_complex_storage_1; - template + template class GMap_linear_cell_complex_storage_1; namespace internal { @@ -108,16 +108,16 @@ namespace CGAL { OnMerge, OnSplit, WithID>: public Add_id { - template + template friend class Combinatorial_map_storage_1; - template + template friend class Generalized_map_storage_1; - template + template friend class CMap_linear_cell_complex_storage_1; - template + template friend class GMap_linear_cell_complex_storage_1; template @@ -218,16 +218,16 @@ namespace CGAL { class Cell_attribute_without_info: public Add_id { - template + template friend class Combinatorial_map_storage_1; - template + template friend class Generalized_map_storage_1; - template + template friend class CMap_linear_cell_complex_storage_1; - template + template friend class GMap_linear_cell_complex_storage_1; template @@ -334,16 +334,16 @@ namespace CGAL { class Cell_attribute : public Cell_attribute_without_info { - template + template friend class Combinatorial_map_storage_1; - template + template friend class Generalized_map_storage_1; - template + template friend class CMap_linear_cell_complex_storage_1; - template + template friend class GMap_linear_cell_complex_storage_1; template @@ -374,16 +374,16 @@ namespace CGAL { public Cell_attribute_without_info, public Info_for_cell_attribute { - template + template friend class Combinatorial_map_storage_1; - template + template friend class Generalized_map_storage_1; - template + template friend class CMap_linear_cell_complex_storage_1; - template + template friend class GMap_linear_cell_complex_storage_1; template diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h b/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h index 191b1ea9a9e..39c54355f58 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h @@ -13,6 +13,7 @@ #define COMBINATORIAL_MAP_FWD_H 1 #include +#include namespace CGAL { @@ -23,7 +24,7 @@ struct Combinatorial_map_min_items; struct Generic_map_min_items; #endif -template +template class Combinatorial_map_storage_1; template < unsigned int d_, class Refs_, @@ -33,7 +34,7 @@ template < unsigned int d_, class Refs_, class Items_=Generic_map_min_items, #endif class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Combinatorial_map_storage_1 > + class Storage_= Combinatorial_map_storage_1 > class Combinatorial_map_base; template < unsigned int d_, @@ -43,7 +44,7 @@ template < unsigned int d_, class Items_=Generic_map_min_items, #endif class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Combinatorial_map_storage_1 > + class Storage_= Combinatorial_map_storage_1 > class Combinatorial_map; } // CGAL diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h index 3dd6ba813e7..08eabb22f24 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h @@ -13,6 +13,7 @@ #define CGAL_COMBINATORIAL_MAP_STORAGES_H 1 #include +#include #include #include #include @@ -28,17 +29,20 @@ namespace CGAL { namespace internal { template struct Combinatorial_map_helper; + + template + struct Container_type; } /** @file Combinatorial_map_storages.h * Definition of storages for dD Combinatorial map. */ // Storage of darts with compact container, beta with handles - template + template class Combinatorial_map_storage_1 { public: - typedef Combinatorial_map_storage_1 Self; + typedef Combinatorial_map_storage_1 Self; typedef CGAL::Tag_false Use_index; typedef internal::Combinatorial_map_helper Helper; @@ -57,7 +61,9 @@ namespace CGAL { typedef std::allocator_traits Allocator_traits; typedef typename Allocator_traits::template rebind_alloc Dart_allocator; - typedef Compact_container Dart_container; + + typedef typename internal::Container_type + ::type Dart_container; typedef typename Dart_container::iterator Dart_handle; typedef typename Dart_container::const_iterator Dart_const_handle; @@ -70,7 +76,9 @@ namespace CGAL { typedef Alloc_ Alloc; template struct Container_for_attributes : - public Compact_container::template rebind_alloc > + public internal::Container_type + ::template rebind_alloc>::type {}; /// Typedef for attributes typedef typename internal::template Get_attributes_tuple::type @@ -425,9 +433,9 @@ namespace CGAL { }; /// null_handle - template < unsigned int d_, class Items_, class Alloc_ > - const typename Combinatorial_map_storage_1::Null_handle_type - Combinatorial_map_storage_1::null_handle = nullptr; + template < unsigned int d_, class Items_, class Alloc_, class Concurrent_tag > + const typename Combinatorial_map_storage_1::Null_handle_type + Combinatorial_map_storage_1::null_handle = nullptr; } // namespace CGAL diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index bfc21e7b25a..fa4375ed202 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -26,16 +26,16 @@ namespace CGAL { template class Concurrent_compact_container; - template + template class Combinatorial_map_storage_1; - template + template class Generalized_map_storage_1; - template + template class CMap_linear_cell_complex_storage_1; - template + template class GMap_linear_cell_complex_storage_1; namespace internal { @@ -60,16 +60,16 @@ namespace CGAL { struct Dart_without_info: public Add_id { public: - template + template friend class Combinatorial_map_storage_1; - template + template friend class Generalized_map_storage_1; - template + template friend class CMap_linear_cell_complex_storage_1; - template + template friend class GMap_linear_cell_complex_storage_1; template @@ -210,10 +210,10 @@ namespace CGAL { template struct CGAL_DEPRECATED Dart : public Dart_without_info { - template + template friend class Combinatorial_map_storage_1; - template + template friend class CMap_linear_cell_complex_storage_1; template @@ -310,16 +310,16 @@ namespace CGAL { struct Dart : public Dart_without_info { public: - template + template friend class Combinatorial_map_storage_1; - template + template friend class Generalized_map_storage_1; - template + template friend class CMap_linear_cell_complex_storage_1; - template + template friend class GMap_linear_cell_complex_storage_1; template diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h index 9e0bf9143b9..a349373ba4b 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -593,6 +594,18 @@ namespace CGAL }; }; + // Helper class to define container type depending on the Concurrent_tag + template + struct Container_type + { + typedef CGAL::Compact_container type; + }; + template + struct Container_type + { + typedef CGAL::Concurrent_compact_container type; + }; + } //namespace internal } //namespace CGAL diff --git a/Generalized_map/include/CGAL/Generalized_map_fwd.h b/Generalized_map/include/CGAL/Generalized_map_fwd.h index a006ad1b2b4..0ca8a8bd078 100644 --- a/Generalized_map/include/CGAL/Generalized_map_fwd.h +++ b/Generalized_map/include/CGAL/Generalized_map_fwd.h @@ -13,10 +13,11 @@ #define GENERALIZED_MAP_FWD_H 1 #include +#include namespace CGAL { -template +template class Generalized_map_storage_1; struct Generic_map_min_items; @@ -24,13 +25,13 @@ struct Generic_map_min_items; template < unsigned int d_, class Refs, class Items_=Generic_map_min_items, class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Generalized_map_storage_1 > + class Storage_= Generalized_map_storage_1 > class Generalized_map_base; template < unsigned int d_, class Items_=Generic_map_min_items, class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Generalized_map_storage_1 > + class Storage_= Generalized_map_storage_1 > class Generalized_map; } // CGAL diff --git a/Generalized_map/include/CGAL/Generalized_map_storages.h b/Generalized_map/include/CGAL/Generalized_map_storages.h index a149dd19ede..56040f48759 100644 --- a/Generalized_map/include/CGAL/Generalized_map_storages.h +++ b/Generalized_map/include/CGAL/Generalized_map_storages.h @@ -13,6 +13,7 @@ #define CGAL_GENERALIZED_MAP_STORAGES_H 1 #include +#include #include #include #include @@ -28,6 +29,9 @@ namespace CGAL { namespace internal { template struct Combinatorial_map_helper; + + template + struct Container_type; } /** @file Generalized_map_storages.h @@ -35,11 +39,11 @@ namespace CGAL { */ // Storage of darts with compact container, alpha with handles - template + template class Generalized_map_storage_1 { public: - typedef Generalized_map_storage_1 Self; + typedef Generalized_map_storage_1 Self; typedef CGAL::Tag_false Use_index; typedef internal::Combinatorial_map_helper Helper; @@ -55,7 +59,9 @@ namespace CGAL { typedef std::allocator_traits Allocator_traits; typedef typename Allocator_traits::template rebind_alloc Dart_allocator; - typedef Compact_container Dart_container; + typedef typename internal::Container_type + ::type Dart_container; + typedef typename Dart_container::iterator Dart_handle; typedef typename Dart_container::const_iterator Dart_const_handle; @@ -69,7 +75,9 @@ namespace CGAL { template struct Container_for_attributes : - public Compact_container::template rebind_alloc > + public internal::Container_type + ::template rebind_alloc>::type {}; /// Typedef for attributes typedef typename internal::template Get_attributes_tuple::type @@ -412,9 +420,9 @@ namespace CGAL { }; /// null_handle - template < unsigned int d_, class Items_, class Alloc_ > - const typename Generalized_map_storage_1::Null_handle_type - Generalized_map_storage_1::null_handle = nullptr; + template < unsigned int d_, class Items_, class Alloc_, class Concurrent_tag > + const typename Generalized_map_storage_1::Null_handle_type + Generalized_map_storage_1::null_handle = nullptr; } // namespace CGAL diff --git a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages.h b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages.h index d9e14b49652..c3095592caa 100644 --- a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages.h +++ b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages.h @@ -13,6 +13,7 @@ #define CGAL_CMAP_LINEAR_CELL_COMPLEX_STORAGES_H 1 #include +#include #include #include #include @@ -28,6 +29,9 @@ namespace CGAL { namespace internal { template struct Combinatorial_map_helper; + + template + struct Container_type; } /** @file CMap_linear_cell_complex_storages.h @@ -40,7 +44,7 @@ namespace CGAL { // as template parameter of Dart_wrapper. If we inherit, Self is not // the correct type). template + class Traits_, class Items_, class Alloc_, class Concurrent_tag > class CMap_linear_cell_complex_storage_1 { public: @@ -49,7 +53,7 @@ namespace CGAL { typedef typename Traits_::FT FT; typedef CMap_linear_cell_complex_storage_1 Self; + Items_, Alloc_, Concurrent_tag> Self; typedef CGAL::Tag_false Use_index; typedef internal::Combinatorial_map_helper Helper; @@ -69,7 +73,8 @@ namespace CGAL { typedef std::allocator_traits Allocator_traits; typedef typename Allocator_traits::template rebind_alloc Dart_allocator; - typedef Compact_container Dart_container; + typedef typename internal::Container_type + ::type Dart_container; typedef typename Dart_container::iterator Dart_handle; typedef typename Dart_container::const_iterator Dart_const_handle; @@ -80,12 +85,12 @@ namespace CGAL { typedef Items_ Items; typedef Alloc_ Alloc; - template struct Container_for_attributes : - public Compact_container::template rebind_alloc > + public internal::Container_type + ::template rebind_alloc>::type {}; - /// Typedef for attributes typedef typename internal::template Get_attributes_tuple::type Attributes; @@ -463,11 +468,11 @@ namespace CGAL { /// null_handle template + class Traits_, class Items_, class Alloc_, class Concurrent_tag > const typename CMap_linear_cell_complex_storage_1::Null_handle_type + Items_, Alloc_, Concurrent_tag>::Null_handle_type CMap_linear_cell_complex_storage_1::null_handle = nullptr; + Items_, Alloc_, Concurrent_tag>::null_handle = nullptr; } // namespace CGAL diff --git a/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages.h b/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages.h index e9c333e4aae..c48ec047dfd 100644 --- a/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages.h +++ b/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages.h @@ -28,6 +28,9 @@ namespace CGAL { namespace internal { template struct Combinatorial_map_helper; + + template + struct Container_type; } /** @file GMap_linear_cell_complex_storages.h @@ -40,7 +43,7 @@ namespace CGAL { // as template parameter of Dart_wrapper. If we inherit, Self is not // the correct type). template + class Traits_, class Items_, class Alloc_, class Concurrent_tag > class GMap_linear_cell_complex_storage_1 { public: @@ -49,7 +52,7 @@ namespace CGAL { typedef typename Traits_::FT FT; typedef GMap_linear_cell_complex_storage_1 Self; + Items_, Alloc_, Concurrent_tag> Self; typedef CGAL::Tag_false Use_index; typedef internal::Combinatorial_map_helper Helper; @@ -65,7 +68,9 @@ namespace CGAL { typedef std::allocator_traits Allocator_traits; typedef typename Allocator_traits::template rebind_alloc Dart_allocator; - typedef Compact_container Dart_container; + typedef typename internal::Container_type + ::type Dart_container; + typedef typename Dart_container::iterator Dart_handle; typedef typename Dart_container::const_iterator Dart_const_handle; @@ -79,7 +84,9 @@ namespace CGAL { template struct Container_for_attributes : - public Compact_container::template rebind_alloc > + public internal::Container_type + ::template rebind_alloc>::type {}; /// Typedef for attributes typedef typename internal::template Get_attributes_tuple::type @@ -446,11 +453,11 @@ namespace CGAL { /// null_handle template + class Traits_, class Items_, class Alloc_, class Concurrent_tag > const typename GMap_linear_cell_complex_storage_1::Null_handle_type + Items_, Alloc_, Concurrent_tag>::Null_handle_type GMap_linear_cell_complex_storage_1::null_handle = nullptr; + Items_, Alloc_, Concurrent_tag>::null_handle = nullptr; } // namespace CGAL #if (BOOST_GCC >= 40900) diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h index 17c40957c82..d7a05e197b1 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h @@ -19,11 +19,11 @@ namespace CGAL { template + class Traits_, class Items_, class Alloc_, class Concurrent_tag=CGAL::Tag_false > class CMap_linear_cell_complex_storage_1; template + class Traits_, class Items_, class Alloc_, class Concurrent_tag=CGAL::Tag_false > class GMap_linear_cell_complex_storage_1; template @@ -62,7 +62,7 @@ template < unsigned int d_, unsigned int ambient_dim = d_, class CMap = Combinatorial_map_base, class Storage_ = CMap_linear_cell_complex_storage_1 > + Alloc_, CGAL::Tag_false> > class Linear_cell_complex_for_combinatorial_map; template < unsigned int d_, unsigned int ambient_dim = d_, @@ -73,7 +73,7 @@ template < unsigned int d_, unsigned int ambient_dim = d_, class CMap = Generalized_map_base, class Storage_ = GMap_linear_cell_complex_storage_1 > + Alloc_, CGAL::Tag_false> > class Linear_cell_complex_for_generalized_map; #if !defined(CGAL_NO_DEPRECATED_CODE) @@ -89,7 +89,7 @@ template < unsigned int d_, unsigned int ambient_dim = d_, class CMap = Combinatorial_map_base, class Storage_ = CMap_linear_cell_complex_storage_1 > + Alloc_, CGAL::Tag_false> > class Linear_cell_complex; #endif diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index b2025dfa9af..3877e39f98b 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -476,6 +476,42 @@ public: return m_alloc; } + // Returns the index of the iterator "cit", i.e. the number n so that + // operator[](n)==*cit. + // Complexity : O(#blocks) = O(sqrt(capacity())). + // This function is mostly useful for purposes of efficient debugging at + // higher levels. + size_type index(const_iterator cit) const + { + // We use the block structure to provide an efficient version : + // we check if the address is in the range of each block. + + assert(cit != end()); + + const_pointer c = &*cit; + size_type res=0; + + Mutex::scoped_lock lock(m_mutex); + + for (typename All_items::const_iterator it = m_all_items.begin(), + itend = m_all_items.end(); it != itend; ++it) { + const_pointer p = it->first; + size_type s = it->second; + + // Are we in the address range of this block (excluding first and last + // elements) ? + if ( p