MCPcopy Create free account
hub / github.com/Kitware/CMake / cmRemoveDuplicates

Function cmRemoveDuplicates

Source/cmAlgorithms.h:105–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103
104template <typename ForwardIterator>
105ForwardIterator cmRemoveDuplicates(ForwardIterator first, ForwardIterator last)
106{
107 using Value = typename std::iterator_traits<ForwardIterator>::value_type;
108 struct Hash
109 {
110 std::size_t operator()(ForwardIterator it) const
111 {
112 return std::hash<Value>{}(*it);
113 }
114 };
115
116 struct Equal
117 {
118 bool operator()(ForwardIterator it1, ForwardIterator it2) const
119 {
120 return *it1 == *it2;
121 }
122 };
123 std::unordered_set<ForwardIterator, Hash, Equal> uniq;
124
125 ForwardIterator result = first;
126 while (first != last) {
127 if (!cm::contains(uniq, first)) {
128 if (result != first) {
129 *result = std::move(*first);
130 }
131 uniq.insert(result);
132 ++result;
133 }
134 ++first;
135 }
136 return result;
137}
138
139template <typename Range>
140typename Range::iterator cmRemoveDuplicates(Range& r)

Callers 11

WriteSummaryMethod · 0.85
HandlePackageModeMethod · 0.85
GenerateMainFileMethod · 0.85
InitCustomTargetsMethod · 0.85
SetupWriteAutogenInfoMethod · 0.85
cmList.cxxFile · 0.85
GenerateMainFileMethod · 0.85
AppendTargetMethod · 0.85
ProcessHandlerMethod · 0.85

Calls 4

moveFunction · 0.85
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

ProcessHandlerMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…