Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

•Re: Data Structure needed for Event Queue

by merlyn (Sage)
on May 27, 2002 at 16:38 UTC ( #169615=note: print w/replies, xml ) Need Help??


in reply to Data Structure needed for Event Queue

You could always just shove it into a database with an index. {grin}

I'm not a CS expert, but I think a B-tree might be the right structure (see http://perl.plover.com/BTree/). Pure Perl B-Tree managers are available, such as Tree and Btrees. I think even a Berkeley DB can be stored "in core" with the BerkeleyDB module, and there's a B-Tree version of that.

-- Randal L. Schwartz, Perl hacker


update: yes, with DB_File, you can set up an in-memory DB (use undef for the filename), and with the right comparison callback, you get basic operations like
## add a new $nextevent at $time: push @{$db{$time}}, $nextevent; ## get the lowest event list keys %db; # reset pointer my ($time, $events) = each %db; # lowest events

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://169615]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2022-05-25 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?