ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
onert::util::Set< Element > Class Template Reference

Class for set of custom element &. More...

#include <Set.h>

Public Member Functions

 Set ()=default
 Construct default Set object.
 
 Set (const Set< Element > &)=default
 Construct Set object by copy semantics.
 
 Set (Set< Element > &&)=default
 Construct move Set object by move semantics.
 
Set< Element > & operator= (const Set< Element > &)=default
 copy assignment operator
 
Set< Element > & operator= (Set< Element > &&)=default
 move assignment operator
 
void add (const Element &e)
 Add a given element to the set.
 
void remove (const Element &e)
 remove a given element from the set
 
uint32_t size () const
 Get size of the set.
 
bool empty () const
 Get whether the set is empty.
 
bool contains (const Element &e) const
 Get whether a given element exists in the set.
 
const Element & getOnlyElement () const
 Get first element of the set.
 
Set< Element > operator| (const Set< Element > &other) const
 operator overloading function for |
 
Set< Element > operator& (const Set< Element > &other) const
 operator overloading function for &
 
Set< Element > operator- (const Set< Element > &other) const
 operator overloading function for -
 
std::unordered_set< Element >::const_iterator begin () const
 begin() of const_iterator for this class
 
std::unordered_set< Element >::const_iterator end () const
 end() of const_iterator for this class
 

Detailed Description

template<typename Element>
class onert::util::Set< Element >

Class for set of custom element &.

Template Parameters
ElementKey type of Set

Definition at line 36 of file Set.h.

Constructor & Destructor Documentation

◆ Set() [1/3]

template<typename Element >
onert::util::Set< Element >::Set ( )
default

Construct default Set object.

◆ Set() [2/3]

template<typename Element >
onert::util::Set< Element >::Set ( const Set< Element > &  )
default

Construct Set object by copy semantics.

◆ Set() [3/3]

template<typename Element >
onert::util::Set< Element >::Set ( Set< Element > &&  )
default

Construct move Set object by move semantics.

Member Function Documentation

◆ add()

◆ begin()

template<typename Element >
std::unordered_set< Element >::const_iterator onert::util::Set< Element >::begin ( ) const
inline

begin() of const_iterator for this class

Returns
The first iterator of the set

Definition at line 159 of file Set.h.

159{ return _set.begin(); }

◆ contains()

template<typename Element >
bool onert::util::Set< Element >::contains ( const Element &  e) const
inline

◆ empty()

template<typename Element >
bool onert::util::Set< Element >::empty ( ) const
inline

Get whether the set is empty.

Returns
Whether the set is empty

Definition at line 86 of file Set.h.

86{ return _set.empty(); }

Referenced by onert::ir::Graph::topolSortOperations().

◆ end()

template<typename Element >
std::unordered_set< Element >::const_iterator onert::util::Set< Element >::end ( ) const
inline

end() of const_iterator for this class

Returns
The last iterator of the set

Definition at line 165 of file Set.h.

165{ return _set.end(); }

◆ getOnlyElement()

template<typename Element >
const Element & onert::util::Set< Element >::getOnlyElement ( ) const
inline

Get first element of the set.

Returns
first element of the set

Definition at line 100 of file Set.h.

101 {
102 assert(_set.size() == 1u);
103 return *_set.begin();
104 }

◆ operator&()

template<typename Element >
Set< Element > onert::util::Set< Element >::operator& ( const Set< Element > &  other) const
inline

operator overloading function for &

Returns
A set of elements that overlap in two sets

Definition at line 126 of file Set.h.

127 {
128 Set<Element> ret;
129 for (auto &&e : other)
130 {
131 if (contains(e))
132 {
133 ret.add(e);
134 }
135 }
136 return ret;
137 }
bool contains(const Element &e) const
Get whether a given element exists in the set.
Definition Set.h:94

References onert::util::Set< Element >::add(), and onert::util::Set< Element >::contains().

◆ operator-()

template<typename Element >
Set< Element > onert::util::Set< Element >::operator- ( const Set< Element > &  other) const
inline

operator overloading function for -

Returns
A set of subtracted from another set

Definition at line 143 of file Set.h.

144 {
145 auto ret = *this;
146 for (auto &&e : other)
147 {
148 ret.remove(e);
149 }
150 return ret;
151 }

◆ operator=() [1/2]

template<typename Element >
Set< Element > & onert::util::Set< Element >::operator= ( const Set< Element > &  )
default

copy assignment operator

◆ operator=() [2/2]

template<typename Element >
Set< Element > & onert::util::Set< Element >::operator= ( Set< Element > &&  )
default

move assignment operator

◆ operator|()

template<typename Element >
Set< Element > onert::util::Set< Element >::operator| ( const Set< Element > &  other) const
inline

operator overloading function for |

Returns
A set with two sets combined

Definition at line 112 of file Set.h.

113 {
114 auto ret = *this;
115 for (auto &&e : other)
116 {
117 ret.add(e);
118 }
119 return ret;
120 }

◆ remove()

template<typename Element >
void onert::util::Set< Element >::remove ( const Element &  e)
inline

remove a given element from the set

Parameters
eElement removed

Definition at line 74 of file Set.h.

74{ _set.erase(e); }

Referenced by onert::ir::train::TrainableGraph::btopolSortOperations(), onert::compiler::OperandLowerInfo::removeDefBackend(), onert::compiler::OperandLowerInfo::removeUseBackend(), and onert::ir::Graph::topolSortOperations().

◆ size()

template<typename Element >
uint32_t onert::util::Set< Element >::size ( ) const
inline

Get size of the set.

Returns
The size of the set

Definition at line 80 of file Set.h.

80{ return static_cast<uint32_t>(_set.size()); }

The documentation for this class was generated from the following file: