Class GapBufferWithArray<T>
- Namespace
- AlgorithmsSW.GapBuffer
- Assembly
- AlgorithmsSW.dll
Implements a gap buffer with an underlying array.
public sealed class GapBufferWithArray<T> : IGapBuffer<T>, IRandomAccessList<T>, IReadonlyRandomAccessList<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
- Inheritance
-
GapBufferWithArray<T>
- Implements
-
IGapBuffer<T>IEnumerable<T>
- Inherited Members
- Extension Methods
Constructors
GapBufferWithArray(int)
public GapBufferWithArray(int initialCapacity)
Parameters
initialCapacity
int
Properties
Capacity
public int Capacity { get; }
Property Value
Count
Gets the number of elements in the gap buffer.
public int Count { get; }
Property Value
CursorIndex
Gets the current position of the cursor within the gap buffer.
public int CursorIndex { get; }
Property Value
IsEmpty
Gets a value indicating whether the list is empty.
public bool IsEmpty { get; }
Property Value
this[int]
Gets or sets the element at the specified index.
public T this[int index] { get; set; }
Parameters
index
intThe index of the element to get or set.
Property Value
- T
The element at the specified index.
Methods
AddAfter(T)
Adds an element after the cursor.
public void AddAfter(T item)
Parameters
item
TThe element to add.
AddBefore(T)
Adds an element before the cursor.
public void AddBefore(T item)
Parameters
item
TThe element to add.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator that can be used to iterate through the collection.
MoveCursorBy(int)
Moves the cursor by the specified amount.
public void MoveCursorBy(int offset)
Parameters
offset
intThe amount to move the cursor by.
Exceptions
- InvalidOperationException
moving the cursor past the begging or end.
RemoveAfter()
Removes an element after the cursor.
public T RemoveAfter()
Returns
- T
The removed element.
RemoveBefore()
Removes an element before the cursor.
public T RemoveBefore()
Returns
- T
The removed element.