summaryrefslogtreecommitdiffstats
path: root/examples/network/torrent
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-05-23 10:39:56 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-05-23 13:35:15 +0200
commit77e708d1676803ce4ed7a2511fd80f8848522c63 (patch)
treedf2b8b6963e90af557e177eccf0edecc00486ddc /examples/network/torrent
parent070517f628d1cab07856418cee30e5595051e110 (diff)
Torrent example: replace Java-style iteration with STL iterators
Java-iterators are going to be deprecated. Change-Id: I2e6353f3fd9e2ddaf0767e7f6cea713249d9591e Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'examples/network/torrent')
-rw-r--r--examples/network/torrent/ratecontroller.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/network/torrent/ratecontroller.cpp b/examples/network/torrent/ratecontroller.cpp
index 47b49dba30..87c65096b6 100644
--- a/examples/network/torrent/ratecontroller.cpp
+++ b/examples/network/torrent/ratecontroller.cpp
@@ -123,11 +123,11 @@ void RateController::transfer()
qint64 writeChunk = qMax<qint64>(1, bytesToWrite / pendingSockets.size());
qint64 readChunk = qMax<qint64>(1, bytesToRead / pendingSockets.size());
- QSetIterator<PeerWireClient *> it(pendingSockets);
- while (it.hasNext() && (bytesToWrite > 0 || bytesToRead > 0)) {
- PeerWireClient *socket = it.next();
+ for (auto it = pendingSockets.begin(), end = pendingSockets.end(); it != end && (bytesToWrite > 0 || bytesToRead > 0); /*erasing*/) {
+ auto current = it++;
+ PeerWireClient *socket = *current;
if (socket->state() != QAbstractSocket::ConnectedState) {
- pendingSockets.remove(socket);
+ pendingSockets.erase(current);
continue;
}
@@ -156,7 +156,7 @@ void RateController::transfer()
if (dataTransferred && socket->canTransferMore())
canTransferMore = true;
else
- pendingSockets.remove(socket);
+ pendingSockets.erase(current);
}
} while (canTransferMore && (bytesToWrite > 0 || bytesToRead > 0) && !pendingSockets.isEmpty());