示例#1
0
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;
}
示例#2
0
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;
}
示例#3
0
文件: buffer.c 项目: Lupus/ccl
static StreamBuffer *Create(size_t size)
{
	return CreateWithAllocator(size,CurrentAllocator);
}
示例#4
0
static TreeMap *Create(size_t ElementSize)
{
    return CreateWithAllocator(ElementSize,CurrentMemoryManager);
}
示例#5
0
static PQueue *Create(size_t ElementSize)
{
    return CreateWithAllocator(ElementSize, CurrentAllocator);
}
示例#6
0
static ElementType *Create(size_t startsize)
{
    return CreateWithAllocator(startsize,CurrentAllocator);
}