public void Test() { var root = new SegmentTreeNode<int>(StringComparer.InvariantCultureIgnoreCase); root.Search(new[] {"a"}, 0).Should().BeEmpty(); root.Add(new[] {"a", "b", "c"}, 0, 42).Should().BeTrue(); root.Search(new[] {"a"}, 0).Should().BeEquivalentTo((new[] {"a", "b", "c"}, 42)); root.Search(new[] {"a", "b"}, 0).Should().BeEquivalentTo((new[] {"a", "b", "c"}, 42)); root.Search(new[] {"a", "b", "c"}, 0).Should().BeEquivalentTo((new[] {"a", "b", "c"}, 42)); root.Search(new[] {"a", "b", "c", "d"}, 0).Should().BeEmpty(); root.Add(new[] {"a", "b"}, 0, 42).Should().BeFalse(); root.Delete(new[] {"a", "b", "c"}, 0).Should().BeTrue(); root.Search(new[] {"a"}, 0).Should().BeEmpty(); }
private void CreateOrUpdateFile(string path, IReadOnlyList <string> pathSegments) { var lastWriteTime = File.GetLastWriteTimeUtc(path); if (lastWriteTime == NonExistingWriteTimeUtc) { log.TraceFormat("File {Path} is not exist"); return; } if (filesInfo.TryGetData(pathSegments, 0, out var fileInfo) && lastWriteTime == fileInfo.LastWriteTime) { log.TraceFormat("File {Path} was not updated", path); return; } filesInfo.Add(pathSegments, 0, new FileInfo(path, lastWriteTime)); changes.OnNext(FileChangedEvent.CreatedOrUpdated(path)); log.TraceFormat("File {Path} was created or updated", path); }