about summary refs log tree commit diff
path: root/src/libstd/vec.rs
AgeCommit message (Collapse)AuthorLines
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
2013-11-30Implement mut_chunks() method for MutableVector trait.Palmer Cox-0/+73
mut_chunks() returns an iterator that produces mutable slices. This is the mutable version of the existing chunks() method on the ImmutableVector trait.
2013-11-29Removed a few macro-expanding-to-module workaroundsMarvin Löbel-26/+5
Also documented a few issues
2013-11-28auto merge of #10519 : ↵bors-0/+194
nikomatsakis/rust/issue-8624-borrowck-overly-permissive, r=pnkfelix See #8624 for details. r? @pnkfelix
2013-11-26librustc: Fix merge fallout.Patrick Walton-2/+2
2013-11-26libstd: Fix Win32 and other bustage.Patrick Walton-16/+16
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-2/+6
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-50/+46
2013-11-26librustc: Remove remaining uses of `&fn()` in favor of `||`.Patrick Walton-10/+10
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-60/+65
2013-11-26std: Remove unused attributesklutzy-2/+2
This also enables two tests properly.
2013-11-25Add [mut_]shift_ref/[mut_]pop_ref functions, which return a pointer to the ↵Niko Matsakis-0/+194
first/last item in the slice and modify the slice to exclude the returned item. Useful when writing iterators over mutable references.
2013-11-22Add more benchmark tests to vec.rsg3xzh-2/+70
New benchmark tests in vec.rs: `push`, `starts_with_same_vector`, `starts_with_single_element`, `starts_with_diff_one_element_end`, `ends_with_same_vector`, `ends_with_single_element`, `ends_with_diff_one_element_beginning` and `contains_last_element`
2013-11-21`std::ptr::read_ptr` now takes `*T` instead of `*mut T`Ziad Hatahet-1/+1
Closes #10579
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-27/+29
2013-11-11vec: with_capacity: check for overflowCorey Richardson-1/+5
Fixes #10271
2013-11-08add `clone_from` and `deep_clone_from`Daniel Micay-1/+23
Closes #10240
2013-11-06Register new snapshotsAlex Crichton-14/+1
2013-11-05Rename misleading contains_managed to owns_managedNiko Matsakis-8/+21
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-16/+16
Who doesn't like a massive renaming?
2013-10-17std: Move size/align functions to std::mem. #2240Brian Anderson-22/+22
2013-10-17auto merge of #9908 : alexcrichton/rust/snapshots, r=thestingerbors-80/+0
2013-10-17Register new snapshotsAlex Crichton-80/+0
2013-10-16Implement new methods vec.starts_with()/vec.ends_with()Kevin Ballard-0/+46
2013-10-16Rewrite vec.contains() to be simplerKevin Ballard-2/+2
2013-10-16auto merge of #9833 : alexcrichton/rust/fixes, r=brsonbors-0/+1
Commits have all the fun details
2013-10-15Require module documentation with missing_docAlex Crichton-0/+1
Closes #9824
2013-10-15use element count in slices, not size in bytesDaniel Micay-0/+81
This allows the indexing bounds check or other comparisons against an element length to avoid a multiplication by the size.
2013-10-14std::vec: move documentation from impls to traits.Huon Wilson-302/+303
This means the text is visible in rustdoc.
2013-10-12auto merge of #9608 : hmarr/rust/vec-get-opt, r=huonwbors-0/+18
This adds `get_opt` to `std::vec`, which looks up an item by index and returns an `Option`. If the given index is out of range, `None` will be returned, otherwise a `Some`-wrapped item will be returned. Example use case: ```rust use std::os; fn say_hello(name: &str) { println(fmt!("Hello, %s", name)); } fn main(){ // Try to get the first cmd line arg, but default to "World" let args = os::args(); let default = ~"World"; say_hello(*args.get_opt(1).unwrap_or(&default)); } ``` If there's an existing way of implementing this pattern that's cleaner, I'll happily close this. I'm also open to naming suggestions (`index_opt`?)
2013-09-30std: Remove usage of fmt!Alex Crichton-18/+18
2013-09-29Add get_opt to std::vecHarry Marr-0/+18
2013-09-28auto merge of #9583 : blake2-ppc/rust/connect-vec, r=huonwbors-46/+38
std::vec: Sane implementations for connect_vec and concat_vec Avoid unnecessary copying of subvectors, and calculate the needed space beforehand. These implementations are simple but better than the previous. Also only implement it once, for all `Vector<T>` using: impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V] Closes #9581
2013-09-28std::vec: Remove functions concat, connectblake2-ppc-20/+5
std::vec::{concat, connect, concat_slices, connect_slices} are replaced by the already existing trait methods .concat_vec() and .connect_vec().
2013-09-28std::vec: Sane implementations for connect_vec and concat_vecblake2-ppc-26/+15
Avoid unnecessary copying of subvectors, and calculate the needed space beforehand. These implementations are simple but better than the previous. Also only implement it once, for all `Vector<T>` using: impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V] performance improved according to the bench test: before test vec::bench::concat ... bench: 74818 ns/iter (+/- 408) test vec::bench::connect ... bench: 87066 ns/iter (+/- 376) after test vec::bench::concat ... bench: 17724 ns/iter (+/- 126) test vec::bench::connect ... bench: 18353 ns/iter (+/- 691) Closes #9581
2013-09-28std::vec: Add benchmark for .concat_vec and .connect_vecblake2-ppc-0/+18
2013-09-27auto merge of #9557 : blake2-ppc/rust/vec-lifetime-token, r=thestingerbors-6/+6
std::vec: Use a valid value as lifetime dummy in iterator The current implementation uses `&v[0]` for the lifetime struct field, but that is a dangling pointer for iterators derived from zero-length slices. Example: let v: [int, ..0] = []; println!("{:?}", v.iter()) std::vec::VecIterator<,int>{ptr: (0x7f3768626100 as *()), end: (0x7f3768626100 as *()), lifetime: &139875951207128} To replace this parameter, use a field of type `Option<&'self ()>` that is simply initialized with `None`, but still allows the iterator to have a lifetime parameter.
2013-09-27std::vec: Use a valid value as lifetime dummy in iteratorblake2-ppc-6/+6
The current implementation uses `&v[0]` for the lifetime struct field, but that is a dangling pointer for iterators derived from zero-length slices. Example: let v: [int, ..0] = []; println!("{:?}", v.iter()) std::vec::VecIterator<,int>{ptr: (0x7f3768626100 as *()), end: (0x7f3768626100 as *()), lifetime: &139875951207128} To replace this parameter, use a field of type `Option<&'self ()>` that is simply initialized with `None`, but still allows the iterator to have a lifetime parameter.
2013-09-26Update the compiler to not use printf/printflnAlex Crichton-2/+2
2013-09-25rustdoc: Change all code-blocks with a scriptAlex Crichton-18/+18
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g' find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g' find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
2013-09-21Document a few undocumented methos in VectorLuis de Bethencourt-0/+6
Closes #9379
2013-09-17Document a few undocumented modules in libstdAlex Crichton-0/+2
Hopefull this will make our libstd docs appear a little more "full".
2013-09-17std::at_vec: Fix segfault on overflow when resizing ~[@T]blake2-ppc-0/+8
Easy to reproduce: let mut v = ~[@1]; v.resize(-1); // success a.k.a silent failure v.push(@2); // segfault
2013-09-16std::vec: Add function vec::bytes::push_bytesblake2-ppc-0/+17
`push_bytes` is implemented with `ptr::copy_memory` here since this function is intended to be used to implement `.push_str()` for str, so we want to avoid the overhead.
2013-09-16std::vec: Fix hazards with uint overflows in unsafe codeblake2-ppc-6/+29
Issue #8742 Add the method `.reserve_additional(n: uint)`: Check for overflow in self.len() + n, and reserve that many elements (rounded up to next power of two). Does nothing if self.len() + n < self.capacity() already.
2013-09-12std: Remove Zero impl from vecErick Tryzelaar-21/+4
Vecs are not numeric types, so it doesn't make sense for them to implement Zero.
2013-09-12std: Add Default implementation for vecsErick Tryzelaar-0/+14
2013-09-12std: rename Option::unwrap_or_default() to unwrap_or()Erick Tryzelaar-1/+1