about summary refs log tree commit diff
path: root/src/libstd/collections
AgeCommit message (Collapse)AuthorLines
2016-02-16Avoid iteration when dropping `HashMap`s whose items don't need droppingAndrew Paseltiner-1/+4
This changes the performance of `drop` from linear to constant time for such `HashMap`s. Closes #31711.
2016-02-15clarify how insert() doesn't update keysJack O'Connor-6/+10
The first time I read the docs for `insert()`, I thought it was saying it didn't update existing *values*, and I was confused. Reword the docs to make it clear that `insert()` does update values.
2016-02-11Auto merge of #31357 - rthomas:hashers, r=alexcrichtonbors-0/+14
add a public hasher function for HashSet and HashMap
2016-02-11Add a public hasher function for HashSet and HashMapRyan Thomas-0/+14
2016-02-04Rollup merge of #31415 - tshepang:2-space-indent, r=steveklabnikSteve Klabnik-3/+3
2016-02-04doc: Rust indents are 4-space wide by conventionTshepang Lekhonkhobe-3/+3
2016-02-02Ensure capacity returned of HashMap is max(capacity, length).Ryan Thomas-1/+29
r? @Gankro
2016-01-26Auto merge of #31081 - alexcrichton:stabilize-hasher, r=aturonbors-122/+128
This commit implements the stabilization of the custom hasher support intended for 1.7 but left out due to some last-minute questions that needed some decisions. A summary of the actions done in this PR are: Stable * `std::hash::BuildHasher` * `BuildHasher::Hasher` * `BuildHasher::build_hasher` * `std::hash::BuildHasherDefault` * `HashMap::with_hasher` * `HashMap::with_capacity_and_hasher` * `HashSet::with_hasher` * `HashSet::with_capacity_and_hasher` * `std::collections::hash_map::RandomState` * `RandomState::new` Deprecated * `std::collections::hash_state` * `std::collections::hash_state::HashState` - this trait was also moved into `std::hash` with a reexport here to ensure that we can have a blanket impl to prevent immediate breakage on nightly. Note that this is unstable in both location. * `HashMap::with_hash_state` - renamed * `HashMap::with_capacity_and_hash_state` - renamed * `HashSet::with_hash_state` - renamed * `HashSet::with_capacity_and_hash_state` - renamed Closes #27713
2016-01-26std: Stabilize custom hasher support in HashMapAlex Crichton-122/+128
This commit implements the stabilization of the custom hasher support intended for 1.7 but left out due to some last-minute questions that needed some decisions. A summary of the actions done in this PR are: Stable * `std::hash::BuildHasher` * `BuildHasher::Hasher` * `BuildHasher::build_hasher` * `std::hash::BuildHasherDefault` * `HashMap::with_hasher` * `HashMap::with_capacity_and_hasher` * `HashSet::with_hasher` * `HashSet::with_capacity_and_hasher` * `std::collections::hash_map::RandomState` * `RandomState::new` Deprecated * `std::collections::hash_state` * `std::collections::hash_state::HashState` - this trait was also moved into `std::hash` with a reexport here to ensure that we can have a blanket impl to prevent immediate breakage on nightly. Note that this is unstable in both location. * `HashMap::with_hash_state` - renamed * `HashMap::with_capacity_and_hash_state` - renamed * `HashSet::with_hash_state` - renamed * `HashSet::with_capacity_and_hash_state` - renamed Closes #27713
2016-01-19Add examples of the Entry API to the HashMap documentation.Nathan Kleyn-0/+29
Responding to [a thread of discussion on the Rust subreddit](https://www.reddit.com/r/rust/comments/3racik/mutable_lifetimes_are_too_long_when_matching_an/), it was identified that the presence of the Entry API is not duly publicised. This commit aims to add some reasonable examples of common usages of this API to the main example secion of the `HashMap` documentation. This is part of issue #29348.
2016-01-16std: Stabilize APIs for the 1.7 releaseAlex Crichton-1/+0
This commit stabilizes and deprecates the FCP (final comment period) APIs for the upcoming 1.7 beta release. The specific APIs which changed were: Stabilized * `Path::strip_prefix` (renamed from `relative_from`) * `path::StripPrefixError` (new error type returned from `strip_prefix`) * `Ipv4Addr::is_loopback` * `Ipv4Addr::is_private` * `Ipv4Addr::is_link_local` * `Ipv4Addr::is_multicast` * `Ipv4Addr::is_broadcast` * `Ipv4Addr::is_documentation` * `Ipv6Addr::is_unspecified` * `Ipv6Addr::is_loopback` * `Ipv6Addr::is_unique_local` * `Ipv6Addr::is_multicast` * `Vec::as_slice` * `Vec::as_mut_slice` * `String::as_str` * `String::as_mut_str` * `<[T]>::clone_from_slice` - the `usize` return value is removed * `<[T]>::sort_by_key` * `i32::checked_rem` (and other signed types) * `i32::checked_neg` (and other signed types) * `i32::checked_shl` (and other signed types) * `i32::checked_shr` (and other signed types) * `i32::saturating_mul` (and other signed types) * `i32::overflowing_add` (and other signed types) * `i32::overflowing_sub` (and other signed types) * `i32::overflowing_mul` (and other signed types) * `i32::overflowing_div` (and other signed types) * `i32::overflowing_rem` (and other signed types) * `i32::overflowing_neg` (and other signed types) * `i32::overflowing_shl` (and other signed types) * `i32::overflowing_shr` (and other signed types) * `u32::checked_rem` (and other unsigned types) * `u32::checked_neg` (and other unsigned types) * `u32::checked_shl` (and other unsigned types) * `u32::saturating_mul` (and other unsigned types) * `u32::overflowing_add` (and other unsigned types) * `u32::overflowing_sub` (and other unsigned types) * `u32::overflowing_mul` (and other unsigned types) * `u32::overflowing_div` (and other unsigned types) * `u32::overflowing_rem` (and other unsigned types) * `u32::overflowing_neg` (and other unsigned types) * `u32::overflowing_shl` (and other unsigned types) * `u32::overflowing_shr` (and other unsigned types) * `ffi::IntoStringError` * `CString::into_string` * `CString::into_bytes` * `CString::into_bytes_with_nul` * `From<CString> for Vec<u8>` * `From<CString> for Vec<u8>` * `IntoStringError::into_cstring` * `IntoStringError::utf8_error` * `Error for IntoStringError` Deprecated * `Path::relative_from` - renamed to `strip_prefix` * `Path::prefix` - use `components().next()` instead * `os::unix::fs` constants - moved to the `libc` crate * `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize * `IntoCow` - conflicts with `Into` and may come back later * `i32::{BITS, BYTES}` (and other integers) - not pulling their weight * `DebugTuple::formatter` - will be removed * `sync::Semaphore` - not used enough and confused with system semaphores Closes #23284 cc #27709 (still lots more methods though) Closes #27712 Closes #27722 Closes #27728 Closes #27735 Closes #27729 Closes #27755 Closes #27782 Closes #27798
2016-01-14Require stability annotations on fields of tuple variantsVadim Petrochenkov-2/+6
2015-12-18Fix the falloutVadim Petrochenkov-1/+1
2015-12-17Remove unused importsJeffrey Seyfried-2/+0
2015-12-10std: Remove deprecated functionality from 1.5Alex Crichton-20/+18
This is a standard "clean out libstd" commit which removes all 1.5-and-before deprecated functionality as it's now all been deprecated for at least one entire cycle.
2015-12-05std: Stabilize APIs for the 1.6 releaseAlex Crichton-11/+3
This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * The `#![no_std]` attribute * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
2015-11-20Rename result variable in HashSet's intersection and union examplesFlorian Hahn-4/+4
2015-11-18Add missing annotations and some testsVadim Petrochenkov-1/+18
2015-11-16Auto merge of #29830 - petrochenkov:mapdoc, r=alexcrichtonbors-2/+3
r? @steveklabnik
2015-11-16Fix docs for HashSet::insertSebastian Hahn-4/+1
insert() returns bool, but it was wrongly stated that if the set had the key already present, that key would be returned (this was probably copied from the HashMap docs). Also remove a reference to the module-level documentation, which doesn't make sense as it doesn't give any more context.
2015-11-14docs: Clarify insertion behavior for mapsVadim Petrochenkov-2/+3
2015-11-06Auto merge of #29643 - petrochenkov:stability5, r=alexcrichtonbors-1/+0
Also remove `stable` stability annotations from inherent impls (There will be a warning for useless stability annotations soon.) r? @Gankro
2015-11-06Remove stability annotations from trait impl itemsVadim Petrochenkov-1/+0
Remove `stable` stability annotations from inherent impls
2015-11-04Add note about HashMap::capacity's boundsSteve Klabnik-0/+3
Fixes #24591
2015-10-25Remove key duplication from `BTreeMap` example in `collections`Tobias Bucher-4/+4
2015-10-22Document replacement behavior in some collectionsSteve Klabnik-4/+62
{BTree,Hash}{Map,Set} will not update their key if it already exists, which can matter with more complex keys. This behavior is now documented. Fixes #26888
2015-10-13Correct spelling in docsAndrew Paseltiner-2/+2
2015-10-06Add RFC 1238's `unsafe_destructor_blind_to_params` (UGEH) where needed.Felix S. Klock II-0/+1
I needed it in `RawVec`, `Vec`, and `TypedArena` for `rustc` to bootstrap; but of course that alone was not sufficient for `make check`. Later I added `unsafe_destructor_blind_to_params` to collections, in particular `LinkedList` and `RawTable` (the backing representation for `HashMap` and `HashSet`), to get the regression tests exercising cyclic structure from PR #27185 building. ---- Note that the feature is `dropck_parametricity` (which is not the same as the attribute's name). We will almost certainly vary our strategy here in the future, so it makes some sense to have a not-as-ugly name for the feature gate. (The attribute name was deliberately selected to be ugly looking.)
2015-09-29Remove redundant uses of Iterator::by_ref()Ulrik Sverdrup-1/+1
2015-09-11std: Internalize almost all of `std::rt`Alex Crichton-8/+5
This commit does some refactoring to make almost all of the `std::rt` private. Specifically, the following items are no longer part of its API: * DEFAULT_ERROR_CODE * backtrace * unwind * args * at_exit * cleanup * heap (this is just alloc::heap) * min_stack * util The module is now tagged as `#[doc(hidden)]` as the only purpose it's serve is an entry point for the `panic!` macro via the `begin_unwind` and `begin_unwind_fmt` reexports.
2015-08-31Implement RFC 839 for `{HashMap, HashSet}`Andrew Paseltiner-0/+62
It appears that these impls were left out of #25989 by mistake.
2015-08-28implement RFC 1194Andrew Paseltiner-4/+105
2015-08-25collections doc: remove mention of BitVec, BitSet, VecMapGeorg Brandl-28/+6
These have been removed and should not be documented here.
2015-08-15std: Add issues to all unstable featuresAlex Crichton-12/+24
2015-08-14Auto merge of #27822 - arielb1:inline-round-take-2, r=Gankrobors-0/+1
This speeds up rustc on #25916 from 1.36±0.022s to 1.326±0.025s Tests pass locally (even on 32-bit :-) r? @Gankro
2015-08-13Mark round_up_to_next as inline arielb1-0/+1
This speeds up rustc on #25916 from 1.36±0.022s to 1.326±0.025s Tests pass locally (even on 32-bit :-)
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-18/+6
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-11Add HashSet and HashMap testsGuillaume Gomez-25/+15
2015-08-10Add Send/Sync traits on Iter struct in hash/tableGuillaume Gomez-1/+25
2015-07-27Show appropriate feature flags in docsSteve Klabnik-5/+10
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-3/+3
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-07-06typo "struct has is 0-sized"Oliver Schneider-1/+1
2015-06-24Make `align_of` behave like `min_align_of`.Huon Wilson-11/+11
This removes a footgun, since it is a reasonable assumption to make that pointers to `T` will be aligned to `align_of::<T>()`. This also matches the behaviour of C/C++. `min_align_of` is now deprecated. Closes #21611.
2015-06-18Auto merge of #26192 - alexcrichton:features-clean, r=aturonbors-22/+23
This commit shards the all-encompassing `core`, `std_misc`, `collections`, and `alloc` features into finer-grained components that are much more easily opted into and tracked. This reflects the effort to push forward current unstable APIs to either stabilization or removal. Keeping track of unstable features on a much more fine-grained basis will enable the library subteam to quickly analyze a feature and help prioritize internally about what APIs should be stabilized. A few assorted APIs were deprecated along the way, but otherwise this change is just changing the feature name associated with each API. Soon we will have a dashboard for keeping track of all the unstable APIs in the standard library, and I'll also start making issues for each unstable API after performing a first-pass for stabilization.
2015-06-17std: Split the `std_misc` featureAlex Crichton-22/+23
2015-06-17collections: fix a couple of typosIvan Ukhov-3/+3
2015-06-10Removed many pointless calls to *iter() and iter_mut()Joshua Landau-9/+10
2015-05-31Inline hash_table::calculate_offsets, used by iterators.Eduard Burtescu-0/+1
The `HashMap` and `HashSet` iterators use `RawTable::first_bucket_raw` which is generic and will get inlined cross-crate. However, `first_bucket_raw` calls `calculate_offsets` and the call doesn't get inlined, despite being a simple function. This missing `#[inline]` results in `hash_table::calculate_offsets` showing up at the top of a callgrind profile with 3 million calls (for the testcase in #25916).
2015-05-17Make debug builders take &mut self, add entries methodSteven Fackler-2/+2
[breaking-change]
2015-05-16Small typo in the docsEmilio Cobos Álvarez-1/+1
Just detected it while reading.