Example #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);
        }
Example #2
0
 public void SetFrom(LexicalSortKey other)
 {
     Debug.Assert(other.IsInitialized);
     _treeOrdinal = other._treeOrdinal;
     Volatile.Write(ref _position, other._position);
 }
Example #3
0
        public static LexicalSortKey First(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
        {
            int comparison = Compare(xSortKey, ySortKey);

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