Skip to content

Commit a82d388

Browse files
kovmarci86Gerrit Code Review
authored andcommitted
Merge changes Ie846b105,Ia0b4dc83,I7111bf50 into main
* changes: Import 'taffy' crate Import 'grid' crate Import 'slotmap' crate
2 parents d9f42a2 + 8e59a9e commit a82d388

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+31817
-0
lines changed

crates/grid/.android-checksum.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"package":null,"files":{".cargo-checksum.json":"8b0d4f770e4717dfadc316449d56be8f25455b240c705988ebf48c4f248e4fc3","Android.bp":"bb317acfae50c8113d8c01c7b42cf1996fbf79e893a6a849bdd4e3134c912dff","Cargo.toml":"dd5e534a80da98507c3e49ac93ea203787a77d75b546be06dce55ccafa6e2c88","LICENSE":"d59b3f573f9e3f7318d9c24f042f710e1184bc5522cef96be7954dc6ba77c927","METADATA":"956d838673e3619c2126e1eb50588b65839984b2fa822aa952fa2906ace3317b","MODULE_LICENSE_MIT":"0d6f8afa3940b7f06bebee651376d43bc8b0d5b437337be2696d30377451e93a","README.md":"349942b55ac9eaf352b1ccaf8a67b15fa9d953fffc9ab08348af57c7f7654476","benches/benches.rs":"acb1661440bbfec83b267be4fa8d1a8de22dd2c2467ff01b587891a9fc3674d2","cargo_embargo.json":"0be745f01ba4955b20f2cb5011168c4d8cd396af75c007035ec693c67b17bce7","src/lib.rs":"99633cf7f4fb283046c49513c7ba451cf08374d506dc1df5d1ebc38d117ca454"}}

crates/grid/.cargo-checksum.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"files":{"Cargo.toml":"69fec42da5d88c7c01abb0e2482d0dbb7dfaf16495fb4e83da3df64b91566b77","LICENSE":"965116a3d1e412221d5ff2e58edfab30a62fe112f0f6bf13136a946907869da9","README.md":"7291a0c7fce70323458500e07eb8822213a851600d8b00aef45b05c1209929fb","benches/benches.rs":"d492daebc19d65853c8a1baee99e9f1a09d182413121f23f465357706c9d9698","src/lib.rs":"9d86db518aa0585f064e2c283099e1e4f76c57e857f19193b32dd2bd7764927b"},"package":"fb6ae361963ea5fe52038156ea1729f3b4e4ccc0711c362ab2b2d2c0a259e7c3"}

crates/grid/Android.bp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// This file is generated by cargo_embargo.
2+
// Do not modify this file because the changes will be overridden on upgrade.
3+
4+
package {
5+
default_applicable_licenses: ["external_rust_crates_grid_license"],
6+
default_team: "trendy_team_android_rust",
7+
}
8+
9+
license {
10+
name: "external_rust_crates_grid_license",
11+
visibility: [":__subpackages__"],
12+
license_kinds: ["SPDX-license-identifier-MIT"],
13+
license_text: ["LICENSE"],
14+
}
15+
16+
rust_library {
17+
name: "libgrid",
18+
host_supported: true,
19+
crate_name: "grid",
20+
cargo_env_compat: true,
21+
cargo_pkg_version: "0.16.1",
22+
crate_root: "src/lib.rs",
23+
edition: "2018",
24+
features: [
25+
"default",
26+
"std",
27+
],
28+
apex_available: [
29+
"//apex_available:platform",
30+
"//apex_available:anyapex",
31+
],
32+
product_available: true,
33+
vendor_available: true,
34+
}

crates/grid/Cargo.toml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
2+
#
3+
# When uploading crates to the registry Cargo will automatically
4+
# "normalize" Cargo.toml files for maximal compatibility
5+
# with all versions of Cargo and also rewrite `path` dependencies
6+
# to registry (e.g., crates.io) dependencies.
7+
#
8+
# If you are reading this file be aware that the original Cargo.toml
9+
# will likely look very different (and much more reasonable).
10+
# See Cargo.toml.orig for the original contents.
11+
12+
[package]
13+
edition = "2018"
14+
rust-version = "1.51"
15+
name = "grid"
16+
version = "0.16.1"
17+
authors = ["Armin Becher <[email protected]>"]
18+
build = false
19+
autolib = false
20+
autobins = false
21+
autoexamples = false
22+
autotests = false
23+
autobenches = false
24+
description = "Dynamic generic 2D data structure."
25+
documentation = "https://docs.rs/grid"
26+
readme = "README.md"
27+
keywords = [
28+
"2D",
29+
"array",
30+
"matrix",
31+
"data-structure",
32+
"2D-vector",
33+
]
34+
categories = [
35+
"science",
36+
"data-structures",
37+
]
38+
license = "MIT"
39+
repository = "https://github.com/becheran/grid"
40+
41+
[lib]
42+
name = "grid"
43+
path = "src/lib.rs"
44+
45+
[[bench]]
46+
name = "benches"
47+
path = "benches/benches.rs"
48+
harness = false
49+
50+
[dependencies.serde]
51+
version = "1.0.217"
52+
features = ["derive"]
53+
optional = true
54+
55+
[dev-dependencies.criterion]
56+
version = "0.5.1"
57+
58+
[dev-dependencies.rand]
59+
version = "0.9.0"
60+
61+
[dev-dependencies.serde_json]
62+
version = "1.0.138"
63+
64+
[features]
65+
default = ["std"]
66+
serde = [
67+
"std",
68+
"dep:serde",
69+
]
70+
std = []
71+
72+
[badges.gitlab]
73+
branch = "master"
74+
repository = "becheran/grid_ci"
75+
76+
[badges.maintenance]
77+
status = "actively-developed"

crates/grid/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Armin Becher
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

crates/grid/METADATA

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "grid"
2+
description: "Dynamic generic 2D data structure."
3+
third_party {
4+
version: "0.16.1"
5+
license_type: NOTICE
6+
last_upgrade_date {
7+
year: 2025
8+
month: 2
9+
day: 11
10+
}
11+
homepage: "https://crates.io/crates/grid"
12+
identifier {
13+
type: "Archive"
14+
value: "https://static.crates.io/crates/grid/grid-0.16.1.crate"
15+
version: "0.16.1"
16+
}
17+
}

crates/grid/MODULE_LICENSE_MIT

Whitespace-only changes.

crates/grid/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Grid
2+
3+
[![docs](https://docs.rs/grid/badge.svg)](https://docs.rs/grid)
4+
[![crates.io](https://badgen.net/crates/d/grid)](https://crates.io/crates/grid)
5+
[![build status](https://github.com/becheran/grid/actions/workflows/rust.yml/badge.svg)](https://github.com/becheran/grid/actions)
6+
[![license](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7+
8+
Data structure grid for rust. Provide a two dimensional data structure for rust that is easy to use and fast.
9+
Most of the functionality provided by the [std::vec::Vec](https://doc.rust-lang.org/std/vec/struct.Vec.html) type for one dimensional vectors
10+
is implemented for two dimensions in this crate.
11+
12+
To use *grid* with *no_std* import the library such as:
13+
14+
``` toml
15+
grid = { version = "*", default-features = false }
16+
```
17+
18+
- [documentation](https://docs.rs/grid/)
19+
- [library on crates.io](https://crates.io/crates/grid)

crates/grid/benches/benches.rs

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
use criterion::{criterion_group, criterion_main, Criterion};
2+
use grid::grid;
3+
use grid::Grid;
4+
use rand::Rng;
5+
6+
const SIZE: usize = 1_000;
7+
8+
fn init_vec_vec() -> Vec<Vec<u8>> {
9+
vec![vec![0; SIZE]; SIZE]
10+
}
11+
12+
fn init_grid() -> Grid<u8> {
13+
Grid::init(SIZE, SIZE, 0)
14+
}
15+
16+
fn criterion_benchmark(c: &mut Criterion) {
17+
let mut rng = rand::rng();
18+
let mut rand = || rng.random_range(0..SIZE);
19+
20+
// Init macro
21+
c.bench_function("vecvec_init_macro", |b| {
22+
b.iter(|| {
23+
vec![
24+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
25+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
26+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
27+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
28+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
29+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
30+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
31+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
32+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
33+
vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
34+
]
35+
})
36+
});
37+
c.bench_function("grid_init_macro", |b| {
38+
b.iter(|| {
39+
grid![[0,1,2,3,4,5,6,7,8,9]
40+
[0,1,2,3,4,5,6,7,8,9]
41+
[0,1,2,3,4,5,6,7,8,9]
42+
[0,1,2,3,4,5,6,7,8,9]
43+
[0,1,2,3,4,5,6,7,8,9]
44+
[0,1,2,3,4,5,6,7,8,9]
45+
[0,1,2,3,4,5,6,7,8,9]
46+
[0,1,2,3,4,5,6,7,8,9]
47+
[0,1,2,3,4,5,6,7,8,9]
48+
[0,1,2,3,4,5,6,7,8,9]]
49+
})
50+
});
51+
c.bench_function("grid_from_vec", |b| {
52+
b.iter(|| {
53+
let vec = vec![
54+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7,
55+
8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
56+
6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
57+
4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
58+
];
59+
Grid::from_vec(vec, 10)
60+
})
61+
});
62+
63+
// Constructor
64+
c.bench_function("vecvec_init", |b| b.iter(|| vec![vec![0; SIZE]; SIZE]));
65+
c.bench_function("grid_init", |b| b.iter(|| Grid::init(SIZE, SIZE, 0)));
66+
67+
// Index
68+
c.bench_function("vecvec_idx", |b| {
69+
let vec_vec = init_vec_vec();
70+
b.iter_batched(
71+
|| (rand(), rand()),
72+
|(x, y)| {
73+
let _v = vec_vec[x][y];
74+
},
75+
criterion::BatchSize::SmallInput,
76+
)
77+
});
78+
c.bench_function("grid_idx", |b| {
79+
let grid = init_grid();
80+
b.iter_batched(
81+
|| (rand(), rand()),
82+
|(x, y)| grid[(x, y)],
83+
criterion::BatchSize::SmallInput,
84+
)
85+
});
86+
c.bench_function("vecvec_get", |b| {
87+
let vec_vec = init_vec_vec();
88+
b.iter_batched(
89+
|| (rand(), rand()),
90+
|(x, y)| {
91+
let _v = vec_vec.get(x).unwrap().get(y).unwrap();
92+
},
93+
criterion::BatchSize::SmallInput,
94+
)
95+
});
96+
c.bench_function("grid_get", |b| {
97+
let grid = init_grid();
98+
b.iter_batched(
99+
|| (rand(), rand()),
100+
|(x, y)| {
101+
let _v = grid.get(x, y).unwrap();
102+
},
103+
criterion::BatchSize::SmallInput,
104+
)
105+
});
106+
107+
//Set
108+
c.bench_function("vecvec_set", |b| {
109+
let mut vec_vec = init_vec_vec();
110+
b.iter_batched(
111+
|| (rand(), rand()),
112+
|(x, y)| vec_vec[x][y] = 42,
113+
criterion::BatchSize::SmallInput,
114+
)
115+
});
116+
c.bench_function("grid_set", |b| {
117+
let mut g = init_grid();
118+
b.iter_batched(
119+
|| (rand(), rand()),
120+
|(x, y)| g[(x, y)] = 42,
121+
criterion::BatchSize::SmallInput,
122+
)
123+
});
124+
125+
// Push
126+
c.bench_function("grid_push_row", |b| {
127+
let grid = init_grid();
128+
b.iter_batched(
129+
|| grid.clone(),
130+
|mut g| g.push_row(vec![0; SIZE]),
131+
criterion::BatchSize::SmallInput,
132+
)
133+
});
134+
c.bench_function("grid_push_col", |b| {
135+
let grid = init_grid();
136+
b.iter_batched(
137+
|| grid.clone(),
138+
|mut g| g.push_col(vec![0; SIZE]),
139+
criterion::BatchSize::SmallInput,
140+
)
141+
});
142+
143+
// Pop
144+
c.bench_function("grid_pop_row", |b| {
145+
let grid = init_grid();
146+
b.iter_batched(
147+
|| grid.clone(),
148+
|mut g| g.pop_row(),
149+
criterion::BatchSize::SmallInput,
150+
)
151+
});
152+
c.bench_function("grid_pop_col", |b| {
153+
let grid = init_grid();
154+
b.iter_batched(
155+
|| grid.clone(),
156+
|mut g| g.pop_col(),
157+
criterion::BatchSize::SmallInput,
158+
)
159+
});
160+
161+
// Remove
162+
c.bench_function("grid_remove_row", |b| {
163+
let grid = init_grid();
164+
b.iter_batched(
165+
|| grid.clone(),
166+
|mut g| g.remove_row(2),
167+
criterion::BatchSize::SmallInput,
168+
)
169+
});
170+
c.bench_function("grid_remove_col", |b| {
171+
let grid = init_grid();
172+
b.iter_batched(
173+
|| grid.clone(),
174+
|mut g| g.remove_col(2),
175+
criterion::BatchSize::SmallInput,
176+
)
177+
});
178+
179+
// Rotation
180+
c.bench_function("grid_rotate_left", |b| {
181+
let grid = init_grid();
182+
b.iter_batched(
183+
|| grid.clone(),
184+
|mut g| g.rotate_left(),
185+
criterion::BatchSize::SmallInput,
186+
)
187+
});
188+
c.bench_function("grid_rotate_right", |b| {
189+
let grid = init_grid();
190+
b.iter_batched(
191+
|| grid.clone(),
192+
|mut g| g.rotate_right(),
193+
criterion::BatchSize::SmallInput,
194+
)
195+
});
196+
c.bench_function("grid_rotate_half", |b| {
197+
let grid = init_grid();
198+
b.iter_batched(
199+
|| grid.clone(),
200+
|mut g| g.rotate_half(),
201+
criterion::BatchSize::SmallInput,
202+
)
203+
});
204+
}
205+
206+
criterion_group!(benches, criterion_benchmark);
207+
criterion_main!(benches);

crates/grid/cargo_embargo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)