import std.file, std.conv, core.thread; enum FN = "test.txt"; if (FN.exists) remove(FN); scope(exit) if (FN.exists) remove(FN); { auto s = PersistentStringSet(FN); assert("foo" !in s); assert(s.length == 0); s.add("foo"); } { auto s = PersistentStringSet(FN); assert("foo" in s); assert(s.length == 1); s.remove("foo"); } { auto s = PersistentStringSet(FN); assert("foo" !in s); Thread.sleep(filesystemTimestampGranularity); std.file.write(FN, "foo\n"); assert("foo" in s); Thread.sleep(filesystemTimestampGranularity); std.file.write(FN, "bar\n"); assert(s.lines == ["bar"], text(s.lines)); }
A string hashset, stored one line per entry.