Example #1
0
        public override int CompareTo(VirtualValue other, IComparer <AnyValue> comparator)
        {
            if (other == null || !(other is PathValue))
            {
                throw new System.ArgumentException("Cannot compare different virtual values");
            }

            PathValue otherPath = ( PathValue )other;

            NodeValue[]         nodes              = nodes();
            RelationshipValue[] relationships      = relationships();
            NodeValue[]         otherNodes         = otherPath.Nodes();
            RelationshipValue[] otherRelationships = otherPath.Relationships();

            int x = nodes[0].CompareTo(otherNodes[0], comparator);

            if (x == 0)
            {
                int i      = 0;
                int length = Math.Min(relationships.Length, otherRelationships.Length);

                while (x == 0 && i < length)
                {
                    x = relationships[i].CompareTo(otherRelationships[i], comparator);
                    ++i;
                }

                if (x == 0)
                {
                    x = Integer.compare(relationships.Length, otherRelationships.Length);
                }
            }

            return(x);
        }
Example #2
0
        public override bool Equals(VirtualValue other)
        {
            if (other == null || !(other is PathValue))
            {
                return(false);
            }
            PathValue that = ( PathValue )other;

            return(Size() == that.Size() && Arrays.Equals(Nodes(), that.Nodes()) && Arrays.Equals(Relationships(), that.Relationships()));
        }