Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions gl3n/linalg.d
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,20 @@ struct Vector(type, int dimension_) {
else { assert(false); }
}

size_t toHash() const nothrow @safe {
size_t h = 0;
foreach (v; vector) {
h = hashOf(v, h);
}
return h;
}

unittest {
assert(__traits(compiles, string[vec2]), "Unable to construct an associative array with a Vector as the key");
string[vec2] aa = [ vec2(1, 2): "test" ];
assert(aa[vec2(1, 2)] == "test");
}

}

/// Calculates the product between two vectors.
Expand Down