Skip to content

Commit

Permalink
refactor bitindex to use generic AsRef<[u8]> trait rather than slices
Browse files Browse the repository at this point in the history
  • Loading branch information
matko committed Sep 6, 2019
1 parent ad7dd42 commit e5a50a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/structure/adjacencylist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use super::storage::*;
#[derive(Clone)]
pub struct AdjacencyList<'a> {
nums: LogArray<&'a [u8]>,
bits: BitIndex<'a>,
bits: BitIndex<&'a [u8]>,
}

impl<'a> AdjacencyList<'a> {
pub fn from_parts(nums: LogArray<&'a [u8]>, bits: BitIndex<'a>) -> AdjacencyList<'a> {
pub fn from_parts(nums: LogArray<&'a [u8]>, bits: BitIndex<&'a [u8]>) -> AdjacencyList<'a> {
AdjacencyList { nums, bits }
}

Expand Down
12 changes: 6 additions & 6 deletions src/structure/bitindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use tokio::prelude::*;
const SBLOCK_SIZE: usize = 52;

#[derive(Clone)]
pub struct BitIndex<'a> {
array: BitArray<&'a [u8]>,
blocks: LogArray<&'a [u8]>,
sblocks: LogArray<&'a [u8]>
pub struct BitIndex<M:AsRef<[u8]>+Clone> {
array: BitArray<M>,
blocks: LogArray<M>,
sblocks: LogArray<M>
}

impl<'a> BitIndex<'a> {
pub fn from_parts(array: BitArray<&'a [u8]>, blocks: LogArray<&'a [u8]>, sblocks: LogArray<&'a [u8]>) -> BitIndex<'a> {
impl<M:AsRef<[u8]>+Clone> BitIndex<M> {
pub fn from_parts(array: BitArray<M>, blocks: LogArray<M>, sblocks: LogArray<M>) -> BitIndex<M> {
assert!(sblocks.len() == (blocks.len() + SBLOCK_SIZE - 1) / SBLOCK_SIZE);
assert!(blocks.len() == (array.len() + 63) / 64);

Expand Down

0 comments on commit e5a50a0

Please sign in to comment.