mirror of https://github.com/CGAL/cgal
Add reserve(G, nv, ne, nf)
This commit is contained in:
parent
657aa71e02
commit
725a658dad
|
|
@ -157,6 +157,7 @@ user might encounter.
|
|||
|
||||
- `CGAL::clear()`
|
||||
- `CGAL::copy_face_graph()`
|
||||
- `CGAL::reserve()`
|
||||
|
||||
## Iterators ##
|
||||
- `CGAL::Halfedge_around_source_iterator`
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
#include <CGAL/boost/graph/internal/Has_member_clear.h>
|
||||
#include <CGAL/boost/graph/internal/Has_member_reserve.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
@ -725,6 +726,21 @@ clear_impl(FaceGraph& g)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename FaceGraph, typename T>
|
||||
inline
|
||||
typename boost::enable_if<Has_member_reserve<FaceGraph,T>, void>::type
|
||||
reserve_impl(FaceGraph& g, T nv, T ne, T nf)
|
||||
{
|
||||
g.reserve();
|
||||
}
|
||||
|
||||
template<typename FaceGraph, typename T>
|
||||
inline
|
||||
typename boost::disable_if<Has_member_reserve<FaceGraph,T>, void>::type
|
||||
reserve_impl(FaceGraph& g, T, T, T)
|
||||
{}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -752,6 +768,26 @@ void clear(FaceGraph& g)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
*
|
||||
* If the graph has a member function `reserve()`, it will be called.
|
||||
*
|
||||
* @tparam FaceGraph model of `MutableHalfedgeGraph` and `MutableFaceGraph`
|
||||
*
|
||||
* @param g the graph
|
||||
* @param nv number of vertices
|
||||
* @param ne number of edges
|
||||
* @param nf number of faces
|
||||
*
|
||||
**/
|
||||
template<typename FaceGraph, typename T>
|
||||
void reserve(FaceGraph& g, T nv, T ne, T nf)
|
||||
{
|
||||
internal::reserve_impl(g,nv, ne, nf);
|
||||
}
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
// Include "Euler_operations.h" at the end, because its implementation
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) 2016 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 3 of the License,
|
||||
// or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
// Author(s) : Sebastien Loriot
|
||||
|
||||
|
||||
#ifndef CGAL_HAS_MEMBER_RESERVE_H
|
||||
#define CGAL_HAS_MEMBER_RESERVE_H
|
||||
|
||||
namespace CGAL {
|
||||
namespace internal {
|
||||
|
||||
template<class T>
|
||||
class Has_member_reserve
|
||||
{
|
||||
private:
|
||||
template<class U, U>
|
||||
class check {};
|
||||
|
||||
template<class C>
|
||||
static char f(check<void(C::*)(void), &C::reserve>*);
|
||||
|
||||
template<class C>
|
||||
static int f(...);
|
||||
public:
|
||||
static const bool value = (sizeof(f<T>(0)) == sizeof(char));
|
||||
};
|
||||
|
||||
} // internal
|
||||
} // CGAL
|
||||
|
||||
#endif /* CGAL_HAS_MEMBER_RESERVE_H */
|
||||
Loading…
Reference in New Issue