[MUD-Dev] TECH DGN: Re: a few mud server design questions (long)
Jon Lambert
tychomud at ix.netcom.com
Tue Jul 31 03:14:22 CEST 2001
Adam Martin wrote:
> Store the queue as an indexed list (or some other random-insertion
> point sorted data structure) and then jump in halfway and do >, <
> comparisons to jump to the right place. Insertion becomes O(
> log(n) ). Otherwise you aren't taking advantage of the fact that
> its sorted.
> Perhaps use a red-black tree, with a pointer to the item which is
> head of the queue.
FWIW......
#include <queue>
#include <deque>
#include <vector>
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
time_t x;
priority_queue<time_t, vector<time_t>, greater<time_t> > pq;
x = time(NULL);
pq.push(x);
Sleep(5000);
x = time(NULL);
pq.push(x);
cout << pq.top() << endl;
pq.pop();
cout << pq.top() << endl;
pq.pop();
return 0;
}
--
--* Jon A. Lambert - TychoMUD Email:jlsysinc at ix.netcom.com *--
--* Mud Server Developer's Page <http://tychomud.home.netcom.com> *--
--* If I had known it was harmless, I would have killed it myself.*--
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list