Apache License 2.0

项目介绍

indexmap-rs/indexmap 是一个托管在 GitHub 上的开源项目,主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前获得 2.5k 个 Star、193 次 Fork。

仓库全名
indexmap-rs/indexmap
开源许可证
Apache License 2.0
Star 数
2.5k
Fork 数
193
未关闭 Issue
16

README 摘要

indexmap A pure-Rust hash table which preserves (in a limited sense) insertion order. This crate implements compact map and set data-structures, where the iteration order of the keys is independent from their hash or value. It preserves insertion order (except after removals), and it allows lookup of entries by either hash table key or numerical index. Note: this crate was originally released under the name…

完整内容见 GitHub 原始 README 或本页 。

常见问题

indexmap 用什么语言开发?

主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前有 2.5k 个 Star。

indexmap 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 indexmap 的源码?

可以直接克隆仓库:git clone https://github.com/indexmap-rs/indexmap.git,默认分支为 main;安装与运行步骤见仓库 README。

indexmap 最近还在维护吗?

仓库最近一次更新为 9月5日,当前有 16 个未关闭 Issue;Star 数为 2.5k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A hash table with consistent order and fast iteration; access items by key or sequence index

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
2853
价值分
1531
活跃状态
活跃

语言占比

Rust

README

indexmap

build status crates.io docs rustc

A pure-Rust hash table which preserves (in a limited sense) insertion order.

This crate implements compact map and set data-structures, where the iteration order of the keys is independent from their hash or value. It preserves insertion order (except after removals), and it allows lookup of entries by either hash table key or numerical index.

Note: this crate was originally released under the name ordermap, but it was renamed to indexmap to better reflect its features. The ordermap crate now exists as a wrapper over indexmap with stronger ordering properties.

Background

This was inspired by Python 3.6’s new dict implementation (which remembers the insertion order and is fast to iterate, and is compact in memory).

Some of those features were translated to Rust, and some were not. The result was indexmap, a hash table that has following properties:

  • Order is independent of hash function and hash values of keys.
  • Fast to iterate.
  • Indexed in compact space.
  • Preserves insertion order as long as you don’t call .remove(), .swap_remove(), or other methods that explicitly change order. The alternate .shift_remove() does preserve relative order.
  • Uses hashbrown for the inner table, just like Rust’s libstd HashMap does.

Performance

IndexMap derives a couple of performance facts directly from how it is constructed, which is roughly:

A raw hash table of key-value indices, and a vector of key-value pairs.

  • Iteration is very fast since it is on the dense key-values.

  • Removal is fast since it moves memory areas only in the table, and uses a single swap in the vector.

  • Lookup is fast-ish because the initial 7-bit hash lookup uses SIMD, and indices are densely stored. Lookup also is slow-ish since the actual key-value pairs are stored separately. (Visible when cpu caches size is limiting.)

  • In practice, IndexMap has been tested out as the hashmap in rustc in PR45282 and the performance was roughly on par across the whole workload.

  • If you want the properties of IndexMap, or its strongest performance points fits your workload, it might be the best hash table implementation.

Recent Changes

See RELEASES.md.

评论

暂无评论