> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.kslinkedlist-1.md).

# Class ksLinkedList\<T>

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

A linked list that can be modified while being iterated.

```csharp
public class ksLinkedList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable
```

#### Type Parameters

`T`

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksLinkedList\<T>](/reactor/api-reference/ks.reactor/ks.reactor.kslinkedlist-1.md)

#### Implements

[IList\<T>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1), [ICollection\<T>](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1), [IEnumerable\<T>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IList](https://learn.microsoft.com/dotnet/api/system.collections.ilist), [ICollection](https://learn.microsoft.com/dotnet/api/system.collections.icollection), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Constructors

### ksLinkedList() <a href="#ks_reactor_kslinkedlist_1__ctor" id="ks_reactor_kslinkedlist_1__ctor"></a>

Constructor

```csharp
public ksLinkedList()
```

### ksLinkedList(IEnumerable\<T>) <a href="#ks_reactor_kslinkedlist_1__ctor_system_collections_generic_ienumerable__0" id="ks_reactor_kslinkedlist_1__ctor_system_collections_generic_ienumerable__0"></a>

Copy constructor

```csharp
public ksLinkedList(IEnumerable<T> values)
```

#### Parameters

`values` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)\<T>

Values to initialize the list with.

## Properties

### Count <a href="#ks_reactor_kslinkedlist_1_count" id="ks_reactor_kslinkedlist_1_count"></a>

Number of values in the list.

```csharp
public int Count { get; }
```

#### Property Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Current <a href="#ks_reactor_kslinkedlist_1_current" id="ks_reactor_kslinkedlist_1_current"></a>

The current value being iterated, or default(T) if the list is not being iterated. Throws a MemberAccessException if you try to set it while not iterating the list.

```csharp
public T Current { get; set; }
```

#### Property Value

T

### First <a href="#ks_reactor_kslinkedlist_1_first" id="ks_reactor_kslinkedlist_1_first"></a>

The first value in the list, or default(T) if the list is empty.

```csharp
public T First { get; }
```

#### Property Value

T

### Last <a href="#ks_reactor_kslinkedlist_1_last" id="ks_reactor_kslinkedlist_1_last"></a>

The last value in the list, or default(T) if the list is empty.

```csharp
public T Last { get; }
```

#### Property Value

T

### this\[int] <a href="#ks_reactor_kslinkedlist_1_item_system_int32" id="ks_reactor_kslinkedlist_1_item_system_int32"></a>

Gets/Sets the value at an index.

```csharp
public T this[int index] { get; set; }
```

#### Property Value

T

## Methods

### Add(T) <a href="#ks_reactor_kslinkedlist_1_add__0" id="ks_reactor_kslinkedlist_1_add__0"></a>

Adds a value to the end of the list.

```csharp
public void Add(T value)
```

#### Parameters

`value` T

Value to add.

### Clear() <a href="#ks_reactor_kslinkedlist_1_clear" id="ks_reactor_kslinkedlist_1_clear"></a>

Removes everything from the list.

```csharp
public void Clear()
```

### Contains(T) <a href="#ks_reactor_kslinkedlist_1_contains__0" id="ks_reactor_kslinkedlist_1_contains__0"></a>

Checks if a value is in the list.

```csharp
public bool Contains(T value)
```

#### Parameters

`value` T

Value to check for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the value is in the list.

### CopyTo(T\[], int) <a href="#ks_reactor_kslinkedlist_1_copyto__0___system_int32" id="ks_reactor_kslinkedlist_1_copyto__0___system_int32"></a>

Copies the contents of the list to an array.

```csharp
public void CopyTo(T[] array, int arrayIndex)
```

#### Parameters

`array` T\[]

Array to copy to.

`arrayIndex` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Array index to start copying to.

### GetEnumerator() <a href="#ks_reactor_kslinkedlist_1_getenumerator" id="ks_reactor_kslinkedlist_1_getenumerator"></a>

Gets the enumerator for the list.

```csharp
public IEnumerator<T> GetEnumerator()
```

#### Returns

[IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1)\<T>

Enumerator for the list.

### IndexOf(T) <a href="#ks_reactor_kslinkedlist_1_indexof__0" id="ks_reactor_kslinkedlist_1_indexof__0"></a>

Finds the index of the first occurrence of a value.

```csharp
public int IndexOf(T value)
```

#### Parameters

`value` T

Value to search for.

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

Index of the value, or -1 if the value was not found.

### Insert(int, T) <a href="#ks_reactor_kslinkedlist_1_insert_system_int32__0" id="ks_reactor_kslinkedlist_1_insert_system_int32__0"></a>

Inserts a value at a specified index.

```csharp
public void Insert(int index, T value)
```

#### Parameters

`index` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Index to insert value at.

`value` T

Value to insert.

### InsertNext(T) <a href="#ks_reactor_kslinkedlist_1_insertnext__0" id="ks_reactor_kslinkedlist_1_insertnext__0"></a>

Inserts a value after the current iterator position, or at the end of the list if not iterating.

```csharp
public void InsertNext(T value)
```

#### Parameters

`value` T

Value to insert.

### InsertPrevious(T) <a href="#ks_reactor_kslinkedlist_1_insertprevious__0" id="ks_reactor_kslinkedlist_1_insertprevious__0"></a>

Inserts a value before the current iterator position, or at the start of the list if not iterating.

```csharp
public void InsertPrevious(T value)
```

#### Parameters

`value` T

Value to insert.

### Next() <a href="#ks_reactor_kslinkedlist_1_next" id="ks_reactor_kslinkedlist_1_next"></a>

Advances [Current](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksLinkedList_601_Current) to the next index. If not iterating, begins iterating and [Current](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksLinkedList_601_Current) will point to the first element. If the end of the list is reached, returns false and stops iterating.

```csharp
public bool Next()
```

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if [Current](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksLinkedList_601_Current) advanced to the next element. False if the end of the list was reached.

### Remove(T) <a href="#ks_reactor_kslinkedlist_1_remove__0" id="ks_reactor_kslinkedlist_1_remove__0"></a>

Removes the first occurrence of a value from the list. If the list is currently iterating and the iterated value matches the given value, will remove the iterated node instead of the first occurrence.

```csharp
public bool Remove(T value)
```

#### Parameters

`value` T

Value to remove.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the value was found and removed.

### RemoveAt(int) <a href="#ks_reactor_kslinkedlist_1_removeat_system_int32" id="ks_reactor_kslinkedlist_1_removeat_system_int32"></a>

Removes the value at a specified index.

```csharp
public void RemoveAt(int index)
```

#### Parameters

`index` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Index of value to remove.

### RemoveCurrent() <a href="#ks_reactor_kslinkedlist_1_removecurrent" id="ks_reactor_kslinkedlist_1_removecurrent"></a>

Removes the value at the current iterator position. Does nothing if not iterating, or if the current iterator position was already removed.

```csharp
public bool RemoveCurrent()
```

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if a value was removed.

### ResetCurrent() <a href="#ks_reactor_kslinkedlist_1_resetcurrent" id="ks_reactor_kslinkedlist_1_resetcurrent"></a>

Sets the current iterator pointer to null to stop iterating with [Next](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksLinkedList_601_Next). This will not stop [GetEnumerator](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksLinkedList_601_GetEnumerator) iteration.

```csharp
public void ResetCurrent()
```
