Struct CellPosition
Represents a position in a text mode grid as a (row, column) coordinate pair.
Uses row-first ordering for linear document order comparison.
Assembly: ScyllaTextMode.dll
Syntax
public readonly struct CellPosition : IEquatable<CellPosition>, IComparable<CellPosition>
Constructors
CellPosition(int, int)
Creates a new cell position.
Declaration
public CellPosition(int row, int column)
Parameters
| Type |
Name |
Description |
| int |
row |
Row index (0-based).
|
| int |
column |
Column index (0-based).
|
Fields
Column
Column index (0-based, left to right).
Declaration
public readonly int Column
Field Value
Invalid
Sentinel value representing an invalid or unset position (-1, -1).
Declaration
public static readonly CellPosition Invalid
Field Value
Row
Row index (0-based, top to bottom).
Declaration
Field Value
Properties
IsValid
Gets whether this position is the Invalid sentinel.
Declaration
public bool IsValid { get; }
Property Value
Methods
CompareTo(CellPosition)
Compares this position to another in document order (row-first, then column).
Declaration
public int CompareTo(CellPosition other)
Parameters
| Type |
Name |
Description |
| CellPosition |
other |
The other position to compare to.
|
Returns
| Type |
Description |
| int |
Negative if this comes before other, zero if equal, positive if this comes after.
|
Equals(CellPosition)
Determines whether this position equals another position.
Declaration
public bool Equals(CellPosition other)
Parameters
| Type |
Name |
Description |
| CellPosition |
other |
The other position.
|
Returns
| Type |
Description |
| bool |
True if row and column are equal.
|
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type |
Name |
Description |
| object |
obj |
|
Returns
Overrides
FromFlatIndex(int, int)
Creates a cell position from a flat row-major index.
Declaration
public static CellPosition FromFlatIndex(int index, int columns)
Parameters
| Type |
Name |
Description |
| int |
index |
Flat array index.
|
| int |
columns |
Number of columns in the grid. Must be greater than zero.
|
Returns
| Type |
Description |
| CellPosition |
The corresponding cell position, or Invalid if columns is not positive.
|
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
ToFlatIndex(int)
Converts this position to a flat array index for a grid with the specified column count.
Declaration
public int ToFlatIndex(int columns)
Parameters
| Type |
Name |
Description |
| int |
columns |
Number of columns in the grid. Must be greater than zero.
|
Returns
| Type |
Description |
| int |
Flat row-major index, or 0 if columns is not positive.
|
ToString()
Declaration
public override string ToString()
Returns
Overrides
Operators
operator ==(CellPosition, CellPosition)
Declaration
public static bool operator ==(CellPosition left, CellPosition right)
Parameters
Returns
operator >(CellPosition, CellPosition)
Greater-than operator (document order).
Declaration
public static bool operator >(CellPosition left, CellPosition right)
Parameters
Returns
operator >=(CellPosition, CellPosition)
Greater-than-or-equal operator (document order).
Declaration
public static bool operator >=(CellPosition left, CellPosition right)
Parameters
Returns
operator !=(CellPosition, CellPosition)
Declaration
public static bool operator !=(CellPosition left, CellPosition right)
Parameters
Returns
operator <(CellPosition, CellPosition)
Less-than operator (document order).
Declaration
public static bool operator <(CellPosition left, CellPosition right)
Parameters
Returns
operator <=(CellPosition, CellPosition)
Less-than-or-equal operator (document order).
Declaration
public static bool operator <=(CellPosition left, CellPosition right)
Parameters
Returns
Implements