Menu

#119 RemoveRecurring sohuld be much faster

open
nobody
None
2023-11-14
2023-11-14
No

The current implementation for RemoveRecurring() has cubic time complexity, which means it is unusable when you get to 10,000 pages or so.

Here's an alternate implementation:

public void RemoveRecurring()
        {
            HashSet<string> titles = new HashSet<string>();
            for (int i = pages.Count - 1; i >= 0; i--)
            {
                if (titles.Contains(pages[i].title))
                {
                    pages.RemoveAt(i);
                }
                else
                {
                    titles.Add(pages[i].title);
                }
            }
        }

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.