Coder Social home page Coder Social logo

array-map's Introduction

Hi there ๐Ÿ‘‹

Luro02's github stats

array-map's People

Contributors

luro02 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

array-map's Issues

Tracking issue of unstable features that have to be stabilized before publishing to crates.io

The implementation uses a number of unstable features, which have to be stabilized, before it can be published to crates.io.

  • Currently one is not allowed to use const and type parameters with default parameters, because no design decision has been made yet: rust-lang/rust#44580
  • [(); N].map(|_| None) is used to initialize an array with None: rust-lang/rust#75243
  • ArrayMap::get_each_key_value_mut requires [T; N]::each_mut: rust-lang/rust#76118
  • TryFromIterator uses the "never-type" (!) for an implementation, which can be replaced with core::convert::Infallible: rust-lang/lang-team#60
  • [T; N]::try_map is not implemented in the standard library, so a custom implementation is used, which requires maybe_uninit_uninit_array, maybe_uninit_array_assume_init and try_trait_v2: rust-lang/rust#79711
  • stmt_expr_attributes required for making ahash optional in the array_map macro: rust-lang/rust#15701

Should `ArrayMap::insert` return an error or panic?

Depends on how likely it is that one runs out of capacity? I think it would be good to provide both a panicking and non-panicking method.

The problem is that try_insert seems to be used differently in std/hashbrown, so a different name is needed.

`ArrayMap::remove` should happen in `O(1)`

Currently, each removal causes the entire ArrayMap/ArrayTable to be rebuilt.

This is very inefficient and with linear probing it is possible to remove the entries in O(1), which was done before c8a2e0e, but the implementation did not behave correctly, so it has been replaced with the current implementation, which is inefficient, but correct.

Missing functionality for `ArrayMap`

Functions that should be implemented:

  • ArrayMap::capacity
  • ArrayMap::clear
  • ArrayMap::contains_key
  • ArrayMap::drain
  • ArrayMap::drain_filter
  • ArrayMap::entry
  • ArrayMap::get
  • ArrayMap::get_key_value
  • ArrayMap::get_key_value_mut
  • ArrayMap::get_mut
  • ArrayMap::hasher
  • ArrayMap::insert
  • ArrayMap::is_empty
  • ArrayMap::iter
  • ArrayMap::iter_mut
  • ArrayMap::keys
  • ArrayMap::len
  • ArrayMap::new
  • ArrayMap::raw_entry
  • ArrayMap::raw_entry_mut
  • ArrayMap::remove
  • ArrayMap::remove_entry
  • ArrayMap::retain
  • ArrayMap::try_insert
  • ArrayMap::values
  • ArrayMap::values_mut
  • ArrayMap::with_hasher

Nightly only functions:

  • ArrayMap::get_each_key_value_mut
  • ArrayMap::get_each_mut

Traits:

  • Copy
  • Clone
  • Debug
  • Default
  • PartialEq
  • Eq
  • Extend<(&K, &V)> TryExtend<(&K, &V)>
  • Extend<(K, V)> TryExtend<(K, V)>
  • FromIterator<(K, V)> TryFromIterator<(K, V)>
  • Index<&Q>
  • IntoIterator for &ArrayMap, &mut ArrayMap and ArrayMap
  • serde::Serialize
  • serde::Deserialize

Auto Traits:

  • Send
  • Sync
  • Unpin
  • UnwindSafe
  • RefUnwindSafe

Add `ArraySetFacade`

Functions that should be implemented:

  • ArraySet::new
  • ArraySet::capacity
  • ArraySet::iter
  • ArraySet::len
  • ArraySet::is_empty
  • ArraySet::drain
  • ArraySet::retain
  • ArraySet::drain_filter
  • ArraySet::clear
  • ArraySet::with_build_hasher
  • ArraySet::with_hasher
  • ArraySet::hasher
  • ArraySet::build_hasher
  • ArraySet::difference
  • ArraySet::symmetric_difference
  • ArraySet::intersection
  • ArraySet::union
  • ArraySet::contains
  • ArraySet::get
  • ArraySet::get_or_insert
  • ArraySet::get_or_insert_owned
  • ArraySet::get_or_insert_with
  • ArraySet::is_disjoint
  • ArraySet::is_subset
  • ArraySet::is_superset
  • ArraySet::insert (ArraySet::try_insert)
  • ArraySet::replace
  • ArraySet::remove
  • ArraySet::take

Traits

  • Copy
  • Clone
  • Debug
  • Default
  • PartialEq
  • Eq
  • BitAnd
  • BitOr
  • BitXor
  • Deserialize
  • Serialize
  • TryExtend<&'a T>
  • TryExtend<T>
  • From<ArrayMap<T, (), R, B>>
  • TryFromIterator<T>
  • IntoIterator
  • Sub

Implement `TryFrom<[(K, V); N]> for ArrayMap<K, V, M>`

ArrayMapFacade could implement this:

impl<K, V, R, B, const N: usize> TryFrom<[(K, V); N]> for ArrayMapFacade<K, V, R, B>
where
    K: Eq + Hash,
    R: RawTable<(K, V)> + Default,
    B: BuildHasher + Default,
{
    type Error = CapacityError;

    fn try_from(value: [(K, V); N]) -> Result<Self, Self::Error> {
        let mut result = Self::with_build_hasher(B::default());

        for (key, value) in value {
            result.insert(key, value)?;
        }

        Ok(result)
    }
}

but it conflicts with the "specialized" implementation for FixedSizeTables:

array-map/src/array_map.rs

Lines 1064 to 1081 in 4390c72

impl<K, V, R, B, const N: usize> From<[(K, V); N]> for ArrayMapFacade<K, V, R, B>
where
K: Eq + Hash,
R: FixedSizeTable<(K, V), N> + Default,
B: BuildHasher + Default,
{
fn from(value: [(K, V); N]) -> Self {
let mut result = Self::with_build_hasher(B::default());
for (key, value) in value {
if let Err(error) = result.insert(key, value) {
unreachable_unchecked!(error);
}
}
result
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.