Skip to content

Commit 95b5e2d

Browse files
committed
Step 2: Move allocate_leaf method to insert_operations
- Move allocate_leaf method from lib.rs to insert_operations.rs - Remove original method from lib.rs - All tests still pass (35/35) - Working incrementally to avoid breaking changes
1 parent 91a0c64 commit 95b5e2d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

rust/src/insert_operations.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ use crate::error::{BPlusTreeError, BTreeResult, ModifyResult};
88
use crate::types::{BPlusTreeMap, NodeRef, LeafNode, BranchNode, NodeId, InsertResult, SplitNodeData};
99
use std::marker::PhantomData;
1010

11-
// This module will contain INSERT operations - for now it's just a placeholder
12-
// We'll move methods here incrementally to avoid breaking the build
11+
impl<K: Ord + Clone, V: Clone> BPlusTreeMap<K, V> {
12+
/// Allocate a new leaf node in the arena and return its ID.
13+
pub fn allocate_leaf(&mut self, leaf: LeafNode<K, V>) -> NodeId {
14+
self.leaf_arena.allocate(leaf)
15+
}
16+
}
1317

1418
#[cfg(test)]
1519
mod tests {

rust/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,10 +1399,7 @@ impl<K: Ord + Clone, V: Clone> BPlusTreeMap<K, V> {
13991399
// ENHANCED ARENA-BASED ALLOCATION FOR LEAF NODES
14001400
// ============================================================================
14011401

1402-
/// Allocate a new leaf node in the arena and return its ID.
1403-
pub fn allocate_leaf(&mut self, leaf: LeafNode<K, V>) -> NodeId {
1404-
self.leaf_arena.allocate(leaf)
1405-
}
1402+
// allocate_leaf method moved to insert_operations.rs module
14061403

14071404
/// Deallocate a leaf node from the arena.
14081405
pub fn deallocate_leaf(&mut self, id: NodeId) -> Option<LeafNode<K, V>> {

0 commit comments

Comments
 (0)