From 7790a7f98c56a16e6fed2bf51168881902880c62 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 21 Nov 2010 00:20:36 -0500 Subject: Allow the patricia tree to store non-pointers --- include/bots.h | 4 ++-- include/patricia.h | 22 +++++++++++----------- include/services.h | 2 +- include/users.h | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/bots.h b/include/bots.h index 2c1757a47..bbd40a236 100644 --- a/include/bots.h +++ b/include/bots.h @@ -12,8 +12,8 @@ class BotInfo; -extern CoreExport patricia_tree > BotListByNick; -extern CoreExport patricia_tree BotListByUID; +extern CoreExport patricia_tree > BotListByNick; +extern CoreExport patricia_tree BotListByUID; /** Flags settable on a bot */ diff --git a/include/patricia.h b/include/patricia.h index 73f5c22b9..fc28f4195 100644 --- a/include/patricia.h +++ b/include/patricia.h @@ -8,9 +8,9 @@ template struct patricia_elem { unsigned int bit; patricia_elem *up, *one, *zero; - typename std::list::iterator node; + typename std::list::iterator node; Anope::string key; - Data *data; + Data data; }; template > @@ -19,7 +19,7 @@ class patricia_tree Compare comp; patricia_elem *root; - std::list list; + std::list list; public: @@ -34,8 +34,8 @@ class patricia_tree this->erase(this->root->key); } - typedef typename std::list::iterator iterator; - typedef typename std::list::const_iterator const_iterator; + typedef typename std::list::iterator iterator; + typedef typename std::list::const_iterator const_iterator; inline iterator begin() { return this->list.begin(); } inline iterator end() { return this->list.end(); } @@ -43,13 +43,13 @@ class patricia_tree 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 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(); } - Data *find(const Anope::string &key) + Data find(const Anope::string &key) { size_t keylen = key.length(); patricia_elem *prev = NULL, *cur = this->root; @@ -72,7 +72,7 @@ class patricia_tree return NULL; } - void insert(const Anope::string &key, Data *data) + void insert(const Anope::string &key, Data data) { if (key.empty() || data == NULL) throw CoreExport; @@ -144,7 +144,7 @@ class patricia_tree newelem->node = this->list.begin(); } - Data *erase(const Anope::string &key) + Data erase(const Anope::string &key) { size_t keylen = key.length(); patricia_elem *prev = NULL, *cur = this->root; @@ -200,7 +200,7 @@ class patricia_tree this->list.erase(cur->node); - Data *data = cur->data; + Data data = cur->data; delete cur; return data; diff --git a/include/services.h b/include/services.h index 4d2401883..1ebdf608a 100644 --- a/include/services.h +++ b/include/services.h @@ -850,7 +850,7 @@ struct Exception /*************************************************************************/ -extern CoreExport patricia_tree SessionList; +extern CoreExport patricia_tree SessionList; struct Session { diff --git a/include/users.h b/include/users.h index d9f47792f..b6e8ec612 100644 --- a/include/users.h +++ b/include/users.h @@ -8,8 +8,8 @@ #ifndef USERS_H #define USERS_H -extern CoreExport patricia_tree > UserListByNick; -extern CoreExport patricia_tree UserListByUID; +extern CoreExport patricia_tree > UserListByNick; +extern CoreExport patricia_tree UserListByUID; class CoreExport ChannelStatus : public Flags { -- cgit