Exemple #1
0
        /// <summary>Sort this NameIndex.</summary>
        /// <remarks>Sorting at the name level isn't needed by all apps, so it is optional;
        /// after calling this, HasBeenSorted becomes true and Compare can be called.</remarks>
        public void Sort(StringIndex stringIndex)
        {
            if (HasBeenSorted)
            {
                // only need to sort once
                return;
            }

            NameId[] ids = new NameId[BaseTableOpt.Count + 1];
            for (int i = 1; i <= BaseTableOpt.Count; i++)
            {
                ids[i] = new NameId(i);
            }

            NameSortComparer comparer = new NameSortComparer(this, stringIndex);

            ids.AsMemory().ParallelSort(comparer);

            // build out the table of sort orders by id
            m_nameSortOrder = new SingleValueTable <NameId, int>(NameTable);
            m_nameSortOrder.FillToBaseTableCount();
            for (int i = 1; i < ids.Length; i++)
            {
                m_nameSortOrder[ids[i]] = i;
            }
        }
Exemple #2
0
 internal FindComparer(
     StringIndex parent,
     string toFind,
     StringComparison stringComparison = StringComparison.InvariantCulture)
 {
     m_parent           = parent;
     m_toFind           = toFind;
     m_stringComparison = stringComparison;
 }
Exemple #3
0
 internal NameSortComparer(NameIndex nameIndex, StringIndex stringIndex)
 {
     m_nameIndex   = nameIndex;
     m_stringIndex = stringIndex;
 }