Compatibility: OrdMap
Spec: docs/spec/ordmap-1.md, docs/spec/ordmap-2.md, docs/spec/set-algebra.md,
docs/spec/ordering-and-equality.md, docs/spec/00-overview.md §3. Legend and 01: labels:
../COMPAT.md. GenericOrdMap rows are in crate.md,
OrdMapPool rows in features.md.
There is no HashMap: From<OrdMap> in the spec.
Lookup bounds follow im (BK: Ord + ?Sized, K: Borrow<BK>, 01:bounds). There is no retain
and no iter_mut on OrdMap in im 15.1 or imbl 7; perennial adds neither.
Type and basics (impl<K, V> OrdMap<K, V>, no bounds)
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
OrdMap<K, V> (type) |
struct | alias of GenericOrdMap<K, V, DefaultSharedPtr> |
alias of GenericOrdMap<K, V, P> (01:generic) |
same | tests/compat_ordmap.rs::ord_map_type |
new() -> Self |
O(1) | as im | as im | same | tests/compat_ordmap.rs::new |
with_pool(pool: &OrdMapPool<K, V>) -> Self |
im-rc pool |
absent | size-only handle | differs: pool does not pool allocations (01:pools) | tests/compat_ordmap_features.rs::with_pool |
unit(k: K, v: V) -> Self |
as im | as im | same | tests/compat_ordmap.rs::unit |
|
is_empty(&self) -> bool |
O(1) | as im | as im | same | tests/compat_ordmap.rs::is_empty |
len(&self) -> usize |
O(1) | as im | as im | same | tests/compat_ordmap.rs::len |
ptr_eq(&self, other: &Self) -> bool |
clone → true, edited clone → false, two empty → false | two empty → true | two empty → true | differs: empty maps are ptr_eq (01:ptr_eq-empty) |
tests/compat_ordmap.rs::ptr_eq |
pool(&self) -> &OrdMapPool<K, V> |
im-rc pool |
absent | size-only handle | differs: handle only (01:pools) | tests/compat_ordmap_features.rs::pool |
clear(&mut self) |
O(n) | as im | as im | same | tests/compat_ordmap.rs::clear |
Lookup and navigation (K: Ord)
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
get_max(&self) -> Option<&(K, V)> |
largest entry as a tuple ref | as im | as im | same | tests/compat_ordmap.rs::get_max |
get_min(&self) -> Option<&(K, V)> |
smallest entry | as im | as im | same | tests/compat_ordmap.rs::get_min |
get<BK>(&self, k: &BK) -> Option<&V> |
Comparable bounds |
as im | same | tests/compat_ordmap.rs::get |
|
get_key_value<BK>(&self, k: &BK) -> Option<(&K, &V)> |
as im | as im | same | tests/compat_ordmap.rs::get_key_value |
|
contains_key<BK>(&self, k: &BK) -> bool |
as im | as im | same | tests/compat_ordmap.rs::contains_key |
|
get_prev<BK>(&self, k: &BK) -> Option<(&K, &V)> |
greatest key ≤ k (inclusive; docs wording is wrong) |
as im | as im | same | tests/compat_ordmap.rs::get_prev |
get_next<BK>(&self, k: &BK) -> Option<(&K, &V)> |
least key ≥ k |
as im | as im | same | tests/compat_ordmap.rs::get_next |
iter(&self) -> Iter<'_, K, V> |
ascending | as im | as im | same | tests/compat_ordmap.rs::iter |
range<R, BK>(&self, r: R) -> Iter<'_, K, V> |
ascending, double-ended; inverted/empty ranges yield nothing; len()/size_hint report the whole map |
returns RangedIter, no ExactSize, size_hint (0, Some(n)) |
returns ordmap::Iter (im's shape) with exact len()/size_hint (01:range-type) |
differs: exact len/size_hint (01:range-len) |
tests/compat_ordmap.rs::range |
keys(&self) -> Keys<'_, K, V> |
ascending | as im | as im | same | tests/compat_ordmap.rs::keys |
values(&self) -> Values<'_, K, V> |
ascending by key | as im | as im | same | tests/compat_ordmap.rs::values |
diff<'a>(&'a self, other: &'a Self) -> DiffIter<'a, K, V> |
ascending edits self→other; skips shared structure | two lifetimes 'a, 'b; fixed a miss after shared runs (7.0.2) |
as im's signature; must not miss edits after shared runs | same | tests/differential/ordmap.rs |
is_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> bool |
as im | as im | same | tests/compat_ordmap.rs::is_submap_by |
|
is_proper_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> bool |
as im | as im | same | tests/compat_ordmap.rs::is_proper_submap_by |
|
is_submap<RM>(&self, other: RM) -> bool (V: PartialEq) |
as im | as im | same | tests/compat_ordmap.rs::is_submap |
|
is_proper_submap<RM>(&self, other: RM) -> bool |
as im | as im | same | tests/compat_ordmap.rs::is_proper_submap |
Mutation (K: Ord + Clone, V: Clone)
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
get_mut<BK>(&mut self, k: &BK) -> Option<&mut V> |
as im | as im | same | tests/compat_ordmap.rs::get_mut |
|
get_key_value_mut<Q>(&mut self, k: &Q) -> Option<(&K, &mut V)> |
absent | present | provided, im-style bounds (01 "imbl additions kept") | added (imbl API) | tests/compat_ordmap.rs::get_key_value_mut |
get_prev_mut<BK>(&mut self, k: &BK) -> Option<(&K, &mut V)> |
inclusive | as im | as im | same | tests/compat_ordmap.rs::get_prev_mut |
get_next_mut<BK>(&mut self, k: &BK) -> Option<(&K, &mut V)> |
inclusive | as im | as im | same | tests/compat_ordmap.rs::get_next_mut |
insert(&mut self, k: K, v: V) -> Option<V> |
old value; key object replaced too; a panicking Ord leaves the map intact |
may finish before reaching the panic (fewer comparisons) | as im; map stays valid if Ord panics; comparison count not contractual |
same | tests/compat_ordmap.rs::insert |
remove<BK>(&mut self, k: &BK) -> Option<V> |
as im | as im | same | tests/compat_ordmap.rs::remove |
|
remove_with_key<BK>(&mut self, k: &BK) -> Option<(K, V)> |
as im | as im | same | tests/compat_ordmap.rs::remove_with_key |
|
entry(&mut self, k: K) -> Entry<'_, K, V> |
adds P |
as im | same | tests/compat_ordmap.rs::entry |
Persistent operations
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
update(&self, k: K, v: V) -> Self |
as im | as im | same | tests/compat_ordmap.rs::update |
|
update_with(self, k, v, f: FnOnce(V, V) -> V) -> Self |
takes self by value (HashMap's takes &self) |
as im | as im (by value) | same | tests/compat_ordmap.rs::update_with |
update_with_key(self, k, v, f: FnOnce(&K, V, V) -> V) -> Self |
by value | as im | as im | same | tests/compat_ordmap.rs::update_with_key |
update_lookup_with_key(self, k, v, f: FnOnce(&K, &V, V) -> V) -> (Option<V>, Self) |
by value; previous value | as im | as im | same | tests/compat_ordmap.rs::update_lookup_with_key |
alter(&self, f: FnOnce(Option<V>) -> Option<V>, k: K) -> Self |
as im | as im | same | tests/compat_ordmap.rs::alter |
|
without<BK>(&self, k: &BK) -> Self |
as im | as im | same | tests/compat_ordmap.rs::without |
|
extract<BK>(&self, k: &BK) -> Option<(V, Self)> |
as im | as im | same | tests/compat_ordmap.rs::extract |
|
extract_with_key<BK>(&self, k: &BK) -> Option<(K, V, Self)> |
as im | as im | same | tests/compat_ordmap.rs::extract_with_key |
Combinations (consume both maps; unions* have no S bound)
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
union(self, other: Self) -> Self |
larger map's value wins, self on a tie |
self always wins |
self always wins |
differs: self wins regardless of size (01:union) |
tests/compat_ordmap.rs::union |
union_with(self, other, f: FnMut(V, V) -> V) -> Self |
f(self_v, other_v) |
as im | as im | same | tests/compat_ordmap.rs::union_with |
union_with_key(self, other, f: FnMut(&K, V, V) -> V) -> Self |
as im | as im | same | tests/compat_ordmap.rs::union_with_key |
|
unions(i: impl IntoIterator<Item = Self>) -> Self |
size rule ({1:b,2:b} for the spec probe) |
leftmost wins ({1:a,2:b}) |
leftmost wins | differs: follows the union rule (01:union) |
tests/compat_ordmap.rs::unions |
unions_with(i, f: Fn(V, V) -> V) -> Self |
folds left | as im | as im | same | tests/compat_ordmap.rs::unions_with |
unions_with_key(i, f: Fn(&K, V, V) -> V) -> Self |
folds left | as im | as im | same | tests/compat_ordmap.rs::unions_with_key |
difference(self, other: Self) -> Self |
alias of symmetric_difference |
deprecated | deprecated, same meaning | differs: deprecation warning only (01:difference) | tests/compat_ordmap.rs::difference |
symmetric_difference(self, other: Self) -> Self |
as im | as im | same | tests/compat_ordmap.rs::symmetric_difference |
|
difference_with(self, other, f: FnMut(V, V) -> Option<V>) -> Self |
alias | deprecated | deprecated | differs: deprecation warning only (01:difference) | tests/compat_ordmap.rs::difference_with |
symmetric_difference_with(self, other, f) -> Self |
as im | as im | same | tests/compat_ordmap.rs::symmetric_difference_with |
|
difference_with_key(self, other, f: FnMut(&K, V, V) -> Option<V>) -> Self |
alias | deprecated | deprecated | differs: deprecation warning only (01:difference) | tests/compat_ordmap.rs::difference_with_key |
symmetric_difference_with_key(self, other, f) -> Self |
as im | as im | same | tests/compat_ordmap.rs::symmetric_difference_with_key |
|
relative_complement(self, other: Self) -> Self |
in self, not in other | as im | as im | same | tests/compat_ordmap.rs::relative_complement |
intersection(self, other: Self) -> Self |
keeps self's values | as im | as im | same | tests/compat_ordmap.rs::intersection |
intersection_with<B, C, F>(self, other: OrdMap<K, B>, f: FnMut(V, B) -> C) -> OrdMap<K, C> |
adds P2, P3 generics |
as im | same | tests/compat_ordmap.rs::intersection_with |
|
intersection_with_key<B, C, F>(self, other, f: FnMut(&K, V, B) -> C) -> OrdMap<K, C> |
adds P2, P3 |
as im | same | tests/compat_ordmap.rs::intersection_with_key |
Splitting and slicing (no panics for out-of-range counts)
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
split<BK>(&self, k: &BK) -> (Self, Self) |
< k and > k; equal entry dropped |
as im | as im | same | tests/compat_ordmap.rs::split |
split_lookup<BK>(&self, k: &BK) -> (Self, Option<V>, Self) |
plus the dropped value | as im | as im | same | tests/compat_ordmap.rs::split_lookup |
take(&self, n: usize) -> Self |
n smallest; all if n >= len |
as im | as im | same | tests/compat_ordmap.rs::take |
skip(&self, n: usize) -> Self |
all but n smallest; empty if n >= len |
as im | as im | same | tests/compat_ordmap.rs::skip |
without_min(&self) -> (Option<V>, Self) |
as im | as im | same | tests/compat_ordmap.rs::without_min |
|
without_min_with_key(&self) -> (Option<(K, V)>, Self) |
as im | as im | same | tests/compat_ordmap.rs::without_min_with_key |
|
without_max(&self) -> (Option<V>, Self) |
as im | as im | same | tests/compat_ordmap.rs::without_max |
|
without_max_with_key(&self) -> (Option<(K, V)>, Self) |
as im | as im | same | tests/compat_ordmap.rs::without_max_with_key |
Diff types
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
ordmap::DiffItem<'a, K, V> (enum Add(&K, &V), Update { old, new }, Remove(&K, &V)) |
Debug Update { old: (20, "b"), new: (20, "B") }; PartialEq, Eq |
as im | as im | same | tests/compat_ordmap.rs::diff_item |
ordmap::DiffIter<'a, K, V> (Item DiffItem; V: PartialEq) |
one lifetime | DiffIter<'a, 'b, K, V, P> |
as im's shape | same | tests/compat_ordmap.rs::diff_iter |
ordmap::NodeDiffIter (re-export) |
set-flavoured internal type leaking into docs | not listed | not provided | not provided: internal type in im's docs by accident (01:no-node-diff) | — |
ordmap::NodeDiffItem (enum, re-export) |
as above | not listed | not provided | not provided: internal type in im's docs by accident (01:no-node-diff) | — |
Entry API (same methods and observed results as HashMap's)
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
ordmap::Entry<'a, K, V> (enum Occupied, Vacant) |
no Debug | adds P |
as im (01:generic) | same | tests/compat_ordmap.rs::entry_type |
Entry::or_insert(self, d: V) -> &'a mut V |
as im | as im | same | tests/compat_ordmap.rs::entry_or_insert |
|
Entry::or_insert_with(self, f: FnOnce() -> V) -> &'a mut V |
as im | as im | same | tests/compat_ordmap.rs::entry_or_insert_with |
|
Entry::or_default(self) -> &'a mut V |
as im | as im | same | tests/compat_ordmap.rs::entry_or_default |
|
Entry::key(&self) -> &K |
does not insert | as im | as im | same | tests/compat_ordmap.rs::entry_key |
Entry::and_modify(self, f: FnOnce(&mut V)) -> Self |
as im | as im | same | tests/compat_ordmap.rs::entry_and_modify |
|
ordmap::OccupiedEntry<'a, K, V> (type) |
adds P |
as im | same | tests/compat_ordmap.rs::occupied_entry_type |
|
OccupiedEntry::key(&self) -> &K |
as im | as im | same | tests/compat_ordmap.rs::occupied_entry_key |
|
OccupiedEntry::get(&self) -> &V |
as im | as im | same | tests/compat_ordmap.rs::occupied_entry_get |
|
OccupiedEntry::get_mut(&mut self) -> &mut V |
as im | as im | same | tests/compat_ordmap.rs::occupied_entry_get_mut |
|
OccupiedEntry::into_mut(self) -> &'a mut V |
as im | as im | same | tests/compat_ordmap.rs::occupied_entry_into_mut |
|
OccupiedEntry::insert(&mut self, v: V) -> V |
as im | as im | same | tests/compat_ordmap.rs::occupied_entry_insert |
|
OccupiedEntry::remove(self) -> V |
as im | as im | same | tests/compat_ordmap.rs::occupied_entry_remove |
|
OccupiedEntry::remove_entry(self) -> (K, V) |
as im | as im | same | tests/compat_ordmap.rs::occupied_entry_remove_entry |
|
ordmap::VacantEntry<'a, K, V> (type) |
adds P |
as im | same | tests/compat_ordmap.rs::vacant_entry_type |
|
VacantEntry::key(&self) -> &K |
as im | as im | same | tests/compat_ordmap.rs::vacant_entry_key |
|
VacantEntry::into_key(self) -> K |
as im | as im | same | tests/compat_ordmap.rs::vacant_entry_into_key |
|
VacantEntry::insert(self, v: V) -> &'a mut V |
as im | as im | same | tests/compat_ordmap.rs::vacant_entry_insert |
Iterator types (not FusedIterator in im docs)
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
ordmap::Iter<'a, K, V> (Item (&K, &V)) |
Iterator, DoubleEnded, ExactSize | adds Clone | as im plus Clone | same | tests/compat_ordmap.rs::iter_type |
impl Clone for ordmap::Iter |
absent | present | provided (01 "imbl additions kept") | added (imbl API) | tests/compat_ordmap.rs::iter_impl_clone |
ordmap::Keys<'a, K, V> (Item &K) |
Iterator, DoubleEnded, ExactSize | as im | as im | same | tests/compat_ordmap.rs::keys_type |
ordmap::Values<'a, K, V> (Item &V) |
Iterator, DoubleEnded, ExactSize | as im | as im | same | tests/compat_ordmap.rs::values_type |
ordmap::ConsumingIter<A> (Item (K, V)) |
Iterator, DoubleEnded, ExactSize | ConsumingIter<K, V, P>, adds Clone |
as im's shape plus Clone | same | tests/compat_ordmap.rs::consuming_iter_type |
impl Clone for ordmap::ConsumingIter |
absent | present | provided (01 "imbl additions kept") | added (imbl API) | tests/compat_ordmap.rs::consuming_iter_impl_clone |
ordmap::RangedIter |
re-exported (set-flavoured internal); range does not return it |
returned by range; DoubleEnded, Clone, Debug |
type alias of ordmap::Iter, so imbl-shaped code compiles |
differs: alias of the range iterator, not im's leaked set-flavoured type (01:range-type) | tests/compat_ordmap.rs::ranged_iter_type |
impl Debug for ordmap::RangedIter |
absent | present | provided (on the aliased iterator) | added (imbl API) | tests/compat_ordmap.rs::ranged_iter_impl_debug |
Trait implementations
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
impl Clone |
O(1) | as im | as im | same | tests/compat_ordmap.rs::impl_clone |
impl Default |
as im | as im | same | tests/compat_ordmap.rs::impl_default |
|
impl AsRef<OrdMap<K, V>> |
itself | as im | as im | same | tests/compat_ordmap.rs::impl_as_ref |
impl Debug (K: Ord + Debug, V: Debug) |
{1: "a", 2: "b"} ascending; pretty like BTreeMap |
bound K: Debug, V: Debug |
format as im; bound loosened to imbl's K: Debug, V: Debug (01:loose-bounds) |
same | tests/differential/ordmap.rs |
impl PartialEq |
same keys, == values; shared structure counts as equal (NaN map == its clone) |
as im | as im; a clone always equals its original | same | tests/differential/ordmap.rs |
impl Eq |
as im | as im | same | tests/compat_ordmap.rs::impl_eq |
|
impl PartialOrd |
lexicographic over ascending (k, v) |
as im | as im | same | tests/differential/ordmap.rs |
impl Ord |
lexicographic | as im | as im | same | tests/differential/ordmap.rs |
impl Hash |
(k, v) ascending, no length prefix (≠ BTreeMap) |
as im | as im | same | tests/compat_ordmap.rs::impl_hash |
impl Index<&BK> |
missing key panics OrdMap::index: invalid key |
as im | as im | same | tests/compat_ordmap.rs::impl_index |
impl IndexMut<&BK> |
missing key panics the same text OrdMap::index: invalid key |
as im | as im | same | tests/compat_ordmap.rs::impl_index_mut |
impl Add for OrdMap<K, V> |
union (size rule) |
union (self wins) |
union (self wins) |
differs: follows union (01:union) |
tests/compat_ordmap.rs::impl_add |
impl Add for &OrdMap<K, V> |
union |
union |
union (self wins) |
differs: follows union (01:union) |
tests/compat_ordmap.rs::impl_add_ref |
impl Sum |
union of all ({1:2,2:2} for the spec probe) |
{1:1,2:2} |
leftmost wins | differs: follows union (01:union) |
tests/compat_ordmap.rs::impl_sum |
impl Extend<(RK, RV)> (K: From<RK>, V: From<RV>) |
as im | as im | same | tests/compat_ordmap.rs::impl_extend |
|
impl FromIterator<(RK, RV)> |
later duplicates win | as im | as im | same | tests/compat_ordmap.rs::impl_from_iterator |
impl IntoIterator for OrdMap |
ConsumingIter, ascending |
as im | as im | same | tests/compat_ordmap.rs::impl_into_iterator |
impl IntoIterator for &OrdMap |
Iter |
as im | as im | same | tests/compat_ordmap.rs::impl_into_iterator_ref |
impl From<Vec<(RK, RV)>> |
as im | as im | same | tests/compat_ordmap.rs::impl_from_vec |
|
impl From<&Vec<(RK, RV)>> |
via ToOwned |
as im | as im | same | tests/compat_ordmap.rs::impl_from_vec_ref |
impl From<&[(RK, RV)]> |
via ToOwned |
as im | as im | same | tests/compat_ordmap.rs::impl_from_slice |
impl From<BTreeMap<RK, RV>> |
as im | as im | same | tests/compat_ordmap.rs::impl_from_btree_map |
|
impl From<&BTreeMap<RK, RV>> |
as im | as im | same | tests/compat_ordmap.rs::impl_from_btree_map_ref |
|
impl From<std::collections::HashMap<RK, RV>> |
as im | as im | same | tests/compat_ordmap.rs::impl_from_std_hash_map |
|
impl From<&std::collections::HashMap<RK, RV>> |
as im | as im | same | tests/compat_ordmap.rs::impl_from_std_hash_map_ref |
|
impl From<HashMap<K, V, S>> (crate's HashMap) |
as im | as im | same | tests/compat_ordmap_from_hash_map.rs::impl_from_hash_map |
|
impl From<&HashMap<K, V, S>> |
as im | as im | same | tests/compat_ordmap_from_hash_map.rs::impl_from_hash_map_ref |
|
impl From<&OrdMap<&K, &V>> for OrdMap<OK, OV> |
owning copy via ToOwned |
as im | as im | same | tests/compat_ordmap.rs::impl_from_map_of_refs |
impl Serialize (feature serde) |
as a map | as im | as im | same | tests/compat_ordmap_features.rs::impl_serialize |
impl Deserialize (feature serde) |
last duplicate wins; array input → invalid type: sequence, expected a sequence |
as im | as im, including the error text | same | tests/compat_ordmap_features.rs::impl_deserialize |
impl arbitrary::Arbitrary<'a> (feature arbitrary) |
yes | yes | yes | same | tests/compat_ordmap_features.rs::impl_arbitrary |
impl quickcheck::Arbitrary (feature quickcheck) |
im only | yes | both crates (01:features) | same | tests/compat_ordmap_features.rs::impl_quickcheck_arbitrary |
impl bincode::Encode / Decode (feature bincode) |
absent | yes | not provided | not provided: imbl-only, not in im's API; not in 0.1 (01:imbl-only) | — |
auto traits Send / Sync |
im-rc neither; im when contents are | as im | perennial-rc neither; perennial when contents are |
same | tests/compat_ordmap.rs::auto_traits |