summary refs log tree commit diff
path: root/src/libstd/vec.rs
AgeCommit message (Collapse)AuthorLines
2014-01-08auto merge of #11370 : alexcrichton/rust/issue-10465, r=pwaltonbors-8/+8
Turned out to be a 2-line fix, but the compiler fallout was huge.
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-6/+4
2014-01-07std: Fill in all missing importsAlex Crichton-2/+4
Fallout from the previous commits
2014-01-07'borrowed pointer' -> 'reference'Brian Anderson-1/+1
2013-12-29Add method .as_mut_slice() to MutableVectorKevin Ballard-0/+6
This method is primarily intended to allow for converting a [T, ..N] to a &mut [T].
2013-12-27std: uniform modules titles for docLuca Bruno-1/+1
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-26auto merge of #11127 : huonw/rust/vec-docs, r=alexcrichtonbors-27/+115
2013-12-24std: Get stdtest all passing againAlex Crichton-1/+0
This commit brings the library up-to-date in order to get all tests passing again
2013-12-25std::vec: clarify & examplify more docs.Huon Wilson-16/+79
2013-12-25std::vec: correct .sort()'s doc-string and add someHuon Wilson-11/+36
examples/clarification to others.
2013-12-23std: Fix all code examplesAlex Crichton-5/+3
2013-12-22auto merge of #11082 : brson/rust/noat, r=alexcrichtonbors-21/+28
2013-12-22auto merge of #11064 : huonw/rust/vec-sort, r=alexcrichtonbors-1/+295
This uses quite a bit of unsafe code for speed and failure safety, and allocates `2*n` temporary storage. [Performance](https://gist.github.com/huonw/5547f2478380288a28c2): | n | new | priority_queue | quick3 | |-------:|---------:|---------------:|---------:| | 5 | 200 | 155 | 106 | | 100 | 6490 | 8750 | 5810 | | 10000 | 1300000 | 1790000 | 1060000 | | 100000 | 16700000 | 23600000 | 12700000 | | sorted | 520000 | 1380000 | 53900000 | | trend | 1310000 | 1690000 | 1100000 | (The times are in nanoseconds, having subtracted the set-up time (i.e. the `just_generate` bench target).) I imagine that there is still significant room for improvement, particularly because both priority_queue and quick3 are doing a static call via `Ord` or `TotalOrd` for the comparisons, while this is using a (boxed) closure. Also, this code does not `clone`, unlike `quick_sort3`; and is stable, unlike both of the others.
2013-12-22std::vec: make the sorting closure use `Ordering` rather than just beingHuon Wilson-54/+32
(implicitly) less_eq.
2013-12-21std: Remove some @-boxesBrian Anderson-21/+28
2013-12-20Update next() and size_hint() for MutSpliterIteratorPalmer Cox-11/+8
Update the next() method to just return self.v in the case that we've reached the last element that the iterator will yield. This produces equivalent behavior as before, but without the cost of updating the field. Update the size_hint() method to return a better hint now that #9629 is fixed.
2013-12-20Remove remainder field from MutChunkIterPalmer Cox-13/+10
This field is no longer necessary now that #9629 is fixed since we can just access the length of the remaining slice directly.
2013-12-21std::vec: add a sugary .sort() method for plain Ord sorting.Huon Wilson-6/+63
This moves the custom sorting to `.sort_by`.
2013-12-19auto merge of #11071 : huonw/rust/quiet-test, r=cmrbors-15/+2
2013-12-20std::vec: implement a stable merge sort, deferring to insertion sort forHuon Wilson-1/+260
very small runs. This uses a lot of unsafe code for speed, otherwise we would be having to sort by sorting lists of indices and then do a pile of swaps to put everything in the correct place. Fixes #9819.
2013-12-20std: silence warnings when compiling test.Huon Wilson-15/+2
2013-12-19auto merge of #11061 : huonw/rust/opt-unsafe-vec, r=alexcrichtonbors-48/+105
Before: ``` test vec::bench::random_inserts ... bench: 15025 ns/iter (+/- 409) test vec::bench::random_removes ... bench: 16063 ns/iter (+/- 276) ``` After: ``` test vec::bench::random_inserts ... bench: 5257 ns/iter (+/- 321) test vec::bench::random_removes ... bench: 4980 ns/iter (+/- 94) ```
2013-12-19std::vec: use some unsafe code to optimise `remove`.Huon Wilson-39/+74
Also, add `.remove_opt` and replace `.unshift` with `.remove(0)`. The code size reduction seem to compensate for not having the optimised special cases. This makes the included benchmark more than 3 times faster.
2013-12-19std::vec: replace .insert with a small amount of unsafe code.Huon Wilson-9/+31
This makes the included benchmark more than 3 times faster. Also, `.unshift(x)` is now faster as `.insert(0, x)` which can reuse the allocation if necessary.
2013-12-19std::vec: remove .as_muf_buf, replaced by .as_mut_ptr & .len.Huon Wilson-44/+20
2013-12-19std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.Huon Wilson-38/+10
There's no need for the restrictions of a closure with the above methods.
2013-12-17auto merge of #10998 : thestinger/rust/iter, r=alexcrichtonbors-4/+2
2013-12-17auto merge of #10996 : huonw/rust/more-vec-raw, r=cmrbors-86/+64
The removal of the aliasing &mut[] and &[] from `shift_opt` also comes with its simplification. The above also allows the use of `copy_nonoverlapping_memory` in `[].copy_memory` (I did an audit of each use of `.copy_memory` and `std::vec::bytes::copy_memory`, and I believe none of them are called with arguments can ever alias). This changes requires that `unsafe` code using `copy_memory` **needs** to respect the aliasing rules of `&mut[]`.
2013-12-17std::vec: make init_elem nicer by doing fewer moves.Huon Wilson-5/+1
2013-12-17std::vec: convert .copy_memory to use copy_nonoverlapping_memory.Huon Wilson-5/+5
It is required that &mut[]s are disjoint from all other &(mut)[]s, so this assumption is ok.
2013-12-17std::vec::bytes: remove the reference to overlapping src and dest inHuon Wilson-7/+4
docs for copy_memory. &mut [u8] and &[u8] really shouldn't be overlapping at all (part of the uniqueness/aliasing guarantee of &mut), so no point in encouraging it.
2013-12-17std::vec::raw: convert copy_memory to a method.Huon Wilson-20/+21
2013-12-17std::vec::raw: convert init_elem to a method.Huon Wilson-16/+16
2013-12-16vec: avoid some unsafe code in MoveIterator's dtorDaniel Micay-4/+2
2013-12-17std::vec: remove aliasing &mut [] and &[] from shift_opt.Huon Wilson-43/+27
Also, dramatically simplify it with some tasteful raw pointers, rather than treating everything as a nail with `transmute`.
2013-12-16vec: make the move iterator fast for all typesDaniel Micay-42/+42
Closes #10976
2013-12-15librustc: Remove identifiers named `box`, since it's about to become a keyword.Patrick Walton-2/+2
2013-12-15auto merge of #10984 : huonw/rust/clean-raw, r=cmrbors-145/+94
See commits for details.
2013-12-15std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].Huon Wilson-33/+44
2013-12-15Move std::{str,vec}::raw::set_len to an unsafe method on Owned{Vector,Str}.Huon Wilson-33/+33
2013-12-15std::vec: move pointless `raw::get` and `unsafe_get` functions.Huon Wilson-16/+0
This can easily be written as `(*v.unsafe_ref(i)).clone()`, or just `*v.unsafe_ref(i)` for primitive types like `i32` (the common case).
2013-12-15std::vec::raw: clean up docs.Huon Wilson-4/+6
2013-12-15std::vec::bytes: remove obsolete functions.Huon Wilson-44/+2
These are less useful versions of the comparison operators and TotalOrd trait.
2013-12-15std::vec: remove unnecessary count parameter on {bytes,Huon Wilson-18/+12
raw}::copy_memory. Slices carry their length with them, so we can just use that information.
2013-12-15std: fix spelling in docs.Huon Wilson-8/+9
2013-12-12Inline Finallyalizer::drop, allowing LLVM to optimize `finally`.Eduard Burtescu-0/+55
* fixes the vec::from_elem regression caused by #8780 * added 5 benchmarks for allocating a 1KB ~[u8] and zeroing it
2013-12-11Make 'self lifetime illegal.Erik Price-145/+145
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-03add MutableVector::mut_split(self, pred) -> DoubleEndedIterator<&mut [T]>Guillaume Pinot-4/+110
This method is the mutable version of ImmutableVector::split. It is a DoubleEndedIterator, making mut_rsplit irrelevent. The size_hint method is not optimal because of #9629. At the same time, clarify *split* iterator doc.
2013-12-02rename MutableVector::mut_split(at) to MutableVector::mut_split_at(at)Guillaume Pinot-6/+6
2013-11-30Implement DoubleEndedIterator for MutChunkIter.Palmer Cox-0/+29