예제 #1
0
        public static void RemoveAtUnordered(UnsafeList *list, int index)
        {
            Assert.Check(list != null);

            var count = list->_count;

            // cast to uint trick, which eliminates < 0 check
            if ((uint)index >= (uint)count)
            {
                throw new ArgumentOutOfRangeException();
            }

            // reduce count
            list->_count = --count;

            if (index < count)
            {
                UnsafeBuffer.Move(list->_items, count, index, 1);
            }
        }
예제 #2
0
        public static void RemoveAt(UnsafeList *list, int index)
        {
            Assert.Check(list != null);

            var count = list->_count;

            // cast to uint trick, which eliminates < 0 check
            if ((uint)index >= (uint)count)
            {
                throw new ArgumentOutOfRangeException();
            }

            // reduce count
            list->_count = --count;

            // if index is still less than count, it means we removed an item
            // not at the end of the list, and that we have to shift the items
            // down from (index+1, count-index) to (index, count-index)
            if (index < count)
            {
                UnsafeBuffer.Move(list->_items, index + 1, index, count - index);
            }
        }