summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-01-28 23:09:25 -0500
committerAdam <Adam@anope.org>2011-01-28 23:09:25 -0500
commite62664138b42437186669952a5c1a848c2cdfb02 (patch)
tree803ca8c6ba64bcaf1ed70fbcfac41878f1204063
parent3eadc1509f378f26037dd3b7e1d61e0ac2d35019 (diff)
Added patricia_tree::iterator
-rw-r--r--include/patricia.h93
-rw-r--r--modules/core/bs_botlist.cpp4
-rw-r--r--modules/core/cs_akick.cpp2
-rw-r--r--modules/core/db_plain.cpp2
-rw-r--r--modules/core/os_akill.cpp2
-rw-r--r--modules/core/os_noop.cpp5
-rw-r--r--modules/core/os_session.cpp2
-rw-r--r--modules/core/os_snline.cpp2
-rw-r--r--modules/core/os_sqline.cpp2
-rw-r--r--modules/core/os_staff.cpp19
-rw-r--r--modules/core/os_szline.cpp2
-rw-r--r--modules/core/os_userlist.cpp2
-rw-r--r--modules/extra/db_mysql.cpp4
-rw-r--r--modules/protocol/inspircd12.cpp2
-rw-r--r--modules/protocol/inspircd20.cpp2
-rw-r--r--modules/protocol/plexus.cpp2
-rw-r--r--src/botserv.cpp2
-rw-r--r--src/init.cpp2
-rw-r--r--src/logger.cpp2
-rw-r--r--src/main.cpp22
-rw-r--r--src/modes.cpp2
-rw-r--r--src/operserv.cpp14
-rw-r--r--src/servers.cpp7
-rw-r--r--src/sessions.cpp2
-rw-r--r--src/users.cpp2
25 files changed, 130 insertions, 72 deletions
diff --git a/include/patricia.h b/include/patricia.h
index a7c1d08f0..72be0f94a 100644
--- a/include/patricia.h
+++ b/include/patricia.h
@@ -8,7 +8,6 @@ template<typename Data> struct patricia_elem
{
unsigned int bit;
patricia_elem<Data> *up, *one, *zero;
- typename std::list<Data>::iterator node;
Anope::string key;
Data data;
};
@@ -19,13 +18,13 @@ class patricia_tree
typedef std::basic_string<char, char_traits, std::allocator<char> > String;
patricia_elem<Data> *root;
- std::list<Data> list;
+ size_t count;
public:
-
patricia_tree()
{
this->root = NULL;
+ this->count = 0;
}
virtual ~patricia_tree()
@@ -34,20 +33,8 @@ class patricia_tree
this->erase(this->root->key);
}
- typedef typename std::list<Data>::iterator iterator;
- typedef typename std::list<Data>::const_iterator const_iterator;
-
- inline iterator begin() { return this->list.begin(); }
- inline iterator end() { return this->list.end(); }
-
- inline const const_iterator begin() const { return this->list.begin(); }
- inline const const_iterator end() const { return this->list.end(); }
-
- inline Data front() { return this->list.front(); }
- inline Data back() { return this->list.back(); }
-
- inline size_t size() const { return this->list.size(); }
- inline bool empty() const { return this->list.empty(); }
+ inline size_t size() const { return this->count; }
+ inline bool empty() const { return this->count == 0; }
Data find(const Anope::string &ukey)
{
@@ -101,7 +88,6 @@ class patricia_tree
return;
patricia_elem<Data> *newelem = new patricia_elem<Data>();
- newelem->up = prev;
newelem->key = key;
newelem->data = data;
@@ -111,12 +97,15 @@ class patricia_tree
for (newelem->bit = 0; GET_BIT_XOR(key, cur->key, newelem->bit) == 0; ++newelem->bit);
patricia_elem<Data> *place = prev;
+
while (place && newelem->bit < place->bit)
{
prev = place;
place = place->up;
}
+ newelem->up = place;
+
if (GET_BIT(key, newelem->bit))
{
newelem->one = newelem;
@@ -145,8 +134,7 @@ class patricia_tree
else
this->root = newelem;
- this->list.push_front(data);
- newelem->node = this->list.begin();
+ ++this->count;
}
Data erase(const Anope::string &ukey)
@@ -207,13 +195,74 @@ class patricia_tree
prev->bit = cur->bit;
}
- this->list.erase(cur->node);
-
Data data = cur->data;
delete cur;
+ --this->count;
+
return data;
}
+
+ class iterator
+ {
+ enum IterationState
+ {
+ ITERATION_AT_CENTER,
+ ITERATION_FROM_CENTER
+ };
+
+ patricia_elem<Data> *elem;
+ IterationState from;
+
+ public:
+ iterator(patricia_tree<Data, char_traits> &tree)
+ {
+ this->elem = tree.root;
+ this->from = ITERATION_AT_CENTER;
+ }
+
+ bool next()
+ {
+ if (this->elem == NULL)
+ ;
+ else if (this->from == ITERATION_AT_CENTER)
+ {
+ if (this->elem->zero != NULL && this->elem->zero->bit > this->elem->bit)
+ {
+ this->elem = this->elem->zero;
+ return this->next();
+ }
+
+ this->from = ITERATION_FROM_CENTER;
+ return true;
+ }
+ else if (this->from == ITERATION_FROM_CENTER)
+ {
+ if (this->elem->one != NULL && this->elem->one->bit > this->elem->bit)
+ {
+ this->elem = this->elem->one;
+ this->from = ITERATION_AT_CENTER;
+ return this->next();
+ }
+
+ while (this->elem->up != NULL && this->elem->up->one == this->elem)
+ this->elem = this->elem->up;
+
+ if (this->elem->up != NULL)
+ {
+ this->elem = this->elem->up;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ inline Data operator*()
+ {
+ return this->elem->data;
+ }
+ };
};
diff --git a/modules/core/bs_botlist.cpp b/modules/core/bs_botlist.cpp
index 6ca1b8d45..37901a4a0 100644
--- a/modules/core/bs_botlist.cpp
+++ b/modules/core/bs_botlist.cpp
@@ -31,7 +31,7 @@ class CommandBSBotList : public Command
return MOD_CONT;
}
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
{
BotInfo *bi = *it;
@@ -48,7 +48,7 @@ class CommandBSBotList : public Command
{
source.Reply(BOT_BOTLIST_PRIVATE_HEADER);
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
{
BotInfo *bi = *it;
diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp
index 444c79c46..34d3c8369 100644
--- a/modules/core/cs_akick.cpp
+++ b/modules/core/cs_akick.cpp
@@ -214,7 +214,7 @@ class CommandCSAKick : public Command
{
/* Match against all currently online users with equal or
* higher access. - Viper */
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
{
User *u2 = *it;
diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp
index e589d85f6..695738087 100644
--- a/modules/core/db_plain.cpp
+++ b/modules/core/db_plain.cpp
@@ -826,7 +826,7 @@ class DBPlain : public Module
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na));
}
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
{
BotInfo *bi = *it;
diff --git a/modules/core/os_akill.cpp b/modules/core/os_akill.cpp
index 215d4e3c3..f5212cb2b 100644
--- a/modules/core/os_akill.cpp
+++ b/modules/core/os_akill.cpp
@@ -175,7 +175,7 @@ class CommandOSAKill : public Command
if (user)
mask = "*@" + user->host;
unsigned int affected = 0;
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
if (Anope::Match((*it)->GetIdent() + "@" + (*it)->host, mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
diff --git a/modules/core/os_noop.cpp b/modules/core/os_noop.cpp
index 65915c176..49f29d2c9 100644
--- a/modules/core/os_noop.cpp
+++ b/modules/core/os_noop.cpp
@@ -39,10 +39,11 @@ class CommandOSNOOP : public Command
source.Reply(OPER_NOOP_SET, server.c_str());
/* Kill all the IRCops of the server */
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick);
+ for (bool next = it.next(); next;)
{
User *u2 = *it;
- ++it;
+ next = it.next();
if (u2 && u2->HasMode(UMODE_OPER) && Anope::Match(u2->server->GetName(), server, true))
kill_user(Config->s_OperServ, u2, reason);
diff --git a/modules/core/os_session.cpp b/modules/core/os_session.cpp
index 5c1dfc0ed..712603fa4 100644
--- a/modules/core/os_session.cpp
+++ b/modules/core/os_session.cpp
@@ -134,7 +134,7 @@ class CommandOSSession : public Command
source.Reply(OPER_SESSION_LIST_HEADER, mincount);
source.Reply(OPER_SESSION_LIST_COLHEAD);
- for (patricia_tree<Session *>::const_iterator it = SessionList.begin(), it_end = SessionList.end(); it != it_end; ++it)
+ for (patricia_tree<Session *>::iterator it(SessionList); it.next();)
{
Session *session = *it;
diff --git a/modules/core/os_snline.cpp b/modules/core/os_snline.cpp
index 5845c6d25..9ea88ec5e 100644
--- a/modules/core/os_snline.cpp
+++ b/modules/core/os_snline.cpp
@@ -190,7 +190,7 @@ class CommandOSSNLine : public Command
if (mask[masklen - 1] == ' ')
mask.erase(masklen - 1);
unsigned int affected = 0;
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
if (Anope::Match((*it)->realname, mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
diff --git a/modules/core/os_sqline.cpp b/modules/core/os_sqline.cpp
index 72a208be2..dbf6dcbe4 100644
--- a/modules/core/os_sqline.cpp
+++ b/modules/core/os_sqline.cpp
@@ -171,7 +171,7 @@ class CommandOSSQLine : public Command
if (!mask.empty() && !reason.empty())
{
unsigned int affected = 0;
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
if (Anope::Match((*it)->nick, mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
diff --git a/modules/core/os_staff.cpp b/modules/core/os_staff.cpp
index 5c5e7fac1..5b1af9ae1 100644
--- a/modules/core/os_staff.cpp
+++ b/modules/core/os_staff.cpp
@@ -26,27 +26,22 @@ class CommandOSStaff : public Command
for (std::list<std::pair<Anope::string, Anope::string> >::iterator it = Config->Opers.begin(), it_end = Config->Opers.end(); it != it_end; ++it)
{
- int found = 0;
Anope::string nick = it->first, type = it->second;
NickAlias *na = findnick(nick);
if (na)
{
- /* We have to loop all users as some may be logged into an account but not a nick */
- for (patricia_tree<User *>::const_iterator uit = UserListByNick.begin(), uit_end = UserListByNick.end(); uit != uit_end; ++uit)
+ NickCore *nc = na->nc;
+ for (std::list<User *>::iterator uit = nc->Users.begin(); uit != nc->Users.end(); ++uit)
{
User *u2 = *uit;
- if (u2->Account() && u2->Account() == na->nc)
- {
- found = 1;
- if (na->nick.equals_ci(u2->nick))
- source.Reply(OPER_STAFF_FORMAT, '*', type.c_str(), u2->nick.c_str());
- else
- source.Reply(OPER_STAFF_AFORMAT, '*', type.c_str(), na->nick.c_str(), u2->nick.c_str());
- }
+ if (na->nick.equals_ci(u2->nick))
+ source.Reply(OPER_STAFF_FORMAT, '*', type.c_str(), u2->nick.c_str());
+ else
+ source.Reply(OPER_STAFF_AFORMAT, '*', type.c_str(), na->nick.c_str(), u2->nick.c_str());
}
- if (!found)
+ if (nc->Users.empty())
source.Reply(OPER_STAFF_FORMAT, ' ', type.c_str(), na->nick.c_str());
}
}
diff --git a/modules/core/os_szline.cpp b/modules/core/os_szline.cpp
index 7e9783c8d..4535335ed 100644
--- a/modules/core/os_szline.cpp
+++ b/modules/core/os_szline.cpp
@@ -174,7 +174,7 @@ class CommandOSSZLine : public Command
if (user && user->ip())
mask = user->ip.addr();
unsigned int affected = 0;
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
if ((*it)->ip() && Anope::Match((*it)->ip.addr(), mask))
++affected;
float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0;
diff --git a/modules/core/os_userlist.cpp b/modules/core/os_userlist.cpp
index 80448d35c..4f5c9d0f9 100644
--- a/modules/core/os_userlist.cpp
+++ b/modules/core/os_userlist.cpp
@@ -50,7 +50,7 @@ class CommandOSUserList : public Command
{
source.Reply(OPER_USERLIST_HEADER);
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
{
User *u2 = *it;
diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp
index b90ab0834..180b66463 100644
--- a/modules/extra/db_mysql.cpp
+++ b/modules/extra/db_mysql.cpp
@@ -745,7 +745,7 @@ class DBMySQL : public Module
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel));
}
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
{
CurBot = *it;
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, CurBot));
@@ -1315,7 +1315,7 @@ static void SaveDatabases()
me->RunQuery("TRUNCATE TABLE `anope_bs_core`");
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
me->OnBotCreate(*it);
me->RunQuery("TRUNCATE TABLE `anope_cs_info`");
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 824d931ff..9efc80b51 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -326,7 +326,7 @@ bool event_endburst(const Anope::string &source, const std::vector<Anope::string
if (!s)
throw CoreException("Got ENDBURST without a source");
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
{
User *u = *it;
if (u->server == s && !u->IsIdentified())
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index e24a5c0c4..dcfdbf298 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -312,7 +312,7 @@ bool event_endburst(const Anope::string &source, const std::vector<Anope::string
if (!s)
throw CoreException("Got ENDBURST without a source");
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
{
User *u = *it;
if (u->server == s && !u->IsIdentified())
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 634627715..8243e605a 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -580,7 +580,7 @@ bool event_eob(const Anope::string &source, const std::vector<Anope::string> &pa
if (s)
{
s->Sync(true);
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
{
User *u = *it;
if (u->server == s && !u->IsIdentified())
diff --git a/src/botserv.cpp b/src/botserv.cpp
index fac49761d..8c99cd2c4 100644
--- a/src/botserv.cpp
+++ b/src/botserv.cpp
@@ -34,7 +34,7 @@ void get_botserv_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
{
BotInfo *bi = *it;
diff --git a/src/init.cpp b/src/init.cpp
index fc53d6a2b..6ee84478a 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -57,7 +57,7 @@ void introduce_user(const Anope::string &user)
}
/* We make the bots go online */
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
{
User *u = *it;
diff --git a/src/logger.cpp b/src/logger.cpp
index 8198e29a2..191f977d4 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -36,7 +36,7 @@ void InitLogChannels(ServerConfig *config)
c->SetFlag(CH_LOGCHAN);
c->SetFlag(CH_PERSIST);
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
{
BotInfo *bi = *it;
diff --git a/src/main.cpp b/src/main.cpp
index 96488189f..c59fe7829 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -172,9 +172,11 @@ void do_restart_services()
if (quitmsg.empty())
quitmsg = "Restarting";
/* Send a quit for all of our bots */
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick);
+ for (bool next = it.next(); next;)
{
BotInfo *bi = *it;
+ next = it.next();
/* Don't use quitmsg here, it may contain information you don't want people to see */
ircdproto->SendQuit(bi, "Restarting");
@@ -214,9 +216,11 @@ static void services_shutdown()
if (started && UplinkSock)
{
/* Send a quit for all of our bots */
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick);
+ for (bool next = it.next(); next;)
{
BotInfo *bi = *it;
+ next = it.next();
/* Don't use quitmsg here, it may contain information you don't want people to see */
ircdproto->SendQuit(bi, "Shutting down");
@@ -228,8 +232,13 @@ static void services_shutdown()
ircdproto->SendSquit(Config->ServerName, quitmsg);
- while (!UserListByNick.empty())
- delete UserListByNick.front();
+ patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick);
+ for (bool next = uit.next(); next;)
+ {
+ User *u = *uit;
+ next = uit.next();
+ delete u;
+ }
}
SocketEngine->Process();
delete UplinkSock;
@@ -497,10 +506,11 @@ int main(int ac, char **av, char **envp)
FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect());
/* Clear all of our users, but not our bots */
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end;)
+ patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick);
+ for (bool next = it.next(); next;)
{
User *u = *it;
- ++it;
+ next = it.next();
if (u->server != Me)
delete u;
diff --git a/src/modes.cpp b/src/modes.cpp
index bc870cb1b..3a79409a6 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -78,7 +78,7 @@ void SetDefaultMLock(ServerConfig *config)
}
/* Apply the new modes to channels */
- for (patricia_tree<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<BotInfo *, ci::ci_char_traits>::iterator it(BotListByNick); it.next();)
{
BotInfo *bi = *it;
diff --git a/src/operserv.cpp b/src/operserv.cpp
index 610d24e61..c08a0e53d 100644
--- a/src/operserv.cpp
+++ b/src/operserv.cpp
@@ -599,10 +599,11 @@ XLine *SNLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
{
Anope::string rreason = "G-Lined: " + reason;
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end;)
+ patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick);
+ for (bool next = uit.next(); next;)
{
- User *user = *it;
- ++it;
+ User *user = *uit;
+ next = uit.next();
if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->realname, x->Mask))
kill_user(Config->ServerName, user, rreason);
@@ -729,10 +730,11 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
}
else
{
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end;)
+ patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick);
+ for (bool next = uit.next(); next;)
{
- User *user = *it;
- ++it;
+ User *user = *uit;
+ next = uit.next();
if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->nick, x->Mask))
kill_user(Config->ServerName, user, rreason);
diff --git a/src/servers.cpp b/src/servers.cpp
index 47a5e5389..ada6a8632 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -85,10 +85,11 @@ Server::~Server()
if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS))
{
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end;)
+ patricia_tree<User *, ci::ci_char_traits>::iterator uit(UserListByNick);
+ for (bool next = uit.next(); next;)
{
- User *u = *it;
- ++it;
+ User *u = *uit;
+ next = uit.next();
if (u->server == this)
{
diff --git a/src/sessions.cpp b/src/sessions.cpp
index aa5627529..7ff165346 100644
--- a/src/sessions.cpp
+++ b/src/sessions.cpp
@@ -53,7 +53,7 @@ void get_session_stats(long &count, long &mem)
count = SessionList.size();
mem = sizeof(Session) * SessionList.size();
- for (patricia_tree<Session *>::const_iterator it = SessionList.begin(), it_end = SessionList.end(); it != it_end; ++it)
+ for (patricia_tree<Session *>::iterator it(SessionList); it.next();)
{
Session *session = *it;
diff --git a/src/users.cpp b/src/users.cpp
index 488f143c8..970b70c64 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -682,7 +682,7 @@ void get_user_stats(long &count, long &mem)
{
count = mem = 0;
- for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
{
User *user = *it;