C# performant alternatives to HashSet and Dictionary that do not use GetHashCode
<p>I'm looking for built-in alternatives of <code>HashSet</code> and <code>Dictionary</code> objects that have better performance than lists but do not use the internal <code>GetHashCode</code> method. I need this because for the class I have written, there is no way of writing a <code>GetHashCode</code> method that fulfills the usual contract with <code>Equals</code> other than</p>

<pre><code>public override int GetHashCode() { return 0; } // or return any other constant value
</code></pre>

<p>which would turn <code>HashSet</code> and <code>Dictionary</code> into ordinary lists (performance-wise).</p>

<p>So what I need is a set implementation and a mapping implementation. Any suggestions?</p>

<p>EDIT:</p>

<p>My class is a tolerance-based 3-dimensional vector class:</p>

<pre><code>public class Vector
{
    private static const double TOL = 1E-10;
    private double x, y, z;

    public Vector(double x, double y, double z)
    {
        this.x = x; this.y = y; this.z = z;
    }

    public override bool Equals(object o)
    {
        Vector other = o as Vector;

        if (other == null)
            return false;

        return ((Math.Abs(x - other.x) &lt;= TOL) &amp;&amp;
                (Math.Abs(y - other.y) &lt;= TOL) &amp;&amp;
                (Math.Abs(z - other.z) &lt;= TOL));
    }
}
</code></pre>

<p>Note that my <code>Equals</code> method is not transitive. However, in my use case I can make it "locally" transitive because at some point, I will know all vectors that I need to put into my set / mapping key set, and I also know that they will come in clusters. So when I have collected all vectors, I will choose one representative per cluster and replace all original vectors by the representative. Then <code>Equals</code> will be transitive among the elements of my set / mapping key set.</p>

<p>When I have my set or mapping, I will collect vectors from another source (for the sake of this question let's assume I'll ask a user to type in a vector). These can be any possible vector. Those will never be added to the set/mapping, but I will need to know if they are contained in the set / key set of the mapping (regarding tolerance), and I will need to know their value from the mapping.</p>