Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!ames!pasteur!cinna!c164-bd From: c164-bd@cinna.uucp (John D. Mitchell) Newsgroups: comp.lang.pascal Subject: Re: Quick Directories/Better Sorts Message-ID: <9075@pasteur.Berkeley.EDU> Date: 20 Nov 90 03:33:11 GMT References: <9011180716.AA29001@gnu.AI.MIT.EDU> Sender: news@pasteur.Berkeley.EDU Reply-To: c164-bd@cinna.UUCP (John D. Mitchell) Followup-To: comp.lang.pascal Distribution: usa Organization: University of California, Berkeley Lines: 37 In article <9011180716.AA29001@gnu.AI.MIT.EDU> Adams@J (jma@gnu.ai.mit.edu) writes: >Is there a way to do the reproduce FindFirst() + FindNext() commands >using Inline statements or something else to make them FASTER? I'm writing The reason it's so slow is that TP's FindFirst()/Next() is that it switches the Disk Transfer Area (DTA) to the one you give it in the FindFirst() call each time and then restores it after each call. It might even do some other housekeeping stuff. You can get around this nasty overhead be setting up your own dta and directly use the DOS Findfirst/next functions. I have written a generic directory/file traversal package and then used that for a bunch of little disk utilities. The speed/responsiveness of the utilities has been plenty quick enough for me (and I am into speed :-)) , but I have seen other people's utilities that are faster. There are ways that you could directly access the disk tables (using 'undocumented' DOS calls). I haven't ever bothered to figure that stuff out. > >II. > >I've got a record structure stored on disk, (let's say 5000) records. I'd like >to be able to get those 5000 records into MEMORY. Right now, I keep running >out of stack space. (structure too large).. If possible, can I access >other memory in pascal (to store my data) and once I run out of memory, >can I sort on disk at highspeed... One possible Idea I had was to use an >Index in memory (hell, 5000-10000 Integers in pascal shouldn't be too memory- >intensive...) and then sort the "Index" array in memory... but I can't get One fairly easy to implement solution would be to use a HeapSort with the in memory heap some size closest to the magical 64K boundary. You can find a good description of this in Algorithms by Robert Sedgewick. Be sure to get the second edition. I'd probably do it this way. Good luck, John D. Mitchell johnm@cory.Berkeley.EDU