sparse_set_container 1.2.3

A container based on sparse set. Stable keys, O(1) lookup, cache-friendly iterations, and no hashing.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright (C) Pavel Grebnev 2024
// Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT).

/// A key that can be used to access elements in a SparseSet, the key is unique for each element,
/// and it is only valid for the SparseSet it was created in.
///
/// The key should be stored only runtime, it doesn't make sense to serialize it since
/// the SparseSet data is not persistent
///
/// Every key generated by the same SparseSet is unique, they will not repeat even if the element
/// is removed and new ones are added.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SparseKey {
    pub(crate) sparse_index: usize,
    pub(crate) epoch: usize,
}