예제 #1
0
        public bool Filter(byte[] dataMustBeUnique)
        {
            var hashCode = MiscProcedures.GetArrayHashCode(dataMustBeUnique);

            if (_recentHashcodesHS.Contains(hashCode))
            {
                return(false);
            }

            _recentHashcodesHS.Add(hashCode);
            _recentHashcodes.AddLast(hashCode);

            if (_recentHashcodes.Count > _maxRecentItemsToKeep)
            {
                var removedItem = _recentHashcodes.First;
                _recentHashcodes.RemoveFirst();
                _recentHashcodesHS.Remove(removedItem.Value);
            }

            return(true);
        }
예제 #2
0
 public bool DataIsUnique(byte[] data)
 {
     return(!_recentHashcodesHS.Contains(MiscProcedures.GetArrayHashCode(data)));
 }