MemoryPINGui.LibraryResultsProcessor.AddLibraryRange C# (CSharp) Метод

AddLibraryRange() публичный Метод

public AddLibraryRange ( string libraryname, int startAddress, int endAddress ) : bool
libraryname string
startAddress int
endAddress int
Результат bool
        public bool AddLibraryRange(string libraryname, int startAddress, int endAddress)
        {
            if (startAddress < 0 || endAddress < 0 || endAddress <= startAddress)
            {
                return false;
            }

            /*
             * O(N) lookup is incorrect, but whatever. There probably won't be that many libraries_string_interval.
             * (I'm sure in 5 years when I come back to this code, I'll hate myself for that comment.)
             */
            foreach(Interval i in libraries_string_interval.Values)
            {
                // don't insert a new library if we arlready have something here
                if (i.Contains(startAddress+1) || i.Contains(endAddress))
                {
                    return false;
                }
            }

            foreach (string s in libraries_interval_string.Values)
            {
                if (s.CompareTo(libraryname) == 0)
                {
                    return false;
                }
            }

            Debug.WriteLine("Adding: {0} to {1:X}-{2:X}", libraryname, startAddress, endAddress);
            // insert the new interval
            Interval interval = new Interval(startAddress, endAddress);

            libraries_string_interval[libraryname] = interval;
            libraries_interval_string[interval] = libraryname;

            return true;
        }