Start to integrate the index class into the compact container with index.

This commit is contained in:
Guillaume Damiand 2014-10-03 17:35:26 +02:00
parent 8cd88542de
commit 7efb4bdbda
8 changed files with 155 additions and 240 deletions

View File

@ -389,7 +389,7 @@ namespace CGAL {
template < unsigned int, typename> template < unsigned int, typename>
friend struct GMap_dart; friend struct GMap_dart;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
template<typename, unsigned int, typename> template<typename, unsigned int, typename>
@ -498,7 +498,7 @@ namespace CGAL {
template <unsigned int, typename> template <unsigned int, typename>
friend struct GMap_dart; friend struct GMap_dart;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
template<typename, unsigned int, typename> template<typename, unsigned int, typename>
@ -610,7 +610,7 @@ namespace CGAL {
template < unsigned int, class, class, class, class > template < unsigned int, class, class, class, class >
friend class Combinatorial_map_base; friend class Combinatorial_map_base;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
public: public:
@ -639,7 +639,7 @@ namespace CGAL {
template < unsigned int, class, class, class, class > template < unsigned int, class, class, class, class >
friend class Combinatorial_map_base; friend class Combinatorial_map_base;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
public: public:

View File

@ -403,26 +403,6 @@ namespace CGAL {
// Thus we initialize null_dart_handle in the Combinatorial_map constructor // Thus we initialize null_dart_handle in the Combinatorial_map constructor
#endif // CGAL_CMAP_DEPRECATED #endif // CGAL_CMAP_DEPRECATED
template<typename T>
class MyIndex
{
public:
MyIndex(size_t s=-1) : idx(s)
{}
operator size_t() const
{ return idx; }
MyIndex<T>& operator++()
{ ++idx; return *this; }
MyIndex<T> operator++(int)
{ MyIndex<T> res(*this); ++idx; return res; }
MyIndex<T>& operator--()
{ --idx; return *this; }
MyIndex<T> operator--(int)
{MyIndex<T> res(*this); --idx; return res;}
private:
T idx;
};
// Storage with combinatorial maps using index // Storage with combinatorial maps using index
template<unsigned int d_, class Items_, class Alloc_> template<unsigned int d_, class Items_, class Alloc_>
class Combinatorial_map_storage_2 class Combinatorial_map_storage_2
@ -436,12 +416,13 @@ private:
typedef typename Dart_wrapper::Dart Dart; typedef typename Dart_wrapper::Dart Dart;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator; typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef unsigned int size_type; // Type used as index.
typedef Compact_container_with_index_2<Dart,Dart_allocator, typedef Compact_container_with_index_2<Dart,Dart_allocator,
Constant_size_policy_for_cc_with_size<1024> > Constant_size_policy_for_cc_with_size<1024>, size_type >
Dart_container; Dart_container;
typedef CGAL::Tag_true Use_index; typedef CGAL::Tag_true Use_index;
typedef typename Dart_container::size_type size_type;
typedef Items_ Items; typedef Items_ Items;
typedef Alloc_ Alloc; typedef Alloc_ Alloc;
@ -450,7 +431,7 @@ private:
struct Container_for_attributes : public struct Container_for_attributes : public
Compact_container_with_index_2<T, Compact_container_with_index_2<T,
typename Alloc_::template rebind<T>::other, typename Alloc_::template rebind<T>::other,
Constant_size_policy_for_cc_with_size<1024> > Constant_size_policy_for_cc_with_size<1024>, size_type >
{}; {};
/// Typedef for attributes /// Typedef for attributes
@ -460,23 +441,18 @@ private:
struct Attribute_type: public Helper::template Attribute_type<i> struct Attribute_type: public Helper::template Attribute_type<i>
{}; {};
template<int i> template<int i>
struct Attribute_handle: public CGAL::MyIndex<unsigned int> // public Helper::template Attribute_handle<i> struct Attribute_handle: public Helper::template Attribute_handle<i>
{ {};
explicit Attribute_handle(size_t s=-1) : MyIndex<unsigned int>(s)
{}
};
template<int i> template<int i>
struct Attribute_const_handle:public CGAL::MyIndex<unsigned int>//Helper::template Attribute_const_handle<i> struct Attribute_const_handle:
{ public Helper::template Attribute_const_handle<i>
explicit Attribute_const_handle(size_t s=-1) : MyIndex<unsigned int>(s) {};
{}
};
template<int i> template<int i>
struct Attribute_range: public Helper::template Attribute_range<i> struct Attribute_range: public Helper::template Attribute_range<i>
{}; {};
template<int i> template<int i>
struct Attribute_const_range: struct Attribute_const_range:
public Helper::template Attribute_const_range<i> public Helper::template Attribute_const_range<i>
{}; {};
/// Number of marks /// Number of marks
@ -487,11 +463,7 @@ private:
// typedef unsigned int Dart_index; // typedef unsigned int Dart_index;
// typedef MyIndex<unsigned int> Dart_index; // typedef MyIndex<unsigned int> Dart_index;
struct Dart_index : public CGAL::MyIndex<unsigned int> typedef typename Dart_container::Index Dart_index;
{
explicit Dart_index(size_t s=-1) : MyIndex<unsigned int>(s)
{}
};
// Definition of old types, for backward compatibility. // Definition of old types, for backward compatibility.
typedef Dart_index Dart_handle; typedef Dart_index Dart_handle;

View File

@ -135,34 +135,21 @@ public:
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
static const size_type bottom; static const size_type bottom;
class handle : public internal::Handle<T,size_type> class Index : public internal::MyIndex<T,size_type>
{ {
public: public:
typedef typename Compact_container_with_index::size_type size_type; typedef typename Compact_container_with_index::size_type size_type;
typedef internal::MyIndex<T,size_type> Base;
explicit handle(size_type _idx= (std::numeric_limits<size_type>::max)()/2) explicit Index(size_type idx=(std::numeric_limits<size_type>::max)()/2)
: Handle<T,size_type>(_idx) : Base(idx)
{} {}
handle(const_iterator it) Index(const const_iterator& it) : Base(it)
: Handle<T,size_type>(it)
{} {}
handle(iterator it) Index(const iterator& it) : Base(it)
: Handle<T,size_type>(it)
{} {}
bool operator==(const handle& rhs) const
{
return idx() == rhs.idx();
}
bool operator<(const handle& rhs) const
{
return idx() < rhs.idx();
}
}; };
friend class internal::CC_iterator_with_index<Self, false>; friend class internal::CC_iterator_with_index<Self, false>;
@ -640,13 +627,10 @@ private:
// Sets the pointer part and the type of the pointee. // Sets the pointer part and the type of the pointee.
static void static_set_type(T& e, Type t) static void static_set_type(T& e, Type t)
{ {
// This out of range compare is always true and causes lots of
// unnecessary warnings.
// CGAL_precondition(0 <= t && t < 2);
Traits::size_t(e) &= ( ~mask_type | ( ((size_type)t) <<(nbbits_size_type_m1) ) ); Traits::size_t(e) &= ( ~mask_type | ( ((size_type)t) <<(nbbits_size_type_m1) ) );
} }
// get the value of the element (removing the two bits) // get the value of the element (removing the used bit)
static size_type static_get_val(const T& e) static size_type static_get_val(const T& e)
{ return (Traits::size_t(e) & ~mask_type); } { return (Traits::size_t(e) & ~mask_type); }
@ -680,7 +664,7 @@ private:
block_size = Incr_policy::first_block_size; block_size = Incr_policy::first_block_size;
capacity_ = 0; capacity_ = 0;
size_ = 0; size_ = 0;
free_list = bottom; free_list = bottom;
all_items = All_items(); all_items = All_items();
} }
@ -692,7 +676,7 @@ private:
All_items all_items; All_items all_items;
}; };
template < class T, class Allocator, class Increment_policy, class IndexType > template < class T, class Allocator, class Increment_policy, class IndexType >
const typename Compact_container_with_index<T, Allocator, Increment_policy, IndexType>::size_type Compact_container_with_index<T, Allocator, Increment_policy, IndexType>::bottom = (std::numeric_limits<typename Compact_container_with_index<T, Allocator, Increment_policy, IndexType>::size_type>::max)()/2 -1; const typename Compact_container_with_index<T, Allocator, Increment_policy, IndexType>::size_type Compact_container_with_index<T, Allocator, Increment_policy, IndexType>::bottom = (std::numeric_limits<typename Compact_container_with_index<T, Allocator, Increment_policy, IndexType>::size_type>::max)()/2;
/*template < class T, class Allocator, class Increment_policy > /*template < class T, class Allocator, class Increment_policy >
void Compact_container_with_index<T, Allocator, Increment_policy>::merge(Self &d) void Compact_container_with_index<T, Allocator, Increment_policy>::merge(Self &d)
@ -952,77 +936,67 @@ namespace internal {
}*/ }*/
template<typename T, typename IT > template<typename T, typename IT >
class Handle class MyIndex
{ {
public: public:
typedef MyIndex<T,IT> Self;
typedef IT size_type;
typedef IT size_type; /// Constructor. Default construction creates a kind of "NULL" index.
/// max/2 because the most significant bit must be equal to 0 (used).
explicit MyIndex(size_type idx=(std::numeric_limits<size_type>::max)()/2)
: m_idx(idx)
{}
/// Constructor. Default construction creates an invalid handle. /// Get the underlying index
explicit Handle(size_type _idx= (std::numeric_limits<size_type>::max)()/2) : idx_(_idx) {} operator size_t() const
{ return m_idx; }
/// Get the underlying index of this handle /// reset index to be NULL
size_type idx() const { return idx_; } void reset()
{ m_idx = (std::numeric_limits<size_type>::max)()/2; }
size_type& idx() { return idx_; } /// return whether the handle is valid
bool is_valid() const
{ return m_idx != (std::numeric_limits<size_type>::max)()/2; }
/// reset handle to be invalid /// are two indices equal?
void reset() { idx_= (std::numeric_limits<size_type>::max)()/2; } bool operator==(const Self& rhs) const
{ return m_idx == rhs.m_idx; }
/// return whether the handle is valid /// are two handles different?
bool is_valid() const { return idx_ != (std::numeric_limits<size_type>::max)()/2; } bool operator!=(const Self& rhs) const
{ return m_idx != rhs.m_idx; }
/// are two handles equal? /// Comparisons
bool operator==(const T& _rhs) const { bool operator<(const Self& rhs) const
return idx_ == _rhs.idx_; { return m_idx < rhs.m_idx; }
} bool operator>(const Self& rhs) const
{ return m_idx > rhs.m_idx; }
bool operator<=(const Self& rhs) const
{ return m_idx <= rhs.m_idx; }
bool operator>=(const Self& rhs) const
{ return m_idx >= rhs.m_idx; }
/// are two handles different? /// Increment the internal index. This operations does not
bool operator!=(const Handle<T,IT>& _rhs) const { /// guarantee that the index is valid or undeleted after the
return idx_ != _rhs.idx_; /// 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; }
/// Comparison by index. /// Increment the internal index. This operations does not
bool operator<(const Handle<T,IT>& _rhs) const { /// guarantee that the index is valid or undeleted after the
return idx_ < _rhs.idx_; /// increment.
} Self operator++(int) { Self tmp(*this); ++m_idx; return tmp; }
/// Decrement the internal index. This operations does not
/// Increment the internal index. This operations does not /// guarantee that the index is valid or undeleted after the
/// guarantee that the index is valid or undeleted after the /// decrement.
/// increment. Self operator--(int) { Self tmp(*this); --m_idx; return tmp; }
Handle& operator++() { ++idx_; return *this; } private:
/// Decrement the internal index. This operations does not size_type m_idx;
/// guarantee that the index is valid or undeleted after the
/// decrement.
Handle& operator--() { --idx_; return *this; }
/// Increment the internal index. This operations does not
/// guarantee that the index is valid or undeleted after the
/// increment.
Handle operator++(int) { Handle tmp(*this); ++idx_; return tmp; }
/// Decrement the internal index. This operations does not
/// guarantee that the index is valid or undeleted after the
/// decrement.
Handle operator--(int) { Handle tmp(*this); --idx_; return tmp; }
private:
size_type idx_;
};
template<typename T, typename IT1, typename IT2 >
class Handle2 : public Handle<T,IT2>
{
typedef Handle<T,IT2> Base;
public:
/// Constructor. Default construction creates an invalid handle.
explicit Handle2(size_type _cc_idx, size_type _idx = (std::numeric_limits<size_type>::max)()/2)
: Base(_idx), cc_idx_(_cc_idx) {}
size_type cc_idx() const { return cc_idx_; }
size_type& cc_idx() { return cc_idx_; }
public:
size_type cc_idx_;
}; };
} // namespace internal } // namespace internal

View File

@ -95,34 +95,21 @@ public:
static const size_type bottom; static const size_type bottom;
class handle : public internal::Handle<T,size_type> class Index : public internal::MyIndex<T,size_type>
{ {
public: public:
typedef typename Compact_container_with_index_2::size_type size_type; typedef typename Compact_container_with_index_2::size_type size_type;
typedef internal::MyIndex<T,size_type> Base;
explicit handle(size_type _idx= (std::numeric_limits<size_type>::max)()/2) explicit Index(size_type idx=(std::numeric_limits<size_type>::max)()/2)
: Handle<T,size_type>(_idx) : Base(idx)
{} {}
handle(const_iterator it) Index(const const_iterator& it) : Base(it)
: Handle<T,size_type>(it)
{} {}
handle(iterator it) Index(const iterator& it) : Base(it)
: Handle<T,size_type>(it)
{} {}
bool operator==(const handle& rhs) const
{
return idx() == rhs.idx();
}
bool operator<(const handle& rhs) const
{
return idx() < rhs.idx();
}
}; };
friend class internal::CC_iterator_with_index<Self, false>; friend class internal::CC_iterator_with_index<Self, false>;
friend class internal::CC_iterator_with_index<Self, true>; friend class internal::CC_iterator_with_index<Self, true>;
@ -240,12 +227,12 @@ public:
// (just forward the arguments to the constructor, to optimize a copy). // (just forward the arguments to the constructor, to optimize a copy).
#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
template < typename... Args > template < typename... Args >
size_type emplace(const Args&... args) Index emplace(const Args&... args)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret = free_list;
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -255,12 +242,12 @@ public:
} }
#else #else
// inserts a default constructed item. // inserts a default constructed item.
size_type emplace() Index emplace()
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -271,13 +258,12 @@ public:
} }
template < typename T1 > template < typename T1 >
size_type Index emplace(const T1 &t1)
emplace(const T1 &t1)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -287,13 +273,12 @@ public:
} }
template < typename T1, typename T2 > template < typename T1, typename T2 >
size_type Index emplace(const T1 &t1, const T2 &t2)
emplace(const T1 &t1, const T2 &t2)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -303,13 +288,12 @@ public:
} }
template < typename T1, typename T2, typename T3 > template < typename T1, typename T2, typename T3 >
size_type Index emplace(const T1 &t1, const T2 &t2, const T3 &t3)
emplace(const T1 &t1, const T2 &t2, const T3 &t3)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -319,13 +303,12 @@ public:
} }
template < typename T1, typename T2, typename T3, typename T4 > template < typename T1, typename T2, typename T3, typename T4 >
size_type Index emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -335,14 +318,13 @@ public:
} }
template < typename T1, typename T2, typename T3, typename T4, typename T5 > template < typename T1, typename T2, typename T3, typename T4, typename T5 >
size_type Index emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4,
emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5)
const T5 &t5)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -353,14 +335,13 @@ public:
template < typename T1, typename T2, typename T3, typename T4, template < typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6 > typename T5, typename T6 >
size_type Index emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4,
emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6)
const T5 &t5, const T6 &t6)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -371,14 +352,13 @@ public:
template < typename T1, typename T2, typename T3, typename T4, template < typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7 > typename T5, typename T6, typename T7 >
size_type Index emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4,
emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7)
const T5 &t5, const T6 &t6, const T7 &t7)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -389,14 +369,13 @@ public:
template < typename T1, typename T2, typename T3, typename T4, template < typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8 > typename T5, typename T6, typename T7, typename T8 >
size_type Index emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4,
emplace(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7, const T8 &t8)
const T5 &t5, const T6 &t6, const T7 &t7, const T8 &t8)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -406,12 +385,12 @@ public:
} }
#endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES #endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
size_type insert(const T &t) Index insert(const T &t)
{ {
if (free_list == bottom) if (free_list == bottom)
allocate_new_block(); allocate_new_block();
size_type ret = free_list; Index ret(free_list);
T& e = operator[](free_list); T& e = operator[](free_list);
static_set_type(e, USED); static_set_type(e, USED);
free_list = static_get_val(e); free_list = static_get_val(e);
@ -434,7 +413,7 @@ public:
insert(first, last); insert(first, last);
} }
void erase(size_type x) void erase(Index x)
{ {
CGAL_precondition(type(x) == USED); CGAL_precondition(type(x) == USED);
T& e = operator[](x); T& e = operator[](x);
@ -563,7 +542,7 @@ private:
// Get the type of the pointee. // Get the type of the pointee.
static Type static_type(const T& e) static Type static_type(const T& e)
// TODO check if this is ok for little and big endian // TODO check if this is ok for little and big endian
{ return (Type) ((Traits::size_t(e) & mask_type)>>(nbbits_size_type_m1)); } { return (Type) ((size_type(e) & mask_type)>>(nbbits_size_type_m1)); }
Type type(size_type e) const Type type(size_type e) const
{ return static_type(operator[](e)); } { return static_type(operator[](e)); }
@ -574,19 +553,19 @@ private:
// This out of range compare is always true and causes lots of // This out of range compare is always true and causes lots of
// unnecessary warnings. // unnecessary warnings.
// CGAL_precondition(0 <= t && t < 2); // CGAL_precondition(0 <= t && t < 2);
Traits::size_t(e) &= ( ~mask_type | ( ((size_type)t) <<(nbbits_size_type_m1) ) ); size_type(e) &= ( ~mask_type | ( ((size_type)t) <<(nbbits_size_type_m1) ) );
} }
// get the value of the element (removing the two bits) // get the value of the element (removing the two bits)
static size_type static_get_val(const T& e) static size_type static_get_val(const T& e)
{ return (Traits::size_t(e) & ~mask_type); } { return (size_type(e) & ~mask_type); }
size_type get_val(size_type e) const size_type get_val(size_type e) const
{ return static_get_val(operator[](e)); } { return static_get_val(operator[](e)); }
// set the value of the element and its type // set the value of the element and its type
static void static_set_val(T& e, size_type v, Type t) static void static_set_val(T& e, size_type v, Type t)
{ Traits::size_t(e)=v | ( ((size_type)t) <<(nbbits_size_type_m1)); } { size_type(e)=v | ( ((size_type)t) <<(nbbits_size_type_m1)); }
void set_val(size_type e, size_type v, Type t) void set_val(size_type e, size_type v, Type t)
{ static_set_val(operator[](e), v, t); } { static_set_val(operator[](e), v, t); }
@ -616,7 +595,7 @@ private:
template < class T, class Allocator, class Increment_policy, class IndexType > template < class T, class Allocator, class Increment_policy, class IndexType >
const typename Compact_container_with_index_2<T, Allocator, Increment_policy, IndexType>::size_type const typename Compact_container_with_index_2<T, Allocator, Increment_policy, IndexType>::size_type
Compact_container_with_index_2<T, Allocator, Increment_policy, IndexType>::bottom = (std::numeric_limits<typename Compact_container_with_index_2<T, Allocator, Increment_policy, IndexType>::size_type>::max)()/2 -1; Compact_container_with_index_2<T, Allocator, Increment_policy, IndexType>::bottom = (std::numeric_limits<typename Compact_container_with_index_2<T, Allocator, Increment_policy, IndexType>::size_type>::max)()/2;
/*template < class T, class Allocator, class Increment_policy, class IndexType > /*template < class T, class Allocator, class Increment_policy, class IndexType >
void Compact_container_with_index<T, Allocator, Increment_policy, IndexType>::merge(Self &d) void Compact_container_with_index<T, Allocator, Increment_policy, IndexType>::merge(Self &d)

View File

@ -68,10 +68,10 @@ namespace CGAL {
template <class, class, class, class> template <class, class, class, class>
friend class Compact_container; friend class Compact_container;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index_2; friend class Compact_container_with_index_2;
template<class, unsigned int, unsigned int> template<class, unsigned int, unsigned int>
@ -365,10 +365,10 @@ namespace CGAL {
template <class, class, class, class> template <class, class, class, class>
friend class Compact_container; friend class Compact_container;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index_2; friend class Compact_container_with_index_2;
template<class, unsigned int, unsigned int> template<class, unsigned int, unsigned int>
@ -538,17 +538,13 @@ namespace CGAL {
public: public:
size_type for_compact_container_with_index() const size_type for_compact_container_with_index() const
{ return st; } { return mbeta[0]; }
size_type& for_compact_container_with_index() size_type& for_compact_container_with_index()
{ return st; } { return mbeta[0]; }
protected: protected:
union /// Beta for each dimension +1 (from 0 to dimension).
{ Dart_handle mbeta[dimension+1];
size_type st;
/// Beta for each dimension +1 (from 0 to dimension).
Dart_handle mbeta[dimension+1];
};
/// Values of Boolean marks. /// Values of Boolean marks.
mutable std::bitset<NB_MARKS> mmarks; mutable std::bitset<NB_MARKS> mmarks;

View File

@ -393,17 +393,27 @@ namespace CGAL
typedef typename CMap::template Container_for_attributes<T> type; typedef typename CMap::template Container_for_attributes<T> type;
}; };
template<typename T, typename WithIndex=typename CMap::Use_index>
struct GetIndexOrHandle
{ typedef typename T::iterator type; };
template<typename T>
struct GetIndexOrHandle<T, Tag_true>
{ typedef typename T::Index type; };
template<typename T, typename WithIndex=typename CMap::Use_index>
struct GetConstIndexOrConstHandle
{ typedef typename T::const_iterator type; };
template<typename T>
struct GetConstIndexOrConstHandle<T, Tag_true>
{ typedef typename T::Index type; };
// defines as type Compact_container<T>::iterator // defines as type Compact_container<T>::iterator
template <class T> template <class T>
struct Add_compact_container_iterator{ struct Add_compact_container_iterator{
typedef typename CMap::Alloc::template rebind<T>::other Attr_allocator; typedef typename CMap::Alloc::template rebind<T>::other Attr_allocator;
typedef typename CMap::template Container_for_attributes<T>::iterator typedef typename CMap::template Container_for_attributes<T>::iterator
iterator_type; iterator_type;
typedef typename GetIndexOrHandle
// TODO case when there is no Use_index typedef in CMap <typename CMap::template Container_for_attributes<T> >::type type;
typedef typename boost::mpl::if_
< typename boost::is_same<typename CMap::Use_index,Tag_true>::type,
typename CMap::Dart_handle, iterator_type >::type type;
}; };
// defines as type Compact_container<T>::const_iterator // defines as type Compact_container<T>::const_iterator
@ -412,10 +422,8 @@ namespace CGAL
typedef typename CMap::Alloc::template rebind<T>::other Attr_allocator; typedef typename CMap::Alloc::template rebind<T>::other Attr_allocator;
typedef typename CMap::template Container_for_attributes<T>:: typedef typename CMap::template Container_for_attributes<T>::
const_iterator iterator_type; const_iterator iterator_type;
typedef typename GetConstIndexOrConstHandle
typedef typename boost::mpl::if_ <typename CMap::template Container_for_attributes<T> >::type type;
< typename boost::is_same<typename CMap::Use_index,Tag_true>::type,
typename CMap::Dart_handle, iterator_type >::type type;
}; };
// All the attributes (with CGAL::Void) // All the attributes (with CGAL::Void)

View File

@ -69,7 +69,7 @@ namespace CGAL {
template <class, class, class, class> template <class, class, class, class>
friend class Compact_container; friend class Compact_container;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
template <class, class, class> template <class, class, class>
@ -130,11 +130,11 @@ namespace CGAL {
template <class, class, class, class> template <class, class, class, class>
friend class Compact_container; friend class Compact_container;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_2; friend class Compact_container_with_index_2;
public: public:
typedef Cell_attribute<LCC, void, Tag, typedef Cell_attribute<LCC, void, Tag,
@ -182,7 +182,7 @@ namespace CGAL {
template < unsigned int, class, class, class, class > template < unsigned int, class, class, class, class >
friend class Combinatorial_map_base; friend class Combinatorial_map_base;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
public: public:
@ -238,7 +238,7 @@ namespace CGAL {
template < unsigned int, class, class, class, class > template < unsigned int, class, class, class, class >
friend class Combinatorial_map_base; friend class Combinatorial_map_base;
template <class, class, class> template <class, class, class, class>
friend class Compact_container_with_index; friend class Compact_container_with_index;
public: public:

View File

@ -449,12 +449,13 @@ namespace CGAL {
typedef typename Dart_wrapper::Dart Dart; typedef typename Dart_wrapper::Dart Dart;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator; typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef unsigned int size_type; // Type used as index.
typedef Compact_container_with_index_2<Dart,Dart_allocator, typedef Compact_container_with_index_2<Dart,Dart_allocator,
Constant_size_policy_for_cc_with_size<1024> > Constant_size_policy_for_cc_with_size<1024>, size_type >
Dart_container; Dart_container;
typedef CGAL::Tag_true Use_index; typedef CGAL::Tag_true Use_index;
typedef typename Dart_container::size_type size_type;
typedef Items_ Items; typedef Items_ Items;
typedef Alloc_ Alloc; typedef Alloc_ Alloc;
@ -463,7 +464,7 @@ namespace CGAL {
struct Container_for_attributes : public struct Container_for_attributes : public
Compact_container_with_index_2<T, Compact_container_with_index_2<T,
typename Alloc_::template rebind<T>::other, typename Alloc_::template rebind<T>::other,
Constant_size_policy_for_cc_with_size<1024> > Constant_size_policy_for_cc_with_size<1024>, size_type >
{}; {};
/// Typedef for attributes /// Typedef for attributes
@ -473,23 +474,12 @@ namespace CGAL {
struct Attribute_type: public Helper::template Attribute_type<i> struct Attribute_type: public Helper::template Attribute_type<i>
{}; {};
template<int i> template<int i>
struct MyAttribute_handle: public CGAL::MyIndex<unsigned int> // public Helper::template Attribute_handle<i> struct Attribute_handle: public Helper::template Attribute_handle<i>
{ {};
MyAttribute_handle(size_t s=-1) : MyIndex<unsigned int>(s)
{}
};
template<int i> template<int i>
struct Attribute_handle struct Attribute_const_handle:
{typedef MyAttribute_handle<i> type;}; public Helper::template Attribute_const_handle<i>
template<int i> {};
struct MyAttribute_const_handle:public CGAL::MyIndex<unsigned int>//Helper::template Attribute_const_handle<i>
{
MyAttribute_const_handle(size_t s=-1) : MyIndex<unsigned int>(s)
{}
};
template<int i>
struct Attribute_const_handle
{typedef MyAttribute_const_handle<i> type;};
template<int i> template<int i>
struct Attribute_range: public Helper::template Attribute_range<i> struct Attribute_range: public Helper::template Attribute_range<i>
{}; {};
@ -505,11 +495,7 @@ namespace CGAL {
static const unsigned int dimension = d_; static const unsigned int dimension = d_;
// typedef unsigned int Dart_index; // typedef unsigned int Dart_index;
struct Dart_index : public CGAL::MyIndex<unsigned int> typedef typename Dart_container::Index Dart_index;
{
Dart_index(size_t s=-1) : MyIndex<unsigned int>(s)
{}
};
// Definition of old types, for backward compatibility. // Definition of old types, for backward compatibility.
typedef Dart_index Dart_handle; typedef Dart_index Dart_handle;