Ejemplo n.º 1
0
        /// <summary>
        /// Compare two lexical sort keys in a compilation.
        /// </summary>
        public static int Compare(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
        {
            int comparison;

            if (xSortKey.TreeOrdinal != ySortKey.TreeOrdinal)
            {
                if (xSortKey.TreeOrdinal < 0)
                {
                    return(1);
                }
                else if (ySortKey.TreeOrdinal < 0)
                {
                    return(-1);
                }

                comparison = xSortKey.TreeOrdinal - ySortKey.TreeOrdinal;
                Debug.Assert(comparison != 0);
                return(comparison);
            }

            return(xSortKey.Position - ySortKey.Position);
        }
Ejemplo n.º 2
0
 public void SetFrom(LexicalSortKey other)
 {
     Debug.Assert(other.IsInitialized);
     _treeOrdinal = other._treeOrdinal;
     Volatile.Write(ref _position, other._position);
 }
Ejemplo n.º 3
0
        public static LexicalSortKey First(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
        {
            int comparison = Compare(xSortKey, ySortKey);

            return(comparison > 0 ? ySortKey : xSortKey);
        }