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


C++ Hasher类代码示例

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


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

示例1: TimeOne

 /**
  * Time and report the execution of one hash across the entire Dictionary
  *
  * \param [in] hindex index of the hash Collider to use
  */
 void TimeOne (const int hindex)
 {
   // Hashing speed
   uint32_t reps = 100;
   Hasher h = m_hashes[hindex].m_hash;
   int start = clock ();
   for (std::vector<std::string>::const_iterator w = m_words.begin ();
        w != m_words.end();
        ++w)
     {
       for (uint32_t i = 0; i < reps; ++i)
         {
           h.clear ().GetHash32 (*w);
         }
     }
   int stop = clock ();
   double delta = stop - start;
   double per = 1e9 * delta / (m_nphrases * reps * CLOCKS_PER_SEC);
   
   std::cout << std::left
             << std::setw (32) << m_hashes[hindex].GetName ()
             << std::right
             << std::setw (10) << m_nphrases
             << std::setw (10) << reps
             << std::setw (10) << stop - start
             << std::setw (12) << per
             << std::endl;
   
 }  // TimeOne ()
开发者ID:shuiziliuBUPT,项目名称:HelloWorld,代码行数:34,代码来源:hash-example.cpp

示例2: hashWithSalt

Common::Hash Hasher::hashWithSalt(const Common::Hash& hash, quint64 salt)
{
   Hasher hasher;
   hasher.addData(hash.getData(), Hash::HASH_SIZE);
   hasher.addSalt(salt);
   return hasher.getResult();
}
开发者ID:PowerKiKi,项目名称:D-LAN,代码行数:7,代码来源:Hash.cpp

示例3: hash

		std::size_t FunctionTypeData::hash() const {
			Hasher hasher;
			hasher.add(attributes());
			hasher.add(returnType());
			hasher.add(parameterTypes());
			return hasher.get();
		}
开发者ID:scrossuk,项目名称:locic,代码行数:7,代码来源:FunctionType.cpp

示例4: hash

Common::Hash Hasher::hash(const QString& str)
{
   const QByteArray data = str.toUtf8();

   Hasher hasher;
   hasher.addData(data.constData(), data.size());
   return hasher.getResult();
}
开发者ID:PowerKiKi,项目名称:D-LAN,代码行数:8,代码来源:Hash.cpp

示例5: _callbackExt

void Hasher::_callbackExt(int gpio, int level, uint32_t tick, void *user)
{
   /*
      Need a static callback to link with C.
   */

   Hasher *mySelf = (Hasher *) user;

   mySelf->_callback(gpio, level, tick); /* Call the instance callback. */
}
开发者ID:Bahamuttg,项目名称:pigpio,代码行数:10,代码来源:ir_hasher.cpp

示例6: hash

			size_t hash() const {
				Hasher hasher;
				hasher.add(kind());
				
				switch (kind()) {
					case NULLVAL:
						break;
					case BOOLEAN:
						hasher.add(boolValue());
						break;
					case INTEGER:
						hasher.add(integerValue());
						break;
					case FLOATINGPOINT:
						hasher.add(floatValue());
						break;
					case CHARACTER:
						hasher.add(characterValue());
						break;
					case STRING:
						hasher.add(stringValue());
						break;
				}
				
				return hasher.get();
			}
开发者ID:scrossuk,项目名称:locic,代码行数:26,代码来源:Constant.hpp

示例7:

ImageView &TransientAllocator::request_attachment(unsigned width, unsigned height, VkFormat format, unsigned index)
{
	Hasher h;
	h.u32(width);
	h.u32(height);
	h.u32(format);
	h.u32(index);

	auto hash = h.get();
	auto *node = transients.request(hash);
	if (node)
		return node->handle->get_view();

	auto image_info = ImageCreateInfo::transient_render_target(width, height, format);
	node = transients.emplace(hash, device->create_image(image_info, nullptr));
	return node->handle->get_view();
}
开发者ID:aliaspider,项目名称:beetle-psx-libretro,代码行数:17,代码来源:render_pass.cpp

示例8: generateHash

void
generateHash(
    const char* filename ) {
    // Create hasher
    Hasher hasher;
    MD5Strategy* md5Strategy = new MD5Strategy();
    hasher.addStrategy( md5Strategy );
    SHA256Strategy* sha256Strategy = new SHA256Strategy();
    hasher.addStrategy( sha256Strategy );

    // Read the file and hash it
    ifstream input( filename, ios_base::in | ios_base::binary );
    if ( input.is_open() ) {
        char buffer[1024];
        hasher.init();
        while ( !input.eof() ) {
            input.read( buffer, 1023 );
            int numRead = input.gcount();
            hasher.update( buffer, numRead );
        }
        input.close();
        string messageDigest;
        hasher.digest( "MD5", messageDigest );
        cout << messageDigest << " ";
        hasher.digest( "SHA256", messageDigest );
        cout << messageDigest << endl;
    }
    else {
        cerr << "ERROR: Unable to open file: " << filename << endl;
    }
}
开发者ID:PlantandFoodResearch,项目名称:irods,代码行数:31,代码来源:HasherTest.cpp

示例9: getHasher

 error
 getHasher( const std::string& _name, Hasher& _hasher ) {
     boost::unordered_map<const std::string, const HashStrategy*>::const_iterator it = _strategies.find( _name );
     if ( _strategies.end() == it ) {
         std::stringstream msg;
         msg << "Unknown hashing scheme [" << _name << "]";
         return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
     }
     _hasher.init( it->second );
     return SUCCESS();
 }
开发者ID:pombreda,项目名称:irods,代码行数:11,代码来源:irods_hasher_factory.cpp

示例10: test

 void
 test (std::string const& what, std::size_t n)
 {
     using namespace std;
     using namespace std::chrono;
     xor_shift_engine g(1);
     array<std::uint8_t, KeySize> key;
     auto const start = clock_type::now();
     while(n--)
     {
         rngfill (key, g);
         Hasher h;
         h.append(key.data(), KeySize);
         volatile size_t temp =
             static_cast<std::size_t>(h);
         (void)temp;
     }
     auto const elapsed = clock_type::now() - start;
     log << setw(12) << what << " " <<
         duration<double>(elapsed) << "s";
 }
开发者ID:BobWay,项目名称:rippled,代码行数:21,代码来源:hash_speed_test.cpp

示例11: hash

		size_t Predicate::hash() const {
			Hasher hasher;
			hasher.add(kind());
			
			switch (kind()) {
				case TRUE:
				case FALSE:
				case SELFCONST:
				{
					break;
				}
				case AND:
				{
					hasher.add(andLeft());
					hasher.add(andRight());
					break;
				}
				case OR:
				{
					hasher.add(orLeft());
					hasher.add(orRight());
					break;
				}
				case SATISFIES:
				{
					hasher.add(satisfiesType());
					hasher.add(satisfiesRequirement());
					break;
				}
				case VARIABLE:
				{
					hasher.add(variableTemplateVar());
					break;
				}
			}
			
			return hasher.get();
		}
开发者ID:scrossuk,项目名称:locic,代码行数:38,代码来源:Predicate.cpp

示例12: flush_graphics_pipeline

void CommandBuffer::flush_graphics_pipeline()
{
	Hasher h;
	active_vbos = 0;
	auto &layout = current_layout->get_resource_layout();
	for_each_bit(layout.attribute_mask, [&](uint32_t bit) {
		h.u32(bit);
		active_vbos |= 1u << attribs[bit].binding;
		h.u32(attribs[bit].binding);
		h.u32(attribs[bit].format);
		h.u32(attribs[bit].offset);
	});

	for_each_bit(active_vbos, [&](uint32_t bit) {
		h.u32(vbo_input_rates[bit]);
		h.u32(vbo_strides[bit]);
	});

	h.u64(render_pass->get_cookie());
	h.u64(current_program->get_cookie());
	h.data(static_state.words, sizeof(static_state.words));

	if (static_state.state.blend_enable)
	{
		const auto needs_blend_constant = [](VkBlendFactor factor) {
			return factor == VK_BLEND_FACTOR_CONSTANT_COLOR || factor == VK_BLEND_FACTOR_CONSTANT_ALPHA;
		};
		bool b0 = needs_blend_constant(static_cast<VkBlendFactor>(static_state.state.src_color_blend));
		bool b1 = needs_blend_constant(static_cast<VkBlendFactor>(static_state.state.src_alpha_blend));
		bool b2 = needs_blend_constant(static_cast<VkBlendFactor>(static_state.state.dst_color_blend));
		bool b3 = needs_blend_constant(static_cast<VkBlendFactor>(static_state.state.dst_alpha_blend));
		if (b0 || b1 || b2 || b3)
			h.data(reinterpret_cast<uint32_t *>(potential_static_state.blend_constants),
			       sizeof(potential_static_state.blend_constants));
	}

	auto hash = h.get();
	current_pipeline = current_program->get_graphics_pipeline(hash);
	if (current_pipeline == VK_NULL_HANDLE)
		current_pipeline = build_graphics_pipeline(hash);
}
开发者ID:aliaspider,项目名称:beetle-psx-libretro,代码行数:41,代码来源:command_buffer.cpp

示例13: main

// **Sample** main function/driver-- THIS IS NOT A COMPLETE TEST SUITE
// YOU MUST WRITE YOUR OWN TESTS
// See assignment description.
int main( int argc, char* argv[])
{
    // Generate empty hash tables:
    Hasher* goodHashRP1 = new Hasher('g', 'd');
    Hasher* goodHashQP1 = new Hasher('g', 'q');
    Hasher* badHashRP1 = new Hasher('b', 'd');
    Hasher* badHashQP1 = new Hasher('b', 'q');
    
    // Generate hash tables that are systematically loaded from file.
    // Note that if you cannot fit an element you should stop inserting elements
    // and set a flag to full.
    Hasher* goodHashRPa = new Hasher('g', 'd', 0.25, "4000record.txt");
		Hasher* goodHashRPb = new Hasher('g', 'd', 0.50, "4000record.txt");
		Hasher* goodHashRPc = new Hasher('g', 'd', 0.75, "4000record.txt");
    Hasher* goodHashQPa = new Hasher('g', 'q', 0.25, "4000record.txt");
    Hasher* goodHashQPb = new Hasher('g', 'q', 0.50, "4000record.txt");
    Hasher* goodHashQPc = new Hasher('g', 'q', 0.75, "4000record.txt");
    Hasher* poorHashRPa = new Hasher('b', 'd', 0.25, "4000record.txt");
    Hasher* poorHashRPb = new Hasher('b', 'd', 0.50, "4000record.txt");
    Hasher* poorHashRPc = new Hasher('b', 'd', 0.75, "4000record.txt");
    Hasher* poorHashQPa = new Hasher('b', 'q', 0.25, "4000record.txt");
    Hasher* poorHashQPb = new Hasher('b', 'q', 0.50, "4000record.txt");
    Hasher* poorHashQPc = new Hasher('b', 'q', 0.75, "4000record.txt");
	  goodHashRPa->printStat();
		goodHashRPb->printStat();
		goodHashRPc->printStat();
		goodHashQPa->printStat();
		goodHashQPb->printStat();
		goodHashQPc->printStat();
		poorHashRPa->printStat();
		poorHashRPb->printStat();
		poorHashRPc->printStat();
		poorHashQPa->printStat();
		poorHashQPb->printStat();
		poorHashQPc->printStat();

    // Sample use case:
		std::cout << "Insert MUZEJKGA 10" << std::endl;
    std::string key = "MUZEJKGA";
    int value = 10;
    if(goodHashRP1->insert(key, value)) 
        std::cout << "Inserted" << std::endl;
    else
        std::cout << "Failed to insert" << std::endl;
    
    goodHashRP1->printTable();

    int subscript = -1; 
    std::cout << "search for inserted" << std::endl;
    if(goodHashRP1->search(key, subscript)) 
        std::cout << "Found at " << subscript << std::endl;
    else
        std::cout << "Failed to find" << std::endl;
    
    goodHashRP1->printTable();
    std::cout << "remove that one" << std::endl;
		if(goodHashRP1->remove(key)) 
        std::cout << "Removed" << std::endl;
    else
        std::cout << "Not deleted/not found" << std::endl;
    
		goodHashRP1->printTable();
    
		std::cout << "remove once more" << std::endl;
    if(goodHashRP1->remove(key)) 
        std::cout << "Removed" << std::endl;
    else
        std::cout << "Not deleted/not found" << std::endl;
    goodHashRP1->printTable();

		std::cout << "insert again" << std::endl;
    if(goodHashRP1->insert(key, value)) 
        std::cout << "Inserted" << std::endl;
    else
        std::cout << "Failed to insert" << std::endl;
    goodHashRP1->printTable();
		std::cout << "search for it" << std::endl;
    if(goodHashRP1->search(key, subscript)) 
        std::cout << "Found at " << subscript << std::endl;
    else
        std::cout << "Failed to find" << std::endl;
    goodHashRP1->printTable();
		value=3;
		std::cout << "insert with same key diff val" << std::endl;
    if(goodHashRP1->insert(key, value)) 
        std::cout << "Inserted" << std::endl;
    else
        std::cout << "Failed to insert" << std::endl;
    goodHashRP1->printTable();
		std::cout << "find it" << std::endl;
    if(goodHashRP1->search(key, subscript)) 
        std::cout << "Found at " << subscript << std::endl;
    else
        std::cout << "Failed to find" << std::endl;
    goodHashRP1->printTable();
		std::cout << "remove " << std::endl;
    if(goodHashRP1->remove(key)) 
//.........这里部分代码省略.........
开发者ID:krxsky,项目名称:AlgoData,代码行数:101,代码来源:hashDriver.cpp

示例14: hash

		size_t Value::hash() const {
			Hasher hasher;
			hasher.add(kind());
			hasher.add(type());
			
			switch (kind()) {
				case Value::SELF:
					break;
				case Value::THIS:
					break;
				case Value::CONSTANT:
					hasher.add(constant());
					break;
				case Value::ALIAS:
					hasher.add(&(alias()));
					hasher.add(aliasTemplateArguments().size());
					for (const auto& argument: aliasTemplateArguments()) {
						hasher.add(argument);
					}
					break;
				case Value::PREDICATE:
					hasher.add(predicate());
					break;
				case Value::LOCALVAR:
					hasher.add(&(localVar()));
					break;
				case Value::REINTERPRET:
					hasher.add(reinterpretOperand());
					break;
				case Value::DEREF_REFERENCE:
					hasher.add(derefOperand());
					break;
				case Value::TERNARY:
					hasher.add(ternaryCondition());
					hasher.add(ternaryIfTrue());
					hasher.add(ternaryIfFalse());
					break;
				case Value::CAST:
					hasher.add(castTargetType());
					hasher.add(castOperand());
					break;
				case Value::POLYCAST:
					hasher.add(polyCastTargetType());
					hasher.add(polyCastOperand());
					break;
				case Value::INTERNALCONSTRUCT:
					hasher.add(internalConstructParameters().size());
					for (const auto& param: internalConstructParameters()) {
						hasher.add(param);
					}
					break;
				case Value::MEMBERACCESS:
					hasher.add(memberAccessObject());
					hasher.add(&(memberAccessVar()));
					break;
				case Value::BIND_REFERENCE:
					hasher.add(bindReferenceOperand());
					break;
				case Value::TYPEREF:
					hasher.add(typeRefType());
					break;
				case Value::TEMPLATEVARREF:
					hasher.add(templateVar());
					break;
				case Value::CALL:
					hasher.add(callValue());
					hasher.add(callParameters().size());
					for (const auto& param: callParameters()) {
						hasher.add(param);
					}
					break;
				case Value::FUNCTIONREF:
					hasher.add(functionRefParentType());
					hasher.add(&(functionRefFunction()));
					hasher.add(functionRefTemplateArguments().size());
					for (const auto& arg: functionRefTemplateArguments()) {
						hasher.add(arg);
					}
					break;
				case Value::TEMPLATEFUNCTIONREF:
					hasher.add(templateFunctionRefParentType());
					hasher.add(templateFunctionRefName());
					hasher.add(templateFunctionRefFunctionType());
					break;
				case Value::METHODOBJECT:
					hasher.add(methodObject());
					hasher.add(methodOwner());
					break;
				case Value::INTERFACEMETHODOBJECT:
					hasher.add(interfaceMethodObject());
					hasher.add(interfaceMethodOwner());
					break;
				case Value::STATICINTERFACEMETHODOBJECT:
					hasher.add(staticInterfaceMethodObject());
					hasher.add(staticInterfaceMethodOwner());
					break;
				case Value::CAPABILITYTEST:
					hasher.add(capabilityTestCheckType());
					hasher.add(capabilityTestCapabilityType());
					break;
//.........这里部分代码省略.........
开发者ID:scrossuk,项目名称:locic,代码行数:101,代码来源:Value.cpp

示例15: flush_descriptor_set

void CommandBuffer::flush_descriptor_set(uint32_t set)
{
	auto &layout = current_layout->get_resource_layout();
	auto &set_layout = layout.sets[set];
	uint32_t num_dynamic_offsets = 0;
	uint32_t dynamic_offsets[VULKAN_NUM_BINDINGS];
	Hasher h;

	// UBOs
	for_each_bit(set_layout.uniform_buffer_mask, [&](uint32_t binding) {
		h.u64(cookies[set][binding]);
		h.u32(bindings[set][binding].buffer.range);
		VK_ASSERT(bindings[set][binding].buffer.buffer != VK_NULL_HANDLE);

		dynamic_offsets[num_dynamic_offsets++] = bindings[set][binding].buffer.offset;
	});

	// SSBOs
	for_each_bit(set_layout.storage_buffer_mask, [&](uint32_t binding) {
		h.u64(cookies[set][binding]);
		h.u32(bindings[set][binding].buffer.offset);
		h.u32(bindings[set][binding].buffer.range);
		VK_ASSERT(bindings[set][binding].buffer.buffer != VK_NULL_HANDLE);
	});

	// Sampled buffers
	for_each_bit(set_layout.sampled_buffer_mask, [&](uint32_t binding) {
		h.u64(cookies[set][binding]);
		VK_ASSERT(bindings[set][binding].buffer_view != VK_NULL_HANDLE);
	});

	// Sampled images
	for_each_bit(set_layout.sampled_image_mask, [&](uint32_t binding) {
		h.u64(cookies[set][binding]);
		h.u64(secondary_cookies[set][binding]);
		h.u32(bindings[set][binding].image.imageLayout);
		VK_ASSERT(bindings[set][binding].image.imageView != VK_NULL_HANDLE);
		VK_ASSERT(bindings[set][binding].image.sampler != VK_NULL_HANDLE);
	});

	// Storage images
	for_each_bit(set_layout.storage_image_mask, [&](uint32_t binding) {
		h.u64(cookies[set][binding]);
		h.u32(bindings[set][binding].image.imageLayout);
		VK_ASSERT(bindings[set][binding].image.imageView != VK_NULL_HANDLE);
	});

	// Input attachments
	for_each_bit(set_layout.input_attachment_mask, [&](uint32_t binding) {
		h.u64(cookies[set][binding]);
		h.u32(bindings[set][binding].image.imageLayout);
		VK_ASSERT(bindings[set][binding].image.imageView != VK_NULL_HANDLE);
	});

	Hash hash = h.get();
	auto allocated = current_layout->get_allocator(set)->find(hash);

	// The descriptor set was not successfully cached, rebuild.
	if (!allocated.second)
	{
		uint32_t write_count = 0;
		uint32_t buffer_info_count = 0;
		VkWriteDescriptorSet writes[VULKAN_NUM_BINDINGS];
		VkDescriptorBufferInfo buffer_info[VULKAN_NUM_BINDINGS];

		for_each_bit(set_layout.uniform_buffer_mask, [&](uint32_t binding) {
			auto &write = writes[write_count++];
			write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
			write.pNext = nullptr;
			write.descriptorCount = 1;
			write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
			write.dstArrayElement = 0;
			write.dstBinding = binding;
			write.dstSet = allocated.first;

			// Offsets are applied dynamically.
			auto &buffer = buffer_info[buffer_info_count++];
			buffer = bindings[set][binding].buffer;
			buffer.offset = 0;
			write.pBufferInfo = &buffer;
		});

		for_each_bit(set_layout.storage_buffer_mask, [&](uint32_t binding) {
			auto &write = writes[write_count++];
			write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
			write.pNext = nullptr;
			write.descriptorCount = 1;
			write.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
			write.dstArrayElement = 0;
			write.dstBinding = binding;
			write.dstSet = allocated.first;
			write.pBufferInfo = &bindings[set][binding].buffer;
		});

		for_each_bit(set_layout.sampled_buffer_mask, [&](uint32_t binding) {
			auto &write = writes[write_count++];
			write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
			write.pNext = nullptr;
			write.descriptorCount = 1;
			write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
//.........这里部分代码省略.........
开发者ID:aliaspider,项目名称:beetle-psx-libretro,代码行数:101,代码来源:command_buffer.cpp


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