Logo

Programming-Idioms

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

Idiom #34 Create a set of objects

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

#include <unordered_set>
std::unordered_set<T, hasher, eq> x;

Using a custom hasher and eq (equality checking function)
#include <unordered_set>
std::unordered_set<T> x;

T must be hashable
using System.Collections.Generic;
HashSet<T> x = new HashSet<T>();

Where T is the type of element

New implementation...