[neurun] Define operation index list (#2532)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 30 Aug 2018 08:12:03 +0000 (17:12 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 30 Aug 2018 08:12:03 +0000 (17:12 +0900)
Define operation index list (used for use-def)
Use list to support frequent append & remove

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/src/graph/operation/IndexList.cc [new file with mode: 0644]
runtimes/neurun/src/graph/operation/IndexList.h [new file with mode: 0644]

diff --git a/runtimes/neurun/src/graph/operation/IndexList.cc b/runtimes/neurun/src/graph/operation/IndexList.cc
new file mode 100644 (file)
index 0000000..6a8ac54
--- /dev/null
@@ -0,0 +1,24 @@
+#include "IndexList.h"
+
+#include <algorithm>
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+
+IndexList::IndexList(std::initializer_list<Index> list) : _list(list)
+{
+  // DO NOTHING
+}
+
+bool IndexList::contains(const ::neurun::graph::operation::Index &index) const
+{
+  return std::find(_list.begin(), _list.end(), index) != _list.end();
+}
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun
diff --git a/runtimes/neurun/src/graph/operation/IndexList.h b/runtimes/neurun/src/graph/operation/IndexList.h
new file mode 100644 (file)
index 0000000..2bcca09
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef __NEURUN_GRAPH_OPERATION_INDEX_LIST_H__
+#define __NEURUN_GRAPH_OPERATION_INDEX_LIST_H__
+
+#include <initializer_list>
+#include <list>
+
+#include "Index.h"
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+
+class IndexList
+{
+public:
+  IndexList(void) = default;
+  IndexList(std::initializer_list<Index> list);
+
+public:
+  void append(const Index &index) { _list.push_back(index); }
+  void remove(const Index &index) { _list.remove(index); }
+
+public:
+  uint32_t size() const { return static_cast<uint32_t>(_list.size()); }
+  const std::list<Index> &list() const { return _list; }
+  bool contains(const Index &index) const;
+
+private:
+  std::list<Index> _list;
+};
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun
+
+#endif // __NEURUN_GRAPH_OPERATION_INDEX_LIST_H__