Пример #1
0
 public void Clear()
 {
     if (m_data.Length > 0)
     {
         PinnedListImpl.SetCount(m_list, 0);
     }
 }
Пример #2
0
        public void Assign(List <T> sourceList)
        {
            var sourceData = PinnedListImpl.GetInternalArray(sourceList);
            var count      = sourceList.Count;

            ResizeDiscard(count);
            System.Array.Copy(sourceData, m_data, count);
        }
Пример #3
0
 public void LockList(Action <List <T> > body)
 {
     if (m_gch.IsAllocated)
     {
         m_gch.Free();
     }
     body(m_list);
     m_data = PinnedListImpl.GetInternalArray(m_list);
     m_gch  = GCHandle.Alloc(m_data, GCHandleType.Pinned);
 }
Пример #4
0
 public void Resize(int size)
 {
     if (size > m_data.Length)
     {
         LockList(l =>
         {
             l.Capacity = size;
         });
     }
     PinnedListImpl.SetCount(m_list, size);
 }
Пример #5
0
 public void ResizeDiscard(int size)
 {
     if (size > m_data.Length)
     {
         if (m_gch.IsAllocated)
         {
             m_gch.Free();
         }
         m_data = new T[size];
         m_list = PinnedListImpl.CreateIntrusiveList(m_data);
         m_gch  = GCHandle.Alloc(m_data, GCHandleType.Pinned);
     }
     else
     {
         PinnedListImpl.SetCount(m_list, size);
     }
 }
Пример #6
0
 public PinnedList(List <T> data, bool clone = false)
 {
     m_list = clone ? new List <T>(data) : data;
     m_data = PinnedListImpl.GetInternalArray(m_list);
     m_gch  = GCHandle.Alloc(m_data, GCHandleType.Pinned);
 }
Пример #7
0
 public PinnedList(T[] data, bool clone = false)
 {
     m_data = clone ? (T[])data.Clone() : data;
     m_list = PinnedListImpl.CreateIntrusiveList(m_data);
     m_gch  = GCHandle.Alloc(m_data, GCHandleType.Pinned);
 }
Пример #8
0
 public PinnedList(int size = 0)
 {
     m_data = new T[size];
     m_list = PinnedListImpl.CreateIntrusiveList(m_data);
     m_gch  = GCHandle.Alloc(m_data, GCHandleType.Pinned);
 }