MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / four_level

Function four_level

cranelift/bforest/src/set.rs:563–604  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

561
562 #[test]
563 fn four_level() {
564 let mut f = SetForest::<i32>::new();
565 let mut s = dense4l(&mut f);
566
567 assert_eq!(
568 s.iter(&f).collect::<Vec<_>>()[0..10],
569 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
570 );
571
572 let mut c = s.cursor(&mut f, &());
573
574 c.verify();
575
576 // Peel off a whole sub-tree of the root by deleting from the front.
577 // The 900 element is near the front of the second sub-tree.
578 assert!(c.goto(900));
579 assert_eq!(c.tpath(), "node48[1]--node47[0]--node26[0]--node20[4]");
580 assert!(c.goto(0));
581 for i in 0..900 {
582 assert!(!c.is_empty());
583 assert_eq!(c.remove(), Some(i));
584 }
585 c.verify();
586 assert_eq!(c.elem(), Some(900));
587
588 // Delete backwards from somewhere in the middle.
589 assert!(c.goto(3000));
590 for i in (2000..3000).rev() {
591 assert_eq!(c.prev(), Some(i));
592 assert_eq!(c.remove(), Some(i));
593 assert_eq!(c.elem(), Some(3000));
594 }
595 c.verify();
596
597 // Remove everything in a scattered manner, triggering many collapsing patterns.
598 for i in 0..4000 {
599 if c.goto((i * 7) % 4000) {
600 c.remove();
601 }
602 }
603 assert!(c.is_empty());
604 }
605
606 #[test]
607 fn four_level_clear() {

Callers

nothing calls this directly

Calls 6

dense4lFunction · 0.85
newFunction · 0.50
cursorMethod · 0.45
verifyMethod · 0.45
gotoMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected