Need a collection of unique elements (like C++ std::set).

Cooler kulkin at hotbox.ru
Wed Jan 1 13:54:11 PST 2014


Example in C++:
   set<int> uniqueInts;
   assert(uniqueInts.count(99) == 0);
   uniqueInts.insert(99);
   assert(uniqueInts.count(99) == 1);
   uniqueInts.erase(99);
   assert(uniqueInts.count(99) == 0);

Which it will be analogue solution in D?

I need a collection that can hold number of items, and can tell 
me weather is an item in the collection or not. I found that 
RedBlackTree can help me. But RedBlackTree uses O(log(n)) time 
for insert/remove operations. On the other hand we have built-in 
associative arrays with hashed keys. But associative arrays 
requires pairs of (key, value), which is quite wasting in my case.
May be it will be convenient to allow void[key] built-in 
collections?
Any suggestion?


More information about the Digitalmars-d mailing list