[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
        Analysis of the Example Code:
        ------------------------------------------------------------------
                In this special edition of the FAQ, you'll find three
        examples of how to use the FORCE memory allocation routines.

                The first is the iCopy program, which copies files from
        one place to another, but has an indicator that progresses as the
        copy progresses.  This is nice for those times when you have to
        copy the JD library to a floppy.  By the way, it's about twice
        as fast as the system copy because it uses a larger copy buffer,
        but you'll only notice it for large files.  To get the usage
        for the iCopy program just 'Make' it with Jmake and then type
        iCopy with no parameters.

                The second example is Fsort, which is a replacement of
        the system SORT command.  It started out as another example
        of how to use malloc() and calloc(), but I later decided to go
        all out and write a non-constrained heap manager that basically
        acts as a dynamic array (we'll come to this in a minute).  Like
        the system SORT command, Fsort's only function is to sort a
        sequence of strings.  Fsort does this by reading in the given
        files ( or the STD_IN handle if there are none ), and creating
        a giant array of pointers to each of the strings in the input.
        Then it sorts the array with a Quick_Sort algorithm, which is
        probably why it's twice as fast as the system SORT, which must
        use a slower algorithm such as the Shell_Sort, or the Insertion-
        Sort.

                The final example is a non-constrained heap library.  By
        non-constrained I mean that it doesn't keep a standard heap
        ordering property, and the items added are just appended to the
        current heap.  I realize that its tough to call it a heap if it
        really isn't one, but it wouldn't be too tough to modify the
        heap_insert() function to maintain the heap property.

                The source code and the library for the heap manager
        are included here, along with a heap.faq file which further
        details the usage of the library.


See Also: i_copy.prg fsort.prg
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson