about summary refs log tree commit diff
path: root/src/libstd/collections
AgeCommit message (Collapse)AuthorLines
2014-10-06library-level docs for collectionsAlexis Beingessner-3/+317
2014-09-27auto merge of #17517 : pczarn/rust/hashmap-lifetimes, r=alexcrichtonbors-5/+15
Fixes #17500
2014-09-27complete btree rewriteAlexis Beingessner-1/+1
Replaces BTree with BTreeMap and BTreeSet, which are completely new implementations. BTreeMap's internal Node representation is particularly inefficient at the moment to make this first implementation easy to reason about and fairly safe. Both collections are also currently missing some of the tooling specific to sorted collections, which is planned as future work pending reform of these APIs. General implementation issues are discussed with TODOs internally Perf results on x86_64 Linux: test treemap::bench::find_rand_100 ... bench: 76 ns/iter (+/- 4) test treemap::bench::find_rand_10_000 ... bench: 163 ns/iter (+/- 6) test treemap::bench::find_seq_100 ... bench: 77 ns/iter (+/- 3) test treemap::bench::find_seq_10_000 ... bench: 115 ns/iter (+/- 1) test treemap::bench::insert_rand_100 ... bench: 111 ns/iter (+/- 1) test treemap::bench::insert_rand_10_000 ... bench: 996 ns/iter (+/- 18) test treemap::bench::insert_seq_100 ... bench: 486 ns/iter (+/- 20) test treemap::bench::insert_seq_10_000 ... bench: 800 ns/iter (+/- 15) test btree::map::bench::find_rand_100 ... bench: 74 ns/iter (+/- 4) test btree::map::bench::find_rand_10_000 ... bench: 153 ns/iter (+/- 5) test btree::map::bench::find_seq_100 ... bench: 82 ns/iter (+/- 1) test btree::map::bench::find_seq_10_000 ... bench: 108 ns/iter (+/- 0) test btree::map::bench::insert_rand_100 ... bench: 220 ns/iter (+/- 1) test btree::map::bench::insert_rand_10_000 ... bench: 620 ns/iter (+/- 16) test btree::map::bench::insert_seq_100 ... bench: 411 ns/iter (+/- 12) test btree::map::bench::insert_seq_10_000 ... bench: 534 ns/iter (+/- 14) BTreeMap still has a lot of room for optimization, but it's already beating out TreeMap on most access patterns. [breaking-change]
2014-09-25auto merge of #17378 : Gankro/rust/hashmap-entry, r=aturonbors-6/+287
Deprecates the `find_or_*` family of "internal mutation" methods on `HashMap` in favour of the "external mutation" Entry API as part of RFC 60. Part of #17320, but this still needs to be done on the rest of the maps. However they don't have any internal mutation methods defined, so they can be done without deprecating or breaking anything. Work on `BTree` is part of the complete rewrite in #17334. The implemented API deviates from the API described in the RFC in two key places: * `VacantEntry.set` yields a mutable reference to the inserted element to avoid code duplication where complex logic needs to be done *regardless* of whether the entry was vacant or not. * `OccupiedEntry.into_mut` was added so that it is possible to return a reference into the map beyond the lifetime of the Entry itself, providing functional parity to `VacantEntry.set`. This allows the full find_or_insert functionality to be implemented using this API. A PR will be submitted to the RFC to amend this. [breaking-change]
2014-09-24implement entry API for HashMapAlexis Beingessner-6/+287
Deprecates the `find_or_*` family of "internal mutation" methods on `HashMap` in favour of the "external mutation" Entry API as part of RFC 60. Part of #17320, although this still needs to be done on the rest of the maps, they don't have any internal mutation methods defined, so they can be done without deprecating or breaking anything. Work on `BTree`'s is part of the complete rewrite in #17334. The implemented API deviates from the API described in the RFC in two key places: * `VacantEntry.set` yields a mutable reference to the inserted element to avoid code duplication where complex logic needs to be done *regardless* of whether the entry was vacant or not. * `OccupiedEntry.into_mut` was added so that it is possible to return a reference into the map beyond the lifetime of the Entry itself, providing functional parity to `VacantEntry.set`. This allows the full find_or_insert functionality to be implemented using this API. A PR will be submitted to the RFC to amend this. [breaking-change]
2014-09-24Fix free lifetime vars in HashMap's iteratorsPiotr Czarnecki-5/+15
2014-09-21Remove #[allow(deprecated)] from libstdAlex Crichton-3/+4
2014-09-16Fallout from renamingAaron Turon-17/+23
2014-09-16Align with _mut conventionsAaron Turon-4/+16
As per [RFC 52](https://github.com/rust-lang/rfcs/blob/master/active/0052-ownership-variants.md), use `_mut` suffixes to mark mutable variants, and `into_iter` for moving iterators. [breaking-change]
2014-09-04std: Fix overflow of HashMap's capacityPiotr Czarnecki-32/+49
2014-09-04std: Refine and document HashMap's codePiotr Czarnecki-482/+704
* branchless `bucket.next()` * robin_hood is a free function * fixed the resize policy that was off by one * documented the growth algorithm * updated documentation after interface changes * removed old fixmes
2014-09-02std: Split hashmap.rs into modulesPiotr Czarnecki-1660/+1743
2014-09-02std: RawTable exposes a safe interface for HashMapPiotr Czarnecki-528/+883
Introduced a new growth algorithm.
2014-09-02std: branchless bucket distance for hashmapPiotr Czarnecki-9/+1
2014-08-29Register new snapshotsAlex Crichton-18/+0
2014-08-27Implement generalized object and type parameter bounds (Fixes #16462)Niko Matsakis-2/+20
2014-08-13core: Rename ImmutableEqSlice to ImmutablePartialEqSliceBrian Anderson-1/+1
This is in the prelude and won't break much code. [breaking-change]
2014-08-13std: Rename various slice traits for consistencyBrian Anderson-1/+1
ImmutableVector -> ImmutableSlice ImmutableEqVector -> ImmutableEqSlice ImmutableOrdVector -> ImmutableOrdSlice MutableVector -> MutableSlice MutableVectorAllocating -> MutableSliceAllocating MutableCloneableVector -> MutableCloneableSlice MutableOrdVector -> MutableOrdSlice These are all in the prelude so most code will not break. [breaking-change]
2014-08-12auto merge of #16195 : P1start/rust/more-index, r=aturonbors-6/+48
Implement `Index` for `RingBuf`, `HashMap`, `TreeMap`, `SmallIntMap`, and `TrieMap`. If there’s anything that I missed or should be removed, let me know.
2014-08-12Implement Index for HashMapP1start-6/+48
This also deprecates HashMap::get. Use indexing instead.
2014-08-01Fix misspelled comments.Joseph Crail-1/+1
2014-07-30Library changes for RFC #43Cameron Zwarich-1/+2
2014-07-28doc: reduce overlong sentenceTshepang Lekhonkhobe-1/+1
2014-07-27doc: Correctly onclose code blocks in HashSetJonas Hietala-0/+3
2014-07-26auto merge of #15941 : treeman/rust/doc-lru, r=alexcrichtonbors-0/+85
2014-07-24Cleanup HashMap documentation.Jonas Hietala-53/+68
Link to mentioned methods. Use `# Failure` tags to describe failure. Make `pop_equiv`, `find_equiv` and `get_copy` standalone.
2014-07-24Cleanup LruCache doc.Jonas Hietala-9/+8
2014-07-24Documentation examples for LruCache.Jonas Hietala-0/+86
2014-07-24Remove explicit rust code specifier. Unhide use HashMap.Jonas Hietala-56/+56
2014-07-24Fill in example code for HashMap.Jonas Hietala-19/+293
Add an example showing how to use the map with a custom type. Fill in examples for methods in the hashmap file without ones. Also move pop_equiv next to related public methods, to not create a duplicate trait implementation in the docs.
2014-07-23Just land alreadyBrian Anderson-1/+1
2014-07-23collections: Move push/pop to MutableSeqBrian Anderson-1/+1
Implement for Vec, DList, RingBuf. Add MutableSeq to the prelude. Since the collections traits are in the prelude most consumers of these methods will continue to work without change. [breaking-change]
2014-07-22auto merge of #15867 : cmr/rust/rewrite-lexer4, r=alexcrichtonbors-0/+2
2014-07-21Add a ton of ignore-lexer-testCorey Richardson-0/+2
2014-07-18Remove examples from trait implementations. Unhide imports.Jonas Hietala-154/+18
2014-07-18Fill in documentation for HashSet.Jonas Hietala-37/+267
Example how to use the set with a custom type. Fill in examples for the missing methods.
2014-07-16Extend HashSet documentation.Jonas Hietala-4/+159
Add main example and simple examples for the methods.
2014-07-13Stabilization for `owned` (now `boxed`) and `cell`Aaron Turon-1/+1
This PR is the outcome of the library stabilization meeting for the `liballoc::owned` and `libcore::cell` modules. Aside from the stability attributes, there are a few breaking changes: * The `owned` modules is now named `boxed`, to better represent its contents. (`box` was unavailable, since it's a keyword.) This will help avoid the misconception that `Box` plays a special role wrt ownership. * The `AnyOwnExt` extension trait is renamed to `BoxAny`, and its `move` method is renamed to `downcast`, in both cases to improve clarity. * The recently-added `AnySendOwnExt` extension trait is removed; it was not being used and is unnecessary. [breaking-change]
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-7/+7
[breaking-change]
2014-07-04librustc: Remove the `&LIFETIME EXPR` production from the language.Patrick Walton-6/+3
This was parsed by the parser but completely ignored; not even stored in the AST! This breaks code that looks like: static X: &'static [u8] = &'static [1, 2, 3]; Change this code to the shorter: static X: &'static [u8] = &[1, 2, 3]; Closes #15312. [breaking-change]
2014-07-02auto merge of #15257 : erickt/rust/hashmap, r=alexcrichtonbors-15/+18
While `HashMap::new` and `HashMap::with_capacity` were being initialized with a random `SipHasher`, it turns out that `HashMap::from_iter` was just using the default instance of `SipHasher`, which wasn't randomized. This closes that bug, and also inlines some important methods.
2014-06-30libstd: set baseline stability levels.Aaron Turon-0/+2
Earlier commits have established a baseline of `experimental` stability for all crates under the facade (so their contents are considered experimental within libstd). Since `experimental` is `allow` by default, we should use the same baseline stability for libstd itself. This commit adds `experimental` tags to all of the modules defined in `std`, and `unstable` to `std` itself.
2014-06-30std: micro optimize Hash{Map,Set}::{new,with_capacity}Erick Tryzelaar-0/+8
2014-06-30std: make sure HashMap from_iter uses random initialization by defaultErick Tryzelaar-15/+10
It turns out that HashMap's from_iter implementation was being initialized without the sip keys being randomized. This adds a custom default hasher that should avoid this potential vulnerability.
2014-06-28Rename all raw pointers as necessaryAlex Crichton-3/+3
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-70/+70
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-15Register new snapshotsAlex Crichton-44/+0
2014-06-11std: Remove i18n/l10n from format!Alex Crichton-0/+44
* The select/plural methods from format strings are removed * The # character no longer needs to be escaped * The \-based escapes have been removed * '{{' is now an escape for '{' * '}}' is now an escape for '}' Closes #14810 [breaking-change]
2014-06-10auto merge of #14696 : jakub-/rust/dead-struct-fields, r=alexcrichtonbors-3/+2
This uncovered some dead code, most notably in middle/liveness.rs, which I think suggests there must be something fishy with that part of the code. The #[allow(dead_code)] annotations on some of the fields I am not super happy about but as I understand, marker type may disappear at some point.
2014-06-09core: Move the collections traits to libcollectionsAlex Crichton-7/+8
This commit moves Mutable, Map, MutableMap, Set, and MutableSet from `core::collections` to the `collections` crate at the top-level. Additionally, this removes the `deque` module and moves the `Deque` trait to only being available at the top-level of the collections crate. All functionality continues to be reexported through `std::collections`. [breaking-change]