mirror of https://github.com/CGAL/cgal
Ok for gmap with index (and hash for indices)
This commit is contained in:
parent
b04d6ebc67
commit
a6da7bef70
|
|
@ -41,8 +41,8 @@ struct Default_storage_for_cmap_when_tag<CGAL::Tag_true>
|
|||
using type=Combinatorial_map_storage_2<d_, Items_, Alloc_>;
|
||||
};
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_use_index_tag,Use_index,false)
|
||||
template<typename T, bool typedefined=Has_use_index_tag<T>::value>
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_use_index_tag_cmap,Use_index,false)
|
||||
template<typename T, bool typedefined=Has_use_index_tag_cmap<T>::value>
|
||||
struct Default_storage_for_cmap
|
||||
{
|
||||
template<unsigned int d_, class Items_, class Alloc_>
|
||||
|
|
@ -52,23 +52,24 @@ template<typename T>
|
|||
struct Default_storage_for_cmap<T, true>
|
||||
{
|
||||
template<unsigned int d_, class Items_, class Alloc_>
|
||||
using type=typename Default_storage_for_cmap_when_tag<typename T::Use_index>::
|
||||
type<d_, Items_, Alloc_>;
|
||||
using type=typename CGAL::internal::template
|
||||
Default_storage_for_cmap_when_tag<typename T::Use_index>::
|
||||
template type<d_, Items_, Alloc_>;
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
template<unsigned int d_, class Refs_,
|
||||
class Items_=Generic_map_min_items,
|
||||
class Alloc_=CGAL_ALLOCATOR(int),
|
||||
class Storage_=typename internal::Default_storage_for_cmap<Items_>::
|
||||
type<d_, Items_, Alloc_>>
|
||||
class Storage_=typename internal::template
|
||||
Default_storage_for_cmap<Items_>::template type<d_, Items_, Alloc_>>
|
||||
class Combinatorial_map_base;
|
||||
|
||||
template<unsigned int d_,
|
||||
class Items_=Generic_map_min_items,
|
||||
class Alloc_=CGAL_ALLOCATOR(int),
|
||||
class Storage_=typename internal::Default_storage_for_cmap<Items_>::
|
||||
type<d_, Items_, Alloc_>>
|
||||
class Storage_=typename internal::template
|
||||
Default_storage_for_cmap<Items_>::template type<d_, Items_, Alloc_>>
|
||||
class Combinatorial_map;
|
||||
|
||||
} // CGAL
|
||||
|
|
|
|||
|
|
@ -71,6 +71,59 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template<class Index_type>
|
||||
class Index_for_cc_with_index
|
||||
{
|
||||
public:
|
||||
using Self=Index_for_cc_with_index<Index_type>;
|
||||
using size_type=Index_type;
|
||||
|
||||
/// Constructor. Default construction creates a kind of "NULL" index.
|
||||
/// max/2 because the most significant bit must be equal to 0 (used).
|
||||
Index_for_cc_with_index(size_type idx=(std::numeric_limits<size_type>::max)()/2)
|
||||
: m_idx(idx)
|
||||
{}
|
||||
|
||||
/// Get the underlying index
|
||||
operator size_t() const
|
||||
{ return m_idx; }
|
||||
|
||||
// Constructor allowing to transform an index from one container to another
|
||||
template<typename Index2>
|
||||
Index_for_cc_with_index(const Index2& idx): m_idx(static_cast<size_t>(idx))
|
||||
{}
|
||||
|
||||
/// return whether the handle is valid
|
||||
bool is_valid() const
|
||||
{ return m_idx != (std::numeric_limits<size_type>::max)()/2; }
|
||||
|
||||
/// Increment the internal index. This operations does not
|
||||
/// guarantee that the index is valid or undeleted after the
|
||||
/// increment.
|
||||
Self& operator++() { ++m_idx; return *this; }
|
||||
/// Decrement the internal index. This operations does not
|
||||
/// guarantee that the index is valid or undeleted after the
|
||||
/// decrement.
|
||||
Self& operator--() { --m_idx; return *this; }
|
||||
|
||||
/// Increment the internal index. This operations does not
|
||||
/// guarantee that the index is valid or undeleted after the
|
||||
/// increment.
|
||||
Self operator++(int) { Self tmp(*this); ++m_idx; return tmp; }
|
||||
/// Decrement the internal index. This operations does not
|
||||
/// guarantee that the index is valid or undeleted after the
|
||||
/// decrement.
|
||||
Self operator--(int) { Self tmp(*this); --m_idx; return tmp; }
|
||||
|
||||
size_type for_compact_container() const
|
||||
{ return m_idx; }
|
||||
void for_compact_container(size_type v)
|
||||
{ m_idx=v; }
|
||||
|
||||
private:
|
||||
size_type m_idx;
|
||||
};
|
||||
|
||||
namespace internal
|
||||
{
|
||||
struct Index_hash_function {
|
||||
|
|
@ -107,30 +160,7 @@ public:
|
|||
|
||||
static const size_type bottom;
|
||||
|
||||
class Index : public internal::MyIndex<T,size_type>
|
||||
{
|
||||
public:
|
||||
typedef typename Compact_container_with_index_2::size_type size_type;
|
||||
typedef internal::MyIndex<T,size_type> Base;
|
||||
|
||||
Index(size_type idx=(std::numeric_limits<size_type>::max)()/2)
|
||||
: Base(idx)
|
||||
{}
|
||||
|
||||
Index(const Index& idx): Base(idx)
|
||||
{}
|
||||
|
||||
Index(const const_iterator& it) : Base(it)
|
||||
{}
|
||||
|
||||
Index(const iterator& it) : Base(it)
|
||||
{}
|
||||
|
||||
// Constructor allowing to transform an index from one container to another
|
||||
template<typename Index2>
|
||||
Index(const Index2& idx): Base(static_cast<size_t>(idx))
|
||||
{}
|
||||
};
|
||||
using Index=Index_for_cc_with_index<IndexType>;
|
||||
friend class internal::CC_iterator_with_index<Self, false>;
|
||||
friend class internal::CC_iterator_with_index<Self, true>;
|
||||
|
||||
|
|
@ -573,4 +603,17 @@ void Compact_container_with_index_2<T, Allocator, Increment_policy, IndexType>::
|
|||
|
||||
} //namespace CGAL
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <class Index_type>
|
||||
struct hash<CGAL::Index_for_cc_with_index<Index_type>>:
|
||||
public CGAL::cpp98::unary_function<CGAL::Index_for_cc_with_index<Index_type>,
|
||||
std::size_t>
|
||||
{
|
||||
std::size_t operator()(const CGAL::Index_for_cc_with_index<Index_type>& idx) const
|
||||
{ return CGAL::internal::Index_hash_function()(idx); }
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // CGAL_COMPACT_CONTAINER_WITH_INDEX_2_H
|
||||
|
|
|
|||
|
|
@ -16,8 +16,18 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
struct Min_items: public CGAL::Generic_map_min_items
|
||||
{
|
||||
#ifdef USE_COMPACT_CONTAINER_WITH_INDEX
|
||||
typedef CGAL::Tag_true Use_index;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct Map_2_dart_items
|
||||
{
|
||||
#ifdef USE_COMPACT_CONTAINER_WITH_INDEX
|
||||
typedef CGAL::Tag_true Use_index;
|
||||
#endif
|
||||
/// Dart_wrapper defines the type of darts used.
|
||||
template < class Refs >
|
||||
struct Dart_wrapper
|
||||
|
|
@ -31,6 +41,9 @@ struct Map_2_dart_items
|
|||
|
||||
struct Map_2_dart_max_items_3
|
||||
{
|
||||
#ifdef USE_COMPACT_CONTAINER_WITH_INDEX
|
||||
typedef CGAL::Tag_true Use_index;
|
||||
#endif
|
||||
/// Dart_wrapper defines the type of darts used.
|
||||
template < class Refs >
|
||||
struct Dart_wrapper
|
||||
|
|
@ -46,6 +59,9 @@ struct Map_2_dart_max_items_3
|
|||
|
||||
struct Map_3_dart_items_3
|
||||
{
|
||||
#ifdef USE_COMPACT_CONTAINER_WITH_INDEX
|
||||
typedef CGAL::Tag_true Use_index;
|
||||
#endif
|
||||
/// Dart_wrapper defines the type of darts used.
|
||||
template < class Refs >
|
||||
struct Dart_wrapper
|
||||
|
|
@ -60,6 +76,9 @@ struct Map_3_dart_items_3
|
|||
|
||||
struct Map_3_dart_max_items_3
|
||||
{
|
||||
#ifdef USE_COMPACT_CONTAINER_WITH_INDEX
|
||||
typedef CGAL::Tag_true Use_index;
|
||||
#endif
|
||||
/// Dart_wrapper defines the type of darts used.
|
||||
template < class Refs >
|
||||
struct Dart_wrapper
|
||||
|
|
@ -87,9 +106,11 @@ struct MonInfo
|
|||
{ return mnb==info.mnb && s==info.s && ptr==info.ptr; }
|
||||
};
|
||||
|
||||
class Another_map_3_dart_items_3
|
||||
struct Another_map_3_dart_items_3
|
||||
{
|
||||
public:
|
||||
#ifdef USE_COMPACT_CONTAINER_WITH_INDEX
|
||||
typedef CGAL::Tag_true Use_index;
|
||||
#endif
|
||||
/// Dart_wrapper defines the type of darts used.
|
||||
template < class Refs >
|
||||
struct Dart_wrapper
|
||||
|
|
@ -104,6 +125,9 @@ public:
|
|||
|
||||
struct Map_dart_items_4
|
||||
{
|
||||
#ifdef USE_COMPACT_CONTAINER_WITH_INDEX
|
||||
typedef CGAL::Tag_true Use_index;
|
||||
#endif
|
||||
template < class Refs >
|
||||
struct Dart_wrapper
|
||||
{
|
||||
|
|
@ -118,6 +142,9 @@ struct Map_dart_items_4
|
|||
|
||||
struct Map_dart_max_items_4
|
||||
{
|
||||
#ifdef USE_COMPACT_CONTAINER_WITH_INDEX
|
||||
typedef CGAL::Tag_true Use_index;
|
||||
#endif
|
||||
template < class Refs >
|
||||
struct Dart_wrapper
|
||||
{
|
||||
|
|
@ -133,16 +160,16 @@ struct Map_dart_max_items_4
|
|||
};
|
||||
|
||||
// noinfo, void, void, void
|
||||
typedef CGAL::Combinatorial_map<2, CGAL::Generic_map_min_items > Map1;
|
||||
typedef CGAL::Combinatorial_map<2, Min_items> Map1;
|
||||
|
||||
// noinfo, double, void, double
|
||||
typedef CGAL::Combinatorial_map<2, Map_2_dart_items > Map2;
|
||||
typedef CGAL::Combinatorial_map<2, Map_2_dart_items> Map2;
|
||||
|
||||
// info=int, int, int, double
|
||||
typedef CGAL::Combinatorial_map<2, Map_2_dart_max_items_3> Map3;
|
||||
|
||||
// noinfo, void, void, void, void
|
||||
typedef CGAL::Combinatorial_map<3, CGAL::Generic_map_min_items > Map4;
|
||||
typedef CGAL::Combinatorial_map<3, Min_items> Map4;
|
||||
|
||||
// noinfo, double, void, int, double
|
||||
typedef CGAL::Combinatorial_map<3, Map_3_dart_items_3> Map5;
|
||||
|
|
|
|||
|
|
@ -200,8 +200,8 @@ namespace CGAL {
|
|||
typename Converters, typename DartInfoConverter,
|
||||
typename PointConverter>
|
||||
void generic_copy(GMap2& amap,
|
||||
std::unordered_map<Dart_handle_2, Dart_handle,Hash_function>* origin_to_copy,
|
||||
std::unordered_map<Dart_handle, Dart_handle_2,Hash_function>* copy_to_origin,
|
||||
std::unordered_map<Dart_handle_2, Dart_handle>* origin_to_copy,
|
||||
std::unordered_map<Dart_handle, Dart_handle_2>* copy_to_origin,
|
||||
const Converters& converters,
|
||||
const DartInfoConverter& dartinfoconverter,
|
||||
const PointConverter& pointconverter,
|
||||
|
|
@ -232,7 +232,7 @@ namespace CGAL {
|
|||
// Create an mapping between darts of the two maps (originals->copies).
|
||||
// (here we cannot use CGAL::Unique_hash_map because it does not provide
|
||||
// iterators...
|
||||
std::unordered_map<Dart_handle_2, Dart_handle,Hash_function> local_dartmap;
|
||||
std::unordered_map<Dart_handle_2, Dart_handle> local_dartmap;
|
||||
if (origin_to_copy==nullptr) // Use local_dartmap if user does not provides its own unordered_map
|
||||
{ origin_to_copy=&local_dartmap; }
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ namespace CGAL {
|
|||
|
||||
unsigned int min_dim=(dimension<amap.dimension?dimension:amap.dimension);
|
||||
|
||||
typename std::unordered_map<Dart_handle_2, Dart_handle, Hash_function>::iterator
|
||||
typename std::unordered_map<Dart_handle_2, Dart_handle>::iterator
|
||||
dartmap_iter, dartmap_iter_end=origin_to_copy->end();
|
||||
for (dartmap_iter=origin_to_copy->begin(); dartmap_iter!=dartmap_iter_end;
|
||||
++dartmap_iter)
|
||||
|
|
@ -306,9 +306,9 @@ namespace CGAL {
|
|||
typename PointConverter>
|
||||
void copy(GMap2& amap,
|
||||
std::unordered_map
|
||||
<typename GMap2::Dart_handle, Dart_handle, Hash_function>* origin_to_copy,
|
||||
<typename GMap2::Dart_handle, Dart_handle>* origin_to_copy,
|
||||
std::unordered_map
|
||||
<Dart_handle, typename GMap2::Dart_handle, Hash_function>* copy_to_origin,
|
||||
<Dart_handle, typename GMap2::Dart_handle>* copy_to_origin,
|
||||
const Converters& converters,
|
||||
const DartInfoConverter& dartinfoconverter,
|
||||
const PointConverter& pointconverter,
|
||||
|
|
@ -328,9 +328,9 @@ namespace CGAL {
|
|||
typename PointConverter>
|
||||
void copy_from_const(const GMap2& amap,
|
||||
std::unordered_map
|
||||
<typename GMap2::Dart_const_handle, Dart_handle, Hash_function>* origin_to_copy,
|
||||
<typename GMap2::Dart_const_handle, Dart_handle>* origin_to_copy,
|
||||
std::unordered_map
|
||||
<Dart_handle, typename GMap2::Dart_const_handle, Hash_function>* copy_to_origin,
|
||||
<Dart_handle, typename GMap2::Dart_const_handle>* copy_to_origin,
|
||||
const Converters& converters,
|
||||
const DartInfoConverter& dartinfoconverter,
|
||||
const PointConverter& pointconverter,
|
||||
|
|
@ -349,9 +349,9 @@ namespace CGAL {
|
|||
template<typename GMap2, typename Converters, typename DartInfoConverter>
|
||||
void copy(GMap2& amap,
|
||||
std::unordered_map
|
||||
<typename GMap2::Dart_handle, Dart_handle, Hash_function>* origin_to_copy,
|
||||
<typename GMap2::Dart_handle, Dart_handle>* origin_to_copy,
|
||||
std::unordered_map
|
||||
<Dart_handle, typename GMap2::Dart_handle, Hash_function>* copy_to_origin,
|
||||
<Dart_handle, typename GMap2::Dart_handle>* copy_to_origin,
|
||||
const Converters& converters,
|
||||
const DartInfoConverter& dartinfoconverter,
|
||||
bool copy_marks=true,
|
||||
|
|
@ -369,9 +369,9 @@ namespace CGAL {
|
|||
template <typename GMap2, typename Converters, typename DartInfoConverter>
|
||||
void copy_from_const(const GMap2& amap,
|
||||
std::unordered_map
|
||||
<typename GMap2::Dart_const_handle, Dart_handle, Hash_function>* origin_to_copy,
|
||||
<typename GMap2::Dart_const_handle, Dart_handle>* origin_to_copy,
|
||||
std::unordered_map
|
||||
<Dart_handle, typename GMap2::Dart_const_handle, Hash_function>* copy_to_origin,
|
||||
<Dart_handle, typename GMap2::Dart_const_handle>* copy_to_origin,
|
||||
const Converters& converters,
|
||||
const DartInfoConverter& dartinfoconverter,
|
||||
bool copy_marks=true,
|
||||
|
|
@ -389,9 +389,9 @@ namespace CGAL {
|
|||
template<typename GMap2, typename Converters>
|
||||
void copy(GMap2& amap,
|
||||
std::unordered_map
|
||||
<typename GMap2::Dart_handle, Dart_handle, Hash_function>* origin_to_copy,
|
||||
<typename GMap2::Dart_handle, Dart_handle>* origin_to_copy,
|
||||
std::unordered_map
|
||||
<Dart_handle, typename GMap2::Dart_handle, Hash_function>* copy_to_origin,
|
||||
<Dart_handle, typename GMap2::Dart_handle>* copy_to_origin,
|
||||
const Converters& converters,
|
||||
bool copy_marks=true,
|
||||
bool copy_perforated_darts=false,
|
||||
|
|
@ -406,9 +406,9 @@ namespace CGAL {
|
|||
template <typename GMap2, typename Converters>
|
||||
void copy_from_const(const GMap2& amap,
|
||||
std::unordered_map
|
||||
<typename GMap2::Dart_const_handle, Dart_handle, Hash_function>* origin_to_copy,
|
||||
<typename GMap2::Dart_const_handle, Dart_handle>* origin_to_copy,
|
||||
std::unordered_map
|
||||
<Dart_handle, typename GMap2::Dart_const_handle, Hash_function>* copy_to_origin,
|
||||
<Dart_handle, typename GMap2::Dart_const_handle>* copy_to_origin,
|
||||
const Converters& converters,
|
||||
bool copy_marks=true,
|
||||
bool copy_perforated_darts=false,
|
||||
|
|
@ -423,9 +423,9 @@ namespace CGAL {
|
|||
template<typename GMap2>
|
||||
void copy(GMap2& amap,
|
||||
std::unordered_map
|
||||
<typename GMap2::Dart_handle, Dart_handle, Hash_function>* origin_to_copy=nullptr,
|
||||
<typename GMap2::Dart_handle, Dart_handle>* origin_to_copy=nullptr,
|
||||
std::unordered_map
|
||||
<Dart_handle, typename GMap2::Dart_handle, Hash_function>* copy_to_origin=nullptr,
|
||||
<Dart_handle, typename GMap2::Dart_handle>* copy_to_origin=nullptr,
|
||||
bool copy_marks=true,
|
||||
bool copy_perforated_darts=false,
|
||||
size_type mark_perforated=INVALID_MARK)
|
||||
|
|
@ -439,9 +439,9 @@ namespace CGAL {
|
|||
template <typename GMap2>
|
||||
void copy_from_const(const GMap2& amap,
|
||||
std::unordered_map
|
||||
<typename GMap2::Dart_const_handle, Dart_handle, Hash_function>* origin_to_copy=nullptr,
|
||||
<typename GMap2::Dart_const_handle, Dart_handle>* origin_to_copy=nullptr,
|
||||
std::unordered_map
|
||||
<Dart_handle, typename GMap2::Dart_const_handle, Hash_function>* copy_to_origin=nullptr,
|
||||
<Dart_handle, typename GMap2::Dart_const_handle>* copy_to_origin=nullptr,
|
||||
bool copy_marks=true,
|
||||
bool copy_perforated_darts=false,
|
||||
size_type mark_perforated=INVALID_MARK)
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ struct Default_storage_for_gmap_when_tag<CGAL::Tag_true>
|
|||
using type=Generalized_map_storage_2<d_, Items_, Alloc_>;
|
||||
};
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_use_index_tag,Use_index,false)
|
||||
template<typename T, bool typedefined=Has_use_index_tag<T>::value>
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_use_index_tag_gmap,Use_index,false)
|
||||
template<typename T, bool typedefined=Has_use_index_tag_gmap<T>::value>
|
||||
struct Default_storage_for_gmap
|
||||
{
|
||||
template<unsigned int d_, class Items_, class Alloc_>
|
||||
|
|
@ -52,23 +52,24 @@ template<typename T>
|
|||
struct Default_storage_for_gmap<T, true>
|
||||
{
|
||||
template<unsigned int d_, class Items_, class Alloc_>
|
||||
using type=typename Default_storage_for_gmap_when_tag<typename T::Use_index>::
|
||||
type<d_, Items_, Alloc_>;
|
||||
using type=typename CGAL::internal::template
|
||||
Default_storage_for_gmap_when_tag<typename T::Use_index>::
|
||||
template type<d_, Items_, Alloc_>;
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
template<unsigned int d_, class Refs_,
|
||||
class Items_=Generic_map_min_items,
|
||||
class Alloc_=CGAL_ALLOCATOR(int),
|
||||
class Storage_=typename internal::Default_storage_for_gmap<Items_>::
|
||||
type<d_, Items_, Alloc_>>
|
||||
class Storage_=typename internal::template
|
||||
Default_storage_for_gmap<Items_>::template type<d_, Items_, Alloc_>>
|
||||
class Generalized_map_base;
|
||||
|
||||
template <unsigned int d_,
|
||||
class Items_=Generic_map_min_items,
|
||||
class Alloc_=CGAL_ALLOCATOR(int),
|
||||
class Storage_=typename internal::Default_storage_for_gmap<Items_>::
|
||||
type<d_, Items_, Alloc_>>
|
||||
class Storage_=typename internal::template
|
||||
Default_storage_for_gmap<Items_>::template type<d_, Items_, Alloc_>>
|
||||
class Generalized_map;
|
||||
|
||||
} // CGAL
|
||||
|
|
|
|||
Loading…
Reference in New Issue