Skip to content
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

Closed
wants to merge 12 commits into from
Closed

Document Deque trait and bitv. #15824

wants to merge 12 commits into from

Conversation

treeman
Copy link
Contributor

@treeman treeman commented Jul 20, 2014

Examples for Deque, Bitv and BitvSet. Normalize documentation style and some source code reorganization.

@@ -8,6 +8,51 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Collections implemented with bitvectors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not "bit vectors"?

@treeman
Copy link
Contributor Author

treeman commented Jul 20, 2014

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) {
Copy link
Contributor

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.

@errordeveloper
Copy link
Contributor

I know it's a bit laborious, but would makes it easier to review and blame or bisect 👍

@treeman
Copy link
Contributor Author

treeman commented Jul 20, 2014

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 {
Copy link
Member

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.
Copy link
Member

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?

treeman added 2 commits July 20, 2014 14:32
So all comes in the order union, intersection, difference and
symmetric_difference.
///
/// # Example
///
/// With a `Deque` we can simulate a stack:
Copy link
Member

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));
Copy link
Member

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

```

@huonw
Copy link
Member

huonw commented Jul 20, 2014

Awesome docs! Thanks so much for this.

@treeman
Copy link
Contributor Author

treeman commented Jul 20, 2014

I think I've got the commits sorted out and I've simplified most examples.

Thanks for the good eyes and tips!

@treeman treeman deleted the deque-bitv-doc branch July 22, 2014 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants