require 'ostruct'
class Object
def hash_to_ostruct(visited = [])
self
end
end
class Array
def hash_to_ostruct(visited = [])
map { |x| x.hash_to_ostruct(visited) }
end
end
class Hash
def hash_to_ostruct(visited = [])
os = OpenStruct.new
each do |k, v|
item = visited.find { |x| x.first.object_id == v.object_id }
if item
os.send("#{k}=", item.last)
else
os.send("#{k}=", v.hash_to_ostruct(visited + [ [self, os] ]))
end
end
os
end
end
hash = { "country" => {:a => "a"}, :population => 20_000_000 }
p hash.hash_to_ostruct
分享到:
相关推荐
Hash programming in SAS. to show you how hash objects in SAS DATA steps can be used to lookup ...you should be able to start wisely incorporating hash object programming techniques in your applications.
Learning to Hash with Binary Deep Neural Network
就像从git hash-object一样计算对象ID。 安装 npm install git-hash-object 用法 const gitHashObject = require ( "git-hash-object" ) ; gitHashObject ( "Hello World" ) ; //=> "5e1c309dae7f45e0f39b1bf3ac3...
This book starts with simple first attempts devoid of collision resolution strategies, and moves through improvements and extensions illustrating different design ideas and approaches, followed by ...
import hashObject from 'hash-obj' ; hashObject ( { ':unicorn:' : ':rainbow:' } , { algorithm : 'sha1' } ) ; //=> '3de3bc784035b559784fc276f47493d60555fba3' 原料药 hashObject(对象,选项?) 目的 类型...
MurmurHash算法由Austin Appleby创建于2008年,现已应用到Hadoop、libstdc 、nginx、libmemcached,Redis,Memcached,Cassandra,HBase,Lucene等开源系统。2011年Appleby被Google雇佣,随后Google推出其变种的...
uthash开源的hash函数实现,里面的uthash.h可用
内容描述:用于crypto中hash爆破的强大工具。 优势:相较于其他hash工具,具有更快的算力,使用方便简洁。 适用:适用于md5,sha256等典型hash加密方式,反推出所需的源码。
代码如下://Hash对象的工具函数 function $H(object) { return new Hash(object);... object.toObject() : Object.clone(object); } //覆盖Enumerable里面的方法,遍历Hash对象时会用到 function _each(i
Just add a UT_hash_handle to the structure and choose one or more fields in your structure to act as the key. Then use these macros to store, retrieve or delete items from the hash table
Ohm - Redis的Object-hash映射库
uthash 是C的比较优秀的开源代码,它实现了常见的hash操作函数,例如查找、插入、删除等待。该套开源代码采用宏的方式实现hash函数的相关功能,支持C语言的任意数据结构最为key值,甚至可以采用多个值作为key,无论...
All of these utils are designed to execute only one specific function. Since they all work with STDIN and STDOUT you can group them into chains. Detailed description See the hashcat wiki page of ...
RS-Hash Function Value: " + ghl.RSHash(key)); System.out.println(" 2. JS-Hash Function Value: " + ghl.JSHash(key)); System.out.println(" 3. PJW-Hash Function Value: " + ghl.PJWHash(key)); System....
pluck_to_hash, 扩展ActiveRecord以返回散列的array 这是什么?通过添加返回 pluck_to_hash的array 而不是数组 array的方法扩展 wsrr 。 在抓取多个列以呈现json或者你需要访问视图中的各个字段时有用例如。支持 ...
stm32f407平台上实现的hash算法
3维hashin失效准则~复合材料层合板
Hash在线解密平台最新版php实现纯txt存储哈希跟明文对应表查询
work, we propose an image hash algorithm with block level content pro- tection. It extracts features from DFT coefficients of image blocks. Ex- periments show that the hash has strong robustness ...
Hashcat is the self-proclaimed world's fastest password recovery tool. It had a proprietary code base until 2015, but is now released as free software. Versions are available for Linux, OS X, and ...