summary refs log tree commit diff
path: root/src/libcollections/bitv.rs
AgeCommit message (Collapse)AuthorLines
2014-10-07Use slice syntax instead of slice_to, etc.Nick Cameron-1/+1
2014-10-02Revert "Use slice syntax instead of slice_to, etc."Aaron Turon-1/+1
This reverts commit 40b9f5ded50ac4ce8c9323921ec556ad611af6b7.
2014-10-02Use slice syntax instead of slice_to, etc.Nick Cameron-1/+1
2014-09-21Fix fallout from Vec stabilizationAlex Crichton-2/+2
2014-09-16Fallout from renamingAaron Turon-5/+5
2014-09-03bitv: add larger tests, better benchmarks & remove dead code.Huon Wilson-22/+29
There were no tests for iteration etc. with more than 5 elements, i.e. not even going beyond a single word. This situation is rectified. Also, the only benchmarks for `set` were with a constant bit value, which was not indicative of every situation, due to inlining & branch removal. This adds a benchmark at the other end of the spectrum: random input.
2014-08-26Use temp vars for implicit coercion to ^[T]Nick Cameron-1/+1
2014-08-21bitv: make sure benchmarks run long enoughVinzent Steinberg-7/+19
Previously they were too short (less than 10 ns), so the benchmarker could not resolve them meaningfully. Now they should run in the order of 100 ns.
2014-08-21bitv: make benchmarks always return a valueVinzent Steinberg-8/+11
This makes sure that the benchmarked code does not get optimized away. Also fixed a typo. Fixes #12118.
2014-08-19auto merge of #16241 : P1start/rust/doc-fixes, r=alexcrichtonbors-50/+55
For crates `alloc`–`collections`. This is mostly just updating a few function/method descriptions to use the indicative style. cc #4361; I’ve sort of assumed that the third-person indicative style has been decided on, but I could update this to use the imperative style if that’s preferred, or even update this to remove all function-style-related changes. (I think that standardising on one thing, even if it’s not the ‘best’ option, is still better than having no standard at all.) The indicative style seems to be more common in the Rust standard library at the moment, especially in the newer modules (e.g. `collections::vec`), more popular in the discussion about it, and also more popular amongst other languages (see https://github.com/rust-lang/rust/issues/4361#issuecomment-33470215).
2014-08-19auto merge of #16582 : Gankro/rust/bitv, r=alexcrichtonbors-26/+41
This was bothering me (and some other people). The macro was necessary in a transient step of my development, but I converged on a design where it was unnecessary, but it didn't really click that that had happened. This fixes it up.
2014-08-19A few minor documentation fixesP1start-50/+55
2014-08-18Fixing bitvset is_disjoint, fixes #16587Alexis Beingessner-1/+19
2014-08-18Refactor BitV internals to not use macro, reduce duplicationAlexis Beingessner-25/+22
2014-08-18auto merge of #16559 : Gankro/rust/bitv, r=pcwaltonbors-3/+114
These were the only differing-size-based errors I noticed. Might be more.
2014-08-17Correct internal BitvSet 0-padding, fixes #16542Alexis Beingessner-3/+114
2014-08-17auto merge of #16550 : kaseyc/rust/fix_documentation_error, r=alexcrichtonbors-1/+1
2014-08-16Fix an error in a code sample in bitv.rsKasey Carrothers-1/+1
2014-08-16librustc: Forbid external crates, imports, and/or items from beingPatrick Walton-2/+1
declared with the same name in the same scope. This breaks several common patterns. First are unused imports: use foo::bar; use baz::bar; Change this code to the following: use baz::bar; Second, this patch breaks globs that import names that are shadowed by subsequent imports. For example: use foo::*; // including `bar` use baz::bar; Change this code to remove the glob: use foo::{boo, quux}; use baz::bar; Or qualify all uses of `bar`: use foo::{boo, quux}; use baz; ... baz::bar ... Finally, this patch breaks code that, at top level, explicitly imports `std` and doesn't disable the prelude. extern crate std; Because the prelude imports `std` implicitly, there is no need to explicitly import it; just remove such directives. The old behavior can be opted into via the `import_shadowing` feature gate. Use of this feature gate is discouraged. This implements RFC #116. Closes #16464. [breaking-change]
2014-08-12Deprecation fallout in libcollectionsAaron Turon-7/+7
2014-08-02auto merge of #16180 : jbcrail/rust/fix-comments, r=steveklabnikbors-1/+1
2014-08-01Fix misspelled comments.Joseph Crail-1/+1
2014-08-01collections: Implement FromIterator/Extendable for BitvSetnham-1/+27
2014-07-28Implement Ord for TrieMap/TrieSet/SmallIntMap/Bitv/BitvSetnham-1/+8
2014-07-28Implement PartialOrd for Bitv and BitvSetnham-1/+40
2014-07-23Remove kludgy imports from vec! macroBrian Anderson-1/+1
2014-07-23collections: Move push/pop to MutableSeqBrian Anderson-1/+1
Implement for Vec, DList, RingBuf. Add MutableSeq to the prelude. Since the collections traits are in the prelude most consumers of these methods will continue to work without change. [breaking-change]
2014-07-21Simplify and cleanup bitv examples.Jonas Hietala-74/+120
2014-07-21Describe BitPositions and TwoBitPositions.Jonas Hietala-0/+2
2014-07-21Polish bitv docs.Jonas Hietala-39/+44
2014-07-21Main bitv example: prime sieve.Jonas Hietala-0/+49
2014-07-21Move intersection above difference and symmetric_differance.Jonas Hietala-29/+29
So all comes in the order union, intersection, difference and symmetric_difference.
2014-07-21Document BitvSet.Jonas Hietala-19/+297
2014-07-21Document Bitv.Jonas Hietala-94/+307
2014-07-21Group union, intersect and difference in Bitv.Jonas Hietala-22/+22
2014-07-21Place union as the first function, for consistency.Jonas Hietala-12/+12
2014-07-21Move in-place functions below their iterator variants.Jonas Hietala-24/+24
2014-07-10auto merge of #15556 : alexcrichton/rust/snapshots, r=brsonbors-6/+1
Closes #15544
2014-07-09libcollections: Use iterators instead of old-style loops.Luqman Aden-34/+10
2014-07-09Register new snapshotsAlex Crichton-6/+1
Closes #15544
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-9/+9
[breaking-change]
2014-07-07librustc (RFC #34): Implement the new `Index` and `IndexMut` traits.Patrick Walton-15/+49
This will break code that used the old `Index` trait. Change this code to use the new `Index` traits. For reference, here are their signatures: pub trait Index<Index,Result> { fn index<'a>(&'a self, index: &Index) -> &'a Result; } pub trait IndexMut<Index,Result> { fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Result; } Closes #6515. [breaking-change]
2014-07-02collections::bitv: clean up and unit test `BitvSet::is_subset`Andrew Poelstra-55/+36
2014-07-02collections::bitv: change constructors for `Bitv` and `BitvSet`Andrew Poelstra-69/+81
`Bitv::new` has been renamed `Bitv::with_capacity`. The new function `Bitv::new` now creates a `Bitv` with no elements. The new function `BitvSet::with_capacity` creates a `BitvSet` with a specified capacity.
2014-07-02collections::bitv: Implement several methods for `Bitv` and `BitvSet`Andrew Poelstra-41/+295
On Bitv: - Add .push() and .pop() which take and return bool, respectively - Add .truncate() which truncates a Bitv to a specific length - Add .grow() which grows a Bitv by a specific length - Add .reserve() which grows the underlying storage to be able to hold a specified number of bits without resizing - Implement FromIterator<Vec<bool>> - Implement Extendable<bool> - Implement Collection - Implement Mutable - Remove .from_bools() since FromIterator<Vec<bool>> now accomplishes this. - Remove .assign() since Clone::clone_from() accomplishes this. On BitvSet: - Add .reserve() which grows the underlying storage to be able to hold a specified number of bits without resizing - Add .get_ref() and .get_mut_ref() to return references to the underlying Bitv
2014-07-02collections::bitv: Add documentation and #[inline]'sAndrew Poelstra-2/+26
Add documentation to methods on BitvSet that were missing them. Also make sure #[inline] is on all methods that are (a) one-liners or (b) private methods whose only purpose is code deduplication.
2014-07-02collections::bitv: replace internal iterators with external onesAndrew Poelstra-54/+88
2014-07-02collections::bitv: remove some ancient interfacesAndrew Poelstra-24/+3
Removes the following methods from `Bitv`: - `to_vec`: translates a `Bitv` into a bulky `Vec<uint>` of 0's and 1's replace with: `bitv.iter().map(|b| if b {1} else {0}).collect()` - `to_bools`: translates a `Bitv` into a `Vec<bool>` replace with: `bitv.iter().collect()` - `ones`: internal iterator over all 1 bits in a `Bitv` replace with: `BitvSet::from_bitv(bitv).iter().advance(fn)` These methods had specific functionality which can be replicated more generally by the modern iterator system. (Also `to_vec` was not even unit tested!)
2014-07-02collections::bitv: correct use of Vec<T>::growAndrew Poelstra-2/+11
The argument passed to Vec::grow is the number of elements to grow the vector by, not the target number of elements. The old `Bitv` code did the wrong thing, allocating more memory than it needed to.
2014-07-02collections::bitv: ensure correct masking behaviourAndrew Poelstra-83/+87
The internal masking behaviour for `Bitv` is now defined as: - Any entirely words in self.storage must be all zeroes. - Any partially used words may have anything at all in their unused bits. This means: - When decreasing self.nbits, care must be taken that any no-longer-used words are zeroed out. - When increasing self.nbits, care must be taken that any newly-unmasked bits are set to their correct values. - When reading words, care should be taken that the values of unused bits are not used. (Preferably, use `Bitv::mask_words` which zeroes them out for you.) The old behaviour was that every unused bit was always set to zero. The problem with this is that unused bits are almost never read, so forgetting to do this will result in very subtle and hard-to-track down bugs. This way the responsibility for masking falls on the places which might cause unused bits to be read: for now, this is only `Bitv::mask_words` and `BitvSet::insert`.