Esempio n. 1
0
        internal void Organize()
        {
            // Fill in the positions array (with default values).
            for (int i = 0; i < _positions.Length; i++)
            {
                _positions[i] = new PositionRecord(_others[i]);
            }

            // Set up the index in others map.
            _indexInPositions = new Dictionary <XmlNode, int>(_others.Count);
            for (int i = 0; i < _others.Count; i++)
            {
                _indexInPositions[_others[i]] = i;
            }

            // mark exact nodes: each node in _others that has a corresponding node in primary is marked
            // with the index of that primary node.
            for (int i = 0; i < _primary.Count; i++)
            {
                XmlNode primaryChild = _primary[i];
                XmlNode otherChild;
                if (_correspondences.TryGetValue(primaryChild, out otherChild))
                {
                    _positions[_indexInPositions[otherChild]].exactPosition = i;
                }
            }

            if (_correspondences.Count < _others.Count)
            {
                SetRangesForUnmatchedOthers();
            }

            // determine whether order is different
            for (int i = 0; i < _positions.LongLength - 1; i++)
            {
                if (_positions[i].Key > _positions[i + 1].Key)
                {
                    _orderIsDifferent = true;
                    break;
                }
            }
            _orderIsConsistent = true;
            foreach (PositionRecord pr in _positions)
            {
                if (!pr.OrderIsConsistent)
                {
                    _orderIsConsistent = false;
                }
            }
            // NB sort AFTER determining whether order is changed and consistent,
            // since it changes the information used to determine that.
            SortPositions();
            ResolveAmbiguities();
            _orderIsAmbiguous = IsAmbiguous();
        }
Esempio n. 2
0
            int IComparer.Compare(Object x, Object y)
            {
                PositionRecord xpr = x as PositionRecord;
                PositionRecord ypr = y as PositionRecord;

                if (xpr.Key < ypr.Key)
                {
                    return(-1);
                }
                if (xpr.Key > ypr.Key)
                {
                    return(1);
                }
                return(0);
            }
Esempio n. 3
0
        internal void Organize()
        {
            // Fill in the positions array (with default values).
            for (int i = 0; i < _positions.Length; i++)
                _positions[i] = new PositionRecord(_others[i]);

            // Set up the index in others map.
            _indexInPositions = new Dictionary<XmlNode, int>(_others.Count);
            for (int i = 0; i < _others.Count; i++)
                _indexInPositions[_others[i]] = i;

            // mark exact nodes: each node in _others that has a corresponding node in primary is marked
            // with the index of that primary node.
            for (int i = 0; i < _primary.Count; i++)
            {
                XmlNode primaryChild = _primary[i];
                XmlNode otherChild;
                if (_correspondences.TryGetValue(primaryChild, out otherChild))
                    _positions[_indexInPositions[otherChild]].exactPosition = i;
            }

            if (_correspondences.Count < _others.Count)
                SetRangesForUnmatchedOthers();

            // determine whether order is different
            for (int i = 0; i < _positions.LongLength - 1; i++)
            {
                if (_positions[i].Key > _positions[i + 1].Key)
                {
                    _orderIsDifferent = true;
                    break;
                }
            }
            _orderIsConsistent = true;
            foreach (PositionRecord pr in _positions)
            {
                if (!pr.OrderIsConsistent)
                    _orderIsConsistent = false;
            }
            // NB sort AFTER determining whether order is changed and consistent,
            // since it changes the information used to determine that.
            SortPositions();
            ResolveAmbiguities();
            _orderIsAmbiguous = IsAmbiguous();
        }