2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __ONERT_MODEL_OPERATION_INDEX_SET_H__
18 #define __ONERT_MODEL_OPERATION_INDEX_SET_H__
22 #include <initializer_list>
23 #include <unordered_set>
32 class OperationIndexSet
35 OperationIndexSet(void) = default;
36 OperationIndexSet(std::initializer_list<OperationIndex> list);
39 void insert(const OperationIndex &index) { _set.insert(index); }
40 void clear(void) { _set.clear(); }
41 void remove(const OperationIndex &index)
43 auto itr = std::find(_set.begin(), _set.end(), index);
44 assert(itr != _set.end());
49 uint32_t size() const { return static_cast<uint32_t>(_set.size()); }
50 bool contains(const OperationIndex &index) const;
53 std::unordered_set<OperationIndex>::iterator begin(void) { return _set.begin(); }
54 std::unordered_set<OperationIndex>::iterator end(void) { return _set.end(); }
55 std::unordered_set<OperationIndex>::const_iterator begin(void) const { return _set.begin(); }
56 std::unordered_set<OperationIndex>::const_iterator end(void) const { return _set.end(); }
59 std::unordered_set<OperationIndex> _set;
65 #endif // __ONERT_MODEL_OPERATION_INDEX_SET_H__