Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • D

Idiom #34 Create a set of objects

Declare and initialize a set x containing unique objects of type T.

import std.container: redBlackTree;
auto x = redBlackTree!T;

By default standard red-black trees don't accept duplicates, hence making great sets.
#include <unordered_set>
std::unordered_set<T, hasher, eq> x;

Using a custom hasher and eq (equality checking function)

New implementation...