ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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 38 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 161 of file Set.h.

161{ 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 88 of file Set.h.

88{ 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 167 of file Set.h.

167{ 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 102 of file Set.h.

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

◆ 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 128 of file Set.h.

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

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 145 of file Set.h.

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

◆ 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 114 of file Set.h.

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

◆ 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 76 of file Set.h.

76{ _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 82 of file Set.h.

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

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