コード例 #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;
            }
        }
コード例 #2
0
ファイル: SingleValueTable.cs プロジェクト: microsoft/BuildXL
 /// <summary>
 /// Construct a CachingBuilder.
 /// </summary>
 protected CachingBuilder(SingleValueTable <TId, TValue> valueTable)
 {
     ValueTable = valueTable;
     // Prepopulate the dictionary that does the caching
     for (int i = 0; i < ValueTable.Count; i++)
     {
         TId id = default(TId).CreateFrom(i + 1);
         Entries.Add(ValueTable[id], id);
     }
 }
コード例 #3
0
ファイル: RelationTable.cs プロジェクト: microsoft/BuildXL
        /// <summary>
        /// Construct a RelationTable from a one-to-one SingleValueTable.
        /// </summary>
        /// <remarks>
        /// The only real point of doing this is to be able to invert the resulting relation.
        /// </remarks>
        public static RelationTable <TFromId, TToId> FromSingleValueTable(
            SingleValueTable <TFromId, TToId> baseTable,
            ITable <TToId> relatedTable)
        {
            RelationTable <TFromId, TToId> result = new RelationTable <TFromId, TToId>(baseTable, relatedTable);

            TToId[] buffer = new TToId[1];
            TToId[] empty  = new TToId[0];
            foreach (TFromId id in baseTable.Ids)
            {
                if (!s_toComparer.Equals(baseTable[id], default))
                {
                    buffer[0] = baseTable[id];
                    result.Add(buffer);
                }
                else
                {
                    result.Add(empty);
                }
            }

            return(result);
        }