[neurun] Support iteration for operand::Object (#2608)
author이한종/동작제어Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Wed, 5 Sep 2018 09:05:57 +0000 (18:05 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 5 Sep 2018 09:05:57 +0000 (18:05 +0900)
Support const/non-const iteration for operand::Object.

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/neurun/src/graph/operand/Set.cc
runtimes/neurun/src/graph/operand/Set.h

index 862e011..4f8263c 100644 (file)
@@ -31,6 +31,22 @@ Object &Set::at(const Index &index) { return *(_objects.at(index)); }
 
 bool Set::exist(const Index &index) const { return index.value() < _objects.size(); }
 
+void Set::iterate(const std::function<void(const Index &, const Object &)> &fn) const
+{
+  for (const auto &e : _objects)
+  {
+    fn(e.first, *e.second);
+  }
+}
+
+void Set::iterate(const std::function<void(const Index &, Object &)> &fn)
+{
+  for (auto &e : _objects)
+  {
+    fn(e.first, *e.second);
+  }
+}
+
 } // namespace operand
 } // namespace graph
 } // namespace neurun
index 754aec1..5b310cd 100644 (file)
@@ -26,6 +26,8 @@ public:
   const Object &at(const Index &) const;
   Object &at(const Index &);
   bool exist(const Index &) const;
+  void iterate(const std::function<void(const Index &, const Object &)> &fn) const;
+  void iterate(const std::function<void(const Index &, Object &)> &fn);
 
 private:
   const Index generateIndex();