From 07b8507ce9ff8510dbae21300e122591aed53c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Axel=20S=C3=B8gaard?= Date: Wed, 28 Nov 2012 21:38:02 +0100 Subject: [PATCH] Rename to bit-vector-popcount --- collects/data/bit-vector.rkt | 6 +++--- collects/data/private/count-bits-in-fixnum.rkt | 6 +++--- collects/tests/data/bit-vector.rkt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/collects/data/bit-vector.rkt b/collects/data/bit-vector.rkt index 13fb64803d..fc6812095e 100644 --- a/collects/data/bit-vector.rkt +++ b/collects/data/bit-vector.rkt @@ -93,9 +93,9 @@ (bit-vector-copy bv start end)])]) bit-vector-copy)) -(define (bit-vector-count bv) +(define (bit-vector-popcount bv) (for/sum ([fx (in-fxvector (bit-vector-words bv))]) - (fxcount fx))) + (fxpopcount fx))) (define-vector-wraps "bit-vector" bit-vector? bit-vector-length bit-vector-ref bit-vector-set! make-bit-vector @@ -167,7 +167,7 @@ (-> bit-vector? exact-nonnegative-integer? boolean? any)] [bit-vector-length (-> bit-vector? any)] - [bit-vector-count + [bit-vector-popcount (-> bit-vector? any)] (rename bit-vector-copy* bit-vector-copy diff --git a/collects/data/private/count-bits-in-fixnum.rkt b/collects/data/private/count-bits-in-fixnum.rkt index 3489e48cd9..d2b804996a 100644 --- a/collects/data/private/count-bits-in-fixnum.rkt +++ b/collects/data/private/count-bits-in-fixnum.rkt @@ -1,7 +1,7 @@ #lang racket (require racket/unsafe/ops (for-syntax racket/fixnum racket/vector)) -(provide fxcount) +(provide fxpopcount) ;; Count set bits for 30 bit number in 5 steps. ;; for 62 bit number in 6. @@ -20,7 +20,7 @@ #x3FFF0000FFFF0000 #x3FFFFFFF00000000)) -(define-syntax (mk-fxcount stx) +(define-syntax (mk-fxpopcount stx) (syntax-case stx () [(_ name) ;; Choose at compile time what word length is @@ -37,5 +37,5 @@ (unsafe-fxand n #,f))]) n)))])) -(mk-fxcount fxcount) +(mk-fxpopcount fxpopcount) diff --git a/collects/tests/data/bit-vector.rkt b/collects/tests/data/bit-vector.rkt index ddc508a645..4a8528c6f4 100644 --- a/collects/tests/data/bit-vector.rkt +++ b/collects/tests/data/bit-vector.rkt @@ -98,7 +98,7 @@ (bit-vector-set! bv 400 #t) (check-equal? bv (for/bit-vector ([i 1000]) (= i 400))))) -(test-case "bit-vector-count" +(test-case "bit-vector-popcount" (let () (define (test) (define fill (odd? (random 2))) @@ -107,6 +107,6 @@ (for ([n (in-set ns)]) (bit-vector-set! bv n (not fill))) (define count (if fill (- 1000 (set-count ns)) (set-count ns))) - (check-equal? (bit-vector-count bv) count)) + (check-equal? (bit-vector-popcount bv) count)) (for ([i (in-range 100)]) (test))))