c# - Is there a LinkedList collection that supports dictionary type operations -


i profiling application trying work out why operations extremely slow. 1 of classes in application collection based on linkedlist. here's basic outline, showing couple of methods , fluff removed:

  public class linkinfocollection : propertynotificationobject, ienumerable<linkinfo>   {      private linkedlist<linkinfo> _items;      public linkinfocollection()     {       _items = new linkedlist<linkinfo>();     }      public void add(linkinfo item)     {       _items.addlast(item);     }      public linkinfo this[guid id]     { { return _items.singleordefault(i => i.id == id); } }    } 

the collection used store hyperlinks (represented linkinfo class) in single list. however, each hyperlink has list of hyperlinks point it, , list of hyperlinks points to. basically, it's navigation map of website. means can having infinite recursion when links go each other, implemented linked list - understand it, means every hyperlink, no matter how many times referenced hyperlink, there ever 1 copy of object.

the id property in above example guid.

with long winded description out way, problem simple - according profiler, when constructing map small website, indexer referred above called no less 27906 times. extraordinary amount. still need work out if it's necessary called many times, @ same time, know if there's more efficient way of doing indexer primary bottleneck identified profiler (also assuming isn't lying!). still needed linked list behaviour don't want more 1 copy of these hyperlinks floating around killing memory, need able access them unique key.

does have advice offer on improving performance of indexer. have indexer uses uri rather guid, less problematic building incoming/outgoing links done guid.

thanks; richard moss

you should use dictionary<guid, linkinfo>.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -