Пример #1
0
        public static Enumerator <T> GetEnumerator <T>(UnsafeSortedSet *set) where T : unmanaged
        {
            UDebug.Assert(set != null);
            UDebug.Assert(typeof(T).TypeHandle.Value == set->_typeHandle);

            return(new Enumerator <T>(set));
        }
Пример #2
0
        public static void CopyTo <T>(UnsafeSortedSet *set, void *destination, int destinationIndex)
            where T : unmanaged
        {
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(ThrowHelper.ArgumentOutOfRange_Index);
            }
            UDebug.Assert(set != null);
            UDebug.Assert(typeof(T).TypeHandle.Value == set->_typeHandle);

            var enumerator = GetEnumerator <T>(set);
            var dest       = (T *)destination;

            int i = 0;

            while (enumerator.MoveNext())
            {
                dest[destinationIndex + i] = enumerator.Current;
                i++;
            }
        }
Пример #3
0
        public static void Add <T>(UnsafeSortedSet *set, T item)
            where T : unmanaged, IComparable <T>
        {
            UDebug.Assert(set != null);
            UDebug.Assert(typeof(T).TypeHandle.Value == set->_typeHandle);

            UnsafeOrderedCollection.Insert <T>(&set->_collection, item);
        }
Пример #4
0
        public static bool Contains <T>(UnsafeSortedSet *set, T item)
            where T : unmanaged, IComparable <T>
        {
            UDebug.Assert(set != null);
            UDebug.Assert(typeof(T).TypeHandle.Value == set->_typeHandle);

            return(UnsafeOrderedCollection.Find <T>(&set->_collection, item) != null);
        }
Пример #5
0
        public static void Free(UnsafeSortedSet *set)
        {
            if (set == null)
            {
                return;
            }

            if (set->_collection.Entries.Dynamic == 1)
            {
                UnsafeBuffer.Free(&set->_collection.Entries);
            }

            // clear memory
            *set = default;

            // free it
            Memory.Free(set);
        }
Пример #6
0
 public Enumerator(UnsafeSortedSet *set)
 {
     _keyOffset = set->_collection.KeyOffset;
     _iterator  = new UnsafeOrderedCollection.Enumerator(&set->_collection);
 }
Пример #7
0
        public static void Clear(UnsafeSortedSet *set)
        {
            UDebug.Assert(set != null);

            UnsafeOrderedCollection.Clear(&set->_collection);
        }
Пример #8
0
        public static bool IsFixedSize(UnsafeSortedSet *set)
        {
            UDebug.Assert(set != null);

            return(set->_collection.Entries.Dynamic == 0);
        }
Пример #9
0
        public static int GetCapacity(UnsafeSortedSet *set)
        {
            UDebug.Assert(set != null);

            return(set->_collection.Entries.Length);
        }
Пример #10
0
        public static int GetCount(UnsafeSortedSet *set)
        {
            UDebug.Assert(set != null);

            return(UnsafeOrderedCollection.GetCount(&set->_collection));
        }
Пример #11
0
 public NativeSortedSet(int capacity, bool fixedSize)
 {
     m_inner = UnsafeSortedSet.Allocate <T>(capacity, fixedSize);
 }
Пример #12
0
 public NativeSortedSet(int capacity)
 {
     m_inner = UnsafeSortedSet.Allocate <T>(capacity, false);
 }