[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

20334: RE: [MUD-Dev] TECH DGN: Re: a few mud server design questions (long)

[Full Header] [Plain Text]
From: "Jon Lambert" <tychomud@ix.netcom.com>
Newsgroups: nu.kanga.list.mud-dev
Date: Tue, 31 Jul 2001 03:14:22 -0400
References: [1]
Organization: Kanga.Nu
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@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@kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev