document sparse set #18
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Discussion
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Platform
All
Platform
Android
Platform
IOS
Platform
Linux
Platform
MacOS
Platform
Mobile
Platform
UNIX
Platform
Web
Platform
Windows
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Testing
Not needed
Testing
Required
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: nonsensical-dev/zenyx-engine#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "sparse-set-docs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
document sparse setto WIP: document sparse setWIP: document sparse setto document sparse set@ -13,0 +15,4 @@
/// The sparse allocator is mainly used for bulk allocations in the system's page size
/// for the lookup array. It will also be used for the array of pointers into those
/// bulk allocations. Additionally it will be used for the reverse map that generates keys
/// from the value in the internal packed array
Nit, missing period.
@ -13,0 +21,4 @@
///
/// All operations on this datastructure, meaning insertion, lookup, and deletion, are `O(1)`.
///
/// This datastructure does not in any way guarantee ordering of the values on
"datastructure" is two words not one (i.e. data structure).
@ -18,1 +32,4 @@
/// The paginated array of keys. The value at the key is an index into the dense array minus
/// one where the value corresponding to that key is stored.
sparse: Vec<SparsePage<SparseAlloc>, SparseAlloc>,
/// The dense array where the values corresponding to the keys are stored
Nit, missing period.
@ -18,2 +34,4 @@
sparse: Vec<SparsePage<SparseAlloc>, SparseAlloc>,
/// The dense array where the values corresponding to the keys are stored
dense: Vec<T, PackedAlloc>,
/// The reverse map to get the index in the sparse array from the index in the dense array
Nit, missing period.
@ -52,15 +105,39 @@ where
}
}
/// Gets the value with the key `id`
Nit, missing period.
@ -84,6 +161,15 @@ where
}
}
/// Gets the index in the dense array for a key `id`
Nit, missing period.
@ -92,2 +178,4 @@
}
/// This reduces the usage count for a page in the sparse array, deallocating
/// it if it is not used anymore
Nit, missing period.
@ -103,6 +191,7 @@ where
}
}
/// Increase the page usage count for a page in the sparse array
Nit, missing period.
@ -133,3 +243,4 @@
self.len() == 0
}
/// Returns the number of values in this sparse set
Nit, missing period.
@ -137,3 +258,4 @@
self.dense.len()
}
/// Checks if the sparse set contains a value with key `id`
Nit, missing period.
@ -149,3 +315,4 @@
&self.dense
}
/// Mutable version of [`Self::keys`]
Nit, missing period.
8b16afb604
to2704efbd9b
@ -10,17 +10,36 @@ use bytemuck::Contiguous;
const SPARSE_PAGESIZE: usize = (1 << 10) * 4;
type SparsePage<A> = Option<(Box<[Option<NonZeroUsize>; SPARSE_PAGESIZE], A>, usize)>;
/// A sparse set for fast lookup of large indices
Nit, missing period.
LGTM