static TreeMap *Copy(TreeMap *src) { TreeMap *result; struct Node *pSrc; if (src == NULL) { iError.RaiseError("Copy",CONTAINER_ERROR_BADARG); return NULL; } pSrc = bt_first(src); result = CreateWithAllocator(src->ElementSize,src->Allocator); while (pSrc) { iTreeMap.Add(result,pSrc->data,NULL); pSrc = bt_next(src,pSrc); } return result; }
static PQueue *Copy(const PQueue *src) { PQueue *result; Iterator *it; int r; PQueueElement *obj; if (src == NULL) return NULL; result = CreateWithAllocator(src->ElementSize,src->Allocator); if (result == NULL) return NULL; it = iHeap.NewIterator(src->Heap); for (obj = it->GetFirst(it); obj != NULL; obj = it->GetNext(it)) { if (obj->Key != INT_MIN) { r = Add(result,obj->Key,obj->Data); if (r < 0) { Finalize(result); return NULL; } } } iHeap.deleteIterator(it); return result; }
static StreamBuffer *Create(size_t size) { return CreateWithAllocator(size,CurrentAllocator); }
static TreeMap *Create(size_t ElementSize) { return CreateWithAllocator(ElementSize,CurrentMemoryManager); }
static PQueue *Create(size_t ElementSize) { return CreateWithAllocator(ElementSize, CurrentAllocator); }
static ElementType *Create(size_t startsize) { return CreateWithAllocator(startsize,CurrentAllocator); }