%! % SOME FAST AND EFFICIENT POSTSCRIPT SORT UTILITIES % ================================================= % Copyright c 2003 by Don Lancaster and Synergetics, Box 809, Thatcher, AZ, 85552 % (428) 428-4073 don@tinaja.com http://www.tinaja.com % Consulting services available per http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights fully reserved. % Personal use permitted provided header and entire file remains intact. % Linking welcome. Reposting expressly forbidden. % version 1.06 % These fast and efficient PostScript sorting utilities are further described % in http://www.tinaja.com/glib/presort.pdf in our GuruGram library. % Described are a speed optimized alpha bubble sort and a bin presorter that % dramatically further increases sorting speeds. Typical sort times for % 400 items on a 800 MHz Pentium are 0.250 seconds for bubble and 0.020 % seconds for bubble with presort. % The ready-to-run routines appear below with some test loops. They may be % extracted and modified for your use. % Be sure to use a Distiller Job Option that does not add additional processing % times for special features. % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is recommended but not required % for this program. % After obvious location mods, uncomment ONE of the following two lines: % (C:\\windows\\desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def % Uncomment next line if gonzo is in use % guru % activate gonzo utilities % Stopwatch utilities extracted from Gonzo... % ============================ % timing utilities. use stopwatchon and stopwatchoff for simple % one shot timing. For multiple time totals, use resettimer % starttimer stoptimer ... starttimer stoptimer reporttimer /stopwatchoff {stoptimer reporttimer} def % for single shots /stopwatchon {resettimer starttimer} def % for single shots /reporttimer {mytime 1000 div (\rElapsed time: ) print 20 string cvs print ( seconds.\r) print flush} def % to host /resettimer {/mytime 0 def} def % reset timer /starttimer {usertime /mytimenow exch def} def % add to time so far /stoptimer {usertime mytimenow sub /mytime exch mytime add def} def % for multiple timing intervals % ========================== % ========================== % standard data /stdat is a collection of 271 strings for testing /stddat [(Tca785 pdf) (Humidity measurement principles tutorial pdf) (Fluxgate) (Its a gas) (Bargain pages) (12C508 WAKEUP) (Pic sinewave) (Guru s timeline) (Postscript transparency) (Cubic spline) (Breath alcohol detector ) (Biomedical Instrumentation tutorial) (Pdf_sec.ps) (Rice and Tesla turbine) (Bidding scams live auction) (412 xerox tech mode) (Earth inclination magnetic north tutorial) (Spline math) (Surplus dilbert books) (NE5520) (Mitutoyo scale bcd format) (Receiver strong 4355 version download) (Hydrogen energy) (Tv extend drill cable coaxial fish) (Bytes Transferred mismatch webtrends) (TTL FM LEBANON) (COS objects) (Plating current efficiencies surface geometries) (Delete plug-in adobe acrobat) (Filter cookbook download) (Acrobat distiller) (Watermark.api Acrobat) (PSD Position Sensitive Detector) (Mc145447) (Save html pdf netscape) (Max126 ) (Cryogenic pumps tutorials) (Genlocking hardware) (Stratasys auction) (Superregenerative detector) (Uniscan scheme download) (Farenheit Rankine Kelvin Centigrade) (SVG Adobe acrobat) (Top-octave generator) (Hydrogen energy) (Polywater pole setting foam) (Pic 16f84 products) (PostScript ADDfont) (On-demand book publishing low volume) (Acrobat Distiller) (Cubic spline) (Cubic bezier surface) (Simplify postscript) (Tesla autobiography ebooks download) (3 phase power equation) (Cubic spline) (Html full screen) (Peltier cells vehicle air conditioning ) (Http://www.tinaja.com/glib/pstrans.pdf) (Handy numbers list country codes) (Images jpg en postscript) (Gs append pdf side) (Acrobat security printing) (Santa bitmaps) (16f84 gateway) (PIC development boards vendors) (TAS455 Repair) (NURBS math) (Pic microcontroller encryption project ) (Example of postscript) (Arizona source code pic) (Adobe acrobat cooltype bgr) (SCR FIRING CIRCUIT TUTORIAL) (Voice dimmer scheme) (Crest factor) (Electronic compass pic16f84) (Kty schematic) (Flutterwumper) (Chain codes) (Loctite luminescent) (Ecg true type font) (Bezier curve) (CTS DSR) (Microprocessor pic) (Acrobat distiller) (Bitmap directory) (Micro cookbook I ) (HYDROGEN) (Genie psrt) (Archaeomagnetism ) (PWM Modulation and Demodulation Circuit Design) (Hv2405e) (Byte range acrobat) (Html tutorial redirecting) (Binary chain code) (Content-range http cgi) (SPLINE CUBIC) (UGN3013) (Metering digital speed rotations of motors ) (Related:www.tinaja.com/glib/hackar1.pdf) (Acrobat distiller) (Tv repairing pdf ) (Lcd font editor ) (HTML referral) (Video output spec db15 canon ) (Problem searching ghostscript acrobat problem) (Techniks and methods of System Analysis) (Binary chain code ) (Three inverters programable pic) (Distiller error printer) (Automatic voltage regulator fuzzy pdf) (Thomson rr 600 cd user manual) (Binary chain encoder) (Bezier cubic java) (Compound gauges) (Striking voltage fluorescent service ) (BMP file format ) (Visual Basic Gauss Jordan ) (Pfa font ) (Transmission line transformers) (Bargain pages) (IBM patents pdf) (Allpass opamp) (Hide save on acrobat) (Conversion degrees compass cad) (Http://www.tinaja.com/glib/resbar02.pdf) (Ds1624 ) (Install pfm adobe) (Hydrogen fuel) (Speed meter digital pic) (Thumbnail pdf file in html) (Max631 application) (Hydrogen electrolysis) (Rewiring phone lines tutorial) (Photoshop 6 tutorial filetype:pdf) (74hc02 code radio) (Justified fonts ) (Postscript bdef) (Acrobat distiller) (74HC02 pinouts) (SI 3241 voltage regulator) (Uhr 16F84) (Acrobat distiller) (Microchip pic software ) (Fuel cell handbook) (Postscript font cache distiller) (Square word ghostscript pdf problem) (Adobe acrobat editor) (PIC robots) (Hot rolling of steel tutorials free) (Info on hydrogen) (Adobe acrobat software development kit) (Java spline control point) (Led lazer pinouts) (Acrobat distiller) (Print acrobat distiller) (Hydrogen fuel) (Ba1404 spec) (Copyright symbol encoding) (Slow start 6100c scanner) (Adobe acrobat 5 download) (Copyright symbol html encoding) (Related:www.solarbotics.net/library/circuits/bot_head_pshead.html) (Pdf xobjects) (IC 4013 Tutorial) (Micro Cookbook updates) (Using adobe acrobat distiller) (3d models Santa Claus) (Bargain Pages) (Bitmap resampling code) (Enter Password in 5 seconds or this machine will self destruct and destroy everything in a 50 foot radius. 5....4....3....2...1.....BOOM!!!!) (Surplus fiberscope) (Aircraft skin scews) (Pdf flate compression code) (Get integers out of string) (Mac interface circuit pic) (Free ebook for download attenuators) (My Ebay) (Acrobat Distiller download) (Dissolvable laundry bags) (Sum stereo mono schematics) (Electret for steady state pressure) (Hydrogen fuel ) (Tektronix 2215A) (Pic tools) (Pic tutorials) (Single sideband, polyphase networks) (Web friendly colors) (Microprocessor pic) (Ghostscript acrobat password) (Microwave ) (Curve slope spline) (Adobe acrobat the plugin initialize.) (Html tutorial redirection page) (Microcontroller tutorial) (Postscript reader .pfa) (Understanding wavelets) (Spline) (AC motor control pic microcontroller) (Backwards phone lookup) (Adobe acrobat http options 5) (Rf variable attenuator pot) (Cubic spline) (Bezier curve length) (.bin archive repair) (Adobe pdfmark Reference Manual) (Basic stamp midi footswitch) (Drmo williamsburg) (Avi files inductive position encoder) (Hack keynet internet cards) (Copyright symbols) (Santa Claus International Resourcing inc.) (Curve fitting power) (Acrobat distiller) (Bitmap font generator) (Sign changer circuit analog) (Best metals for thermocouples) (Triac 603) (Vcr controller) (Samples ic free electronics semiconductors) (Pendulum vacuum valve) (Buckyball capacitor) (\(PIC, microcontroller\) \(video\)) (THIOKOL DYNACHEM MODEL 300) (Quadrants for sines and cosines) (Adobe byte range ) (Suspa gas spring sell) (Acrobat distiller tutorial ) (Robotics projects stepper pic 16f84) (POSTSCRIPT DISTILLER) (What is acrobat distiller) (QMS Magic Color 330 fuser rollers) (Transformer railroad antique schematics) (RFID handbook) (Ignition system pic microcontroller) (Convert old Aldus Freehand files) (Genie garage door circuits) (Old frothingslosh pale stale ale) (Fundamentals of solar energy) (Chirp radar) (Dummy text to use in website samples) (Bezier algorithms ) (Tutorials for postscript) (Email contact of don) (Bmp file format ) (Wein-bridge oscillator with agc) (Converting JPEG to PDF) (Postscript viewer) (Shake light piezo) (Digimatic bcd format) (Turbine cars electric hybrid ) (Magnetic sensors pavel ripka) (Postscript curveto) (Piezoelectric ring bender) (Don lancaster) (Magnetic sensors pavel ripka fluxgate ext pdf) (Iron-on printing t-shirts va fairfax) (Copyright symbols) (Precision humidity gauge probe) (Why do people use primary research) (Bookbinding fabric glue soak ) (On demand publishing ) (Bezier curves) (Shareware for Wavelet analysis) (M65830 schematic) (General Radio universal filter 1952) (Total reflection x-ray fluorescence tutorial) (Mouse bot pic) (Zero Crossing Triac Driver Output Optocoupler) (Multimeter eico model 249 ) (Basic stamp heart rate )] store % ============= stddat length == % report strings being tested % ============= % A speed optimized alphanumeric bubble sorter /alphabubblesort2 { /curmat1 exch store % save input string array curmat1 length 1 sub -1 1 { % outer count down unsorted item loop curmat1 0 get % initial PREVIOUS to stack top exch 1 exch 1 exch { % start inner bubble loop /posn exch store % save position curmat1 posn get % get PRESENT string 2 copy lt {exch}if % swap PRESENT and PREVIOUS? curmat1 exch posn 1 sub exch put % save new PREVIOUS to array } for % finish inner bubble loop curmat1 exch posn exch put % save last string } for % finish outer count down item loop curmat1 } bind store % exit with string array on stack % ============== % pre sort data into bins % ========================================================== % If you are doing many repeat timings to improve stopwatch accuracy, temporarily % disable vm reclaimation by uncommenting the next line... -1 vmreclaim % Needed only if you are doing high repeat stopwatch timings % Disabling vm reclamation should NOT be required for normal program use. % ============================================================ stopwatchon % start timing 100 { % BE SURE TO DIVIDE TIME RESULTS BY REPEAT TRIPS % do loop /matmat mark 256 {[]} repeat ] store % make 256 bin array stddat { dup % get & save each string in turn dup 0 get /curint exch store % save ASCII value of first character mark exch matmat % start to expand needed bin curint get aload pop ] % complete needed bin new definition matmat exch curint exch put % define new bin } forall mark % start final sorted arrray for report matmat { dup % get each USED bin in turn length 1 ge { % does bin have any strings in it? dup length 2 ge { % at least two strings in bin? alphabubblesort2{ }forall}if % yes, bubble sort bin to stack }{pop} ifelse % no, add sole bin string to stack } forall ] % end final sorted array for report } repeat % for repeated timing only stopwatchoff % report time {==} forall % report sorted strings % report alpha sorted strings 0 vmreclaim % fix possible vm pileup (\n\n\n\n\noldbubble \n\n\n) print flush % separate log results % Compare against no-bins bubble sort... stopwatchon % start timer 100 { % BE SURE TO DIVIDE TIME RESULTS BY REPEAT TRIPS % do loop stddat alphabubblesort2 } repeat stopwatchoff % report time {==} forall % report sorted strings % EOF