/usr/share/scsh-0.6/big/linked-queue.scm is in scsh-common-0.6 0.6.7-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | ; Copyright (c) 1993-1999 by Richard Kelsey and Jonathan Rees. See file COPYING.
; This file is no longer used.
; Queues implemented as doubly linked lists (because the thread package needs
; to delete queue entries quickly).
; The exported procedures are those of the simpler queue package, with the
; addition of DELETE-QUEUE-ENTRY!. ENQUEUE! returns a queue-entry which can
; then be passed to DELETE-QUEUE-ENTRY! to remove the thing from the queue.
(define-record-type q-entry :q-entry
(make-q-entry data prev next)
q-entry?
(data q-entry-data)
(prev q-entry-prev set-q-entry-prev!)
(next q-entry-next set-q-entry-next!))
(define queue? q-entry?)
(define (make-queue)
(let ((e (make-q-entry #f #f #f)))
(set-q-entry-prev! e e)
(set-q-entry-next! e e)
e))
(define (queue-empty? q)
(eq? (q-entry-next q) q))
(define (enqueue! q thing)
(let* ((prev (q-entry-prev q))
(e (make-q-entry thing prev q)))
(set-q-entry-prev! q e)
(set-q-entry-next! prev e)
e))
(define (queue-head q)
(let ((e (q-entry-next q)))
(if (eq? q e) ;(queue-empty? q)
(error "empty queue" q)
(q-entry-data e))))
(define (dequeue! q)
(let ((e (q-entry-next q)))
(cond ((eq? q e) ;(queue-empty? q)
(error "empty queue" q))
(else
(set-q-entry-next! q (q-entry-next e))
(set-q-entry-prev! (q-entry-next q) q)
(q-entry-data e)))))
(define (delete-queue-entry! e)
(let ((next (q-entry-next e))
(prev (q-entry-prev e)))
(set-q-entry-next! prev next)
(set-q-entry-prev! next prev)))
(define (queue->list q)
(do ((e (q-entry-prev q) (q-entry-prev e))
(l '() (cons (q-entry-data e) l)))
((eq? q e) l)))
(define (queue-length q)
(do ((e (q-entry-prev q) (q-entry-prev e))
(l 0 (+ l 1)))
((eq? q e) l)))
(define (delete-from-queue! q v)
(let loop ((e (q-entry-next q)))
(cond ((eq? e q))
((eq? (q-entry-data e) v)
(delete-queue-entry! e))
(else
(loop (q-entry-next e))))))
|