Cinchoo – Collections, NestedList, Part 1

ChoNestedList

.NET provides standard List<T> collection class that represents strongly typed list of objects that can be accessed by index. But lacks to store and access another List<T> object as an item. Cinchoo provides this elegant feature through ChoNestedList<T> collection class, where you can store another List<T> or ChoNestedList<T> object as an item along with other strongly typed objects. It provides endless nested opportunity to store items. It exposes most of the List<T> object members.

How to use

1. Add reference to Cinchoo.Core.dll assembly

2. Namespace Cinchoo.Core.Collections.Generic

Sample code,

static void Main(string[] args)
{
    ChoNestedList topList = new ChoNestedList();
    topList.Add("TopList-Tom");
    topList.Add("TopList-Mark");

    ChoNestedList nestedList1 = new ChoNestedList();
    nestedList1.Add("NestedList1-Raj");
    nestedList1.Add("NestedList1-Peter");
    nestedList1.Add("NestedList1-Samuel");
    topList.Add(nestedList1);

    topList.Add("TopList-Nancy");

    foreach (string name in topList)
        Console.WriteLine(name);
}

When you run the above code, the output will be

TopList-Tom
TopList-Mark
NestedList1-Raj
NestedList1-Peter
NestedList1-Samuel
TopList-Nancy
Press any key to continue . . .

It provides most of the IList<T> members

void AddRange(IEnumerable<T> collection);
int BinarySearch(T item);
int BinarySearch(T item, IComparer<T> comparer);
int BinarySearch(int index, int count, T item, IComparer<T> comparer);
List<TOutput> ConvertAll<TOutput>(Converter<T, TOutput> converter);
void CopyTo(int index, T[] array, int arrayIndex, int count);
void CopyTo(T[] array);
bool Exists(Predicate<T> match);
T Find(Predicate<T> match);
List<T> FindAll(Predicate<T> match);
int FindIndex(Predicate<T> match);
int FindIndex(int startIndex, int count, Predicate<T> match);
int FindIndex(int startIndex, Predicate<T> match);
T FindLast(Predicate<T> match);
int FindLastIndex(int startIndex, Predicate<T> match);
int FindLastIndex(int startIndex, int count, Predicate<T> match);
int FindLastIndex(Predicate<T> match);
void ForEach(Action<T> action);
List<T> GetRange(int index, int count);
int IndexOf(T item, int index);
int IndexOf(T item, int index, int count);
void InsertRange(int index, IEnumerable<T> collection);
int LastIndexOf(T item, int index);
int LastIndexOf(T item, int index, int count);
int LastIndexOf(T item);
int RemoveAll(Predicate<T> match);
void RemoveRange(int index, int count);
void Reverse(int index, int count);
void Reverse();
T[] ToArray();
void TrimExcess();
bool TrueForAll(Predicate<T> match);

Also, it is ObservableCollection. It can be used to bind to WPF controls as well.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s