Replace bit-vec crate with bitvec
This commit is contained in:
parent
e6a404a29e
commit
ec638e4d02
|
@ -10,7 +10,6 @@ version = "0.7.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bit-vec = "0.6"
|
|
||||||
bitvec = "0.18"
|
bitvec = "0.18"
|
||||||
blake2s_simd = "0.5"
|
blake2s_simd = "0.5"
|
||||||
ff = "0.8"
|
ff = "0.8"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use super::multicore::Worker;
|
use super::multicore::Worker;
|
||||||
use bit_vec::{self, BitVec};
|
use bitvec::{array::BitArray, order::Lsb0, vec::BitVec};
|
||||||
use bitvec::{array::BitArray, order::Lsb0};
|
|
||||||
use ff::PrimeField;
|
use ff::PrimeField;
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use group::prime::{PrimeCurve, PrimeCurveAffine};
|
use group::prime::{PrimeCurve, PrimeCurveAffine};
|
||||||
|
@ -112,14 +111,13 @@ impl<'a> QueryDensity for &'a FullDensity {
|
||||||
|
|
||||||
pub struct DensityTracker {
|
pub struct DensityTracker {
|
||||||
bv: BitVec,
|
bv: BitVec,
|
||||||
total_density: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> QueryDensity for &'a DensityTracker {
|
impl<'a> QueryDensity for &'a DensityTracker {
|
||||||
type Iter = bit_vec::Iter<'a>;
|
type Iter = std::iter::Cloned<bitvec::slice::Iter<'a, Lsb0, usize>>;
|
||||||
|
|
||||||
fn iter(self) -> Self::Iter {
|
fn iter(self) -> Self::Iter {
|
||||||
self.bv.iter()
|
self.bv.iter().cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_query_size(self) -> Option<usize> {
|
fn get_query_size(self) -> Option<usize> {
|
||||||
|
@ -129,10 +127,7 @@ impl<'a> QueryDensity for &'a DensityTracker {
|
||||||
|
|
||||||
impl DensityTracker {
|
impl DensityTracker {
|
||||||
pub fn new() -> DensityTracker {
|
pub fn new() -> DensityTracker {
|
||||||
DensityTracker {
|
DensityTracker { bv: BitVec::new() }
|
||||||
bv: BitVec::new(),
|
|
||||||
total_density: 0,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_element(&mut self) {
|
pub fn add_element(&mut self) {
|
||||||
|
@ -142,12 +137,11 @@ impl DensityTracker {
|
||||||
pub fn inc(&mut self, idx: usize) {
|
pub fn inc(&mut self, idx: usize) {
|
||||||
if !self.bv.get(idx).unwrap() {
|
if !self.bv.get(idx).unwrap() {
|
||||||
self.bv.set(idx, true);
|
self.bv.set(idx, true);
|
||||||
self.total_density += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_total_density(&self) -> usize {
|
pub fn get_total_density(&self) -> usize {
|
||||||
self.total_density
|
self.bv.count_ones()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue