comparison OrthancFramework/Sources/Toolbox.h @ 4981:d0c34145320c

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 25 Apr 2022 17:32:58 +0200
parents 96a3e81eba90
children 95d8e0540219
comparison
equal deleted inserted replaced
4980:8b95fc86b8d9 4981:d0c34145320c
195 195
196 // returns true if all element of 'needles' are found in 'haystack' 196 // returns true if all element of 'needles' are found in 'haystack'
197 template <typename T> static bool IsSetInSet(const std::set<T>& needles, const std::set<T>& haystack) 197 template <typename T> static bool IsSetInSet(const std::set<T>& needles, const std::set<T>& haystack)
198 { 198 {
199 for (typename std::set<T>::const_iterator it = needles.begin(); 199 for (typename std::set<T>::const_iterator it = needles.begin();
200 it != needles.end(); it++) 200 it != needles.end(); ++it)
201 { 201 {
202 if (haystack.count(*it) == 0) 202 if (haystack.count(*it) == 0)
203 { 203 {
204 return false; 204 return false;
205 } 205 }
212 template <typename T> static size_t GetMissingsFromSet(std::set<T>& missings, const std::set<T>& needles, const std::set<T>& haystack) 212 template <typename T> static size_t GetMissingsFromSet(std::set<T>& missings, const std::set<T>& needles, const std::set<T>& haystack)
213 { 213 {
214 missings.clear(); 214 missings.clear();
215 215
216 for (typename std::set<T>::const_iterator it = needles.begin(); 216 for (typename std::set<T>::const_iterator it = needles.begin();
217 it != needles.end(); it++) 217 it != needles.end(); ++it)
218 { 218 {
219 if (haystack.count(*it) == 0) 219 if (haystack.count(*it) == 0)
220 { 220 {
221 missings.insert(*it); 221 missings.insert(*it);
222 } 222 }
226 } 226 }
227 227
228 template <typename T> static void AppendSets(std::set<T>& target, const std::set<T>& toAppend) 228 template <typename T> static void AppendSets(std::set<T>& target, const std::set<T>& toAppend)
229 { 229 {
230 for (typename std::set<T>::const_iterator it = toAppend.begin(); 230 for (typename std::set<T>::const_iterator it = toAppend.begin();
231 it != toAppend.end(); it++) 231 it != toAppend.end(); ++it)
232 { 232 {
233 target.insert(*it); 233 target.insert(*it);
234 } 234 }
235 } 235 }
236 236
237 template <typename T> static void RemoveSets(std::set<T>& target, const std::set<T>& toRemove) 237 template <typename T> static void RemoveSets(std::set<T>& target, const std::set<T>& toRemove)
238 { 238 {
239 for (typename std::set<T>::const_iterator it = toRemove.begin(); 239 for (typename std::set<T>::const_iterator it = toRemove.begin();
240 it != toRemove.end(); it++) 240 it != toRemove.end(); ++it)
241 { 241 {
242 target.erase(*it); 242 target.erase(*it);
243 } 243 }
244 } 244 }
245 245