about summary refs log tree commit diff
path: root/src/libstd/collections/hash/map.rs
AgeCommit message (Collapse)AuthorLines
2017-03-17Fix a spelling error in HashMap documentation, and slightly reword it to be ↵Jeff Walden-2/+2
more precise.
2017-03-11Implement placement-in protocol for `HashMap`Charlie Fan-5/+155
2017-03-03Reduce size overhead of adaptative hashmaparthurprs-16/+8
Exposes a boolean flag in RawTable and use it instead of a bool field in HashMap. Fixes: #40042
2017-02-20Simplify adaptive hashmaparthurprs-23/+11
2017-02-18Fix spelling in commentsarthurprs-5/+5
2017-02-16Resize hashmap when long probes are detectedarthurprs-12/+105
2017-02-15Rollup merge of #39839 - king6cong:refine-doc, r=frewsxcvCorey Farwell-1/+1
make doc consistent with var name
2017-02-15Auto merge of #39560 - F001:retainHashMap, r=alexcrichtonbors-39/+75
std: Add retain method for HashMap and HashSet Fix #36648 r? @bluss
2017-02-15make doc consistent with var nameking6cong-1/+1
2017-02-08std: Add retain method for HashMap and HashSetf001-39/+75
Fix #36648
2017-02-05Rollup merge of #39393 - ollie27:stab_impls, r=alexcrichtonCorey Farwell-8/+8
Fix a few impl stability attributes The versions show up in rustdoc.
2017-02-03Add missing urls in HashMapGuillaume Gomez-5/+12
2017-01-29Fix a few impl stability attributesOliver Middleton-8/+8
The versions show up in rustdoc.
2017-01-13Change `to_owned` to `to_string` in docsStjepan Glavina-2/+2
We should teach conversion from `str` to `String` using `to_string` rather than the legacy `to_owned`.
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-2/+81
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-07Rollup merge of #38186 - frewsxcv:default, r=GuillaumeGomezGuillaume Gomez-0/+4
Add docs for last undocumented `Default` `impl`. Add doc comment for `Default` `impl` on `DefaultHasher`. Fixes https://github.com/rust-lang/rust/issues/36265.
2016-12-06Add doc comment for `Default` `impl` on `DefaultHasher`.Corey Farwell-0/+4
2016-12-06Auto merge of #38017 - arthurprs:hm-extend, r=blussbors-4/+13
Smarter HashMap/HashSet pre-allocation for extend/from_iter HashMap/HashSet from_iter and extend are making totally different assumptions. A more balanced decision may allocate half the lower hint (rounding up). For "well defined" iterators this effectively limits the worst case to two resizes (the initial reserve + one resize). cc #36579 cc @bluss
2016-12-06Smarter HashMap/HashSet extendarthurprs-4/+13
2016-11-27Use displacement instead of initial bucket in HashMap codearthurprs-18/+21
2016-10-31Don't reuse RandomState seedsarthurprs-14/+12
2016-10-06Auto merge of #36753 - srinivasreddy:hash, r=nrcbors-184/+264
run rustfmt on libstd/collections/hash folder
2016-10-04Rollup merge of #36902 - ollie27:stab_impls, r=alexcrichtonManish Goregaokar-3/+3
std: Correct stability attributes for some implementations These are displayed by rustdoc so should be correct.
2016-10-03Auto merge of #36815 - alexcrichton:stabilize-1.13, r=aturonbors-2/+26
std: Stabilize and deprecate APIs for 1.13 This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-10-03std: Stabilize and deprecate APIs for 1.13Alex Crichton-2/+26
This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` * `DefaultHasher` * `DefaultHasher::new` * `DefaultHasher::default` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-10-03Auto merge of #36766 - nnethercote:hash-span-capacity, r=blussbors-85/+94
Clarify HashMap's capacity handling. HashMap has two notions of "capacity": - "Usable capacity": the number of elements a hash map can hold without resizing. This is the meaning of "capacity" used in HashMap's API, e.g. the `with_capacity()` function. - "Internal capacity": the number of allocated slots. Except for the zero case, it is always larger than the usable capacity (because some slots must be left empty) and is always a power of two. HashMap's code is confusing because it does a poor job of distinguishing these two meanings. I propose using two different terms for these two concepts. Because "capacity" is already used in HashMap's API to mean "usable capacity", I will use a different word for "internal capacity". I propose "span", though I'm happy to consider other names.
2016-10-03Avoid overflow check in `HashMap::reserve`'s fast path.Nicholas Nethercote-2/+3
2016-10-01std: Correct stability attributes for some implementationsOliver Middleton-3/+3
These are displayed by rustdoc so should be correct.
2016-09-29Auto merge of #36557 - sfackler:fix-hashdos-docs, r=alexcrichtonbors-8/+22
Clean up hasher discussion on HashMap * We never want to make guarantees about protecting against attacks. * "True randomness" is not the right terminology to be using in this context. * There is significantly more nuance to the performance of SipHash than "somewhat slow". r? @steveklabnik Follow up to discussion on #35371
2016-09-29Mention FNVSteven Fackler-1/+1
2016-09-29Clarify HashMap's capacity handling.Nicholas Nethercote-85/+93
This commit does the following. - Changes the terminology for capacities used within HashMap's code. "Internal capacity" is now consistently "raw capacity", and "usable capacity" is now consistently just "capacity". This makes the code easier to understand. - Reworks capacity and raw capacity computations. Raw capacity computations are now handled in a single place: `DefaultResizePolicy::raw_capacity()`. This function correctly returns zero when given zero, which means that the following cases now result in a capacity of zero when they previously did not. * `Hash{Map,Set}::with_capacity(0)` * `Hash{Map,Set}::with_capacity_and_hasher(0)` * `Hash{Map,Set}::shrink_to_fit()`, when used with a hash map/set whose elements have all been removed - Strengthens the language used in the comments describing the above functions, to make it clearer when they will result in a map/set with a capacity of zero. The new language is based on the language used for the corresponding functions in `Vec`. - Adds tests for the above zero-capacity cases. - Removes `test_resize_policy` because it is no longer useful.
2016-09-28Rollup merge of #36740 - frehberg:apidoc, r=steveklabnikJonathan Turner-0/+16
Document init of HashSet/HashMap from vector
2016-09-27Update map.rsFrank Rehberger-4/+6
2016-09-27run rustfmt on libstd/collections/hash folderSrinivas Reddy Thatiparthy-184/+264
2016-09-26Update map.rsFrank Rehberger-1/+1
2016-09-26Update map.rsFrank Rehberger-5/+2
2016-09-26Document init of HashSet/HashMap from vectorFrank Rehberger-0/+17
2016-09-26Don't allocate during default HashSet creation.Nicholas Nethercote-0/+15
The following `HashMap` creation functions don't allocate heap storage for elements. ``` HashMap::new() HashMap::default() HashMap::with_hasher() ``` This is good, because it's surprisingly common to create a HashMap and never use it. So that case should be cheap. However, `HashSet` does not have the same behaviour. The corresponding creation functions *do* allocate heap storage for the default number of non-zero elements (which is 32 slots for 29 elements). ``` HashMap::new() HashMap::default() HashMap::with_hasher() ``` This commit gives `HashSet` the same behaviour as `HashMap`, by simply calling the corresponding `HashMap` functions (something `HashSet` already does for `with_capacity` and `with_capacity_and_hasher`). It also reformats one existing `HashSet` construction to use a consistent single-line format. This speeds up rustc itself by 1.01--1.04x on most of the non-tiny rustc-benchmarks.
2016-09-17Clean up hasher discussion on HashMapSteven Fackler-8/+22
* We never want to make guarantees about protecting against attacks. * "True randomness" is not the right terminology to be using in this context. * There is significantly more nuance to the performance of SipHash than "somewhat slow".
2016-09-11Documentation for default types modifiedathulappadan-1/+1
2016-09-11Documentation of what does for each typeathulappadan-0/+2
2016-09-06Add missing urlsggomez-18/+42
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-2/+0
2016-08-23Auto merge of #35656 - Stebalien:fused, r=alexcrichtonbors-1/+16
Implement 1581 (FusedIterator) * [ ] Implement on patterns. See https://github.com/rust-lang/rust/issues/27721#issuecomment-239638642. * [ ] Handle OS Iterators. A bunch of iterators (`Args`, `Env`, etc.) in libstd wrap platform specific iterators. The current ones all appear to be well-behaved but can we assume that future ones will be? * [ ] Does someone want to audit this? On first glance, all of the iterators on which I implemented `FusedIterator` appear to be well-behaved but there are a *lot* of them so a second pair of eyes would be nice. * I haven't touched rustc internal iterators (or the internal rand) because rustc doesn't actually call `fuse()`. * `FusedIterator` can't be implemented on `std::io::{Bytes, Chars}`. Closes: #35602 (Tracking Issue) Implements: rust-lang/rfcs#1581
2016-08-19std: Stabilize APIs for the 1.12 releaseAlex Crichton-8/+11
Stabilized * `Cell::as_ptr` * `RefCell::as_ptr` * `IpAddr::is_{unspecified,loopback,multicast}` * `Ipv6Addr::octets` * `LinkedList::contains` * `VecDeque::contains` * `ExitStatusExt::from_raw` - both on Unix and Windows * `Receiver::recv_timeout` * `RecvTimeoutError` * `BinaryHeap::peek_mut` * `PeekMut` * `iter::Product` * `iter::Sum` * `OccupiedEntry::remove_entry` * `VacantEntry::into_key` Deprecated * `Cell::as_unsafe_cell` * `RefCell::as_unsafe_cell` * `OccupiedEntry::remove_pair` Closes #27708 cc #27709 Closes #32313 Closes #32630 Closes #32713 Closes #34029 Closes #34392 Closes #34285 Closes #34529
2016-08-18Add a FusedIterator trait.Steven Allen-1/+16
This trait can be used to avoid the overhead of a fuse wrapper when an iterator is already well-behaved. Conforming to: RFC 1581 Closes: #35602
2016-08-16Auto merge of #35354 - tomgarcia:covariant-drain, r=alexcrichtonbors-0/+2
Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariant Fixed the rest of the Drain iterators.
2016-08-05Update HashMap docs regarding DoS protectionMichael Gattozzi-7/+6
Because of changes to how Rust acquires randomness HashMap is not guaranteed to be DoS resistant. This commit reflects these changes in the docs themselves and provides an alternative method to creating a hash that is resistant if needed.
2016-08-04Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariantThomas Garcia-0/+2
2016-07-26Rollup merge of #35001 - rdwilliamson:patch-1, r=alexcrichtonSteve Klabnik-1/+1
Fix HashMap's values_mut example to use println! Fix HashMap's values_mut example to use println!