MRUList

by tsachi 14. March 2009 16:12
public class MRUList<T> : List<T>

{

// Summary:

// Initializes a new instance of the System.Collections.Generic.List<T> class

// that is empty and has the default initial capacity.

public MRUList() : base() {}

//

// Summary:

// Initializes a new instance of the System.Collections.Generic.List<T> class

// that contains elements copied from the specified collection and has sufficient

// capacity to accommodate the number of elements copied.

//

// Parameters:

// collection:

// The collection whose elements are copied to the new list.

//

// Exceptions:

// System.ArgumentNullException:

// collection is null.

public MRUList(IEnumerable<T> collection) : base(collection) {}

//

// Summary:

// Initializes a new instance of the System.Collections.Generic.List<T> class

// that is empty and has the specified initial capacity.

//

// Parameters:

// capacity:

// The number of elements that the new list can initially store.

//

// Exceptions:

// System.ArgumentOutOfRangeException:

// capacity is less than 0.

public MRUList(int capacity) : base(capacity) {}

// Summary:

// Adds an object to the end of the System.Collections.Generic.List<T>.

//

// Parameters:

// item:

// The object to be added to the end of the System.Collections.Generic.List<T>.

// The value can be null for reference types.

public new void Add(T item)

{

if( Capacity == Count )

{

RemoveAt(0);

};

base.Add( item );

}

}

 

 

 

Tags:

C# & .Net

Advertisements

About the author

9+ years experience in software, software engineering, software development, software architecture, software development methodology and practices, web, internet, intranet, distributed application, client/server, object-oriented analysis and design, requirements analysis and modeling, data modeling, and database design. Progressed through end-user application, servers and databases work to management positions. Held positions with management responsibility, including training and technological leading, for up to 5 employees. Engaged in computer applications development with focus over video streaming, web and security.