public void SplitHashes(string txtHashes) { var hashes = txtHashes.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).Select(c => Regex.Replace(c, @"[^0-9A-Za-z]", "")).ToList(); if (UnhashingEndianness == Endianness.BigEndian) { foreach (var hash in hashes) { if (Helpers.Hashes.IsHash(hash)) { Hashes.Add(Helpers.Hashes.Reverse(Convert.ToUInt32(hash, 16))); } } } else { foreach (var hash in hashes) { if (Helpers.Hashes.IsHash(hash)) { Hashes.Add(Convert.ToUInt32(hash, 16)); } } } }
public void Add(byte[] bytes, int count) { Hashes.Add(bytes, count); if (Topk != null) { long frequency = Hashes.EstimateCount(bytes); Topk.UpdateExpectIncreasing(bytes, frequency); } }
public static Hashes ToHashes(this object value) { Hashes array = new Hashes(); var objectArray = value as Object[]; foreach (Object current in objectArray) { array.Add(current as Hash); } return array; }
public static Hashes ToHashes(this object value) { Hashes array = new Hashes(); var objectArray = value as Object[]; foreach (Object current in objectArray) { array.Add(current as Hash); } return(array); }
private void Put(Block block) { try { // 添加一个新的高度的区块 VerifyExecuteBlock(block); cacheBlocks.Enqueue(block, out _); StateTransition(block); int nativeBlockIndex = blockHashes.Add(block.Hash); // TODO: 把区块写入数据库 } catch { } }
/// <summary> /// Adds the specified file hash to the index.</summary> public FileHash AddFileHash(FileHash hash) { // if a hash is not yet on the index, add it and return the provided pointer // otherwise return the pointer of the object that is already in the index if (Hashes.Add(hash)) { return(hash); } else { return(Hashes.FirstOrDefault(x => x.Equals(hash))); } }
private void AddToDictAndHash(ulong hash, long start, long count) { List <LinePosition> linesPosition; if (!_hash2LinePositions.TryGetValue(hash, out linesPosition)) { linesPosition = new List <LinePosition>() { new LinePosition(start, count) }; _hash2LinePositions.Add(hash, linesPosition); } else { linesPosition.Add(new LinePosition(start, count)); } Hashes.Add(hash); }
private void BuildCore(MerkleNode node, BitWriter flags) { if (node == null) { return; } flags.Write(node.IsMarked); if (node.IsLeaf || !node.IsMarked) { Hashes.Add(node.Hash); } if (node.IsMarked) { BuildCore(node.Left, flags); BuildCore(node.Right, flags); } }
public object ConstructObject <T>(Stream stream) where T : class, new() { if (typeof(T) == typeof(Hash)) { StreamReader streamReader = new StreamReader(stream); JToken j = JObject.Parse(streamReader.ReadToEnd()); return(ToDictionary(j)); } else if (typeof(T) == typeof(Hashes)) { StreamReader streamReader = new StreamReader(stream); JToken j = JArray.Parse(streamReader.ReadToEnd()); object[] enumerable = ToDictionary(j) as object[]; var hashes = new Hashes(); foreach (object item in enumerable) { hashes.Add(item as Hash); } return(hashes); } else { DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(T)); T result = new T(); result = dataContractJsonSerializer.ReadObject(stream) as T; return(result); } }