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); }
public bool DataIsUnique(byte[] data) { return(!_recentHashcodesHS.Contains(MiscProcedures.GetArrayHashCode(data))); }