Skip to content

Commit db057f0

Browse files
fu5hamaxdedNiklasNummelinforny
authored
Add sparse set implementation (#1)
- Adds `TypedSparseSet`, the main sparse set implementation + `NetworkedSet` which combines two sparse sets with the same id type but different key spaces for the case of client + server replication - Adds `IdAllocator` for allocating ids into `TypedSparseSet`/`NetworkedSet` - Adds `SetId` trait + `define_id!` macro to create your own id types --------- Co-authored-by: Max de Danschutter <m.danschutter@gmail.com> Co-authored-by: Niklas Nummelin <niklas.nummelin@embark-studios.com> Co-authored-by: Peter Fornwall <peter.fornwall@embark-studios.com>
1 parent 04e0da3 commit db057f0

File tree

8 files changed

+1692
-10
lines changed

8 files changed

+1692
-10
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
- uses: Swatinem/rust-cache@v2
4646
- run: cargo fetch
4747
- name: cargo test build
48-
run: cargo build --tests
49-
- run: cargo test
48+
run: cargo build --tests --all-features
49+
- run: cargo test --all-features
5050

5151
publish-check:
5252
name: Publish Check

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
<!-- next-header -->
1111
## Unreleased
12+
13+
- Adds sparse set + id implementation
14+
- Adds `TypedSparseSet`, the main sparse set implementation + `NetworkedSet` which combines two
15+
sparse sets with the same id type but different key spaces for the case of client + server
16+
replication
17+
- Adds `IdAllocator` for allocating ids into `TypedSparseSet`/`NetworkedSet`
18+
- Adds `SetId` trait + `define_id!` macro to create your own id types
19+
1220
## `0.5.0`
1321

1422
- `LinearMap::new` and `LinearSet::new` are now `const`

Cargo.lock

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ zero_sized_map_values = "warn"
9696
default = []
9797
speedy = ["dep:speedy"]
9898
serde = ["dep:serde", "indexmap/serde"]
99+
test = ["serde", "speedy"]
99100

100101
[dependencies]
101102
foldhash = "0.1"
@@ -104,9 +105,12 @@ serde = { version = "1.0.158", default-features = false, features = [
104105
"derive",
105106
"std",
106107
], optional = true }
107-
speedy = { version = "0.8", optional = true, features = ["glam"] }
108+
speedy = { version = "0.8", optional = true }
108109
rustc-hash = "1.1.0"
109110

111+
[dev-dependencies]
112+
bincode = "1"
113+
110114
[package.metadata.docs.rs]
111115
all-features = true
112116
rustdoc-args = ["--cfg", "docsrs"]

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ pub mod linear_set;
119119
#[doc(inline)]
120120
pub use linear_set::LinearSet;
121121

122+
/// Provides the foundations of a "generational arena" / ECS-like storage, performing efficient
123+
/// mapping from a large linear key space to densely packed data.
124+
pub mod sparse_set;
125+
122126
/// Type-alias of [`UnorderedMap`] that is useful when you are using keys that are [`NoHashable`]
123127
pub type UnorderedNoHashMap<K, V> = UnorderedMap<K, V, BuildNoHashHasher<K>>;
124128

0 commit comments

Comments
 (0)