Commit bfb8db48 authored by Tiago Peixoto's avatar Tiago Peixoto

Include option to disable the use of google sparsehash

parent 3a7350b5
......@@ -153,6 +153,19 @@ AC_ARG_ENABLE([cairo], [AS_HELP_STRING([--disable-cairo],[disable cairo drawing
[AC_MSG_RESULT(yes)]
)
[USING_SPARSEHASH=yes]
AC_MSG_CHECKING(whether to enable sparsehash...)
AC_ARG_ENABLE([sparsehash], [AS_HELP_STRING([--disable-sparsehash],[disable use of google's sparsehash [default=enabled] ])],
if test $enableval = no; then
[USING_SPARSEHASH=no]
[AC_MSG_RESULT(no)]
else
[AC_MSG_RESULT(yes)]
fi
,
[AC_MSG_RESULT(yes)]
)
dnl Override prefix with default value if not set
if test "x${prefix}" = "xNONE"; then
prefix=${ac_default_prefix}
......@@ -285,11 +298,13 @@ if test "$USING_CAIRO" = "yes"; then
fi
dnl sparsehash
dnl set template depth and hidden visibility
[CPPFLAGS="${CPPFLAGS} -I/usr/include/sparsehash -I/usr/include/google"]
AC_CHECK_HEADER([dense_hash_set],
if test "$USING_SPARSEHASH" = "yes"; then
[CPPFLAGS="${CPPFLAGS} -I/usr/include/sparsehash -I/usr/include/google"]
AC_CHECK_HEADER([dense_hash_set],
[],
[AC_MSG_ERROR([sparsehash headers not found])])
AC_DEFINE_UNQUOTED([HAVE_SPARSEHASH],"1", [Using google's sparsehash])
fi
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
......
......@@ -21,22 +21,21 @@
#include <cmath>
#include <iostream>
#include <ext/numeric>
using __gnu_cxx::power;
#include "config.h"
#include "tr1_include.hh"
#include TR1_HEADER(unordered_set)
#include TR1_HEADER(unordered_map)
#include TR1_HEADER(tuple)
#ifdef HAVE_SPARSEHASH
#include <dense_hash_set>
#include <dense_hash_map>
#endif
namespace graph_tool
{
#ifdef HAVE_SPARSEHASH
using google::dense_hash_set;
using google::dense_hash_map;
#endif
using namespace boost;
......@@ -685,11 +684,17 @@ double move_vertex(size_t v, size_t nr, Eprop& mrs, Vprop& mrp, Vprop& mrm,
double Si = 0, Sf = 0;
vector<pair<vertex_t, vertex_t> > m_entries;
#ifdef HAVE_SPARSEHASH
dense_hash_set<pair<vertex_t, vertex_t>, boost::hash<pair<vertex_t, vertex_t> > > m_entries_set;
#else
unordered_set<pair<vertex_t, vertex_t>, boost::hash<pair<vertex_t, vertex_t> > > m_entries_set;
#endif
if (get_ds)
{
#ifdef HAVE_SPARSEHASH
m_entries_set.set_empty_key(make_pair(graph_traits<Graph>::null_vertex(),
graph_traits<Graph>::null_vertex()));
#endif
move_entries(vertex(v, g), nr, b, g, bg, m_entries, m_entries_set);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment