summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-11-23 07:09:39 (GMT)
committerTobias Markmann <tm@ayena.de>2016-11-23 11:30:02 (GMT)
commite405ff3561be3d3c0bd79d7d5173923a8828cf02 (patch)
tree9118ef838ebfaec1df90ec24761944b5d833774c /Swiften/Client/BlockListImpl.cpp
parent8a71b91be885652f37c5aab5e1ecf25af4599fbc (diff)
downloadswift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.zip
swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.tar.bz2
Migrate remaining Swiften/Base/foreach.h use to range-based for loop
Test-Information: Build on macOS 10.12.1 and all tests pass. Change-Id: Iedaa3fa7e7672c77909fd0568bf30e9393cb87e0
Diffstat (limited to 'Swiften/Client/BlockListImpl.cpp')
-rw-r--r--Swiften/Client/BlockListImpl.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/Swiften/Client/BlockListImpl.cpp b/Swiften/Client/BlockListImpl.cpp
index ebffff8..54dcdf5 100644
--- a/Swiften/Client/BlockListImpl.cpp
+++ b/Swiften/Client/BlockListImpl.cpp
@@ -1,74 +1,72 @@
/*
- * Copyright (c) 2011-2015 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Client/BlockListImpl.h>
#include <algorithm>
-#include <Swiften/Base/foreach.h>
-
using namespace Swift;
BlockListImpl::BlockListImpl() : state(Init) {
}
void BlockListImpl::setItems(const std::vector<JID>& newItems) {
// JIDs which are in the current list but not in the new list, are removed.
- foreach (const JID& jid, items) {
+ for (const auto& jid : items) {
if (std::find(newItems.begin(), newItems.end(), jid) == newItems.end()) {
onItemRemoved(jid);
}
}
// JIDs which are in the new list but not in the current list, are added.
- foreach (const JID& jid, newItems) {
+ for (const auto& jid : newItems) {
if (std::find(items.begin(), items.end(), jid) == items.end()) {
onItemAdded(jid);
}
}
items = newItems;
}
void BlockListImpl::addItem(const JID& item) {
if (std::find(items.begin(), items.end(), item) == items.end()) {
items.push_back(item);
onItemAdded(item);
}
}
void BlockListImpl::removeItem(const JID& item) {
size_t oldSize = items.size();
items.erase(std::remove(items.begin(), items.end(), item), items.end());
if (items.size() != oldSize) {
onItemRemoved(item);
}
}
void BlockListImpl::setState(State state) {
if (this->state != state) {
this->state = state;
onStateChanged();
}
}
void BlockListImpl::addItems(const std::vector<JID>& items) {
- foreach (const JID& item, items) {
+ for (const auto& item : items) {
addItem(item);
}
}
void BlockListImpl::removeItems(const std::vector<JID>& items) {
std::vector<JID> itemsToRemove = items;
- foreach (const JID& item, itemsToRemove) {
+ for (const auto& item : itemsToRemove) {
removeItem(item);
}
}
void BlockListImpl::removeAllItems() {
removeItems(items);
}