From eb10065bc8b3b4a84d1ac0f923b4945da762d503 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Wed, 5 Sep 2018 18:05:57 +0900 Subject: [PATCH] [neurun] Support iteration for operand::Object (#2608) Support const/non-const iteration for operand::Object. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/graph/operand/Set.cc | 16 ++++++++++++++++ runtimes/neurun/src/graph/operand/Set.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/runtimes/neurun/src/graph/operand/Set.cc b/runtimes/neurun/src/graph/operand/Set.cc index 862e011..4f8263c 100644 --- a/runtimes/neurun/src/graph/operand/Set.cc +++ b/runtimes/neurun/src/graph/operand/Set.cc @@ -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 &fn) const +{ + for (const auto &e : _objects) + { + fn(e.first, *e.second); + } +} + +void Set::iterate(const std::function &fn) +{ + for (auto &e : _objects) + { + fn(e.first, *e.second); + } +} + } // namespace operand } // namespace graph } // namespace neurun diff --git a/runtimes/neurun/src/graph/operand/Set.h b/runtimes/neurun/src/graph/operand/Set.h index 754aec1..5b310cd 100644 --- a/runtimes/neurun/src/graph/operand/Set.h +++ b/runtimes/neurun/src/graph/operand/Set.h @@ -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 &fn) const; + void iterate(const std::function &fn); private: const Index generateIndex(); -- 2.7.4