Пример #1
0
		static DArray<T> alloc(Memory& mem, size_t length)
		{
			auto ptr = cast(T*)mem.allocRaw(ARRAY_BYTE_SIZE(length) MEMBERTYPEID);
			DArray<T> ret = {ptr, length};
			ret.zeroFill();
			return ret;
		}
Пример #2
0
		DArray<T> dup(Memory& mem)
		{
			auto retPtr = cast(T*)mem.allocRaw(ARRAY_BYTE_SIZE(length) MEMBERTYPEID);
			DArray<T> ret = {retPtr, this->length};
			ret.slicea(*this);
			return ret;
		}
Пример #3
0
	void Deque::resizeArray(Memory& mem, size_t newSize)
	{
		if(mDataLen == newSize)
			return;

		assert(newSize > mSize);

		GCObject** newData = cast(GCObject**)mem.allocRaw(newSize * sizeof(GCObject*) MEMBERTYPEID);

		if(mSize > 0)
		{
			if(mEnd > mStart)
				memcpy(newData, mDataPtr + mStart, (mEnd - mStart) * sizeof(GCObject*));
			else
			{
				size_t endLen = mDataLen - mStart;
				memcpy(newData, mDataPtr + mStart, endLen * sizeof(GCObject*));
				memcpy(newData + endLen, mDataPtr, mEnd * sizeof(GCObject*));
			}
		}

		void* p = mDataPtr;
		auto sz = mDataLen * sizeof(GCObject*);
		mem.freeRaw(p, sz MEMBERTYPEID);
		mDataPtr = newData;
		mDataLen = newSize;
		mStart = 0;
		mEnd = mSize;
	}