More complete operator overloading

This commit is contained in:
Hackerpilot 2014-08-22 14:48:35 -07:00
parent ca34a0640e
commit 459be4704a
1 changed files with 11 additions and 1 deletions

View File

@ -90,7 +90,7 @@ public:
this.type = type; this.type = type;
} }
int opCmp(ref const ACSymbol other) const int opCmp(ref const ACSymbol other) const pure nothrow @safe
{ {
// Compare the pointers because the strings have been interned. // Compare the pointers because the strings have been interned.
// Identical strings MUST have the same address // Identical strings MUST have the same address
@ -101,6 +101,16 @@ public:
return 0; return 0;
} }
bool opEquals(ref const ACSymbol other) const pure nothrow @safe
{
return other.name.ptr == this.name.ptr;
}
size_t toHash() const pure nothrow @safe
{
return (cast(size_t) name.ptr) * 27_644_437;
}
/** /**
* Gets all parts whose name matches the given string. * Gets all parts whose name matches the given string.
*/ */