Пример #1
0
    public void UnsafeHashSet_IsEmpty()
    {
        var container = new UnsafeHashSet <int>(0, Allocator.Persistent);

        Assert.IsTrue(container.IsEmpty);

        Assert.IsTrue(container.Add(0));
        Assert.IsFalse(container.IsEmpty);
        Assert.AreEqual(1, container.Capacity);
        ExpectedCount(ref container, 1);

        container.Remove(0);
        Assert.IsTrue(container.IsEmpty);

        Assert.IsTrue(container.Add(0));
        container.Clear();
        Assert.IsTrue(container.IsEmpty);

        container.Dispose();
    }
Пример #2
0
    public void UnsafeHashSet_EIU_ExceptWith_BxA()
    {
        var setA = new UnsafeHashSet <int>(8, Allocator.TempJob)
        {
            0, 1, 2, 3, 4, 5
        };
        var setB = new UnsafeHashSet <int>(8, Allocator.TempJob)
        {
            3, 4, 5, 6, 7, 8
        };

        setB.ExceptWith(setA);

        ExpectedCount(ref setB, 3);
        Assert.True(setB.Contains(6));
        Assert.True(setB.Contains(7));
        Assert.True(setB.Contains(8));

        setA.Dispose();
        setB.Dispose();
    }