Ejemplo n.º 1
0
 public void IsSortedUtil()
 {
     Assert.That(
         OneThreeTwoFour.Begin().IsSortedUntil(
             OneThreeTwoFour.End(),
             IsIntLessThanInt).Index,
         Is.EqualTo(2));
 }
Ejemplo n.º 2
0
    public void PushHeap()
    {
        NativeArrayIterator <int> pushHeapIt = FourTwoThreeOne.Begin().Copy(
            FourTwoThreeOne.End(),
            arrLong.Begin());

        pushHeapIt.SetCurrent(5);
        pushHeapIt = pushHeapIt.GetNext();
        arrLong.Begin().PushHeap(pushHeapIt, IsIntLessThanInt);
        Assert.That(arrLong, Is.EqualTo(new[] { 5, 4, 3, 1, 2, 0, 0, 0 }));
    }
Ejemplo n.º 3
0
 public void Merge()
 {
     Assert.That(
         arr.Begin().Merge(
             arr.End(),
             OneThreeThreeFour.Begin(),
             OneThreeThreeFour.End(),
             arrLong.Begin(),
             IsIntLessThanInt
             ).Index,
         Is.EqualTo(8));
     Assert.That(arrLong, Is.EqualTo(new[] { 1, 1, 2, 2, 3, 3, 3, 4 }));
 }
Ejemplo n.º 4
0
 public void Includes()
 {
     Assert.That(
         arr.Begin().Includes(
             arr.End(),
             TwoThree.Begin(),
             TwoThree.End(),
             IsIntLessThanInt),
         Is.True);
 }
Ejemplo n.º 5
0
    public void PartitionCopy()
    {
        NativeArrayIterator <int> outResultTrue;
        NativeArrayIterator <int> outResultFalse;

        arr.Begin().PartitionCopy(
            arr.End(),
            arr2.Begin(),
            arr3.Begin(),
            IsIntEven,
            out outResultTrue,
            out outResultFalse
            );
        Assert.That(outResultTrue.Index, Is.EqualTo(2));
        Assert.That(outResultFalse.Index, Is.EqualTo(2));
        Assert.That(arr, Is.EqualTo(new[] { 1, 2, 2, 3 }));
        Assert.That(arr2, Is.EqualTo(new[] { 2, 2, 0, 0 }));
        Assert.That(arr3, Is.EqualTo(new[] { 1, 3, 0, 0 }));
    }
Ejemplo n.º 6
0
    public void PrevPermutation()
    {
        Assert.That(
            ThreeTwoOne.Begin().PrevPermutation(
                ThreeTwoOne.End(),
                IsIntLessThanInt),
            Is.True);
        Assert.That(ThreeTwoOne, Is.EqualTo(new[] { 3, 1, 2 }));


        Assert.That(
            ThreeTwoOne.Begin().PrevPermutation(
                ThreeTwoOne.End(),
                IsIntLessThanInt),
            Is.True);
        Assert.That(ThreeTwoOne, Is.EqualTo(new[] { 2, 3, 1 }));

        Assert.That(
            ThreeTwoOne.Begin().PrevPermutation(
                ThreeTwoOne.End(),
                IsIntLessThanInt),
            Is.True);
        Assert.That(ThreeTwoOne, Is.EqualTo(new[] { 2, 1, 3 }));


        Assert.That(
            ThreeTwoOne.Begin().PrevPermutation(
                ThreeTwoOne.End(),
                IsIntLessThanInt),
            Is.True);
        Assert.That(ThreeTwoOne, Is.EqualTo(new[] { 1, 3, 2 }));


        Assert.That(
            ThreeTwoOne.Begin().PrevPermutation(
                ThreeTwoOne.End(),
                IsIntLessThanInt),
            Is.True);
        Assert.That(ThreeTwoOne, Is.EqualTo(new[] { 1, 2, 3 }));

        Assert.That(
            ThreeTwoOne.Begin().PrevPermutation(
                ThreeTwoOne.End(),
                IsIntLessThanInt),
            Is.False);
        Assert.That(ThreeTwoOne, Is.EqualTo(new[] { 3, 2, 1 }));
    }
Ejemplo n.º 7
0
 public void MakeHeap()
 {
     OneTwoThreeFour.Begin().Copy(OneTwoThreeFour.End(), arr2.Begin());
     arr2.Begin().MakeHeap(arr2.End(), IsIntLessThanInt);
     Assert.That(arr2, Is.EqualTo(new[] { 4, 2, 3, 1 }));
 }
Ejemplo n.º 8
0
 public void Copy()
 {
     Assert.That(
         arr.Begin().Copy(arr.IteratorAt(2), arr2.Begin()).Index,
         Is.EqualTo(2));
     Assert.That(arr2, Is.EqualTo(new[] { 1, 2, 0, 0 }));
 }
Ejemplo n.º 9
0
 public void GetAdvanced()
 {
     Assert.That(arr.Begin().GetAdvanced(1).GetCurrent(), Is.EqualTo(2));
 }