-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add certified btree set, add get_random
- Loading branch information
1 parent
7f7971c
commit 22923a8
Showing
11 changed files
with
480 additions
and
127 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::collections::btree_map::iter::SBTreeMapIter; | ||
use crate::collections::certified_btree_set::SCertifiedBTreeSet; | ||
use crate::encoding::AsFixedSizeBytes; | ||
use crate::primitive::s_ref::SRef; | ||
use crate::primitive::StableType; | ||
use crate::AsHashableBytes; | ||
|
||
pub struct SCertifiedBTreeSetIter<'a, T> { | ||
iter: SBTreeMapIter<'a, T, ()>, | ||
} | ||
|
||
impl<'a, T: StableType + AsFixedSizeBytes + Ord + AsHashableBytes> SCertifiedBTreeSetIter<'a, T> { | ||
pub fn new(set: &'a SCertifiedBTreeSet<T>) -> Self { | ||
Self { | ||
iter: SBTreeMapIter::new(&set.map.inner), | ||
} | ||
} | ||
} | ||
|
||
impl<'a, T: StableType + AsFixedSizeBytes + Ord> Iterator for SCertifiedBTreeSetIter<'a, T> { | ||
type Item = SRef<'a, T>; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
self.iter.next().map(|it| it.0) | ||
} | ||
} | ||
|
||
impl<'a, T: StableType + AsFixedSizeBytes + Ord> DoubleEndedIterator | ||
for SCertifiedBTreeSetIter<'a, T> | ||
{ | ||
fn next_back(&mut self) -> Option<Self::Item> { | ||
self.iter.next_back().map(|it| it.0) | ||
} | ||
} |
Oops, something went wrong.