mirror of https://github.com/CGAL/cgal
add example for unordered_set
This commit is contained in:
parent
b197a3402f
commit
92a647b1af
|
|
@ -370,6 +370,8 @@ counterparts. `Vertex_iterator`, `Halfedge_iterator`, and
|
|||
the handles appear in function parameter lists, the respective
|
||||
iterators can be passed as well.
|
||||
|
||||
All handles are model of `LessThanComparable` and `Hashable`.
|
||||
|
||||
*/
|
||||
/// @{
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,13 @@ looking up keys whose type may differ from `Type`, as long as users supply
|
|||
a comparison functor `CompareKey`, between the keys and set elements;
|
||||
and catenating and splitting sets.
|
||||
|
||||
\section stl_hash Hashing
|
||||
|
||||
For handles and indices of vertices, halfedges, faces, etc., we provide specializations of `boost::hash<T>` and `std::hash<T>, so that they can be used with classes such as `boost::unordered_map`.
|
||||
|
||||
\cgalExample{STL_Extension/unordered_map.cpp}
|
||||
|
||||
|
||||
\section stl_polyobject Polymorphic Object
|
||||
|
||||
The class `Object` can store an object of whatever other type.
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@ Circulator
|
|||
Number_types
|
||||
Kernel_23
|
||||
Miscellany
|
||||
Surface_mesh
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@
|
|||
\example STL_Extension/in_place_list_prog.cpp
|
||||
\example STL_Extension/min_element_if_example.cpp
|
||||
\example STL_Extension/min_max_element_example.cpp
|
||||
\example STL_Extension/unordered_map.cpp
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef CGAL::Surface_mesh<Point_3> Mesh;
|
||||
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::unordered_map<vertex_descriptor, int> bum;
|
||||
Mesh mesh;
|
||||
vertex_descriptor vd = mesh.add_vertex();
|
||||
bum[vd] = 7812;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -130,6 +130,8 @@ namespace CGAL {
|
|||
|
||||
/// This class represents a vertex.
|
||||
/// \cgalModels `Index`
|
||||
/// \cgalModels `LessThanComparable`
|
||||
/// \cgalModels `Hashable`
|
||||
/// \sa `Halfedge_index`, `Edge_index`, `Face_index`
|
||||
class SM_Vertex_index
|
||||
: public SM_Index<SM_Vertex_index>
|
||||
|
|
@ -149,6 +151,8 @@ namespace CGAL {
|
|||
|
||||
/// This class represents a halfedge.
|
||||
/// \cgalModels `Index`
|
||||
/// \cgalModels `LessThanComparable`
|
||||
/// \cgalModels `Hashable`
|
||||
/// \sa `Vertex_index`, `Edge_index`, `Face_index`
|
||||
class SM_Halfedge_index
|
||||
: public SM_Index<SM_Halfedge_index>
|
||||
|
|
@ -168,6 +172,8 @@ namespace CGAL {
|
|||
|
||||
/// This class represents a face
|
||||
/// \cgalModels `Index`
|
||||
/// \cgalModels `LessThanComparable`
|
||||
/// \cgalModels `Hashable`
|
||||
/// \sa `Vertex_index`, `Halfedge_index`, `Edge_index`
|
||||
class SM_Face_index
|
||||
: public SM_Index<SM_Face_index>
|
||||
|
|
@ -187,6 +193,8 @@ namespace CGAL {
|
|||
|
||||
/// This class represents an edge.
|
||||
/// \cgalModels `Index`
|
||||
/// \cgalModels `LessThanComparable`
|
||||
/// \cgalModels `Hashable`
|
||||
/// \sa `Vertex_index`, `Halfedge_index`, `Face_index`
|
||||
class SM_Edge_index
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue