Struct sokoban::node_allocator::NodeAllocator
source · #[repr(C)]pub struct NodeAllocator<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> {
pub size: u64,
pub nodes: [Node<T, NUM_REGISTERS>; MAX_SIZE],
/* private fields */
}
Fields§
§size: u64
Size of the allocator. The max value this can take is MAX_SIZE
nodes: [Node<T, NUM_REGISTERS>; MAX_SIZE]
Nodes containing data, with NUM_REGISTERS
registers that store arbitrary data
Implementations§
source§impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
pub fn new() -> Self
pub fn initialize(&mut self)
pub fn get(&self, i: u32) -> &Node<T, NUM_REGISTERS>
pub fn get_mut(&mut self, i: u32) -> &mut Node<T, NUM_REGISTERS>
sourcepub fn add_node(&mut self, node: T) -> u32
pub fn add_node(&mut self, node: T) -> u32
Adds a new node to the allocator. The function returns the current pointer to the free list, where the new node is inserted
sourcepub fn remove_node(&mut self, i: u32) -> Option<&T>
pub fn remove_node(&mut self, i: u32) -> Option<&T>
Removes the node at index i
from the alloctor and adds the index to the free list
When deleting nodes, you MUST clear all registers prior to calling remove_node
pub fn disconnect(&mut self, i: u32, j: u32, r_i: u32, r_j: u32)
pub fn clear_register(&mut self, i: u32, r_i: u32)
pub fn connect(&mut self, i: u32, j: u32, r_i: u32, r_j: u32)
pub fn set_register(&mut self, i: u32, value: u32, r_i: u32)
pub fn get_register(&self, i: u32, r_i: u32) -> u32
Trait Implementations§
source§impl<T: Clone + Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Clone for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
impl<T: Clone + Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Clone for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
source§fn clone(&self) -> NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
fn clone(&self) -> NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Default for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Default for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
source§impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> ZeroCopy for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> ZeroCopy for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
source§impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Zeroable for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Zeroable for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
impl<T: Copy + Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Copy for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
impl<T: Default + Copy + Clone + Pod + Zeroable, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Pod for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>
Auto Trait Implementations§
impl<T, const MAX_SIZE: usize, const NUM_REGISTERS: usize> RefUnwindSafe for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>where T: RefUnwindSafe,
impl<T, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Send for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>where T: Send,
impl<T, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Sync for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>where T: Sync,
impl<T, const MAX_SIZE: usize, const NUM_REGISTERS: usize> Unpin for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>where T: Unpin,
impl<T, const MAX_SIZE: usize, const NUM_REGISTERS: usize> UnwindSafe for NodeAllocator<T, MAX_SIZE, NUM_REGISTERS>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self
.