Sage-ST ä

Sortlibx

Documentation

CompareKey QuickSort STRCompareKey STRQuickSort
Sort SortWithHandle




  procedure Sort
             (const NumberOfRecords : cardinal;
              const Swap            : SwapProc;
              const Compare         : CompareProc); stdcall;

  exports Sort name 'SortLibX_Sort';

  //*
  //  Sort - Sort an array of records.
  //
  //
  //  This routine provides the interface to the a quicksort algorithm.
  //  The user must provide two routines to make this interface work.
  //  First the user must provide a routine to swap two records of the
  //  array of records being sorted.  Second the user must provide a routine
  //  to compare the key fields of two records.  This routine must return an
  //  integer number result of the compare.  The user must also tell this
  //  routine how many records are to be sorted.  The user may then sort
  //  any record structure desired.
  //
  //  CALLING SEQUENCE -
  //
  //    Sort (NumberOfRecords, Swap, Compare);
  //
  //  ENTRY -
  //
  //    NumberOfRecords : cardinal
  //      The number of records to be sorted.
  //
  //    Swap : SwapProc
  //      A procedure to be used to swap records with.
  //
  //    Compare : CompareProc
  //      A procedure to be used to compare keys with.
  //




  procedure SortWithHandle
             (const handle          : pointer;
              const NumberOfRecords : cardinal;
              const Swap            : SwapHProc;
              const Compare         : CompareHProc); stdcall;

  exports SortWithHandle name 'SortLibX_SortWithHandle';

  //*
  //  SortWithHandle - Sort an array of records as defined by the handle.
  //
  //
  //  This routine provides the interface to the a quicksort algorithm.
  //  The user must provide a handle and two routines to make this interface work.
  //  First the user must provide an address of a structure that points to the
  //  data to be sorted.  This way the information being sorted doesn't have
  //  to be global as it needs to be with the regular sort.
  //  Second the user must provide a routine to swap two records of the
  //  array of records being sorted.  Third the user must provide a routine
  //  to compare the key fields of two records.  This routine must return an
  //  integer number result of the compare.  The user must also tell this
  //  routine how many records are to be sorted.  The user may then sort
  //  any record structure desired.
  //
  //  CALLING SEQUENCE -
  //
  //    SortWithHandle (Handle, NumberOfRecords, Swap, Compare);
  //
  //  ENTRY -
  //
  //    Handle : ADDRESS
  //      A handle that points to a user defined structure.  This pointer will then
  //      be passed to the compare and swap routines to allow them to work on non-global data.
  //
  //    NumberOfRecords : cardinal
  //      The number of records to be sorted.
  //
  //    Swap : SwapProc
  //      A procedure to be used to swap records with.
  //
  //    Compare : CompareProc
  //      A procedure to be used to compare keys with.
  //




  procedure QuickSort
             (var   Keys          : array of char;
              const NumberOfKeys  : cardinal;
              const XKeyStart     : cardinal;
              const XKeyLength    : cardinal;
              const XRecordLength : cardinal); overload; stdcall;

  exports QuickSort (var   Keys          : array of char;
                     const NumberOfKeys  : cardinal;
                     const XKeyStart     : cardinal;
                     const XKeyLength    : cardinal;
                     const XRecordLength : cardinal) name 'SortLibX_QuickSort';

  //*
  //  QuickSort - Sort an array of character keys.
  //
  //
  //  This routine sorts an array of characters which make up records.
  //  The records may be any length and must have a key in each record.
  //  This key may be any length.  The routine uses the very efficient
  //  quicksort algorithm.  Since the quicksort algorithm does not
  //  maintain the relative order of equal keys, the user must make the
  //  keys unique by appending a set of characters to the original keys.
  //  If the original order of equal keys is not important the user can
  //  ignore this point.
  //
  //  CALLING SEQUENCE -
  //
  //    QuickSort (Keys, NumberOfKeys, KeyStart, KeyLength, RecordLength);
  //
  //  ENTRY -
  //
  //    Keys : array of char
  //      An array of characters containing the records to sort.
  //
  //    NumberOfKeys : cardinal
  //      The number of records to be sorted.
  //
  //    KeyStart : cardinal
  //      The position of the first character of the key in the
  //      record.  One is assumed to be the first character
  //      position.
  //
  //    KeyLength : cardinal
  //      The number of bytes in the key.
  //
  //    RecordLength : cardinal
  //      The number of bytes in each record.
  //
  //  EXIT -
  //
  //    Keys : array of char
  //      A sorted array of records is returned.
  //




  procedure QuickSort
             (var   Keys          : string;
              const NumberOfKeys  : cardinal;
              const XKeyStart     : cardinal;
              const XKeyLength    : cardinal;
              const XRecordLength : cardinal); overload; stdcall;

  exports QuickSort (var   Keys          : string;
                     const NumberOfKeys  : cardinal;
                     const XKeyStart     : cardinal;
                     const XKeyLength    : cardinal;
                     const XRecordLength : cardinal) name 'SortLibX_STRQuickSort';

  //*
  //  STRQuickSort - See documentation of QuickSort.
  //




  function CompareKey
             (var   key1      : array of char;
              var   key2      : array of char;
              const KeyLength : cardinal) : integer; overload; stdcall;

  exports CompareKey (var   key1      : array of char;
                      var   key2      : array of char;
                      const KeyLength : cardinal) name 'SortLibX_CompareKey';

  //*
  //  CompareKey - Compare two keys for equality.
  //
  //
  //  This routine compares two keys made up of arrays of characters.
  //  The routine returns to the user a zero if the arrays are equal,
  //  a minus one if array one is less than array two and a plus one
  //  if array one is greater than array two.
  //
  //  CALLING SEQUENCE -
  //
  //    I := CompareKey (Key1, Key2, KeyLength)
  //
  //  ENTRY -
  //
  //    Key1 : array of char
  //      An array of characters containing the first key.
  //
  //    Key2 : array of char
  //      An array of characters containing the second key.
  //
  //    KeyLength : cardinal
  //      The number of bytes in each array to compare.
  //
  //  EXIT -
  //
  //    I : integer
  //      A flag indicating the result of the compare.  If array
  //      one is less than array two then 'I' is -1.  If array
  //      one is greater than array two then 'I' is 1.  If array
  //      one is equal to array two then 'I' is 0.
  //




  function CompareKey
             (var   key1      : string;
              var   key2      : string;
              const KeyLength : cardinal) : integer; overload; stdcall;

  exports CompareKey (var   key1      : string;
                      var   key2      : string;
                      const KeyLength : cardinal) name 'SortLibX_STRCompareKey';

  //*
  //  STRCompareKey - See documentation of CompareKey.
  //




Send mail to   warren.merrill@inl.gov with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance