void CRUCacheDDLLockHandler::SortObjectsByUid()
{
	RUASSERT(NULL == pObjSortedArray_);
	
	Lng32 size = objMap_.GetCount();

	// Copy the pointers to the links to the array first ...
	pObjSortedArray_ = new PObjectLink[size];

	CDSMapPosition<ObjectLink *> pos;

	ObjectLink *pLink;
	TInt64 *uid;

	objMap_.GetStartPosition(pos);

	for (Int32 i=0; TRUE == pos.IsValid(); i++)
	{
		objMap_.GetNextAssoc(pos, uid, pLink);
		
		pObjSortedArray_[i] = pLink;
	}

	// ... and sort the array
	qsort(pObjSortedArray_, size, sizeof(PObjectLink), CompareElem);
}
void CRUEmpCheckVector::Build()
{
	size_ = epMap_.GetCount();
	if (0 == size_)
	{
		return;
	}
	
	pVec_ = new Elem[size_];

	CDSMapPosition<Lng32> mpos;
	Lng32 i, ep, val;

	for (i=0, epMap_.GetStartPosition(mpos); TRUE == mpos.IsValid(); i++)
	{
		epMap_.GetNextAssoc(mpos, ep, val);
		pVec_[i].epoch_ = ep;
	}
	RUASSERT(i == size_);

	qsort(pVec_, size_, sizeof(Elem), CompareElem);
}
CRUCacheDDLLockHandler::~CRUCacheDDLLockHandler()
{
	// Free the sorted array of pointers
	if (NULL != pObjSortedArray_)
	{
		delete [] pObjSortedArray_;
	}

	// Free the data owned by the hash table
	CDSMapPosition<ObjectLink *> pos;

	ObjectLink *pLink;
	TInt64 *uid;

	objMap_.GetStartPosition(pos);
	
	while (TRUE == pos.IsValid())
	{
		objMap_.GetNextAssoc(pos, uid, pLink);
		delete pLink;
	}

	objMap_.RemoveAll();
}