Ejemplo n.º 1
0
            public int GetHashCode(UniqueBlockStructure <BlockTypeTable> obj)
            {
                //TODO: This hash function is not very good, see http://stackoverflow.com/a/1079419/410020

                var table = (BlockTypeTable)obj;

                int result = 17;
                var stringBlockComparer = new StringBlock.StringBlockEqualityComparer();

                unchecked
                {
                    foreach (var item in table)
                    {
                        result = result * 31 + stringBlockComparer.GetHashCode(item.Item1);
                        result = result * 31 + item.Item2;
                    }
                }
                return(result);
            }
Ejemplo n.º 2
0
            public bool Equals(UniqueBlockStructure <BlockTypeTable> x, UniqueBlockStructure <BlockTypeTable> y)
            {
                var tableX = (BlockTypeTable)x;
                var tableY = (BlockTypeTable)y;

                if (tableX.Count != tableY.Count)
                {
                    return(false);
                }

                int count = tableX.Count;
                var stringBlockComparer = new StringBlock.StringBlockEqualityComparer();

                for (int i = 0; i < count; i++)
                {
                    Tuple <StringBlock, int> bX = tableX[i];
                    Tuple <StringBlock, int> bY = tableY[i];
                    if (!(stringBlockComparer.Equals(bX.Item1, bY.Item1) && bX.Item2 == bY.Item2))
                    {
                        return(false);
                    }
                }
                return(true);
            }
Ejemplo n.º 3
0
            public int GetHashCode(UniqueBlockStructure <StringBlock> obj)
            {
                string value = ((StringBlock)obj).Value;

                return(value == null ? 0 : value.GetHashCode());
            }
Ejemplo n.º 4
0
 public bool Equals(UniqueBlockStructure <StringBlock> x, UniqueBlockStructure <StringBlock> y)
 {
     return(((StringBlock)x).Value == ((StringBlock)y).Value);
 }