about summary refs log tree commit diff
path: root/src/libstd/collections
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-5984/+0
2020-07-20Auto merge of #74010 - pierwill:pierwill-o-notation, r=GuillaumeGomezbors-1/+1
Use italics for O notation In documentation, I think it makes sense to italicize O notation (*O(n)*) as opposed to using back-ticks (`O(n)`). Visually, back-ticks focus the reader on the literal characters being used, making them ideal for representing code. Using italics, as far I can tell, more closely follows typographic conventions in mathematics and computer science. Just a suggestion, of course! šŸ˜‡
2020-07-19Use italics for O notationpierwill-1/+1
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2020-07-18Use intra-doc links on HashSetManish Goregaokar-38/+9
2020-07-18Use intra-doc links on HashMapManish Goregaokar-68/+19
2020-05-29Remove an old comment from HashMap::extend_reserveJosh Stone-1/+0
2020-05-29Add Extend::{extend_one,extend_reserve}Josh Stone-0/+49
This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-04-29Add explicit references to the BuildHasher traitMark Rousskov-0/+20
2020-04-22More diagnostic items for Clippy usagePhilipp Hansch-0/+2
This adds a couple of more diagnostic items to be used in Clippy. I chose these particular ones because they were the types which we seem to check for the most in Clippy. I'm not sure if the `cfg_attr(not(test))` is needed, but it was also used for `Vec` and a few other types.
2020-04-15big-O notation: parenthesis, multiplication and backticksRalf Jung-4/+4
2020-04-11Change issue number to point to tracking issueChai T. Rex-1/+1
2020-04-10Fixed doc tests for added methodsChai T. Rex-0/+1
2020-04-10Add or_insert_with_key to Entry of HashMap/BTreeMapChai T. Rex-0/+27
Going along with or_insert_with, or_insert_with_key provides the Entry's key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time. This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda.
2020-04-06Don't import integer module in libstdLinus FƤrnstrand-1/+0
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-1/+1
2020-02-13Rollup merge of #67642 - Mark-Simulacrum:relax-bounds, r=AmanieuDylan DPC-75/+71
Relax bounds on HashMap/HashSet These APIs changed from the old bound listed to the new bound (possibly empty): K: Hash + Eq -> K * new * with_capacity K: Eq + Hash, S: BuildHasher -> K, S * with_hasher * with_capacity_and_hasher * hasher K: Eq + Hash + Debug -> K: Debug S: BuildHasher -> S HashMap as Debug K: Eq + Hash -> K S: BuildHasher + Default -> S: Default HashMap as Default Resolves #44777.
2020-01-08Add HashSet::get_or_insert_ownedJosh Stone-0/+32
2019-12-26Relax bounds on HashSet to match hashbrownMark Rousskov-11/+9
No functional changes are made, and all APIs are moved to strictly less restrictive bounds. These APIs changed from the old bound listed to the new bound: T: Hash + Eq -> T * new * with_capacity T: Eq + Hash, S: BuildHasher -> T * with_hasher * with_capacity_and_hasher * hasher T: Eq + Hash + Debug -> T: Debug S: BuildHasher -> S <HashSet as Debug> T: Eq + Hash -> T S: BuildHasher + Default -> S: Default <HashSet as Default>
2019-12-26Relax bounds on HashMap to match hashbrownMark Rousskov-64/+62
No functional changes are made, and all APIs are moved to strictly less restrictive bounds. These APIs changed from the old bound listed to no trait bounds: K: Hash + Eq * new * with_capacity K: Eq + Hash, S: BuildHasher * with_hasher * with_capacity_and_hasher * hasher K: Eq + Hash + Debug -> K: Debug S: BuildHasher -> S <HashMap as Debug> K: Eq + Hash -> K S: BuildHasher + Default -> S: Default <HashMap as Default>
2019-12-26Remove redundant link textsMatthew Kraai-2/+2
2019-12-22Format the worldMark Rousskov-174/+142
2019-12-09Update HashMap documentation hint of the used 'quadratic probing' and 'SIMD ↵Christoph Schmidler-1/+1
lookup' algorithms
2019-11-29Format libstd with rustfmtDavid Tolnay-5/+5
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-11-14introduce benchmarks of HashSet operationsStein Somers-117/+0
2019-11-10Fix HashSet::union performanceStepan Koltsov-1/+1
Consider this example: small_set = 0..2, large_set = 0..1000. To efficiently compute the union of these sets, we should * take all elements of the larger set * for each element of the smaller set check it is not in the larger set This is exactly what this commit does. This particular optimization was implemented a year ago, but the author mistaken `<` and `>`.
2019-11-01Rollup merge of #65112 - jack-t:type-parens-lint, r=varkorTyler Mandry-3/+3
Add lint and tests for unnecessary parens around types This is my first contribution to the Rust project, so I apologize if I'm not doing things the right way. The PR fixes #64169. It adds a lint and tests for unnecessary parentheses around types. I've run `tidy` and `rustfmt` &mdash; I'm not totally sure it worked right, though &mdash; and I've tried to follow the instructions linked in the readme. I tried to think through all the variants of `ast::TyKind` to find exceptions to this lint, and I could only find the one mentioned in the original issue, which concerns types with `dyn`. I'm not a Rust expert, thought, so I may well be missing something. There's also a problem with getting this to build. The new lint catches several things in the, e.g., `core`. Because `x.py` seems to build with an equivalent of `-Werror`, what would have been warnings cause the build to break. I got it to build and the tests to pass with `--warnings warn` on my `x.py build` and `x.py test` commands.
2019-10-29Add lint for unnecessary parens around typesjack-t-3/+3
2019-10-11Rollup merge of #65048 - Kixunil:patch-1, r=KodrAusTyler Mandry-0/+2
Added doc about behavior of extend on HashMap It was unclear what the implementation does when it encounters existing keys. This change makes it clear by documenting the trait impl.
2019-10-09Implement (HashMap) Entry::insert as per #60142Félix Saparelli-0/+47
2019-10-03Added doc about behavior of extend on HashMapMartin HabovŔtiak-0/+2
It was unclear what the implementation does when it encounters existing keys. This change makes it clear by documenting the trait impl.
2019-10-01Remove unneeded `fn main` blocks from docsLzu Tao-13/+6
2019-09-27Stabilize map_get_key_value featureLzu Tao-2/+1
2019-08-16Add the Layout of the failed allocation to TryReserveError::AllocErrorSimon Sapin-2/+5
… and add a separately-unstable field to force non-exhaustive matching (`#[non_exhaustive]` is no implemented yet on enum variants) so that we have the option to later expose the allocator’s error value. CC https://github.com/rust-lang/wg-allocators/issues/23
2019-08-16Update hashbrown to 0.5.0Simon Sapin-1/+1
2019-08-16Rename CollectionAllocError to TryReserveErrorSimon Sapin-9/+9
2019-07-16Test that maplike FromIter satisfies uniquenessNick Hynes-2/+6
2019-07-02HashMap is UnwindSafeSimon Sapin-0/+6
Fixes https://github.com/rust-lang/rust/issues/62301, a regression in 1.36.0 which was caused by hashbrown using `NonZero<T>` where the older hashmap used `Unique<T>`.
2019-05-20Rollup merge of #60511 - taiki-e:libstd-intra-doc, r=Dylan-DPCMazdak Farrokhzad-1/+4
Fix intra-doc link resolution failure on re-exporting libstd Currently, re-exporting libstd items as below will [occur a lot of failures](https://gist.github.com/taiki-e/e33e0e8631ef47f65a74a3b69f456366). ```rust pub use std::*; ``` Until the underlying issue (#56922) fixed, we can fix that so they don't propagate to downstream crates. Related: https://github.com/rust-lang/rust/pull/56941 (That PR fixed failures that occur when re-exporting from libcore to libstd.) r? @QuietMisdreavus
2019-05-17Auto merge of #60899 - cuviper:RawEntryMut-origin-story, r=Centrilbors-2/+4
doc: correct the origin of RawEntryMut
2019-05-16doc: correct the origin of RawEntryMutJosh Stone-2/+4
2019-05-16Comment why get_or_insert returns &TJosh Stone-0/+4
2019-05-16Add a hash_set_entry tracking issueJosh Stone-2/+2
2019-05-16Add entry-like methods to HashSetJosh Stone-0/+52
* `HashSet::get_or_insert` * `HashSet::get_or_insert_with` These provide a simplification of the `Entry` API for `HashSet`, with names chosen to match the similar methods on `Option`.
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-1/+4
2019-04-25ignore-tidy-filelength on all files with greater than 3000 linesvarkor-0/+2
2019-04-24Remove broken testsAmanieu d'Antras-74/+0
2019-04-24Replace the robin-hood hash table with hashbrownAmanieu d'Antras-2278/+405
2019-04-24Mark HashSet functions with #[inline]Amanieu d'Antras-0/+45
2019-04-24Add try_reserve to HashSetAmanieu d'Antras-0/+24
2019-04-24Remove the Recover trait for HashSetAmanieu d'Antras-52/+9