コード例 #1
0
ファイル: Circle.cs プロジェクト: dprotopopov/PlanarGraph
        public override bool Equals(object obj)
        {
            var circle = obj as Circle;
            if (circle == null) return false;
            if (Count != circle.Count) return false;
            if (Count == 0) return true;

            var list1 = new SortedStackListQueue<Vertex>(this) {Comparer = VertexComparer};
            var list2 = new SortedStackListQueue<Vertex>(circle) {Comparer = VertexComparer};
            if (!list1.Equals(list2)) return false;

            int index = circle.IndexOf(this[0]);
            var circle1 = new Circle(circle);
            circle1.Rotate(index);
            if (this.SequenceEqual(circle1)) return true;
            circle1.Rotate();
            circle1.Reverse();
            return this.SequenceEqual(circle1);
        }
コード例 #2
0
        public override bool Equals(object obj)
        {
            var edge = obj as Edge;

            if (obj == null)
            {
                return(false);
            }
            if (Count != edge.Count())
            {
                return(false);
            }
            if (Count == 0)
            {
                return(true);
            }

            var list1 = new SortedStackListQueue <Vertex>(this)
            {
                Comparer = VertexComparer
            };
            var list2 = new SortedStackListQueue <Vertex>(edge)
            {
                Comparer = VertexComparer
            };

            if (!list1.Equals(list2))
            {
                return(false);
            }

            int index = edge.IndexOf(this[0]);
            var edge1 = new Edge(edge);

            edge1.Rotate(index);
            if (this.SequenceEqual(edge1))
            {
                return(true);
            }
            edge1.Rotate();
            edge1.Reverse();
            return(this.SequenceEqual(edge1));
        }