[mathicgb] 66/393: Changed MonomialMap interface to use pointers instead of iterators to be able to support the case where std::unordered_map::iterator and std::unordered_map::local_iterator are not compatible. This was required to compile on GCC.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:33 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.
commit 2431c7074295db59a8b15aeff7cb433f603fdac8
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Wed Oct 17 17:10:46 2012 +0200
Changed MonomialMap interface to use pointers instead of iterators to be able to support the case where std::unordered_map::iterator and std::unordered_map::local_iterator are not compatible. This was required to compile on GCC.
---
src/mathicgb/MonomialMap.hpp | 33 +++++++++++++++++++++------------
src/mathicgb/Poly.hpp | 1 +
src/mathicgb/PolyRing.hpp | 1 +
src/mathicgb/QuadMatrixBuilder.cpp | 2 +-
src/mathicgb/QuadMatrixBuilder.hpp | 4 ++--
5 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/src/mathicgb/MonomialMap.hpp b/src/mathicgb/MonomialMap.hpp
index 36b9922..d2ca751 100755
--- a/src/mathicgb/MonomialMap.hpp
+++ b/src/mathicgb/MonomialMap.hpp
@@ -125,6 +125,7 @@ namespace MonomialMapInternal {
Map;
typedef typename Map::iterator iterator;
typedef typename Map::const_iterator const_iterator;
+ typedef typename Map::value_type value_type;
MapClass(const PolyRing& ring):
mArena(),
@@ -142,20 +143,16 @@ namespace MonomialMapInternal {
const Map& map() const {return mMap;}
const PolyRing& ring() const {return mMap.key_eq().ring();}
- iterator findProduct(const_monomial a, const_monomial b) {
+ value_type* findProduct(const_monomial a, const_monomial b) {
ring().setGivenHash(mTmp, ring().monomialHashOfProduct(a, b));
size_t bucket = mMap.bucket(mTmp);
auto stop = mMap.end(bucket);
for (auto it = mMap.begin(bucket); it != stop; ++it)
if (ring().monomialIsProductOf(a, b, it->first))
- return it;
- return mMap.end();
+ return &*it;
+ return 0;
}
- const_iterator findProduct(const_monomial a, const_monomial b) const {
- iterator it = const_cast<MapClass<MTT>*>(this)->findProduct(a, b);
- return const_iterator(it);
- }
/*
size_t bucket = mMonomialToCol.
@@ -196,15 +193,27 @@ public:
const_iterator begin() const {return map().begin();}
iterator end() {return map().end();}
const_iterator end() const {return map().end();}
- iterator find(const_monomial m) {return map().find(m);}
- const_iterator find(const_monomial m) const {return map().find(m);}
- iterator findProduct(const_monomial a, const_monomial b) {
- return mMap.findProduct(a, b);
+
+ value_type* find(const_monomial m) {
+ auto it = map().find(m);
+ if (it == map().end())
+ return 0;
+ else
+ return &*it;
}
- const_iterator findProduct(const_monomial a, const_monomial b) const {
+
+ value_type* findProduct(const_monomial a, const_monomial b) {
return mMap.findProduct(a, b);
}
+ const value_type* find(const_monomial m) const {
+ return const_cast<MonomialMap&>(*this).find(m);
+ }
+
+ const value_type* findProduct(const_monomial a, const_monomial b) const {
+ return const_cast<MonomialMap&>(*this).findProduct(a, b);
+ }
+
size_t size() const {return map().size();}
void clear() {map().clear();}
std::pair<iterator, bool> insert(const value_type& val) {
diff --git a/src/mathicgb/Poly.hpp b/src/mathicgb/Poly.hpp
index 53030d5..81c1b7b 100755
--- a/src/mathicgb/Poly.hpp
+++ b/src/mathicgb/Poly.hpp
@@ -7,6 +7,7 @@
#include <vector>
#include <ostream>
#include <utility>
+#include <cstdio>
class Poly {
public:
diff --git a/src/mathicgb/PolyRing.hpp b/src/mathicgb/PolyRing.hpp
index 5c8e465..cb48d46 100755
--- a/src/mathicgb/PolyRing.hpp
+++ b/src/mathicgb/PolyRing.hpp
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include <memtailor.h>
+#include <cstdio>
#define LT (-1)
#define EQ 0
diff --git a/src/mathicgb/QuadMatrixBuilder.cpp b/src/mathicgb/QuadMatrixBuilder.cpp
index 2947e55..bf94019 100755
--- a/src/mathicgb/QuadMatrixBuilder.cpp
+++ b/src/mathicgb/QuadMatrixBuilder.cpp
@@ -27,7 +27,7 @@ namespace {
{
MATHICGB_ASSERT(top.colCount() == bottom.colCount());
MATHICGB_ASSERT(toMonomial.size() == bottom.colCount());
- MATHICGB_ASSERT(toCol.find(mono) == toCol.end());
+ MATHICGB_ASSERT(toCol.find(mono) == 0);
const QuadMatrixBuilder::ColIndex colCount = top.colCount();
if (colCount == std::numeric_limits<QuadMatrixBuilder::ColIndex>::max())
diff --git a/src/mathicgb/QuadMatrixBuilder.hpp b/src/mathicgb/QuadMatrixBuilder.hpp
index 7a425c9..319e8e5 100755
--- a/src/mathicgb/QuadMatrixBuilder.hpp
+++ b/src/mathicgb/QuadMatrixBuilder.hpp
@@ -169,7 +169,7 @@ class QuadMatrixBuilder {
exists. */
LeftRightColIndex findColumn(const_monomial findThis) const {
auto it = mMonomialToCol.find(findThis);
- if (it != mMonomialToCol.end())
+ if (it != 0)
return it->second;
else
return LeftRightColIndex();
@@ -179,7 +179,7 @@ class QuadMatrixBuilder {
LeftRightColIndex findColumnProduct(const_monomial a, const_monomial b) const
{
auto it = mMonomialToCol.findProduct(a, b);
- if (it != mMonomialToCol.end())
+ if (it != 0)
return it->second;
else
return LeftRightColIndex();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git
More information about the debian-science-commits
mailing list