public void DeleteStream(string streamId)
 {
     lock (_commits)
     {
         InMemoryCommit[] commits = _commits.Where(c => c.StreamId == streamId).ToArray();
         foreach (var commit in commits)
         {
             _commits.Remove(commit);
         }
         ISnapshot[] snapshots = _snapshots.Where(s => s.StreamId == streamId).ToArray();
         foreach (var snapshot in snapshots)
         {
             _snapshots.Remove(snapshot);
         }
         IStreamHead streamHead = _heads.SingleOrDefault(s => s.StreamId == streamId);
         if (streamHead != null)
         {
             _heads.Remove(streamHead);
         }
     }
 }
            public bool AddSnapshot(ISnapshot snapshot)
            {
                lock (_commits)
                {
                    IStreamHead currentHead = _heads.FirstOrDefault(h => h.StreamId == snapshot.StreamId);
                    if (currentHead == null)
                    {
                        return(false);
                    }

                    // if the snapshot is already there do NOT add it (follow the SQL implementation)
                    // and the original GetSnapshot behavior which was to return the first one that was
                    // added to the collection
                    if (_snapshots.Any(s => s.StreamId == snapshot.StreamId && s.StreamRevision == snapshot.StreamRevision))
                    {
                        return(false);
                    }

                    _snapshots.Add(snapshot);
                    _heads.Remove(currentHead);
                    _heads.Add(new StreamHead(currentHead.BucketId, currentHead.StreamId, currentHead.HeadRevision, snapshot.StreamRevision));
                }
                return(true);
            }