zipora 2.1.4

High-performance Rust implementation providing advanced data structures and compression algorithms with memory safety guarantees. Features LRU page cache, sophisticated caching layer, fiber-based concurrency, real-time compression, secure memory pools, SIMD optimizations, and complete C FFI for migration from C++.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
//! Strategy Traits for Unified Hash Map Implementation
//!
//! This module defines the strategy traits that enable the unified ZiporaHashMap
//! to support all existing hash map variants through pluggable algorithms.
//!
//! # Strategy Architecture
//!
//! The strategy pattern allows different algorithms to be combined:
//! - **CollisionResolutionStrategy**: How to handle hash collisions
//! - **StorageLayoutStrategy**: How to organize data in memory
//! - **HashOptimizationStrategy**: Performance optimizations (SIMD, cache, etc.)
//!
//! This enables a single unified implementation to support all use cases that
//! previously required separate implementations.

use crate::containers::FastVec;
use crate::error::{Result, ZiporaError};
use crate::hash_map::cache_locality::{CacheMetrics, Prefetcher};
use crate::hash_map::simd_string_ops::SimdStringOps;
use crate::memory::cache_layout::{CacheOptimizedAllocator, PrefetchHint};
use std::borrow::Borrow;
use std::hash::{BuildHasher, Hash, Hasher};

/// Collision resolution strategy for hash maps
pub trait CollisionResolutionStrategy<K, V> {
    /// Configuration for this strategy
    type Config: Clone;

    /// Context/state maintained by this strategy
    type Context: Default;

    /// Insert a key-value pair using this collision resolution strategy
    fn insert(
        &self,
        context: &mut Self::Context,
        buckets: &mut [HashBucket<K, V>],
        key: K,
        value: V,
        hash: u64,
        config: &Self::Config,
    ) -> Result<Option<V>>;

    /// Lookup a key using this collision resolution strategy
    fn get<'a, Q>(
        &self,
        context: &Self::Context,
        buckets: &'a [HashBucket<K, V>],
        key: &Q,
        hash: u64,
        config: &Self::Config,
    ) -> Option<&'a V>
    where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized;

    /// Remove a key using this collision resolution strategy
    fn remove<Q>(
        &self,
        context: &mut Self::Context,
        buckets: &mut [HashBucket<K, V>],
        key: &Q,
        hash: u64,
        config: &Self::Config,
    ) -> Option<V>
    where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized;

    /// Check if resize is needed
    fn needs_resize(&self, context: &Self::Context, capacity: usize, len: usize) -> bool;

    /// Get probe statistics for this strategy
    fn probe_stats(&self, context: &Self::Context) -> ProbeStats;
}

/// Storage layout strategy for memory organization
pub trait StorageLayoutStrategy<K, V> {
    /// Configuration for this strategy
    type Config: Clone;

    /// Storage context/state
    type Storage;

    /// Initialize storage with given capacity
    fn create_storage(capacity: usize, config: &Self::Config) -> Self::Storage;

    /// Resize storage to new capacity
    fn resize_storage(
        storage: &mut Self::Storage,
        new_capacity: usize,
        config: &Self::Config,
    ) -> Result<()>;

    /// Get bucket array from storage
    fn get_buckets_mut(storage: &mut Self::Storage) -> &mut [HashBucket<K, V>];

    /// Get bucket array from storage (immutable)
    fn get_buckets(storage: &Self::Storage) -> &[HashBucket<K, V>];

    /// Get capacity of storage
    fn capacity(storage: &Self::Storage) -> usize;

    /// Estimate memory usage in bytes
    fn memory_usage(storage: &Self::Storage) -> usize;

    /// Perform layout-specific optimizations
    fn optimize_layout(storage: &mut Self::Storage, config: &Self::Config) -> Result<()>;
}

/// Hash optimization strategy for performance features
pub trait HashOptimizationStrategy<K, V> {
    /// Configuration for optimizations
    type Config: Clone;

    /// Optimization context/state
    type Context: Default;

    /// Pre-insert optimization (e.g., prefetching)
    fn pre_insert(
        &self,
        context: &mut Self::Context,
        key: &K,
        hash: u64,
        buckets: &[HashBucket<K, V>],
        config: &Self::Config,
    );

    /// Post-insert optimization (e.g., cache management)
    fn post_insert(
        &self,
        context: &mut Self::Context,
        key: &K,
        inserted: bool,
        config: &Self::Config,
    );

    /// Pre-lookup optimization
    fn pre_lookup<Q>(
        &self,
        context: &mut Self::Context,
        key: &Q,
        hash: u64,
        buckets: &[HashBucket<K, V>],
        config: &Self::Config,
    ) where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized;

    /// Bulk optimization for multiple operations
    fn bulk_optimize(
        &self,
        context: &mut Self::Context,
        operations: &[OptimizationHint],
        config: &Self::Config,
    );

    /// Get optimization metrics
    fn metrics(&self, context: &Self::Context) -> OptimizationMetrics;
}

/// Generic hash bucket for different strategies
#[repr(align(64))] // Cache line alignment
#[derive(Clone)]
pub struct HashBucket<K, V> {
    /// Hash value (cached for performance)
    pub hash: u64,
    /// Key
    pub key: Option<K>,
    /// Value
    pub value: Option<V>,
    /// Probe distance for Robin Hood hashing
    pub probe_distance: u16,
    /// Strategy-specific flags
    pub flags: u16,
    /// Next bucket index for chaining
    pub next: Option<u32>,
    /// Strategy-specific data
    pub strategy_data: u64,
}

impl<K, V> Default for HashBucket<K, V> {
    fn default() -> Self {
        Self {
            hash: 0,
            key: None,
            value: None,
            probe_distance: 0,
            flags: 0,
            next: None,
            strategy_data: 0,
        }
    }
}

impl<K, V> HashBucket<K, V> {
    /// Check if bucket is empty
    #[inline]
    pub fn is_empty(&self) -> bool {
        self.key.is_none()
    }

    /// Check if bucket is deleted (tombstone)
    pub fn is_deleted(&self) -> bool {
        self.flags & 0x8000 != 0
    }

    /// Mark bucket as deleted
    pub fn mark_deleted(&mut self) {
        self.flags |= 0x8000;
        self.key = None;
        self.value = None;
    }

    /// Clear bucket
    pub fn clear(&mut self) {
        *self = Self::default();
    }
}

/// Probe statistics for collision resolution
#[derive(Debug, Default, Clone)]
pub struct ProbeStats {
    pub average_probe_distance: f64,
    pub max_probe_distance: u16,
    pub total_probes: u64,
    pub collision_count: u64,
    pub variance: f64,
}

/// Optimization metrics
#[derive(Debug, Default, Clone)]
pub struct OptimizationMetrics {
    pub cache_hits: u64,
    pub cache_misses: u64,
    pub prefetch_hits: u64,
    pub simd_operations: u64,
    pub bulk_operations: u64,
}

/// Optimization hints for bulk operations
#[derive(Debug, Clone)]
pub enum OptimizationHint {
    /// Sequential access pattern
    Sequential { start_hash: u64, count: usize },
    /// Random access pattern
    Random { hashes: Vec<u64> },
    /// Bulk insertion
    BulkInsert { count: usize },
    /// Bulk lookup
    BulkLookup { count: usize },
    /// Cache warming
    CacheWarm { bucket_range: std::ops::Range<usize> },
}

// Concrete strategy implementations

/// Robin Hood collision resolution strategy
pub struct RobinHoodStrategy {
    max_probe_distance: u16,
    variance_reduction: bool,
    backward_shift: bool,
}

impl RobinHoodStrategy {
    pub fn new(max_probe_distance: u16, variance_reduction: bool, backward_shift: bool) -> Self {
        Self {
            max_probe_distance,
            variance_reduction,
            backward_shift,
        }
    }
}

#[derive(Debug, Clone)]
pub struct RobinHoodConfig {
    pub max_probe_distance: u16,
    pub variance_reduction: bool,
    pub backward_shift: bool,
}

#[derive(Debug, Default)]
pub struct RobinHoodContext {
    pub total_probe_distance: u64,
    pub max_probe_distance: u16,
    pub collision_count: u64,
    pub eviction_count: u64,
}

impl<K, V> CollisionResolutionStrategy<K, V> for RobinHoodStrategy
where
    K: Hash + Eq + Clone,
    V: Clone,
{
    type Config = RobinHoodConfig;
    type Context = RobinHoodContext;

    fn insert(
        &self,
        context: &mut Self::Context,
        buckets: &mut [HashBucket<K, V>],
        key: K,
        value: V,
        hash: u64,
        config: &Self::Config,
    ) -> Result<Option<V>> {
        let mask = buckets.len() - 1;
        let mut pos = (hash as usize) & mask;
        let mut probe_distance = 0;
        let mut inserting_key = Some(key);
        let mut inserting_value = Some(value);
        let mut inserting_hash = hash;
        let mut inserting_distance = 0;

        loop {
            if probe_distance > config.max_probe_distance {
                return Err(ZiporaError::invalid_state("Exceeded maximum probe distance"));
            }

            let bucket = &mut buckets[pos];

            // Empty bucket - insert here
            if bucket.is_empty() {
                bucket.hash = inserting_hash;
                bucket.key = inserting_key;
                bucket.value = inserting_value;
                bucket.probe_distance = inserting_distance;
                context.total_probe_distance += inserting_distance as u64;
                context.max_probe_distance = context.max_probe_distance.max(inserting_distance);
                return Ok(None);
            }

            // Key already exists - update value
            if bucket.hash == inserting_hash && bucket.key.as_ref() == inserting_key.as_ref() {
                let old_value = bucket.value.take();
                bucket.value = inserting_value;
                return Ok(old_value);
            }

            // Robin Hood: displace if we've traveled further
            if inserting_distance > bucket.probe_distance {
                // Swap the inserting entry with the bucket entry
                std::mem::swap(&mut bucket.hash, &mut inserting_hash);
                std::mem::swap(&mut bucket.key, &mut inserting_key);
                std::mem::swap(&mut bucket.value, &mut inserting_value);
                std::mem::swap(&mut bucket.probe_distance, &mut inserting_distance);
                context.eviction_count += 1;
            }

            pos = (pos + 1) & mask;
            probe_distance += 1;
            inserting_distance += 1;

            if inserting_distance > 0 {
                context.collision_count += 1;
            }
        }
    }

    fn get<'a, Q>(
        &self,
        context: &Self::Context,
        buckets: &'a [HashBucket<K, V>],
        key: &Q,
        hash: u64,
        config: &Self::Config,
    ) -> Option<&'a V>
    where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized,
    {
        let mask = buckets.len() - 1;
        let mut pos = (hash as usize) & mask;
        let mut probe_distance = 0;

        while probe_distance <= config.max_probe_distance {
            let bucket = &buckets[pos];

            if bucket.is_empty() {
                return None;
            }

            if bucket.hash == hash && bucket.key.as_ref().map(|k| k.borrow()) == Some(key) {
                return bucket.value.as_ref();
            }

            // Robin Hood: if we've probed further than this bucket's distance,
            // the key doesn't exist
            if probe_distance > bucket.probe_distance {
                return None;
            }

            pos = (pos + 1) & mask;
            probe_distance += 1;
        }

        None
    }

    fn remove<Q>(
        &self,
        context: &mut Self::Context,
        buckets: &mut [HashBucket<K, V>],
        key: &Q,
        hash: u64,
        config: &Self::Config,
    ) -> Option<V>
    where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized,
    {
        let mask = buckets.len() - 1;
        let mut pos = (hash as usize) & mask;
        let mut probe_distance = 0;

        // Find the key
        while probe_distance <= config.max_probe_distance {
            let bucket = &mut buckets[pos];

            if bucket.is_empty() {
                return None;
            }

            if bucket.hash == hash && bucket.key.as_ref().map(|k| k.borrow()) == Some(key) {
                let value = bucket.value.take();

                if config.backward_shift {
                    // Backward shift deletion
                    self.backward_shift_delete(buckets, pos);
                } else {
                    // Mark as deleted (tombstone)
                    bucket.mark_deleted();
                }

                return value;
            }

            if probe_distance > bucket.probe_distance {
                return None;
            }

            pos = (pos + 1) & mask;
            probe_distance += 1;
        }

        None
    }

    fn needs_resize(&self, context: &Self::Context, capacity: usize, len: usize) -> bool {
        let load_factor = len as f64 / capacity as f64;
        load_factor > 0.7 || context.max_probe_distance > self.max_probe_distance
    }

    fn probe_stats(&self, context: &Self::Context) -> ProbeStats {
        let avg_probe = if context.collision_count > 0 {
            context.total_probe_distance as f64 / context.collision_count as f64
        } else {
            0.0
        };

        ProbeStats {
            average_probe_distance: avg_probe,
            max_probe_distance: context.max_probe_distance,
            total_probes: context.total_probe_distance,
            collision_count: context.collision_count,
            variance: 0.0, // TODO: Calculate variance
        }
    }
}

impl RobinHoodStrategy {
    fn backward_shift_delete<K, V>(&self, buckets: &mut [HashBucket<K, V>], mut pos: usize)
    where
        K: Clone,
        V: Clone,
    {
        let mask = buckets.len() - 1;
        buckets[pos].clear();

        loop {
            let next_pos = (pos + 1) & mask;
            let next_bucket = &buckets[next_pos];

            // Stop if next bucket is empty or at its ideal position
            if next_bucket.is_empty() || next_bucket.probe_distance == 0 {
                break;
            }

            // Move the next bucket backward
            buckets[pos] = buckets[next_pos].clone();
            buckets[pos].probe_distance -= 1;
            buckets[next_pos].clear();

            pos = next_pos;
        }
    }
}

/// Standard storage layout strategy
pub struct StandardStorageStrategy;

#[derive(Debug, Clone)]
pub struct StandardStorageConfig {
    pub initial_capacity: usize,
    pub growth_factor: f64,
}

impl<K, V> StorageLayoutStrategy<K, V> for StandardStorageStrategy {
    type Config = StandardStorageConfig;
    type Storage = FastVec<HashBucket<K, V>>;

    fn create_storage(capacity: usize, config: &Self::Config) -> Self::Storage {
        // Graceful fallback: try full capacity, then half, then empty vec
        let mut storage = FastVec::with_capacity(capacity)
            .or_else(|_| FastVec::with_capacity(capacity / 2))
            .unwrap_or_else(|_| FastVec::new());

        // Only resize if we got some capacity
        if storage.capacity() > 0 {
            let actual_capacity = storage.capacity();
            let _ = storage.resize_with(actual_capacity, Default::default);
        }
        storage
    }

    fn resize_storage(
        storage: &mut Self::Storage,
        new_capacity: usize,
        config: &Self::Config,
    ) -> Result<()> {
        storage.resize_with(new_capacity, Default::default);
        Ok(())
    }

    fn get_buckets_mut(storage: &mut Self::Storage) -> &mut [HashBucket<K, V>] {
        storage.as_mut_slice()
    }

    fn get_buckets(storage: &Self::Storage) -> &[HashBucket<K, V>] {
        storage.as_slice()
    }

    fn capacity(storage: &Self::Storage) -> usize {
        storage.len()
    }

    fn memory_usage(storage: &Self::Storage) -> usize {
        storage.capacity() * std::mem::size_of::<HashBucket<K, V>>()
    }

    fn optimize_layout(storage: &mut Self::Storage, config: &Self::Config) -> Result<()> {
        // No special optimization for standard storage
        Ok(())
    }
}

/// Cache-optimized storage layout strategy
pub struct CacheOptimizedStorageStrategy {
    allocator: CacheOptimizedAllocator,
}

impl CacheOptimizedStorageStrategy {
    pub fn new(allocator: CacheOptimizedAllocator) -> Self {
        Self { allocator }
    }
}

#[derive(Debug, Clone)]
pub struct CacheOptimizedStorageConfig {
    pub cache_line_size: usize,
    pub numa_aware: bool,
    pub prefetch_enabled: bool,
}

// Note: Implementation would use cache-aligned allocation
// For simplicity, using FastVec here but real implementation would use cache allocator
impl<K, V> StorageLayoutStrategy<K, V> for CacheOptimizedStorageStrategy {
    type Config = CacheOptimizedStorageConfig;
    type Storage = FastVec<HashBucket<K, V>>;

    fn create_storage(capacity: usize, config: &Self::Config) -> Self::Storage {
        // TODO: Use cache-aligned allocation
        // Graceful fallback: try full capacity, then half, then empty vec
        let mut storage = FastVec::with_capacity(capacity)
            .or_else(|_| FastVec::with_capacity(capacity / 2))
            .unwrap_or_else(|_| FastVec::new());

        // Only resize if we got some capacity
        if storage.capacity() > 0 {
            let actual_capacity = storage.capacity();
            let _ = storage.resize_with(actual_capacity, Default::default);
        }
        storage
    }

    fn resize_storage(
        storage: &mut Self::Storage,
        new_capacity: usize,
        config: &Self::Config,
    ) -> Result<()> {
        // TODO: Use cache-aligned reallocation
        storage.resize_with(new_capacity, Default::default)?;
        Ok(())
    }

    fn get_buckets_mut(storage: &mut Self::Storage) -> &mut [HashBucket<K, V>] {
        storage.as_mut_slice()
    }

    fn get_buckets(storage: &Self::Storage) -> &[HashBucket<K, V>] {
        storage.as_slice()
    }

    fn capacity(storage: &Self::Storage) -> usize {
        storage.len()
    }

    fn memory_usage(storage: &Self::Storage) -> usize {
        storage.capacity() * std::mem::size_of::<HashBucket<K, V>>()
    }

    fn optimize_layout(storage: &mut Self::Storage, config: &Self::Config) -> Result<()> {
        // TODO: Implement cache optimization
        Ok(())
    }
}

/// SIMD optimization strategy
pub struct SimdOptimizationStrategy {
    simd_ops: &'static SimdStringOps,
}

impl SimdOptimizationStrategy {
    pub fn new() -> Self {
        Self {
            simd_ops: crate::hash_map::simd_string_ops::get_global_simd_ops(),
        }
    }
}

#[derive(Debug, Clone)]
pub struct SimdOptimizationConfig {
    pub enable_string_ops: bool,
    pub enable_bulk_ops: bool,
    pub enable_hash_computation: bool,
}

#[derive(Debug, Default)]
pub struct SimdOptimizationContext {
    pub simd_operations: u64,
    pub bulk_operations: u64,
    pub string_comparisons: u64,
}

impl<K, V> HashOptimizationStrategy<K, V> for SimdOptimizationStrategy {
    type Config = SimdOptimizationConfig;
    type Context = SimdOptimizationContext;

    fn pre_insert(
        &self,
        context: &mut Self::Context,
        key: &K,
        hash: u64,
        buckets: &[HashBucket<K, V>],
        config: &Self::Config,
    ) {
        // TODO: Implement SIMD-accelerated pre-insert optimizations
        context.simd_operations += 1;
    }

    fn post_insert(
        &self,
        context: &mut Self::Context,
        key: &K,
        inserted: bool,
        config: &Self::Config,
    ) {
        // TODO: Implement post-insert optimizations
    }

    fn pre_lookup<Q>(
        &self,
        context: &mut Self::Context,
        key: &Q,
        hash: u64,
        buckets: &[HashBucket<K, V>],
        config: &Self::Config,
    ) where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized,
    {
        // TODO: Implement SIMD-accelerated lookup optimizations
        context.simd_operations += 1;
    }

    fn bulk_optimize(
        &self,
        context: &mut Self::Context,
        operations: &[OptimizationHint],
        config: &Self::Config,
    ) {
        context.bulk_operations += operations.len() as u64;
        // TODO: Implement bulk SIMD optimizations
    }

    fn metrics(&self, context: &Self::Context) -> OptimizationMetrics {
        OptimizationMetrics {
            simd_operations: context.simd_operations,
            bulk_operations: context.bulk_operations,
            ..Default::default()
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_robin_hood_strategy() {
        let strategy = RobinHoodStrategy::new(64, true, true);
        let config = RobinHoodConfig {
            max_probe_distance: 64,
            variance_reduction: true,
            backward_shift: true,
        };
        let mut context = RobinHoodContext::default();
        let mut buckets = vec![HashBucket::default(); 16];

        // Test insertion
        let result = strategy.insert(
            &mut context,
            &mut buckets,
            "key1".to_string(),
            "value1".to_string(),
            123456,
            &config,
        );
        assert!(result.is_ok());
        assert!(result.unwrap().is_none());

        // Test lookup
        let found = strategy.get(&context, &buckets, "key1", 123456, &config);
        assert!(found.is_some());
        assert_eq!(found.unwrap(), "value1");
    }

    #[test]
    fn test_standard_storage_strategy() {
        let strategy = StandardStorageStrategy;
        let config = StandardStorageConfig {
            initial_capacity: 16,
            growth_factor: 2.0,
        };

        let mut storage: <StandardStorageStrategy as StorageLayoutStrategy<String, i32>>::Storage =
            StandardStorageStrategy::create_storage(16, &config);
        assert_eq!(StandardStorageStrategy::capacity(&storage), 16);

        let buckets: &mut [HashBucket<String, i32>] = StandardStorageStrategy::get_buckets_mut(&mut storage);
        assert_eq!(buckets.len(), 16);
    }
}