I've been using a set to store and retrieve simple objects which represent coordinates.
// Creates a point in hex coordinates function hexPoint(q, r) { this.q = q; this.r = r; } I am generating these points multiple times, so that I have easy coordinate pairs to pass around, but I wish to be able to store them in such a way that I do not store duplicate coordinates.
The ECMA 6 Set object relies on references to test object equality, so I am wondering if there is a way to supply this set with a comparable function so that I may allow it to test equality for new objects with the same fields. Otherwise, is there something else I can do to avoid re-implementing this data structure?