Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 173f249bd6e09838e6e183434f98023507de4fdc @per-gron committed Aug 17, 2009
Showing with 19,831 additions and 0 deletions.
  1. +23 −0 LICENSE
  2. +69 −0 ds/queue.scm
  3. +709 −0 ds/wt-tree.scm
  4. +56 −0 misc/al.scm
  5. +222 −0 misc/exception.scm
  6. +47 −0 misc/mailbox.scm
  7. +104 −0 misc/match.scm
  8. +165 −0 misc/optionals.scm
  9. +28 −0 misc/splice.scm
  10. +98 −0 misc/token-table.scm
  11. +185 −0 misc/u8v.scm
  12. +63 −0 misc/uuid.scm
  13. +1,084 −0 net/http-client.scm
  14. +386 −0 net/http-common.scm
  15. +498 −0 net/http-server.scm
  16. +133 −0 net/http-session.scm
  17. +51 −0 net/tcpip.scm
  18. +709 −0 net/uri.scm
  19. +205 −0 net/x-www-form-urlencoded.scm
  20. +281 −0 spork/block.scm
  21. +207 −0 spork/comet.scm
  22. +658 −0 spork/core.scm
  23. +39 −0 spork/counter.scm
  24. +97 −0 spork/file.scm
  25. +1,029 −0 spork/js.scm
  26. +824 −0 spork/widget.scm
  27. +1,722 −0 srfi/1.scm
  28. +2,029 −0 srfi/13.scm
  29. +826 −0 srfi/14.scm
  30. +43 −0 srfi/16.scm
  31. +1,487 −0 srfi/19.scm
  32. +172 −0 srfi/95.scm
  33. +363 −0 string/base64.scm
  34. +1,500 −0 string/digest.scm
  35. +784 −0 string/pregexp.scm
  36. +660 −0 string/sxml-to-xml.scm
  37. +240 −0 string/util.scm
  38. +2,035 −0 string/xml-to-sxml.scm
23 LICENSE
@@ -0,0 +1,23 @@
+Unless otherwise noted in the source files, they are released
+under the MIT license, as follows:
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,69 @@
+;;; A very simple first-in-last-out queue library. Right now the
+;;; implementation is list-based and relies on set-car!/set-cdr!. All
+;;; operations are constant time.
+;;;
+;;; Copyright (c) 2008 Per Eckerdal
+
+(declare (block)
+ (mostly-fixnum)
+ (standard-bindings)
+ (extended-bindings))
+
+(export make-queue
+ (rename: (q-size queue-size)
+ (q? queue?))
+ queue-push!
+ queue-pop!
+ queue-empty?
+ queue-empty!
+ queue-front)
+
+(define-type q
+ id: F71EB1A0-828C-48D5-80C3-1CF3628012F9
+
+ data
+ (end-cons unprintable:)
+ (size unprintable:))
+
+(define (make-end-cons)
+ (cons 'end '()))
+
+(define no-value (list 'no-value))
+
+(define (make-queue)
+ (let ((end-cons (make-end-cons)))
+ (make-q end-cons end-cons 0)))
+
+(define (queue-push! q elm)
+ (let ((new-end-cons (make-end-cons))
+ (old-end-cons (q-end-cons q)))
+ (set-car! old-end-cons elm)
+ (set-cdr! old-end-cons new-end-cons)
+ (q-size-set! q (+ 1 (q-size q)))
+ (q-end-cons-set! q new-end-cons)))
+
+(define (queue-pop! q)
+ (if (queue-empty? q)
+ (error "Queue is empty")
+ (let ((data (q-data q)))
+ (q-data-set! q (cdr data))
+ (q-size-set! q (- (q-size q) 1))
+ (car data))))
+
+(define queue-size q-size)
+
+(define (queue-empty? q)
+ (= 0 (q-size q)))
+
+(define (queue-empty! q)
+ (q-size-set! q 0)
+ (let ((end-cons (make-end-cons)))
+ (q-data-set! q end-cons)
+ (q-end-cons-set! q end-cons)))
+
+(define (queue-front q #!optional (default no-value))
+ (if (queue-empty? q)
+ (if (eq? default no-value)
+ (error "Queue is empty")
+ default)
+ (car (q-data q))))
Oops, something went wrong.

0 comments on commit 173f249

Please sign in to comment.