Table of Contents

Interface IGapBuffer<T>

Namespace
AlgorithmsSW.GapBuffer
Assembly
AlgorithmsSW.dll

Represents a gap buffer, a data structure that allows efficient insertions and deletions at arbitrary positions.

public interface IGapBuffer<T>

Type Parameters

T

The type of elements in the gap buffer.

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.

Properties

Count

Gets the number of elements in the gap buffer.

int Count { get; }

Property Value

int

CursorIndex

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

int CursorIndex { get; }

Property Value

int

this

IGapBuffer<T> @this { get; }

Property Value

IGapBuffer<T>

Methods

AddAfter(T)

Adds an element after the cursor.

void AddAfter(T item)

Parameters

item T

The element to add.

AddBefore(T)

Adds an element before the cursor.

void AddBefore(T item)

Parameters

item T

The element to add.

MoveCursor(int)

Moves the cursor to the specified index.

void MoveCursor(int newCursorIndex)

Parameters

newCursorIndex int

The new index for the cursor.

MoveCursorBy(int)

Moves the cursor by the specified amount.

void MoveCursorBy(int offset)

Parameters

offset int

The amount to move the cursor by.

Exceptions

InvalidOperationException

moving the cursor past the begging or end.

MoveCursorLeft()

void MoveCursorLeft()

MoveCursorRight()

void MoveCursorRight()

RemoveAfter()

Removes an element after the cursor.

T RemoveAfter()

Returns

T

The removed element.

RemoveBefore()

Removes an element before the cursor.

T RemoveBefore()

Returns

T

The removed element.

ValidateCursor(int)

void ValidateCursor(int cursor)

Parameters

cursor int