HNode* CreateHash(int size){ HNode* newNode=(HNode*)malloc(sizeof(HNode)); if(!newNode){ printf("\nMemory error"); } newNode->count=0; int tmpSize=(int)(size/LoadFactor); // if the size will be prime hash function will distribute the data uniformally because it gives unique remainder newNode->size=GetNextPrime(tmpSize); //printf("\nSize is : %d",newNode->size); newNode->HashTable=(BNode**)malloc(sizeof(BNode*)*newNode->size); if(!newNode->HashTable){ printf("\nMemory error"); } int i=0; for(i=0;i<newNode->size;i++){ newNode->HashTable[i]=(BNode*)malloc(sizeof(BNode)); if(!newNode->HashTable[i]){ printf("\nMemory error"); } newNode->HashTable[i]->bCount=0; newNode->HashTable[i]->next=NULL; } return newNode; }
void SingleThread(){ std::vector<unsigned char> Recs; std::ostringstream Line; unsigned int Num = GetNextPrime(); std::cout << Num << std::endl; while (Num != 0) { Recs = Reciprocal(Num); Line << Num << " 0."; for (int i = 1; i < Recs.size(); i++) { Line << (int)Recs[i]; } if(Recs.size() == Num) { AddToSONum(Line.str()); }else if(Recs.size() < Num) { AddToLTNum(Line.str()); } else { AddToGTNum(Line.str()); } Line.str(""); Num = GetNextPrime(); } }
CTextureManager::CTextureManager() : m_pHead(NULL), m_pCacheTxtrList(NULL), m_numOfCachedTxtrList(809) { m_numOfCachedTxtrList = GetNextPrime(800); m_currentTextureMemUsage = 0; m_pYoungestTexture = NULL; m_pOldestTexture = NULL; m_pCacheTxtrList = new TxtrCacheEntry *[m_numOfCachedTxtrList]; SAFE_CHECK(m_pCacheTxtrList); for (uint32 i = 0; i < m_numOfCachedTxtrList; i++) m_pCacheTxtrList[i] = NULL; memset(&m_blackTextureEntry, 0, sizeof(TxtrCacheEntry)); }