home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / utils / ring.elc < prev    next >
Emacs Compiled Lisp  |  1995-08-29  |  2.4 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text


This file was processed as: Emacs Compiled Lisp (other/emacsCompiledLisp).
This format is not currently supported by dexvert.

ConfidenceProgramDetectionMatch TypeSupport
1% dexvert Emacs Compiled Lisp (other/emacsCompiledLisp) magic Unsupported
1% dexvert Combustion 2 Particle Library (other/combustion2ParticleLibrary) ext Unsupported
100% file Emacs/XEmacs v19 byte-compiled Lisp data default
99% file data default
100% TrID Emacs/XEmacs byte-compiled Lisp (generic) default
100% xdgMime text/x-emacs-lisp default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 3b 45 4c 43 13 00 00 00 | 0a 3b 3b 3b 20 63 6f 6d |;ELC....|.;;; com|
|00000010| 70 69 6c 65 64 20 62 79 | 20 63 74 68 6f 6d 70 40 |piled by| cthomp@|
|00000020| 77 69 6c 6c 6f 77 2e 63 | 73 2e 75 69 75 63 2e 65 |willow.c|s.uiuc.e|
|00000030| 64 75 20 6f 6e 20 54 75 | 65 20 41 75 67 20 32 39 |du on Tu|e Aug 29|
|00000040| 20 31 34 3a 32 37 3a 30 | 39 20 31 39 39 35 0a 3b | 14:27:0|9 1995.;|
|00000050| 3b 3b 20 66 72 6f 6d 20 | 66 69 6c 65 20 2f 78 65 |;; from |file /xe|
|00000060| 6d 61 63 73 2f 78 65 6d | 61 63 73 2d 31 39 2e 31 |macs/xem|acs-19.1|
|00000070| 33 2d 72 65 6c 65 61 73 | 65 2f 65 64 69 74 6f 72 |3-releas|e/editor|
|00000080| 2f 6c 69 73 70 2f 75 74 | 69 6c 73 2f 72 69 6e 67 |/lisp/ut|ils/ring|
|00000090| 2e 65 6c 0a 3b 3b 3b 20 | 65 6d 61 63 73 20 76 65 |.el.;;; |emacs ve|
|000000a0| 72 73 69 6f 6e 20 31 39 | 2e 31 33 20 58 45 6d 61 |rsion 19|.13 XEma|
|000000b0| 63 73 20 4c 75 63 69 64 | 2e 0a 3b 3b 3b 20 62 79 |cs Lucid|..;;; by|
|000000c0| 74 65 63 6f 6d 70 20 76 | 65 72 73 69 6f 6e 20 32 |tecomp v|ersion 2|
|000000d0| 2e 32 35 3b 20 31 2d 53 | 65 70 2d 39 34 2e 0a 3b |.25; 1-S|ep-94..;|
|000000e0| 3b 3b 20 6f 70 74 69 6d | 69 7a 61 74 69 6f 6e 20 |;; optim|ization |
|000000f0| 69 73 20 6f 6e 2e 0a 3b | 3b 3b 20 74 68 69 73 20 |is on..;|;; this |
|00000100| 66 69 6c 65 20 75 73 65 | 73 20 6f 70 63 6f 64 65 |file use|s opcode|
|00000110| 73 20 77 68 69 63 68 20 | 64 6f 20 6e 6f 74 20 65 |s which |do not e|
|00000120| 78 69 73 74 20 69 6e 20 | 45 6d 61 63 73 20 31 38 |xist in |Emacs 18|
|00000130| 2e 0a 0a 28 69 66 20 28 | 61 6e 64 20 28 62 6f 75 |...(if (|and (bou|
|00000140| 6e 64 70 20 27 65 6d 61 | 63 73 2d 76 65 72 73 69 |ndp 'ema|cs-versi|
|00000150| 6f 6e 29 0a 09 20 28 6f | 72 20 28 61 6e 64 20 28 |on).. (o|r (and (|
|00000160| 62 6f 75 6e 64 70 20 27 | 65 70 6f 63 68 3a 3a 76 |boundp '|epoch::v|
|00000170| 65 72 73 69 6f 6e 29 20 | 65 70 6f 63 68 3a 3a 76 |ersion) |epoch::v|
|00000180| 65 72 73 69 6f 6e 29 0a | 09 20 20 20 20 20 28 73 |ersion).|. (s|
|00000190| 74 72 69 6e 67 2d 6c 65 | 73 73 70 20 65 6d 61 63 |tring-le|ssp emac|
|000001a0| 73 2d 76 65 72 73 69 6f | 6e 20 22 31 39 22 29 29 |s-versio|n "19"))|
|000001b0| 29 0a 20 20 20 20 28 65 | 72 72 6f 72 20 22 54 68 |). (e|rror "Th|
|000001c0| 69 73 20 66 69 6c 65 20 | 77 61 73 20 63 6f 6d 70 |is file |was comp|
|000001d0| 69 6c 65 64 20 66 6f 72 | 20 45 6d 61 63 73 20 31 |iled for| Emacs 1|
|000001e0| 39 2e 22 29 29 0a 0a 28 | 66 73 65 74 20 27 72 69 |9."))..(|fset 'ri|
|000001f0| 6e 67 2d 70 20 23 5b 28 | 78 29 20 22 08 3a ad 95 |ng-p #[(|x) ".:..|
|00000200| 08 40 a8 ad 90 08 41 3a | ad 8b 08 41 40 a8 ad 85 |.@....A:|...A@...|
|00000210| c1 08 41 41 21 87 22 20 | 5b 78 20 76 65 63 74 6f |..AA!." |[x vecto|
|00000220| 72 70 5d 20 32 20 22 5c | 0a 52 65 74 75 72 6e 73 |rp] 2 "\|.Returns|
|00000230| 20 74 20 69 66 20 58 20 | 69 73 20 61 20 72 69 6e | t if X |is a rin|
|00000240| 67 3b 20 6e 69 6c 20 6f | 74 68 65 72 77 69 73 65 |g; nil o|therwise|
|00000250| 2e 22 5d 29 0a 28 66 73 | 65 74 20 27 6d 61 6b 65 |."]).(fs|et 'make|
|00000260| 2d 72 69 6e 67 20 23 5b | 28 73 69 7a 65 29 20 22 |-ring #[|(size) "|
|00000270| c0 89 c1 5c 6e c3 5c 22 | 42 42 87 22 20 5b 30 20 |...\n.\"|BB." [0 |
|00000280| 6d 61 6b 65 2d 76 65 63 | 74 6f 72 20 73 69 7a 65 |make-vec|tor size|
|00000290| 20 6e 69 6c 5d 20 35 20 | 22 5c 0a 4d 61 6b 65 20 | nil] 5 |"\.Make |
|000002a0| 61 20 72 69 6e 67 20 74 | 68 61 74 20 63 61 6e 20 |a ring t|hat can |
|000002b0| 63 6f 6e 74 61 69 6e 20 | 53 49 5a 45 20 65 6c 65 |contain |SIZE ele|
|000002c0| 6d 65 6e 74 73 2e 22 5d | 29 0a 28 66 73 65 74 20 |ments."]|).(fset |
|000002d0| 27 72 69 6e 67 2d 69 6e | 73 65 72 74 2d 61 74 2d |'ring-in|sert-at-|
|000002e0| 62 65 67 69 6e 6e 69 6e | 67 20 23 5b 28 72 69 6e |beginnin|g #[(rin|
|000002f0| 67 20 69 74 65 6d 29 20 | 22 08 41 41 89 19 47 1a |g item) |".AA..G.|
|00000300| 08 40 1b 08 41 40 1c 5c | 6e 0c 54 5e 14 c5 0b 5c |.@..A@.\|n.T^...\|
|00000310| 6e 5c 22 13 09 0b 0e 06 | 49 88 08 0b a0 88 08 41 |n\".....|I......A|
|00000320| 0c a0 2c 87 22 20 5b 72 | 69 6e 67 20 76 65 63 20 |..,." [r|ing vec |
|00000330| 76 65 63 6c 65 6e 20 68 | 64 20 6c 6e 20 72 69 6e |veclen h|d ln rin|
|00000340| 67 2d 6d 69 6e 75 73 31 | 20 69 74 65 6d 5d 20 34 |g-minus1| item] 4|
|00000350| 20 22 5c 0a 41 64 64 20 | 74 6f 20 52 49 4e 47 20 | "\.Add |to RING |
|00000360| 74 68 65 20 69 74 65 6d | 20 49 54 45 4d 2e 20 20 |the item| ITEM. |
|00000370| 41 64 64 20 69 74 20 61 | 74 20 74 68 65 20 66 72 |Add it a|t the fr|
|00000380| 6f 6e 74 20 28 74 68 65 | 20 65 61 72 6c 79 20 65 |ont (the| early e|
|00000390| 6e 64 29 2e 22 5d 29 0a | 28 66 73 65 74 20 27 72 |nd)."]).|(fset 'r|
|000003a0| 69 6e 67 2d 70 6c 75 73 | 31 20 23 5b 28 69 6e 64 |ing-plus|1 #[(ind|
|000003b0| 65 78 20 76 65 63 6c 65 | 6e 29 20 22 08 c1 5c 5c |ex vecle|n) "..\\|
|000003c0| 89 1a 0b 55 ab 83 c4 aa | 81 5c 6e 29 87 22 20 5b |...U....|.\n)." [|
|000003d0| 69 6e 64 65 78 20 31 20 | 6e 65 77 2d 69 6e 64 65 |index 1 |new-inde|
|000003e0| 78 20 76 65 63 6c 65 6e | 20 30 5d 20 33 20 22 5c |x veclen| 0] 3 "\|
|000003f0| 0a 49 4e 44 45 58 2b 31 | 2c 20 77 69 74 68 20 77 |.INDEX+1|, with w|
|00000400| 72 61 70 61 72 6f 75 6e | 64 22 5d 29 0a 28 66 73 |raparoun|d"]).(fs|
|00000410| 65 74 20 27 72 69 6e 67 | 2d 6d 69 6e 75 73 31 20 |et 'ring|-minus1 |
|00000420| 23 5b 28 69 6e 64 65 78 | 20 76 65 63 6c 65 6e 29 |#[(index| veclen)|
|00000430| 20 22 08 c1 55 ab 83 5c | 6e aa 81 08 c3 5a 87 22 | "..U..\|n....Z."|
|00000440| 20 5b 69 6e 64 65 78 20 | 30 20 76 65 63 6c 65 6e | [index |0 veclen|
|00000450| 20 31 5d 20 32 20 22 5c | 0a 49 4e 44 45 58 2d 31 | 1] 2 "\|.INDEX-1|
|00000460| 2c 20 77 69 74 68 20 77 | 72 61 70 61 72 6f 75 6e |, with w|raparoun|
|00000470| 64 22 5d 29 0a 28 66 73 | 65 74 20 27 72 69 6e 67 |d"]).(fs|et 'ring|
|00000480| 2d 6c 65 6e 67 74 68 20 | 23 5b 28 72 69 6e 67 29 |-length |#[(ring)|
|00000490| 20 22 08 41 40 87 22 20 | 5b 72 69 6e 67 5d 20 31 | ".A@." |[ring] 1|
|000004a0| 20 22 5c 0a 4e 75 6d 62 | 65 72 20 6f 66 20 65 6c | "\.Numb|er of el|
|000004b0| 65 6d 65 6e 74 73 20 69 | 6e 20 74 68 65 20 72 69 |ements i|n the ri|
|000004c0| 6e 67 2e 22 5d 29 0a 28 | 62 79 74 65 2d 63 6f 64 |ng."]).(|byte-cod|
|000004d0| 65 20 22 c0 c1 4d 88 c2 | c3 4d 87 22 20 5b 72 69 |e "..M..|.M." [ri|
|000004e0| 6e 67 2d 65 6d 70 74 79 | 2d 70 20 23 5b 28 72 69 |ng-empty|-p #[(ri|
|000004f0| 6e 67 29 20 22 08 41 40 | c1 55 87 22 20 5b 72 69 |ng) ".A@|.U." [ri|
|00000500| 6e 67 20 30 5d 20 32 5d | 20 72 69 6e 67 2d 69 6e |ng 0] 2]| ring-in|
|00000510| 64 65 78 20 23 5b 28 69 | 6e 64 65 78 20 68 65 61 |dex #[(i|ndex hea|
|00000520| 64 20 72 69 6e 67 6c 65 | 6e 20 76 65 63 6c 65 6e |d ringle|n veclen|
|00000530| 29 20 22 c0 09 5c 6e 5c | 22 11 c0 0b 5c 6e 09 5a |) "..\n\|"...\n.Z|
|00000540| 5c 5c 53 0c 5c 22 87 22 | 20 5b 6d 6f 64 20 69 6e |\\S.\"."| [mod in|
|00000550| 64 65 78 20 72 69 6e 67 | 6c 65 6e 20 68 65 61 64 |dex ring|len head|
|00000560| 20 76 65 63 6c 65 6e 5d | 20 34 5d 5d 20 32 29 0a | veclen]| 4]] 2).|
|00000570| 28 66 73 65 74 20 27 72 | 69 6e 67 2d 69 6e 73 65 |(fset 'r|ing-inse|
|00000580| 72 74 20 23 5b 28 72 69 | 6e 67 20 69 74 65 6d 29 |rt #[(ri|ng item)|
|00000590| 20 22 08 41 41 89 19 47 | 1a 08 40 1b 08 41 40 1c | ".AA..G|..@..A@.|
|000005a0| 09 c5 0b 0c 5c 5c 5c 6e | 5c 22 0e 06 49 0c 5c 6e |....\\\n|\"..I.\n|
|000005b0| 55 ab 89 08 c7 0b 5c 6e | 5c 22 a0 88 aa 86 08 41 |U.....\n|\".....A|
|000005c0| 0c 54 a0 88 2c 87 22 20 | 5b 72 69 6e 67 20 76 65 |.T..,." |[ring ve|
|000005d0| 63 20 76 65 63 6c 65 6e | 20 68 64 20 6c 6e 20 6d |c veclen| hd ln m|
|000005e0| 6f 64 20 69 74 65 6d 20 | 72 69 6e 67 2d 70 6c 75 |od item |ring-plu|
|000005f0| 73 31 5d 20 36 20 22 5c | 0a 49 6e 73 65 72 74 20 |s1] 6 "\|.Insert |
|00000600| 6f 6e 74 6f 20 72 69 6e | 67 20 52 49 4e 47 20 74 |onto rin|g RING t|
|00000610| 68 65 20 69 74 65 6d 20 | 49 54 45 4d 2c 20 61 73 |he item |ITEM, as|
|00000620| 20 74 68 65 20 6e 65 77 | 65 73 74 20 28 6c 61 73 | the new|est (las|
|00000630| 74 29 20 69 74 65 6d 2e | 0a 49 66 20 74 68 65 20 |t) item.|.If the |
|00000640| 72 69 6e 67 20 69 73 20 | 66 75 6c 6c 2c 20 64 75 |ring is |full, du|
|00000650| 6d 70 20 74 68 65 20 6f | 6c 64 65 73 74 20 69 74 |mp the o|ldest it|
|00000660| 65 6d 20 74 6f 20 6d 61 | 6b 65 20 72 6f 6f 6d 2e |em to ma|ke room.|
|00000670| 22 5d 29 0a 28 66 73 65 | 74 20 27 72 69 6e 67 2d |"]).(fse|t 'ring-|
|00000680| 72 65 6d 6f 76 65 20 23 | 5b 28 72 69 6e 67 20 26 |remove #|[(ring &|
|00000690| 6f 70 74 69 6f 6e 61 6c | 20 69 6e 64 65 78 29 20 |optional| index) |
|000006a0| 22 c0 09 21 ab 84 c2 c3 | 21 87 09 40 1c 09 41 40 |"..!....|!..@..A@|
|000006b0| 1d 09 41 41 89 1e 06 47 | 1e 07 c8 0c 0d 5c 5c 53 |..AA...G|.....\\S|
|000006c0| 0e 07 5c 22 1e 09 ca 1e | 0b 0e 0c ac 84 0d 53 16 |..\"....|......S.|
|000006d0| 0c cd 0e 0c 0c 0d 0e 07 | 24 16 0c 0e 06 0e 0c 48 |........|$......H|
|000006e0| 16 0b 0e 0c 0e 09 55 ac | 9a 0e 06 0e 0c 0e 06 ce |......U.|........|
|000006f0| 0e 0c 0e 07 5c 22 48 49 | 88 ce 0e 0c 0e 07 5c 22 |....\"HI|......\"|
|00000700| 89 16 0c aa 61 0e 06 0e | 09 ca 49 88 09 41 0d 53 |....a...|..I..A.S|
|00000710| a0 88 0e 0b 2e 06 87 22 | 20 5b 72 69 6e 67 2d 65 |......."| [ring-e|
|00000720| 6d 70 74 79 2d 70 20 72 | 69 6e 67 20 65 72 72 6f |mpty-p r|ing erro|
|00000730| 72 20 22 52 69 6e 67 20 | 65 6d 70 74 79 22 20 68 |r "Ring |empty" h|
|00000740| 64 20 6c 6e 20 76 65 63 | 20 76 65 63 6c 65 6e 20 |d ln vec| veclen |
|00000750| 6d 6f 64 20 74 6c 20 6e | 69 6c 20 6f 6c 64 65 6c |mod tl n|il oldel|
|00000760| 74 20 69 6e 64 65 78 20 | 72 69 6e 67 2d 69 6e 64 |t index |ring-ind|
|00000770| 65 78 20 72 69 6e 67 2d | 70 6c 75 73 31 5d 20 37 |ex ring-|plus1] 7|
|00000780| 20 22 5c 0a 52 65 6d 6f | 76 65 20 61 6e 20 69 74 | "\.Remo|ve an it|
|00000790| 65 6d 20 66 72 6f 6d 20 | 74 68 65 20 52 49 4e 47 |em from |the RING|
|000007a0| 2e 20 20 52 65 74 75 72 | 6e 20 74 68 65 20 72 65 |. Retur|n the re|
|000007b0| 6d 6f 76 65 64 20 69 74 | 65 6d 2e 0a 49 66 20 6f |moved it|em..If o|
|000007c0| 70 74 69 6f 6e 61 6c 20 | 49 4e 44 45 58 20 69 73 |ptional |INDEX is|
|000007d0| 20 6e 69 6c 2c 20 72 65 | 6d 6f 76 65 20 74 68 65 | nil, re|move the|
|000007e0| 20 6f 6c 64 65 73 74 20 | 69 74 65 6d 2e 20 20 49 | oldest |item. I|
|000007f0| 66 20 69 74 27 73 0a 6e | 75 6d 65 72 69 63 2c 20 |f it's.n|umeric, |
|00000800| 72 65 6d 6f 76 65 20 74 | 68 65 20 65 6c 65 6d 65 |remove t|he eleme|
|00000810| 6e 74 20 69 6e 64 65 78 | 65 64 2e 22 5d 29 0a 28 |nt index|ed."]).(|
|00000820| 66 73 65 74 20 27 72 69 | 6e 67 2d 72 65 66 20 23 |fset 'ri|ng-ref #|
|00000830| 5b 28 72 69 6e 67 20 69 | 6e 64 65 78 29 20 22 c0 |[(ring i|ndex) ".|
|00000840| 09 21 ab 84 c2 c3 21 87 | 09 40 1c 09 41 40 1d 09 |.!....!.|.@..A@..|
|00000850| 41 41 89 1e 06 c7 0e 08 | 0c 0d 0e 06 47 24 48 2b |AA......|....G$H+|
|00000860| 87 22 20 5b 72 69 6e 67 | 2d 65 6d 70 74 79 2d 70 |." [ring|-empty-p|
|00000870| 20 72 69 6e 67 20 65 72 | 72 6f 72 20 22 69 6e 64 | ring er|ror "ind|
|00000880| 65 78 65 64 20 65 6d 70 | 74 79 20 72 69 6e 67 22 |exed emp|ty ring"|
|00000890| 20 68 64 20 6c 6e 20 76 | 65 63 20 72 69 6e 67 2d | hd ln v|ec ring-|
|000008a0| 69 6e 64 65 78 20 69 6e | 64 65 78 5d 20 37 20 22 |index in|dex] 7 "|
|000008b0| 5c 0a 52 65 74 75 72 6e | 73 20 52 49 4e 47 27 73 |\.Return|s RING's|
|000008c0| 20 49 4e 44 45 58 20 65 | 6c 65 6d 65 6e 74 2e 0a | INDEX e|lement..|
|000008d0| 49 4e 44 45 58 20 6e 65 | 65 64 20 6e 6f 74 20 62 |INDEX ne|ed not b|
|000008e0| 65 20 3c 3d 20 74 68 65 | 20 72 69 6e 67 20 6c 65 |e <= the| ring le|
|000008f0| 6e 67 74 68 2c 20 74 68 | 65 20 61 70 70 72 6f 70 |ngth, th|e approp|
|00000900| 72 69 61 74 65 20 6d 6f | 64 75 6c 6f 20 6f 70 65 |riate mo|dulo ope|
|00000910| 72 61 74 69 6f 6e 0a 77 | 69 6c 6c 20 62 65 20 70 |ration.w|ill be p|
|00000920| 65 72 66 6f 72 6d 65 64 | 2e 20 20 45 6c 65 6d 65 |erformed|. Eleme|
|00000930| 6e 74 20 30 20 69 73 20 | 74 68 65 20 6d 6f 73 74 |nt 0 is |the most|
|00000940| 20 72 65 63 65 6e 74 6c | 79 20 69 6e 73 65 72 74 | recentl|y insert|
|00000950| 65 64 3b 20 68 69 67 68 | 65 72 20 69 6e 64 69 63 |ed; high|er indic|
|00000960| 65 73 0a 63 6f 72 72 65 | 73 70 6f 6e 64 20 74 6f |es.corre|spond to|
|00000970| 20 6f 6c 64 65 72 20 65 | 6c 65 6d 65 6e 74 73 20 | older e|lements |
|00000980| 75 6e 74 69 6c 20 74 68 | 65 79 20 77 72 61 70 2e |until th|ey wrap.|
|00000990| 22 5d 29 0a 28 70 72 6f | 76 69 64 65 20 27 72 69 |"]).(pro|vide 'ri|
|000009a0| 6e 67 29 0a | |ng). | |
+--------+-------------------------+-------------------------+--------+--------+