Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Block! v List! dilema...

From: chris:starforge at: 6-Apr-2001 19:09

Hi, Sorry about the waffle, the really important bit is near the end if you're not interested in background detail.. I'm currently working on a project called ROACH (the RebOl Assisted Critter Hunter - a web based bug report and tracking tool. Couldn't resist the acronym). Each ROACH installation can store bugs for a number of projects and each project has its own list of bugs. Bugs can be submitted and commented on by registered users and project admins can alter the status of bugs. If you have ever used a Bulletin Board system like UBB or phpBB you will be familiar with the structure: the front page lists all the projects in the system, selecting a project brings up the list of bugs for that project and clicking on a bug opens the details for the bug. Here's the important bit: the list of bugs for a project is held in a block. The code I use to display the list is: for offset 0 9 1 [ if (start + offset) <= (length? buglist) [ entry: pick buglist (start + offset) ; throw out a table entry to show the bug summary.. ] ] Using a block, I guess that pick for a block is an O(1) operation - a simple array lookup? Now the problem - when a user comments on a bug, or a project admin updates the status of a bug, I want that bug to be moved to the start of the buglist block. Remembering that this list could end up being long (probably into the thousands), removing an element in the middle and inserting it at the start would, I guess, be rather costly. The alternative is to use a list of course: that makes the move very quick, but what does it do to my display code? Is pick for list still O(1) - I guess it isn't? Given that displays vastly outnumber moves, should I just stick with blocks? Or does anyone have a better suggestion? Chris -- New sig in the works Explorer 2260, Designer and Coder -- Never hit a man with glasses. Hit him with a baseball bat.