Пример #1
0
        public void Add(string item)
        {
            using var ms     = ToStream(item);
            using var reader = new BinaryReader(ms);
            var indices = new List <int>();

            foreach (var seed in _seeds)
            {
                ms.Position = 0;
                var hash     = MurMurHasher.Hash(seed, reader);
                var bitIndex = GetBitIndex(hash);
                indices.Add(bitIndex);
                _bits[bitIndex] = true;
            }
        }
Пример #2
0
        public bool MightContain(string item)
        {
            using var ms     = ToStream(item);
            using var reader = new BinaryReader(ms);
            foreach (var seed in _seeds)
            {
                ms.Position = 0;
                var hash     = MurMurHasher.Hash(seed, reader);
                var bitIndex = GetBitIndex(hash);
                if (!_bits[bitIndex])
                {
                    return(false);
                }
            }

            return(true);
        }