Beispiel #1
0
        private void ParseHeaderFile(string aPath, Encoding aCodePage)
        {
            using (var idParser = new HeaderParser(aPath, aCodePage))
            {
                while (idParser.HasNext())
                {
                    var obj = idParser.GetNext();

                    IDTrimmer.TrimEnd(obj.ID);
                    IDNormalizer.NormalizeRecurrenceForID(obj.ID, mHeaderContent);
                    if (!IDValidator.IsValidWithoutRecurrenceCheck(obj.ID))
                    {
                        continue;
                    }

                    mHeaderContent.NameToID[obj.Name] = new HeaderId(obj.ID);

                    IDNormalizer.NormalizeHexaID(obj.ID);

                    if (!mHeaderContent.SortedHeaderResults.ContainsKey(aPath))
                    {
                        mHeaderContent.SortedHeaderResults.Add(aPath, new List <HeaderItem>());
                    }

                    mHeaderContent.SortedHeaderResults[aPath].Add(obj);
                }

                if (mHeaderContent.SortedHeaderResults.ContainsKey(aPath))
                {
                    mHeaderContent.SortedHeaderResults[aPath].Sort(new HeaderResultComparerByID());
                }
            }
        }
Beispiel #2
0
        public int GetPosition(HeaderId aID, string aHeaderPath)
        {
            var searchedItem = new HeaderItem {
                ID = IDNormalizer.CopyNormalizeHexaID(aID)
            };

            if (!SortedHeaderResults.ContainsKey(aHeaderPath))
            {
                SortedHeaderResults.Add(aHeaderPath, new List <HeaderItem>());
            }
            var foundIndex = SortedHeaderResults[aHeaderPath].BinarySearch(0, SortedHeaderResults[aHeaderPath].Count, searchedItem, new HeaderResultComparerByID());

            if (foundIndex >= 0)
            {
                return(Constants.kDuplicateID);
            }
            else
            {
                return(~foundIndex);
            }
        }
 public static int CalculateIndex(HeaderId aID)
 {
     return(Convert.ToInt32(IDNormalizer.CopyNormalizeHexaID(aID).Value) / Constants.kStringTableCapacity);
 }