Struct orx_linked_list::MemoryStatus
source · pub struct MemoryStatus {
pub num_active_nodes: usize,
pub num_used_nodes: usize,
}
Expand description
Utilization of the underlying vector of the linked list.
LinkedList
holds all elements close to each other in a PinnedVec
aiming for better cache locality while using thin references rather
than wide pointers and to reduce heap allocations.
In order to achieve O(1) time complexity while avoiding smart pointers, remove and pop operations are designed to be lazy:
- the links are immediately adjusted; however,
- the memory is not immediately reclaimed leaving a gap in the underlying vector.
This method reveals the memory utilization of the underlying pinned vector at any given time as the fraction of active linked list nodes to total spaces used by the pinned vector.
Some extreme examples are as follows:
- in an push-only situation, memory utilization is equal to 1.0:
num_active_nodes == num_used_nodes
- in a situation where each push is followed by a pop,
memory utilization is 0.0:
num_active_nodes == 0
num_used_nodes == n
, wheren
is the number of items pushed.
Fields§
§num_active_nodes: usize
Number of active nodes in the linked list which is equal to len
of the list.
num_used_nodes: usize
Number of total node capacity used by the underlying data structure to store
the active nodes together with the gaps due to pop_back
, pop_front
and
remove
calls.
Implementations§
source§impl MemoryStatus
impl MemoryStatus
sourcepub fn utilization(&self) -> f32
pub fn utilization(&self) -> f32
Returns num_active_nodes / num_used_nodes
as a measure of utilization of the memory used by the linked list.
Trait Implementations§
source§impl Clone for MemoryStatus
impl Clone for MemoryStatus
source§fn clone(&self) -> MemoryStatus
fn clone(&self) -> MemoryStatus
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MemoryStatus
impl Debug for MemoryStatus
source§impl PartialEq<MemoryStatus> for MemoryStatus
impl PartialEq<MemoryStatus> for MemoryStatus
source§fn eq(&self, other: &MemoryStatus) -> bool
fn eq(&self, other: &MemoryStatus) -> bool
self
and other
values to be equal, and is used
by ==
.