Table of Contents

Class LazyMoveGapBuffer<T>

Namespace
AlgorithmsSW.GapBuffer
Assembly
AlgorithmsSW.dll

This gap buffer does not immediately copy elements around when moving the cursor; the copying only happens once we remove or add elements.

public class LazyMoveGapBuffer<T> : IGapBuffer<T>

Type Parameters

T

The type of elements in the gap buffer.

Inheritance
LazyMoveGapBuffer<T>
Implements
Derived
Inherited Members
Extension Methods

Remarks

A gap buffer is a dynamic array that supports efficient insertions and deletions near a "cursor". Elements can be added or removed before or after the cursor. The cursor can be moved to any position in the buffer.

Constructors

LazyMoveGapBuffer(IGapBuffer<T>)

protected LazyMoveGapBuffer(IGapBuffer<T> eagerBuffer)

Parameters

eagerBuffer IGapBuffer<T>

LazyMoveGapBuffer(Func<IGapBuffer<T>>)

public LazyMoveGapBuffer(Func<IGapBuffer<T>> eagerBufferFactory)

Parameters

eagerBufferFactory Func<IGapBuffer<T>>

LazyMoveGapBuffer(int)

protected LazyMoveGapBuffer(int initialCapacity)

Parameters

initialCapacity int

Properties

Count

Gets the number of elements in the gap buffer.

public int Count { get; }

Property Value

int

CursorIndex

Gets the current position of the cursor within the gap buffer.

public int CursorIndex { get; }

Property Value

int

this

public IGapBuffer<T> @this { get; }

Property Value

IGapBuffer<T>

Methods

AddAfter(T)

Adds an element after the cursor.

public void AddAfter(T item)

Parameters

item T

The element to add.

AddBefore(T)

Adds an element before the cursor.

public void AddBefore(T item)

Parameters

item T

The element to add.

MoveCursor(int)

Moves the cursor to the specified index.

public void MoveCursor(int newCursorIndex)

Parameters

newCursorIndex int

The new index for the cursor.

MoveCursorBy(int)

Moves the cursor by the specified amount.

public void MoveCursorBy(int offset)

Parameters

offset int

The 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.