当前位置: 首页>>代码示例>>C++>>正文


C++ HashNode类代码示例

本文整理汇总了C++中HashNode的典型用法代码示例。如果您正苦于以下问题:C++ HashNode类的具体用法?C++ HashNode怎么用?C++ HashNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HashNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RefreshVertices

void HashGraph::RefreshVertices(unsigned minCount)
{
#pragma omp parallel for
    for (int64 i = 0; i < (int64)table_size; ++i)
    {
        HashNode *node = table[i];
        HashNode *prev = NULL;
        while (node != NULL)
        {
            if (node->IsDead() || node->Count() < minCount)
            {
#pragma omp atomic
                --num_nodes;
                if (prev == NULL)
                {
                    table[i] = node->next;
                    FreeNode(node, omp_get_thread_num());
                    node = table[i];
                }
                else
                {
                    prev->next = node->next;
                    FreeNode(node, omp_get_thread_num());
                    node = prev->next;
                }
            }
            else
            {
                node->ClearStatus();
                prev = node;
                node = prev->next;
            }
        }
    }
}
开发者ID:brettin,项目名称:hku-idba,代码行数:35,代码来源:HashGraph.cpp

示例2: resize

	void resize() {
		int new_length = 4;
		while(new_length < elems_) {
			new_length <<= 1;
		}
		HashNode** new_list = new HashNode*[new_length];
		memset(new_list, 0, sizeof(new_list[0]) * new_length);
		int count = 0;

		for(int i=0; i<length_; ++i) {
			HashNode* now = list_[i];
			while(now != NULL) {
				HashNode* next = now->next_hash;
				Slice key = now->key();
				int hash = now->hash;
				HashNode** ptr = &new_list[hash & (new_length - 1)];

				now->next_hash = *ptr;
				*ptr = now;
				now = next;
				count++;
			}
		}
		assert(elems_ == count);
		delete[] list_;
		list_ = new_list;
		length_ = new_length;
	}
开发者ID:alanzw,项目名称:LiveRender,代码行数:28,代码来源:cache.hpp

示例3: ClearGraph

void HashGraph::ClearGraph()
{
    for (unsigned i = 0; i < table_size; ++i)
    {
        for (HashNode *node = table[i]; node != NULL; node = node->next)
        {
            node->Clear();
            node->SetCount(1);
        }
    }
    num_edges = 0;
}
开发者ID:brettin,项目名称:hku-idba,代码行数:12,代码来源:HashGraph.cpp

示例4: AddAllEdges

void HashGraph::AddAllEdges()
{
    num_edges = 0;
#pragma omp parallel for
    for (int64 i = 0; i < (int64)table_size; ++i)
    {
        for (HashNode *node = table[i]; node; node = node->next)
        {
            node->SetInEdges(15);
            node->SetOutEdges(15);
        }
    }
}
开发者ID:brettin,项目名称:hku-idba,代码行数:13,代码来源:HashGraph.cpp

示例5: evict

void GrCCPathCache::evict(const GrCCPathCache::Key& key, GrCCPathCacheEntry* entry) {
    if (!entry) {
        HashNode* node = fHashTable.find(key);
        SkASSERT(node);
        entry = node->entry();
    }
    SkASSERT(*entry->fCacheKey == key);
    SkASSERT(!entry->hasBeenEvicted());
    entry->fCacheKey->markShouldUnregisterFromPath();  // Unregister the path listener.
    entry->releaseCachedAtlas(this);
    fLRU.remove(entry);
    fHashTable.remove(key);
}
开发者ID:google,项目名称:skia,代码行数:13,代码来源:GrCCPathCache.cpp

示例6: AverageCoverage

double HashGraph::AverageCoverage()
{
    long long sum = 0;
    uint64 valid = 0;
    for (int64 i = 0; i < table_size; ++i)
    {
        for (HashNode *node = table[i]; node; node = node->next)
        {
            sum += node->Count();
            ++valid;
        }
    }

    return 1.0 * sum / valid;
}
开发者ID:brettin,项目名称:hku-idba,代码行数:15,代码来源:HashGraph.cpp

示例7: findPosition

int CTECHashTable<Type>:: findPosition(HashNode<Type> currentNode){
	int position = 0;

	position = currentNode.getKey()%capacity;

	return position;
}
开发者ID:zeajenson,项目名称:classproject_0.6_hashing,代码行数:7,代码来源:CTECHashTable.cpp

示例8: MedianCoverage

double HashGraph::MedianCoverage()
{
    vector<int> v;
    v.reserve(num_nodes);
    for (int64 i = 0; i < table_size; ++i)
    {
        for (HashNode *node = table[i]; node; node = node->next)
        {
            v.push_back(node->Count());
        }
    }

    nth_element(v.begin(), v.begin() + v.size()/2, v.end());

    return *(v.begin() + v.size()/2);
}
开发者ID:brettin,项目名称:hku-idba,代码行数:16,代码来源:HashGraph.cpp

示例9: insert

	HashNode* insert(const Slice& key, int& hit_id, int& rep_id) {
		HashNode* e = reinterpret_cast<HashNode*>(malloc(sizeof(HashNode) - 1 + key.size()));
		e->key_length = key.size();
		e->hash = hash_slice(key);
		memcpy(e->key_data, key.data(), key.size());

		lru_append(e);
		HashNode* old = table_.insert(e);

		if(old != NULL) {
			//命中缓存
			e->cache_id = old->cache_id;

			hit_id = e->cache_id;
			rep_id = -1;

			lru_remove(old);
			lru_release(old);

			//update hit ratio
			hit_cnt++;
		}
		else {
			//没有命中缓存
			hit_id = -1;

			//如果当前的缓存数量超过capacity,把lru_后面的那个缓存单元淘汰掉
			if(table_.size() > capacity_) {
				HashNode* cursor = lru_.next;
				lru_remove(cursor);
				table_.remove(cursor->key(), cursor->hash);

				e->cache_id = cursor->cache_id;
				lru_release(cursor);
			}
			else {
				e->cache_id = last_id++;  //TODO 会无限增长?
			}

			rep_id = e->cache_id;

			//update hit ratio
			set_cnt++;
		}

		return e;
	}
开发者ID:alanzw,项目名称:LiveRender,代码行数:47,代码来源:cache.hpp

示例10: findPosition

long HashTable<Type> :: findPosition(Type data)
{
    long insertedPosition;
    unsigned long address =(long)&data;
    insertedPosition = address % capacity;
    HashNode<Type>* indexPointer = front;
    for (long index = 0; index < insertedPosition; index++)
    {
        indexPointer = indexPointer->getNode();
    }
if (indexPointer->hasStuffed())
{
    insertedPosition = handleCollision(data, insertedPosition);
}
    
    return insertedPosition;
}
开发者ID:Roboteacherutah,项目名称:ScottNodeProject,代码行数:17,代码来源:HashTable.cpp

示例11: findPosition

int HashTable<Type> :: findPosition(HashNode<Type> currentNode)
{
    //We are going "hash" the key of the HashNode to find its value.
    int position = 0;
    
    position = currentNode.getKey() % capacity;
    return position;
}
开发者ID:madeast,项目名称:UpdateNodes,代码行数:8,代码来源:HashTable.cpp

示例12:

int CTECHashTable<Type>::findTablePosition(HashNode<Type> currentNode)
{
	//We are going to "hash" the key of the hashnode to find its storage spot.
	int position = 0;

	position = currentNode.getKey() % tableCapacity;

	return position;
}
开发者ID:smartman97,项目名称:NodeProject,代码行数:9,代码来源:CTECHashTable.cpp

示例13: RefreshEdges

void HashGraph::RefreshEdges()
{
    num_edges = 0;
#pragma omp parallel for
    for (int64 i = 0; i < (int64)table_size; ++i)
    {
        for (HashNode *node = table[i]; node; node = node->next)
        {
            KmerNodeAdapter curr(node);
            for (int strand = 0; strand < 2; ++strand)
            {
                Kmer kmer;
                curr.GetKmer(kmer);
                unsigned edges = curr.OutEdges();
                for (int x = 0; x < 4; ++x)
                {
                    if (edges & (1 << x))
                    {
                        Kmer next = kmer;
                        next.AddRight(x);
                        if (GetNode(next) == NULL)
                            curr.RemoveOutEdge(x);
                        else
                        {
#pragma omp atomic
                            ++num_edges;
                        }
                    }
                }

                curr.ReverseComplement();
            }

            if (node->kmer.IsPalindrome())
            {
                unsigned edges = node->InEdges() | node->OutEdges();
                node->SetInEdges(edges);
                node->SetOutEdges(edges);
            }
        }
    }

    num_edges >>= 1;
}
开发者ID:brettin,项目名称:hku-idba,代码行数:44,代码来源:HashGraph.cpp

示例14: contains

bool CTECHashTable<Type>:: contains(HashNode<Type> currentNode){
	bool isInTable = false;

	int possibleLocation = findPosition(currentNode);

	while(internalStorage[possibleLocation] != nullptr && !isInTable){
		if(internalStorage[possibleLocation] == currentNode.getValue()){
			isInTable = true;
		}
		possibleLocation = (possibleLocation + 1) % capacity;
	}

	return isInTable;
}
开发者ID:zeajenson,项目名称:classproject_0.6_hashing,代码行数:14,代码来源:CTECHashTable.cpp

示例15: remove

bool CTECHashTable<Type>:: remove(HashNode<Type> currentNode){
	bool hasBeenRemoved = false;
	int possibleLocation = findPosition(currentNode);

	if(contains(currentNode)){
		while(internalStorage[possibleLocation] != nullptr && !hasBeenRemoved){
			if(internalStorage[possibleLocation] == currentNode.getValue()){
				hasBeenRemoved = true;
				internalStorage[possibleLocation] = nullptr;
			}
			possibleLocation = (possibleLocation + 1) % capacity;
		}
	}
	return hasBeenRemoved;
}
开发者ID:zeajenson,项目名称:classproject_0.6_hashing,代码行数:15,代码来源:CTECHashTable.cpp


注:本文中的HashNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。