ComparisonIdentity Module
Common notions of value ordering implementing the IComparer interface, for constructing sorted data structures and performing sorting operations.
Functions and values
Function or value |
Description
|
|
Get an implementation of comparison semantics using the given function.
ExampleCreate and use a comparer using the given function:
val comparer: System.Collections.Generic.IComparer<int>
module ComparisonIdentity
from Microsoft.FSharp.Collections
val FromFunction: comparer: ('T -> 'T -> int) -> System.Collections.Generic.IComparer<'T>
val i1: int
val i2: int
val compare: e1: 'T -> e2: 'T -> int (requires comparison)
System.Collections.Generic.IComparer.Compare(x: int, y: int) : int
Evaluates to 0 because 7 and 2 compare as equal using to the provided function.
|
Full Usage:
NonStructural
Returns: IComparer<^T>
An object implementing IComparer using NonStructuralComparison.Compare.
Modifiers: inline Type parameters: ^T |
Get an implementation of comparison semantics using non-structural comparison.
ExampleCreate and use a comparer using structural comparison:
val comparer: System.Collections.Generic.IComparer<System.DateTime>
module ComparisonIdentity
from Microsoft.FSharp.Collections
val NonStructural<'T (requires member (<) and member (>))> : System.Collections.Generic.IComparer<'T> (requires member (<) and member (>))
namespace System
Multiple items
[<Struct>] type DateTime = new: date: DateOnly * time: TimeOnly -> unit + 16 overloads member Add: value: TimeSpan -> DateTime member AddDays: value: float -> DateTime member AddHours: value: float -> DateTime member AddMicroseconds: value: float -> DateTime member AddMilliseconds: value: float -> DateTime member AddMinutes: value: float -> DateTime member AddMonths: months: int -> DateTime member AddSeconds: value: float -> DateTime member AddTicks: value: int64 -> DateTime ... <summary>Represents an instant in time, typically expressed as a date and time of day.</summary> -------------------- System.DateTime () (+0 other overloads) System.DateTime(ticks: int64) : System.DateTime (+0 other overloads) System.DateTime(date: System.DateOnly, time: System.TimeOnly) : System.DateTime (+0 other overloads) System.DateTime(ticks: int64, kind: System.DateTimeKind) : System.DateTime (+0 other overloads) System.DateTime(date: System.DateOnly, time: System.TimeOnly, kind: System.DateTimeKind) : System.DateTime (+0 other overloads) System.DateTime(year: int, month: int, day: int) : System.DateTime (+0 other overloads) System.DateTime(year: int, month: int, day: int, calendar: System.Globalization.Calendar) : System.DateTime (+0 other overloads) System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int) : System.DateTime (+0 other overloads) System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, kind: System.DateTimeKind) : System.DateTime (+0 other overloads) System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, calendar: System.Globalization.Calendar) : System.DateTime (+0 other overloads) System.Collections.Generic.IComparer.Compare(x: System.DateTime, y: System.DateTime) : int
property System.DateTime.Now: System.DateTime with get
<summary>Gets a <see cref="T:System.DateTime" /> object that is set to the current date and time on this computer, expressed as the local time.</summary> <returns>An object whose value is the current local date and time.</returns> property System.DateTime.Today: System.DateTime with get
Evaluates to <summary>Gets the current date.</summary> <returns>An object that is set to today's date, with the time component set to 00:00:00.</returns> 1 .
|
Full Usage:
Structural
Returns: IComparer<'T>
An object implementing IComparer using Operators.compare.
Modifiers: inline Type parameters: 'T |
Get an implementation of comparison semantics using structural comparison.
ExampleCreate and use a comparer using structural comparison:
val compareTuples: System.Collections.Generic.IComparer<int * int>
module ComparisonIdentity
from Microsoft.FSharp.Collections
val Structural<'T (requires comparison)> : System.Collections.Generic.IComparer<'T> (requires comparison)
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int System.Collections.Generic.IComparer.Compare(x: int * int, y: int * int) : int
Evaluates to -1 .
|