-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document Deque trait and bitv. #15824
Conversation
@@ -8,6 +8,51 @@ | |||
// option. This file may not be copied, modified, or distributed | |||
// except according to those terms. | |||
|
|||
//! Collections implemented with bitvectors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not "bit vectors"?
That's interesting. I moved some functions to group them more logically, but it appears github renders them as if I rewrote them. I'll see if I can split up the commits. |
@@ -695,22 +1076,24 @@ impl BitvSet { | |||
} | |||
|
|||
#[inline] | |||
fn other_op(&mut self, other: &BitvSet, f: |uint, uint| -> uint) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above. I'm also not quite sure whether #[inline]
should live above comments, probably not.
I know it's a bit laborious, but would makes it easier to review and blame or bisect 👍 |
Yes I totally understand, no worries. |
//! if bv.get(i) { | ||
//! // mark all multiples as non-prime | ||
//! let mut j = i * i; | ||
//! while j < max_prime { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// mark all multiples of i as non-prime (any multiples below i * i
// will have been marked as non-prime previously)
for j in iter::range(i * i, max_prime, i) { bv.set(j, false) }
/// Organise the bits into bytes, such that the first bit in the | ||
/// `Bitv` becomes the high-order bit of the first byte. If the | ||
/// size of the `Bitv` is not a multiple of 8 then trailing bits | ||
/// will be filled-in with false/0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is false divided by 0? :P
Maybe just false
(with backticks) is enough?
So all comes in the order union, intersection, difference and symmetric_difference.
/// | ||
/// # Example | ||
/// | ||
/// With a `Deque` we can simulate a stack: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, you can efficiently implement a stack with just Vec
(via .push
and .pop
), no need for Deque
or RingBuf
. Maybe this could be moved to after the queue
example?
/// let mut d = DList::new(); | ||
/// d.push_front(1i); | ||
/// d.push_front(2i); | ||
/// assert_eq!(d.front(), Some(&2i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example and those below don't have the closing
```
Awesome docs! Thanks so much for this. |
I think I've got the commits sorted out and I've simplified most examples. Thanks for the good eyes and tips! |
Examples for
Deque
,Bitv
andBitvSet
. Normalize documentation style and some source code reorganization.