Class SimpleList<TObject>
Implementation of a single-linked list.
Implements
Inherited Members
Namespace: EPiServer.BaseLibrary.Collections
Assembly: EPiServer.BaseLibrary.dll
Version: 8.11.0Syntax
public class SimpleList<TObject> : IList<TObject>, ICollection<TObject>, IEnumerable<TObject>, IEnumerable
Type Parameters
Name | Description |
---|---|
TObject | The type of the object stored in the list. |
Constructors
SimpleList()
Declaration
public SimpleList()
Properties
Count
Gets the count of items in the list.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The count. |
Remarks
Note that this property is calculated by iterating over the list. I e it is expensive on large lists.
IsReadOnly
Gets a value indicating whether the System.Collections.Generic.ICollection<T> is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Alwways true, since SimpleList does not support Read-only. |
IsSynchronized
Gets a value indicating whether this instance is synchronized.
Declaration
public virtual bool IsSynchronized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Item[Int32]
Declaration
public TObject this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
TObject |
Methods
Add(TObject)
Adds the specified item to the list.
Declaration
public void Add(TObject item)
Parameters
Type | Name | Description |
---|---|---|
TObject | item | The item to add. |
Remarks
This operation is an O(1) operation.
Clear()
Clears this instance.
Declaration
public virtual void Clear()
Contains(TObject)
Determines whether the System.Collections.Generic.ICollection<T> contains a specific value.
Declaration
public bool Contains(TObject item)
Parameters
Type | Name | Description |
---|---|---|
TObject | item | The object to locate in the System.Collections.Generic.ICollection<T>. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
CopyTo(TObject[], Int32)
Declaration
public void CopyTo(TObject[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
TObject[] | array | |
System.Int32 | arrayIndex |
GetEnumerator()
Returns an enumerator that iterates through the list.
Declaration
public IEnumerator<TObject> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<TObject> | A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. |
Remarks
Even though the enumerator has no locking semantics, it is safe for multithreaded use.
IndexOf(TObject)
Determines the index of a specific item in the System.Collections.Generic.IList<T>.
Declaration
public int IndexOf(TObject item)
Parameters
Type | Name | Description |
---|---|---|
TObject | item | The object to locate in the System.Collections.Generic.IList<T>. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
Insert(Int32, TObject)
Always thows a System.NotImplementedException since the method is not supported by SimpleList.
Inserts an item to the System.Collections.Generic.IList<T> at the specified index.
Declaration
public void Insert(int index, TObject item)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which |
TObject | item | The object to insert into the System.Collections.Generic.IList<T>. |
InsertFirst(TObject)
Inserts the item at the start of the list.
Declaration
public virtual void InsertFirst(TObject item)
Parameters
Type | Name | Description |
---|---|---|
TObject | item | The item to insert. |
Remarks
This operation is an O(1) operation.
InsertLast(TObject)
Inserts the item at the end of the list.
Declaration
public virtual void InsertLast(TObject item)
Parameters
Type | Name | Description |
---|---|---|
TObject | item | The item to insert. |
Remarks
This operation is an O(1) operation.
Remove(TObject)
Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>.
Declaration
public bool Remove(TObject item)
Parameters
Type | Name | Description |
---|---|---|
TObject | item | The object to remove from the System.Collections.Generic.ICollection<T>. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
RemoveAt(Int32)
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
RemoveFirst()
Removes the first item from the list.
Declaration
public virtual TObject RemoveFirst()
Returns
Type | Description |
---|---|
TObject | The removed item. If no item existed it returns null. |
Remarks
This operation is an O(1) operation.
Note that there is no way to distinguish between the case where the list contained an item with the value null versus the case where there was no item to remove. Both cases will return null.
RemoveLast()
Remove last item from the list
Declaration
public virtual TObject RemoveLast()
Returns
Type | Description |
---|---|
TObject | The removed item. If no item existed it returns null. |
Remarks
This operation is an O(n) operation where n is the numer of items in the list. If possible this method should be avoided since all other operations on this class are O(1) operations.
Note that there is no way to distinguish between the case where the list contained an item with the value null versus the case where there was no item to remove. Both cases will return null.
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An System.Collections.IEnumerator object that can be used to iterate through the collection. |
Remarks
Even though the enumerator has no locking semantics, it is safe for multithreaded use.