public void GivenTwoTreapsWithDuplicatesWhenMergeOnIntoAnotherThenFirstTreapHasAllDataAndSecondIsEmpty() { var a = new List <int> { -100, -99, 1, 5, 10, 15, 20, 100, 101 }; var b = new List <int> { -100, -99, 2, 6, 10, 15, 21, 101, 102 }; var first = new Treap <int>(a); var second = new Treap <int>(b); first.MergeIn(second); Assert.Equal(a.Count + b.Count, first.Count); Assert.Empty(second); Assert.Equal(a.Concat(b).OrderBy(i => i), first); }
public void GivenTwoTreapsWhenMergeOnIntoAnotherThenFirstTreapHasAllDataAndSecondIsEmpty() { var a = new List <int> { 1, 5, 10, 15, 20 }; var b = new List <int> { 2, 6, 11, 16, 21 }; var first = new Treap <int>(a); var second = new Treap <int>(b); first.MergeIn(second); Assert.Equal(10, first.Count); Assert.Empty(second); Assert.Equal(a.Concat(b).OrderBy(i => i), first); }
public void GivenOneEmptyAndOneFullTreapsWhenMergeInThenTreapDontChange() { var a = new List <int> { 1, 5, 10, 15, 20 }; var first = new Treap <int>(a); var second = new Treap <int>(); first.MergeIn(second); Assert.Equal(5, first.Count); Assert.Empty(second); Assert.Equal(a.OrderBy(i => i), first); first = new Treap <int>(); second = new Treap <int>(a); first.MergeIn(second); Assert.Equal(5, first.Count); Assert.Empty(second); Assert.Equal(a.OrderBy(i => i), first); }