Created
April 10, 2013 08:32
-
-
Save yamasushi/5352858 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ext/sparse/sparse.scm b/ext/sparse/sparse.scm | |
index 0ea6ec0..20a6727 100644 | |
--- a/ext/sparse/sparse.scm | |
+++ b/ext/sparse/sparse.scm | |
@@ -271,7 +271,7 @@ | |
;;=============================================================== | |
;; dictionary protocol | |
-;; | |
+;; <sparse-table> | |
(define-method dict-get ((dict <sparse-table>) key . maybe-default) | |
(if (null? maybe-default) | |
@@ -290,3 +290,63 @@ | |
(define-method dict-fold ((dict <sparse-table>) proc seed) | |
(sparse-table-fold dict proc seed)) | |
+(define-method dict-for-each ((dict <sparse-table>) proc) | |
+ (sparse-table-for-each dict proc) ) | |
+ | |
+(define-method dict-map ((dict <sparse-table>) proc) | |
+ (sparse-table-map dict proc) ) | |
+ | |
+(define-method dict-keys ((dict <sparse-table>)) | |
+ (sparse-table-keys dict) ) | |
+ | |
+(define-method dict-values ((dict <sparse-table>)) | |
+ (sparse-table-values dict) ) | |
+ | |
+(define-method dict-pop! ((dict <sparse-table>) key :optional default) | |
+ (sparse-table-pop! dict key default) ) | |
+ | |
+(define-method dict-push! ((dict <sparse-table>) key value) | |
+ (sparse-table-push! dict key value) ) | |
+ | |
+(define-method dict-update! ((dict <sparse-table>) key proc :optional default) | |
+ (sparse-table-update! dict key proc default) ) | |
+ | |
+;; <sparse-vector-base> | |
+ | |
+(define-method dict-get ((dict <sparse-vector-base>) key . maybe-default) | |
+ (if (null? maybe-default) | |
+ (sparse-vector-ref dict key) | |
+ (sparse-vector-ref dict key (car maybe-default)))) | |
+ | |
+(define-method dict-put! ((dict <sparse-vector-base>) key val) | |
+ (sparse-vector-set! dict key val)) | |
+ | |
+(define-method dict-delete! ((dict <sparse-vector-base>) key) | |
+ (sparse-vector-delete! dict key)) | |
+ | |
+(define-method dict-exists? ((dict <sparse-vector-base>) key) | |
+ (sparse-vector-exists? dict key)) | |
+ | |
+(define-method dict-fold ((dict <sparse-vector-base>) proc seed) | |
+ (sparse-vector-fold dict proc seed)) | |
+ | |
+(define-method dict-for-each ((dict <sparse-vector-base>) proc) | |
+ (sparse-vector-for-each dict proc) ) | |
+ | |
+(define-method dict-map ((dict <sparse-vector-base>) proc) | |
+ (sparse-vector-map dict proc) ) | |
+ | |
+(define-method dict-keys ((dict <sparse-vector-base>)) | |
+ (sparse-vector-keys dict) ) | |
+ | |
+(define-method dict-values ((dict <sparse-vector-base>)) | |
+ (sparse-vector-values dict) ) | |
+ | |
+(define-method dict-pop! ((dict <sparse-vector-base>) key :optional default) | |
+ (sparse-vector-pop! dict key default) ) | |
+ | |
+(define-method dict-push! ((dict <sparse-vector-base>) key value) | |
+ (sparse-vector-push! dict key value) ) | |
+ | |
+(define-method dict-update! ((dict <sparse-vector-base>) key proc :optional default) | |
+ (sparse-vector-update! dict key proc default) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment