Click here to Skip to main content
15,886,873 members
Articles / Programming Languages / C#

MultiList: .NET Generic List with Multiple Sort Orders

Rate me:
Please Sign up or sign in to vote.
3.55/5 (5 votes)
1 Feb 2008CPOL6 min read 44.2K   200   16  
The MultiList class extends the functionality of the generic list. The MultiList class manages multiple sort orders on lists. It is best suited to object lists where searching is required on more than one criteria.
// 
// MultiList library - Copyright 2008 by Michael Moorman / AsAbove.net
// This work is released to the public domain, and may be used for any purpose, without any conditions.
// 
using System;
using System.Collections.Generic;
using System.Text;

namespace AsAbove.Collections.Exception
{
	/// <summary>
	/// EnumeratorTypeExpectedException is thrown when the <see cref="AsAbove.Collections.MultiList&lt;T&gt;">MultiList</see> class is constructed with an 
	/// invalid type in the first argument. The first argument must an enumerator type.
	/// </summary>
	public class EnumeratorTypeExpectedException : ApplicationException
	{
		/// <summary>
		/// 
		/// </summary>
		public EnumeratorTypeExpectedException ()
			:
			base ("The constructor argument 'typeOfEnum' must be an enumerator type which defines " +
				"the sort orders to be apply to the MultiSort class object")
		{}
	}

	/// <summary>
	/// InsufficientIComparerCountException is thrown by the <see cref="AsAbove.Collections.MultiList&lt;T&gt;">MultiList</see> constructor does not contain
	/// a sufficient number of comparer classes. 
	/// </summary>
	public class InsufficientIComparerCountException : ApplicationException
	{
		/// <summary>
		/// 
		/// </summary>
		/// <param name="count"></param>
		public InsufficientIComparerCountException (int count)
			:
			base ("There were not enough IComparer objects passed to the constructor of the MultiSort class. " +
				"The constructor expected " + count + "IComparer objects")
		{}
	}

	/// <summary>
	/// InvalidEnumeratorException is thrown if a method enumerator argument is provided that does not the 
	/// enumerator type used in the <see cref="AsAbove.Collections.MultiList&lt;T&gt;">MultiList</see> constructor.
	/// </summary>
	public class InvalidEnumeratorException : ApplicationException
	{
		/// <summary>
		/// 
		/// </summary>
		public InvalidEnumeratorException ()
			:
			base ("Invalid enumerator.")
		{ }
	}

	/// <summary>
	/// MultiListObjectNotFoundException is thrown by the <see cref="AsAbove.Collections.MultiList&lt;T&gt;">MultiList</see> class
	/// <see cref="AsAbove.Collections.MultiList&lt;T&gt;.Find&lt;ComparisonType&gt; (AsAbove.Collections.MultiList&lt;T&gt;.ITypeComparer&lt;ComparisonType&gt;, ComparisonType)">Find</see> method when no match is found.
	/// </summary>
	public class MultiListObjectNotFoundException : ApplicationException
	{
		/// <summary>
		/// 
		/// </summary>
		public MultiListObjectNotFoundException ()
			:
			base ("Object not found in list.")
		{ }
	}

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions