PersistentStringSet

A string hashset, stored one line per entry.

Constructors

this
this(string fileName)
Undocumented in source.

Members

Functions

add
void add(string key)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
auto opBinaryRight(string key)
Undocumented in source. Be warned that the author may not have intended to support it.
remove
void remove(string key)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

length
size_t length [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
lines
string[] lines [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

_load
HashSet!string _load(string fileName)
Undocumented in source. Be warned that the author may not have intended to support it.
_save
void _save(string fileName, HashSet!string data)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

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));
}

Meta