Introduction

Generic list in .Net are very slow in filtering because they are general purpose and not specialized for filtering and searching items, When you want to find some specific items form a list generally you will use a foreach and test all items one by one to find the items you need
List<Person> people;
//fill people list from db or other data source
List<Person> result = new List<Person>();
foreach (var p in people)
{
   if (p.Name == "Alex" && p.Family == "Lion")
   {
      result.Add(p);
   }
}

or may use Where extension method, this method accepts a Func<T,bool> as input parameter and runs the delegate function for each item of list :
List<Person> people;
//fill people list from db or other data source
List<Person> result = people.Where(p=p.Name == "Alex" && p.Family == "Lion").ToList()

So whats the Problem ?

In small lists (up too 1000 items) usually there is no problem but when the lists grow up and you want to do fileting many times the this will take many time from CPU to do this filterings, in this cases you need to use a Dictionary, SortedDictionary, Hashset, SortedList and other useful structures as helper.

What the IndexedList do ?

The IndexedList is composed of a list and other useful structure for indexing.
IndexedList do all the jobs in background, Its a very flexible and lightweight library that helps you to create indexes on the fields you need, you can add more than one index on your list too,

Benefits:

  • Declare index on multiple fields.
  • Declare more than one index on a single list.
  • Separate the concepts of List and Index (SoC).
  • Extensible framework.

Last edited Oct 15, 2013 at 1:34 PM by Basir_ansary, version 7