void RunTest() { void *ptr = MUnsafeUtility.GetManagedPtr(this); Test t = MUnsafeUtility.GetObject <Test>(ptr); Debug.Log(f**k); }
public int ConcurrentAdd(ref T value, object lockerObj) { int last = Interlocked.Increment(ref data->count); //Concurrent Resize if (last > data->capacity) { lock (lockerObj) { if (last > data->capacity) { int newCapacity = data->capacity * 2; void *newPtr = MUnsafeUtility.Malloc <T>(sizeof(T) * newCapacity, data->allocator); UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(T) * data->capacity); UnsafeUtility.Free(data->ptr, data->allocator); data->ptr = newPtr; data->capacity = newCapacity; } } } last--; T *ptr = (T *)data->ptr; *(ptr + last) = value; return(last); }
public NativeList(int count, int capacity, Allocator alloc) { isCreated = true; data = MUnsafeUtility.Malloc <NativeListData>(sizeof(NativeListData), alloc); data->count = count; data->capacity = capacity; data->allocator = alloc; data->ptr = MUnsafeUtility.Malloc <T>(sizeof(T) * capacity, alloc); }
public NativeList_ulong(int capacity, Allocator alloc) { isCreated = true; capacity = Mathf.Max(capacity, 1); data = MUnsafeUtility.Malloc <NativeListData>(sizeof(NativeListData), alloc); data->count = 0; data->capacity = capacity; data->allocator = alloc; data->ptr = MUnsafeUtility.Malloc <ulong>(sizeof(ulong) * capacity, alloc); }
public void AddCapacityTo(int capacity) { if (capacity <= data->capacity) { return; } data->capacity = capacity; void *newPtr = MUnsafeUtility.Malloc <ulong>(sizeof(ulong) * data->capacity, data->allocator); UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(ulong) * data->count); UnsafeUtility.Free(data->ptr, data->allocator); data->ptr = newPtr; }
private void Resize() { if (data->count <= data->capacity) { return; } data->capacity *= 2; void *newPtr = MUnsafeUtility.Malloc <ulong>(sizeof(ulong) * data->capacity, data->allocator); UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(ulong) * data->count); UnsafeUtility.Free(data->ptr, data->allocator); data->ptr = newPtr; }
private void Resize() { if (data->count <= data->capacity) { return; } data->capacity = Mathf.Max(data->capacity + 1, (int)(data->capacity * 1.5)); void *newPtr = MUnsafeUtility.Malloc <T>(sizeof(T) * data->capacity, data->allocator); UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(T) * data->count); UnsafeUtility.Free(data->ptr, data->allocator); data->ptr = newPtr; }
private void ResizeToCount() { if (data->count <= data->capacity) { return; } int lastcapacity = data->capacity; data->capacity = data->count; void *newPtr = MUnsafeUtility.Malloc <T>(sizeof(T) * data->capacity, data->allocator); UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(T) * lastcapacity); UnsafeUtility.Free(data->ptr, data->allocator); data->ptr = newPtr; }
public NativeList(int count, Allocator alloc, T defaultValue) { isCreated = true; data = MUnsafeUtility.Malloc <NativeListData>(sizeof(NativeListData), alloc); data->count = count; data->capacity = count; data->allocator = alloc; data->ptr = MUnsafeUtility.Malloc <T>(sizeof(T) * count, alloc); T *add = (T *)data->ptr; for (int i = 0; i < count; ++i) { add[i] = defaultValue; } }
public void AddCapacityTo(int capacity) { if (capacity <= data->capacity) { return; } int lastcapacity = data->capacity; data->capacity = capacity; void *newPtr = MUnsafeUtility.Malloc <T>(sizeof(T) * data->capacity, data->allocator); UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(T) * lastcapacity); UnsafeUtility.Free(data->ptr, data->allocator); data->ptr = newPtr; }
private void ResizeToCount() { if (data->count <= data->capacity) { return; } int oldCap = data->capacity; data->capacity = data->count; void *newPtr = MUnsafeUtility.Malloc <ulong>(sizeof(ulong) * data->capacity, data->allocator); UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(ulong) * oldCap); UnsafeUtility.Free(data->ptr, data->allocator); data->ptr = newPtr; }
private void ResizeToCount() { if (data->count <= data->capacity) { return; } int oldCap = data->capacity; data->capacity = Mathf.Max((int)(oldCap * 1.2f), data->count); void *newPtr = MUnsafeUtility.Malloc <T>(sizeof(T) * data->capacity, data->allocator); UnsafeUtility.MemCpy(newPtr, data->ptr, sizeof(T) * oldCap); UnsafeUtility.Free(data->ptr, data->allocator); data->ptr = newPtr; }