From 630bc9144f6b08eb71af4f043cb5c82b53e9cbe5 Mon Sep 17 00:00:00 2001 From: Manohar Paluri Date: Thu, 27 Aug 2009 20:04:10 +0000 Subject: [PATCH] changed get and operator functions to const ( using find operator of a map instead of [] ) --- cpp/ChordalBayesNet.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cpp/ChordalBayesNet.h b/cpp/ChordalBayesNet.h index ffbd18742..f4310d6b3 100644 --- a/cpp/ChordalBayesNet.h +++ b/cpp/ChordalBayesNet.h @@ -53,8 +53,16 @@ public: void erase(const std::string& key); /** return node with given key */ - inline ConditionalGaussian::shared_ptr get (const std::string& key) { return nodes[key];} - inline ConditionalGaussian::shared_ptr operator[](const std::string& key) { return nodes[key];} + inline ConditionalGaussian::shared_ptr get (const std::string& key) const + { + const_iterator cg = nodes.find(key); // get node + return cg->second; + } + inline ConditionalGaussian::shared_ptr operator[](const std::string& key) const + { + const_iterator cg = nodes.find(key); // get node + return cg->second; + } /** return begin and end of the nodes. FD: breaks encapsulation? */ typedef Nodes::const_iterator const_iterator;