Skip to content

Commit

Permalink
Add methods for FsAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
omaus committed Mar 10, 2023
1 parent 28b7f54 commit 65dbd74
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/FsSpreadsheet/FsAddress.fs
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,30 @@ type FsAddress(rowNumber : int, columnNumber : int, fixedRow : bool, fixedColumn
/// <summary>Updates the row- and columnIndex respective to the given indices.</summary>
member self.UpdateIndices(rowIndex,colIndex) =
_columnNumber <- colIndex
_rowNumber <- rowIndex
_rowNumber <- rowIndex

/// <summary>Updates the row- and columnIndex of a given FsAddress respective to the given indices.</summary>
static member updateIndices rowIndex colIndex (address : FsAddress) =
address.UpdateIndices(rowIndex, colIndex)

/// <summary>Returns the row- and the columnIndex of the FsAddress.</summary>
/// <returns>A tuple consisting of the rowIndex (fst) and the columnIndex (snd).</returns>
member self.ToIndices() = _rowNumber,_columnNumber

/// <summary>Returns the row- and the columnIndex of a given FsAddress.</summary>
/// <returns>A tuple consisting of the rowIndex (fst) and the columnIndex (snd).</returns>
static member toIndices (address : FsAddress) =
address.ToIndices()

/// <summary>Compares the FsAddress with a given other one.</summary>
/// <returns>Returns true if both FsAddresses are equal.</returns>
member self.Compare(address : FsAddress) =
self.Address = address.Address &&
self.ColumnNumber = address.ColumnNumber &&
self.RowNumber = address.RowNumber &&
self.FixedColumn = address.FixedColumn &&
self.FixedRow = address.FixedRow

/// <summary>Checks if 2 FsAddresses are equal.</summary>
static member compare (address1 : FsAddress) (address2 : FsAddress) =
address1.Compare address2

0 comments on commit 65dbd74

Please sign in to comment.