diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 796b71ba629..df3a4b0d686 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -32,25 +32,25 @@ template class Combinatorial_map_storage_1; template -class Combinatorial_map_storage_2; +class Combinatorial_map_storage_with_index; template class Generalized_map_storage_1; template -class Generalized_map_storage_2; +class Generalized_map_storage_with_index; template class CMap_linear_cell_complex_storage_1; template -class CMap_linear_cell_complex_storage_2; +class CMap_linear_cell_complex_storage_with_index; template class GMap_linear_cell_complex_storage_1; template -class GMap_linear_cell_complex_storage_2; +class GMap_linear_cell_complex_storage_with_index; namespace internal { @@ -111,25 +111,25 @@ struct Init_id; friend class Combinatorial_map_storage_1; template - friend class Combinatorial_map_storage_2; + friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template - friend class Generalized_map_storage_2; + friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template - friend class CMap_linear_cell_complex_storage_2; + friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_2; + friend class GMap_linear_cell_complex_storage_with_index; template friend struct internal::Init_id; @@ -236,25 +236,25 @@ struct Init_id; friend class Combinatorial_map_storage_1; template - friend class Combinatorial_map_storage_2; + friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template - friend class Generalized_map_storage_2; + friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template - friend class CMap_linear_cell_complex_storage_2; + friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_2; + friend class GMap_linear_cell_complex_storage_with_index; template friend struct internal::Init_id; @@ -368,25 +368,25 @@ struct Init_id; friend class Combinatorial_map_storage_1; template - friend class Combinatorial_map_storage_2; + friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template - friend class Generalized_map_storage_2; + friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template - friend class CMap_linear_cell_complex_storage_2; + friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_2; + friend class GMap_linear_cell_complex_storage_with_index; public: typedef Tag_ Supports_cell_dart; @@ -423,25 +423,25 @@ struct Init_id; friend class Combinatorial_map_storage_1; template - friend class Combinatorial_map_storage_2; + friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template - friend class Generalized_map_storage_2; + friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template - friend class CMap_linear_cell_complex_storage_2; + friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_2; + friend class GMap_linear_cell_complex_storage_with_index; public: typedef Cell_attribute Self; diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h b/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h index 65f02ff17fd..cd9432defe8 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h @@ -24,7 +24,7 @@ template class Combinatorial_map_storage_1; template -class Combinatorial_map_storage_2; +class Combinatorial_map_storage_with_index; namespace internal { @@ -38,7 +38,7 @@ template<> struct Default_storage_for_cmap_when_tag { template - using type=Combinatorial_map_storage_2; + using type=Combinatorial_map_storage_with_index; }; BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_use_index_tag_cmap,Use_index,false) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h index be89f501f2e..abd5f6200e0 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h @@ -34,10 +34,10 @@ namespace CGAL { // Storage with combinatorial maps using index template - class Combinatorial_map_storage_2 + class Combinatorial_map_storage_with_index { public: - using Self=Combinatorial_map_storage_2; + using Self=Combinatorial_map_storage_with_index; using Use_index=CGAL::Tag_true; using Concurrent_tag=typename internal::Get_concurrent_tag::type; @@ -65,7 +65,7 @@ namespace CGAL { typedef typename Dart_container::size_type size_type; typedef Dart_index Null_descriptor_type; - static Null_descriptor_type null_descriptor; + static const Index_type null_descriptor=Dart_container::null_descriptor; using Type_for_compact_container=Index_type; @@ -108,7 +108,7 @@ namespace CGAL { template using Attribute_const_handle=Attribute_const_descriptor; - static Null_descriptor_type null_handle; + static const Index_type null_handle=null_descriptor; /// Number of marks static const size_type NB_MARKS = 32; @@ -154,7 +154,7 @@ namespace CGAL { Dart_const_range& darts() const { return mdarts_range; } //************************************************************************** - Combinatorial_map_storage_2() : mdarts_range(*this) + Combinatorial_map_storage_with_index() : mdarts_range(*this) {} void init_storage() @@ -164,7 +164,7 @@ namespace CGAL { Dart_index local_null_dart_descriptor = mdarts.emplace(); if(local_null_dart_descriptor!=0) { - std::cerr<<"[ERROR] fatal in Combinatorial_map_storage_2::init_storage" + std::cerr<<"[ERROR] fatal in Combinatorial_map_storage_with_index::init_storage" < - typename Combinatorial_map_storage_2::Dart_index - Combinatorial_map_storage_2::null_dart_descriptor(0); - - /// null_descriptor - template - typename Combinatorial_map_storage_2::Null_descriptor_type - Combinatorial_map_storage_2:: - null_descriptor((std::numeric_limits::max)()); - - template - typename Combinatorial_map_storage_2::Dart_index - Combinatorial_map_storage_2::null_dart_handle(0); - - template - typename Combinatorial_map_storage_2::Null_descriptor_type - Combinatorial_map_storage_2:: - null_handle((std::numeric_limits::max)()); - } // namespace CGAL #if defined(BOOST_GCC) diff --git a/Combinatorial_map/include/CGAL/Compact_container_with_index.h b/Combinatorial_map/include/CGAL/Compact_container_with_index.h index 1bcf372713d..efbc2349a80 100644 --- a/Combinatorial_map/include/CGAL/Compact_container_with_index.h +++ b/Combinatorial_map/include/CGAL/Compact_container_with_index.h @@ -97,6 +97,8 @@ class Free_list_management using size_type=typename CC_with_index::size_type; public: + static const size_type null_descriptor=std::numeric_limits::max(); + Free_list_management(CC_with_index& cc_with_index): m_cc_with_index(cc_with_index) {} @@ -191,6 +193,8 @@ class Free_list_management using Traits=Compact_container_with_index_traits ; public: + static const size_type null_descriptor=std::numeric_limits::max(); + Free_list_management(CC_with_index& cc_with_index): m_cc_with_index(cc_with_index) {} @@ -200,7 +204,7 @@ public: m_used.assign(m_cc_with_index.capacity(), false); m_free_list=0; for(size_type i=0; i(m_cc_with_index.capacity()); ++i) - { Traits::size_t(m_cc_with_index[i])=i+1; } + { Traits::set_size_t(m_cc_with_index[i], i+1); } // Next of the last element is capacity() which is the "nullptr". } @@ -210,7 +214,7 @@ public: CGAL_assertion(m_free_list==old_size); // Previous container was full m_used.resize(m_cc_with_index.capacity(), false); for(size_type i=0; i(m_cc_with_index.capacity()); ++i) - { Traits::size_t(m_cc_with_index[i])=i+1; } + { Traits::set_size_t(m_cc_with_index[i], i+1); } // Nothing to do with m_free_list, because it was equal to old_size. } @@ -234,7 +238,7 @@ public: { CGAL_assertion(i using Traits=Compact_container_with_index_traits ; public: + static const size_type null_descriptor=std::numeric_limits::max()/2; + Free_list_management(CC_with_index& cc_with_index): m_cc_with_index(cc_with_index) {} @@ -327,7 +334,7 @@ public: } void copy_special_data(const T& src, T& dest) - { Traits::size_t(dest)=Traits::size_t(src); } + { Traits::set_size_t(dest, Traits::size_t(src)); } protected: // Definition of the bit squatting : @@ -351,6 +358,11 @@ protected: static size_type static_get_val(const T& e) { return (Traits::size_t(e) & ~mask_type); } + // set the value of the element and its type + static void static_set_type(T& e, Type t) + { Traits::set_size_t(e, static_get_val(e) | + ( ((size_type)t) <<(nbbits_size_type_m1))); } + // set the value of the element and its type static void static_set_val(T& e, size_type v, Type t) { Traits::set_size_t(e, v | ( ((size_type)t) <<(nbbits_size_type_m1))); } @@ -368,7 +380,7 @@ public: using Self=Index_for_cc_with_index; using size_type=Index_type; - /// Constructor. Default construction creates a kind of "NULL" index. + /// Constructor. Index_for_cc_with_index(size_type idx=(std::numeric_limits::max)()) : m_idx(idx) {} @@ -382,9 +394,11 @@ public: Index_for_cc_with_index(const Index2& idx): m_idx(static_cast(idx)) {} - /// return whether the handle is valid - bool is_valid() const - { return m_idx != (std::numeric_limits::max)(); } + bool operator==(const Self& n) const + { return m_idx==n.m_idx; } + + bool operator==(size_type n) const + { return m_idx==n; } /// Increment the internal index. This operations does not /// guarantee that the index is valid or undeleted after the @@ -447,6 +461,11 @@ public: typedef std::reverse_iterator const_reverse_iterator; using Index=Index_for_cc_with_index; + using TFree_list_management=Free_list_management + ; + + static const size_type null_descriptor=TFree_list_management::null_descriptor; + friend class internal::CC_iterator_with_index; friend class internal::CC_iterator_with_index; @@ -728,12 +747,12 @@ private: free_list.init(); } - allocator_type alloc; - size_type capacity_; - size_type size_; - size_type block_size; - pointer all_items; - Free_list_management free_list; + allocator_type alloc; + size_type capacity_; + size_type size_; + size_type block_size; + pointer all_items; + TFree_list_management free_list; }; /*template < class T, class Allocator, class Increment_policy, class IndexType > diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index 9246004d586..3ae2a9d449e 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -33,25 +33,25 @@ namespace CGAL { class Combinatorial_map_storage_1; template - class Combinatorial_map_storage_2; + class Combinatorial_map_storage_with_index; template class Generalized_map_storage_1; template - class Generalized_map_storage_2; + class Generalized_map_storage_with_index; template class CMap_linear_cell_complex_storage_1; template - class CMap_linear_cell_complex_storage_2; + class CMap_linear_cell_complex_storage_with_index; template class GMap_linear_cell_complex_storage_1; template - class GMap_linear_cell_complex_storage_2; + class GMap_linear_cell_complex_storage_with_index; namespace internal { @@ -88,35 +88,35 @@ namespace CGAL { friend class Combinatorial_map_storage_1; template - friend class Combinatorial_map_storage_2; + friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template - friend class Generalized_map_storage_2; + friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template - friend class CMap_linear_cell_complex_storage_2; + friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_2; + friend class GMap_linear_cell_complex_storage_with_index; template friend struct internal::Init_id; - typedef Dart_without_info Self; - typedef typename Refs::Dart_descriptor Dart_descriptor; - typedef typename Refs::size_type size_type; - typedef typename Refs::Dart_const_descriptor Dart_const_descriptor; - typedef typename Refs::Helper Helper; - typedef WithId Has_id; + typedef Dart_without_info Self; + typedef typename Refs::Dart_descriptor Dart_descriptor; + typedef typename Refs::size_type size_type; + typedef typename Refs::Dart_const_descriptor Dart_const_descriptor; + typedef typename Refs::Helper Helper; + typedef WithId Has_id; using Type_for_compact_container=typename Refs::Type_for_compact_container; /// Typedef for attributes @@ -251,25 +251,25 @@ namespace CGAL { friend class Combinatorial_map_storage_1; template - friend class Combinatorial_map_storage_2; + friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template - friend class Generalized_map_storage_2; + friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template - friend class CMap_linear_cell_complex_storage_2; + friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_2; + friend class GMap_linear_cell_complex_storage_with_index; typedef Dart Self; typedef Info_ Info; diff --git a/Generalized_map/include/CGAL/Generalized_map_fwd.h b/Generalized_map/include/CGAL/Generalized_map_fwd.h index 6da380457b9..4febe72d5c2 100644 --- a/Generalized_map/include/CGAL/Generalized_map_fwd.h +++ b/Generalized_map/include/CGAL/Generalized_map_fwd.h @@ -22,7 +22,7 @@ template class Generalized_map_storage_1; template -class Generalized_map_storage_2; +class Generalized_map_storage_with_index; struct Generic_map_min_items; @@ -38,7 +38,7 @@ template<> struct Default_storage_for_gmap_when_tag { template - using type=Generalized_map_storage_2; + using type=Generalized_map_storage_with_index; }; BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_use_index_tag_gmap,Use_index,false) diff --git a/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h b/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h index c0f0624760d..d19bced77cc 100644 --- a/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h +++ b/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h @@ -34,10 +34,10 @@ namespace CGAL { // Storage of darts with compact container, alpha with indices template - class Generalized_map_storage_2 + class Generalized_map_storage_with_index { public: - using Self=Generalized_map_storage_2; + using Self=Generalized_map_storage_with_index; using Use_index=CGAL::Tag_true; using Concurrent_tag=typename internal::Get_concurrent_tag::type; @@ -439,13 +439,13 @@ namespace CGAL { /// null_descriptor template - typename Generalized_map_storage_2::Null_descriptor_type - Generalized_map_storage_2:: + typename Generalized_map_storage_with_index::Null_descriptor_type + Generalized_map_storage_with_index:: null_descriptor((std::numeric_limits::max)()); template - typename Generalized_map_storage_2::Null_descriptor_type - Generalized_map_storage_2:: + typename Generalized_map_storage_with_index::Null_descriptor_type + Generalized_map_storage_with_index:: null_handle((std::numeric_limits::max)()); } // namespace CGAL diff --git a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h index 0a121c9ff72..a2a94774979 100644 --- a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h +++ b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h @@ -33,16 +33,16 @@ namespace CGAL { } // Storage of darts with compact container, alpha using index - // Copy of Combinatorial_map_storage_2 and add new types related + // Copy of Combinatorial_map_storage_with_index and add new types related // to geometry (not possible to inherith because we use Self type // as template parameter of Dart_wrapper. If we inherit, Self is not // the correct type). template - class CMap_linear_cell_complex_storage_2 + class CMap_linear_cell_complex_storage_with_index { public: - using Self=CMap_linear_cell_complex_storage_2; using Use_index=CGAL::Tag_true; using Concurrent_tag=typename internal::Get_concurrent_tag::type; @@ -75,7 +75,7 @@ namespace CGAL { typedef typename Dart_container::size_type size_type; typedef Dart_index Null_descriptor_type; - static Null_descriptor_type null_descriptor; + static const Index_type null_descriptor=Dart_container::null_descriptor; using Type_for_compact_container=Index_type; @@ -129,7 +129,7 @@ namespace CGAL { using Vertex_attribute_handle=Vertex_attribute_descriptor; using Vertex_attribute_const_handle=Vertex_attribute_const_descriptor; - static Null_descriptor_type null_handle; + static const Index_type null_handle=null_descriptor; /// Number of marks static const size_type NB_MARKS = 32; @@ -175,7 +175,7 @@ namespace CGAL { Dart_const_range& darts() const { return mdarts_range; } //************************************************************************** - CMap_linear_cell_complex_storage_2() : mdarts_range(*this) + CMap_linear_cell_complex_storage_with_index() : mdarts_range(*this) {} void init_storage() @@ -185,7 +185,7 @@ namespace CGAL { Dart_index local_null_dart_descriptor = mdarts.emplace(); if(local_null_dart_descriptor!=0) { - std::cerr<<"[ERROR] fatal in CMap_linear_cell_complex_storage_2::init_storage" + std::cerr<<"[ERROR] fatal in CMap_linear_cell_complex_storage_with_index::init_storage" < - typename CMap_linear_cell_complex_storage_2:: - Dart_index CMap_linear_cell_complex_storage_2:: - null_dart_descriptor(0); - - /// null_descriptor - template - typename CMap_linear_cell_complex_storage_2:: - Null_descriptor_type CMap_linear_cell_complex_storage_2:: - null_descriptor((std::numeric_limits::max)()); - - template - typename CMap_linear_cell_complex_storage_2:: - Dart_index CMap_linear_cell_complex_storage_2:: - null_dart_handle(0); - - template - typename CMap_linear_cell_complex_storage_2:: - Null_descriptor_type CMap_linear_cell_complex_storage_2:: - null_handle((std::numeric_limits::max)()); - } // namespace CGAL #if defined(BOOST_GCC) diff --git a/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h b/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h index a791f7f6088..17c17d1b87b 100644 --- a/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h +++ b/Linear_cell_complex/include/CGAL/Cell_attribute_with_point.h @@ -69,25 +69,25 @@ namespace CGAL { friend class Combinatorial_map_storage_1; template - friend class Combinatorial_map_storage_2; + friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template - friend class Generalized_map_storage_2; + friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template - friend class CMap_linear_cell_complex_storage_2; + friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_2; + friend class GMap_linear_cell_complex_storage_with_index; public: typedef Cell_attribute_with_point - friend class Combinatorial_map_storage_2; + friend class Combinatorial_map_storage_with_index; template friend class Generalized_map_storage_1; template - friend class Generalized_map_storage_2; + friend class Generalized_map_storage_with_index; template friend class CMap_linear_cell_complex_storage_1; template - friend class CMap_linear_cell_complex_storage_2; + friend class CMap_linear_cell_complex_storage_with_index; template friend class GMap_linear_cell_complex_storage_1; template - friend class GMap_linear_cell_complex_storage_2; + friend class GMap_linear_cell_complex_storage_with_index; public: typedef Cell_attribute - class GMap_linear_cell_complex_storage_2 + class GMap_linear_cell_complex_storage_with_index { public: - using Self=GMap_linear_cell_complex_storage_2; using Use_index=CGAL::Tag_true; using Concurrent_tag=typename internal::Get_concurrent_tag::type; @@ -462,8 +462,8 @@ namespace CGAL { /// null_descriptor template - typename GMap_linear_cell_complex_storage_2:: - Null_descriptor_type GMap_linear_cell_complex_storage_2:: + Null_descriptor_type GMap_linear_cell_complex_storage_with_index:: null_descriptor((std::numeric_limits::max)()); 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 013fffeefa1..2a807a71b9c 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_fwd.h @@ -27,11 +27,11 @@ class GMap_linear_cell_complex_storage_1; template -class CMap_linear_cell_complex_storage_2; +class CMap_linear_cell_complex_storage_with_index; template -class GMap_linear_cell_complex_storage_2; +class GMap_linear_cell_complex_storage_with_index; template struct LCC_default_kernel; @@ -57,7 +57,7 @@ struct Default_storage_for_lcc_cmap_when_tag { template - using type=CMap_linear_cell_complex_storage_2; }; @@ -92,7 +92,7 @@ struct Default_storage_for_lcc_gmap_when_tag { template - using type=GMap_linear_cell_complex_storage_2; };