Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!agate!pasteur!laertes!c164-bd From: c164-bd@laertes.uucp (John D. Mitchell) Newsgroups: comp.lang.pascal Subject: Re: Quick Directories/Better Sorts Message-ID: <9096@pasteur.Berkeley.EDU> Date: 20 Nov 90 17:33:42 GMT References: <9011180716.AA29001@gnu.AI.MIT.EDU> <9075@pasteur.Berkeley.EDU> <9011200557.AA07075@gnu.AI.MIT.EDU> Sender: news@pasteur.Berkeley.EDU Reply-To: c164-bd@laertes.UUCP (John D. Mitchell) Followup-To: comp.lang.pascal Distribution: usa Organization: University of California, Berkeley Lines: 46 In article <9011200557.AA07075@gnu.AI.MIT.EDU> Adams@J (jma@gnu.ai.mit.edu) writes: >johnm@cory.BERKLEY.EDU: > > You described of a "Heap sort" using the heap memory (I'd assume I would >have to set the heap up pretty high ( {$M} ).. I know in C you can set >a variable so that it makes itself in the heap storage,, can this be >done in pascal??? First, remember that a Heap (ala Heap Sort) is a Data structure while a heap (in the memory management of TP) is a run-time available, dynamic memory pool that is managed by TP (which uses DOS). In other words, the Heap data structure has nothing (inherently) to do with the heap of memory. In using a Heap Sort to sort N records (where the N records are probably way bigger than available memory (forget for the moment virtual memory)) in TP under DOS, you should probably set the {$M} stuff to whatever heap memory the rest of your application needs plus another 64Kb for the Heap (data structure). That's just a design decision. You could just as well allocated an array of records statically (i.e. at compile time) that would fit into 64Kb. In TP you use the new()/delete() or the getmem()/freemem() pairs of functions to allocate/free the heap (memory). (Note: don't mix the pairs!). Go and get (from wherever) a good data structures book and you should find a discussion about the Heap data structure and it's use in Heap sorts. There are good ones by A. Tannenbaum (sp?), N. Kruse, and R. Sedgewick to name a few. > Also: How can a DTA be set up (variables.. offsets, details mon!) > and how do I read it, is it just a sector read?? The DTA is just a struct (record) that is used by the FindFirst()/Next() functions (be it TP or DOS). It only exist in memory. I'm not a home so I can't give details now, but it is described in just about any DOS function reference and in the TP manuals. Basically you set the filename field to the file that you're looking for (normal DOS wildcards allowed), set the file attribute to the appropriate bit pattern for the types of files that you want (i.e. archive, system, directory, etc.) and FindFirst() does the rest. It's all in the manuals. A great discussion of directory traversal stuff (along with code) was in Turbo Technix a couple of years ago. I have a generic package of routines to traverse directories and find files written in TurboC. I could probably make it available. Good luck, John D. Mitchell johnm@cory.Berkeley.EDU