mirror of https://github.com/CGAL/cgal
add hash function for CGAL vector container
This commit is contained in:
parent
622e724e87
commit
697e1abbc9
|
|
@ -27,7 +27,6 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <CGAL/memory.h>
|
#include <CGAL/memory.h>
|
||||||
#include <boost/functional/hash.hpp>
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
@ -175,7 +174,6 @@ namespace internal {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Alloc>
|
template <class T, class Alloc>
|
||||||
std::size_t hash_value(const In_place_list_iterator<T,Alloc>& i)
|
std::size_t hash_value(const In_place_list_iterator<T,Alloc>& i)
|
||||||
{
|
{
|
||||||
|
|
@ -189,7 +187,7 @@ template <class T, class Alloc>
|
||||||
{
|
{
|
||||||
const T* ptr = i.operator->();
|
const T* ptr = i.operator->();
|
||||||
return reinterpret_cast<std::size_t>(ptr)/ sizeof(T);
|
return reinterpret_cast<std::size_t>(ptr)/ sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -792,8 +790,7 @@ namespace std {
|
||||||
|
|
||||||
std::size_t operator()(const CGAL::internal::In_place_list_iterator<T, Alloc>& i) const
|
std::size_t operator()(const CGAL::internal::In_place_list_iterator<T, Alloc>& i) const
|
||||||
{
|
{
|
||||||
const T* ptr = i.operator->();
|
return CGAL::internal::hash_value(i);
|
||||||
return reinterpret_cast<std::size_t>(ptr)/ sizeof(T);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -803,8 +800,7 @@ namespace std {
|
||||||
|
|
||||||
std::size_t operator()(const CGAL::internal::In_place_list_const_iterator<T, Alloc>& i) const
|
std::size_t operator()(const CGAL::internal::In_place_list_const_iterator<T, Alloc>& i) const
|
||||||
{
|
{
|
||||||
const T* ptr =i.operator->();
|
return CGAL::internal::hash_value(i);
|
||||||
return reinterpret_cast<std::size_t>(ptr)/ sizeof(T);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif // CGAL_CFG_NO_STD_HASH
|
#endif // CGAL_CFG_NO_STD_HASH
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <functional>
|
||||||
#include <boost/type_traits/remove_const.hpp>
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
#include <boost/type_traits/remove_pointer.hpp>
|
#include <boost/type_traits/remove_pointer.hpp>
|
||||||
|
|
@ -135,6 +136,13 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template < class T, class Ref, class Ptr>
|
||||||
|
std::size_t hash_value(const vector_iterator<T, Ref, Ptr>& i)
|
||||||
|
{
|
||||||
|
Ptr ptr = i.operator->();
|
||||||
|
return reinterpret_cast<std::size_t>(ptr)/ sizeof(T);
|
||||||
|
}
|
||||||
|
|
||||||
template < class T, class Ref, class Ptr> inline
|
template < class T, class Ref, class Ptr> inline
|
||||||
vector_iterator<T,Ref,Ptr>
|
vector_iterator<T,Ref,Ptr>
|
||||||
operator+( std::ptrdiff_t n, vector_iterator<T,Ref,Ptr> i) {
|
operator+( std::ptrdiff_t n, vector_iterator<T,Ref,Ptr> i) {
|
||||||
|
|
@ -609,4 +617,31 @@ void vector<T, Alloc>::insert( iterator position, size_type n, const T& x) {
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
# pragma warning(push)
|
||||||
|
# pragma warning(disable:4099) // For VC10 it is class hash
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CGAL_CFG_NO_STD_HASH
|
||||||
|
|
||||||
|
template < class T, class Ref, class Ptr>
|
||||||
|
struct hash<CGAL::internal::vector_iterator<T, Ref, Ptr> >
|
||||||
|
: public CGAL::cpp98::unary_function<CGAL::internal::vector_iterator<T, Ref, Ptr>, std::size_t> {
|
||||||
|
|
||||||
|
std::size_t operator()(const CGAL::internal::vector_iterator<T, Ref, Ptr>& i) const
|
||||||
|
{
|
||||||
|
return CGAL::internal::hash_value(i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CGAL_CFG_NO_STD_HASH
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
#endif // CGAL_VECTOR_H //
|
#endif // CGAL_VECTOR_H //
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue