# Xui.Core.Math1D

Assembly: **Xui.Core** · [C# declarations](index.cs) · [Assembly overview](../index.md)

## Types

- [`class Interval<T>`](#api-025cd21e88365e31)
- [`struct Interval<T>.Closed`](#api-b49f09a08eaab150)
- [`struct Interval<T>.ClosedOpen`](#api-a67162be860abe85)

<a id="api-025cd21e88365e31"></a>

## `class Interval<T>`

Provides interval types ([`Xui.Core.Math1D.Interval`1.Closed`](../xui-core-math1d/index.md#api-b49f09a08eaab150) and [`Xui.Core.Math1D.Interval`1.ClosedOpen`](../xui-core-math1d/index.md#api-a67162be860abe85)) over a comparable element type, each modeled as a set with membership, containment, and intersection operations.

```csharp
public partial class Interval<T>
    where T : IComparable<T>, IEquatable<T>
{
    public struct Closed : INonEnumerableSet<T>, IEquatable<Closed>
    {
        public T Start;
        public T End;
        [DebuggerStepThrough]
        public Closed(T start, T end);
        public bool IsEmpty { get; }

        [DebuggerStepThrough]
        public bool Contains(T value);
        [DebuggerStepThrough]
        public bool Contains(Closed other);
        [DebuggerStepThrough]
        public bool Overlaps(Closed other);
        public Closed Intersect(Closed other);
        [DebuggerStepThrough]
        public static implicit operator Closed((T Start, T End) tuple);
        [DebuggerStepThrough]
        public static bool operator ==(Closed left, Closed right);
        [DebuggerStepThrough]
        public static bool operator !=(Closed left, Closed right);
        [DebuggerStepThrough]
        public bool Equals(Closed other);
        public override bool Equals(object? obj);
        public override int GetHashCode();
        [DebuggerStepThrough]
        public override string ToString();
    }
}
public partial class Interval<T>
    where T : IComparable<T>, IEquatable<T>
{
    public struct ClosedOpen : INonEnumerableSet<T>, IEquatable<ClosedOpen>
    {
        public T Start;
        public T End;
        [DebuggerStepThrough]
        public ClosedOpen(T start, T end);
        public bool IsEmpty { get; }

        [DebuggerStepThrough]
        public bool Contains(T value);
        [DebuggerStepThrough]
        public bool Contains(ClosedOpen other);
        [DebuggerStepThrough]
        public bool Overlaps(ClosedOpen other);
        public ClosedOpen Intersect(ClosedOpen other);
        [DebuggerStepThrough]
        public static implicit operator ClosedOpen((T Start, T End) tuple);
        [DebuggerStepThrough]
        public static bool operator ==(ClosedOpen left, ClosedOpen right);
        [DebuggerStepThrough]
        public static bool operator !=(ClosedOpen left, ClosedOpen right);
        [DebuggerStepThrough]
        public bool Equals(ClosedOpen other);
        public override bool Equals(object? obj);
        public override int GetHashCode();
        [DebuggerStepThrough]
        public override string ToString();
    }
}
```


<a id="api-b49f09a08eaab150"></a>

## `struct Interval<T>.Closed`

Represents a closed interval [[`Xui.Core.Math1D.Interval`1.Closed.Start`](../xui-core-math1d/index.md#api-4b349cdcd72b1940), [`Xui.Core.Math1D.Interval`1.Closed.End`](../xui-core-math1d/index.md#api-10551b04cdea4065)] over a comparable type, modeled as a set with membership and containment operations.

The closed convention [Start, End] means both bounds are inclusive. The interval is empty when `Start > End`.

```csharp
public struct Closed : INonEnumerableSet<T>, IEquatable<Closed>
{
    public T Start;
    public T End;
    [DebuggerStepThrough]
    public Closed(T start, T end);
    public bool IsEmpty { get; }

    [DebuggerStepThrough]
    public bool Contains(T value);
    [DebuggerStepThrough]
    public bool Contains(Closed other);
    [DebuggerStepThrough]
    public bool Overlaps(Closed other);
    public Closed Intersect(Closed other);
    [DebuggerStepThrough]
    public static implicit operator Closed((T Start, T End) tuple);
    [DebuggerStepThrough]
    public static bool operator ==(Closed left, Closed right);
    [DebuggerStepThrough]
    public static bool operator !=(Closed left, Closed right);
    [DebuggerStepThrough]
    public bool Equals(Closed other);
    public override bool Equals(object? obj);
    public override int GetHashCode();
    [DebuggerStepThrough]
    public override string ToString();
}
```

<a id="api-857d45e100b5dbad"></a>

### [`Closed.Closed(T start, T end)`](#api-857d45e100b5dbad)


```csharp
[DebuggerStepThrough]
public Closed(T start, T end);
```

Creates a new closed interval [`start`, `end`].

<a id="api-468c77ee16ccca55"></a>

### [`bool Closed.Contains(Closed other)`](#api-468c77ee16ccca55)


```csharp
[DebuggerStepThrough]
public bool Contains(Closed other);
```

Subset test: `other` ⊆ this.

<a id="api-9099395aea622fe0"></a>

### [`bool Closed.Contains(T value)`](#api-9099395aea622fe0)


```csharp
[DebuggerStepThrough]
public bool Contains(T value);
```

Membership test: `value` ∈ [Start, End].

<a id="api-10551b04cdea4065"></a>

### [`T Closed.End`](#api-10551b04cdea4065)


```csharp
public T End;
```

The inclusive upper bound of the interval.

<a id="api-6dc7d4e7e77723aa"></a>

### [`bool Closed.Equals(object? obj)`](#api-6dc7d4e7e77723aa)


```csharp
public override bool Equals(object? obj);
```

Indicates whether this instance and a specified object are equal.

- **`obj`** — The object to compare with the current instance.

**Returns:** `true` if `obj` and this instance are the same type and represent the same value; otherwise, `false`.

<a id="api-59c0e270d62c6bd8"></a>

### [`bool Closed.Equals(Closed other)`](#api-59c0e270d62c6bd8)


```csharp
[DebuggerStepThrough]
public bool Equals(Closed other);
```

Indicates whether the current object is equal to another object of the same type.

- **`other`** — An object to compare with this object.

**Returns:** `true` if the current object is equal to the `other` parameter; otherwise, `false`.

<a id="api-0fc06151e596f175"></a>

### [`int Closed.GetHashCode()`](#api-0fc06151e596f175)


```csharp
public override int GetHashCode();
```

Returns the hash code for this instance.

**Returns:** A 32-bit signed integer that is the hash code for this instance.

<a id="api-e8bc2b4d7401935e"></a>

### [`Closed Closed.Intersect(Closed other)`](#api-e8bc2b4d7401935e)


```csharp
public Closed Intersect(Closed other);
```

Set intersection: this ∩ `other`. Returns ∅ if the intervals do not overlap.

<a id="api-aa3aa03bcd88ec39"></a>

### [`bool Closed.IsEmpty`](#api-aa3aa03bcd88ec39)


```csharp
public bool IsEmpty { get; }
```

Whether this interval represents the empty set (Start &gt; End).

<a id="api-c31ee9bc8aa68355"></a>

### [`bool Closed.Overlaps(Closed other)`](#api-c31ee9bc8aa68355)


```csharp
[DebuggerStepThrough]
public bool Overlaps(Closed other);
```

Whether two intervals share any elements (this ∩ other ≠ ∅).

<a id="api-4b349cdcd72b1940"></a>

### [`T Closed.Start`](#api-4b349cdcd72b1940)


```csharp
public T Start;
```

The inclusive lower bound of the interval.

<a id="api-36f8b94e15537bc5"></a>

### [`string Closed.ToString()`](#api-36f8b94e15537bc5)


```csharp
[DebuggerStepThrough]
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

<a id="api-ce2327ac877284e2"></a>

### [`bool Closed.operator ==(Closed left, Closed right)`](#api-ce2327ac877284e2)


```csharp
[DebuggerStepThrough]
public static bool operator ==(Closed left, Closed right);
```



<a id="api-b4fab630c0f23b98"></a>

### [`Closed.implicit operator Closed((T Start, T End) tuple)`](#api-b4fab630c0f23b98)


```csharp
[DebuggerStepThrough]
public static implicit operator Closed((T Start, T End) tuple);
```

Implicit conversion from a 2-tuple to a closed interval.

<a id="api-9e5a39d11fc16045"></a>

### [`bool Closed.operator !=(Closed left, Closed right)`](#api-9e5a39d11fc16045)


```csharp
[DebuggerStepThrough]
public static bool operator !=(Closed left, Closed right);
```




<a id="api-a67162be860abe85"></a>

## `struct Interval<T>.ClosedOpen`

Represents a half-open interval [[`Xui.Core.Math1D.Interval`1.ClosedOpen.Start`](../xui-core-math1d/index.md#api-5c2bd746c95f1de1), [`Xui.Core.Math1D.Interval`1.ClosedOpen.End`](../xui-core-math1d/index.md#api-cb335c211a84e020)) over a comparable type, modeled as a set with membership and containment operations.

The half-open convention [Start, End) means Start is inclusive and End is exclusive. The interval is empty when `Start >= End`, making [n, n) a natural representation for a cursor position with no selection.

```csharp
public struct ClosedOpen : INonEnumerableSet<T>, IEquatable<ClosedOpen>
{
    public T Start;
    public T End;
    [DebuggerStepThrough]
    public ClosedOpen(T start, T end);
    public bool IsEmpty { get; }

    [DebuggerStepThrough]
    public bool Contains(T value);
    [DebuggerStepThrough]
    public bool Contains(ClosedOpen other);
    [DebuggerStepThrough]
    public bool Overlaps(ClosedOpen other);
    public ClosedOpen Intersect(ClosedOpen other);
    [DebuggerStepThrough]
    public static implicit operator ClosedOpen((T Start, T End) tuple);
    [DebuggerStepThrough]
    public static bool operator ==(ClosedOpen left, ClosedOpen right);
    [DebuggerStepThrough]
    public static bool operator !=(ClosedOpen left, ClosedOpen right);
    [DebuggerStepThrough]
    public bool Equals(ClosedOpen other);
    public override bool Equals(object? obj);
    public override int GetHashCode();
    [DebuggerStepThrough]
    public override string ToString();
}
```

<a id="api-6e8c95efbec7cc76"></a>

### [`ClosedOpen.ClosedOpen(T start, T end)`](#api-6e8c95efbec7cc76)


```csharp
[DebuggerStepThrough]
public ClosedOpen(T start, T end);
```

Creates a new half-open interval [`start`, `end`).

<a id="api-6d44d0badf22e836"></a>

### [`bool ClosedOpen.Contains(ClosedOpen other)`](#api-6d44d0badf22e836)


```csharp
[DebuggerStepThrough]
public bool Contains(ClosedOpen other);
```

Subset test: `other` ⊆ this.

<a id="api-d166fab47c2c18be"></a>

### [`bool ClosedOpen.Contains(T value)`](#api-d166fab47c2c18be)


```csharp
[DebuggerStepThrough]
public bool Contains(T value);
```

Membership test: `value` ∈ [Start, End).

<a id="api-cb335c211a84e020"></a>

### [`T ClosedOpen.End`](#api-cb335c211a84e020)


```csharp
public T End;
```

The exclusive upper bound of the interval.

<a id="api-ef2c8b06e79253ed"></a>

### [`bool ClosedOpen.Equals(object? obj)`](#api-ef2c8b06e79253ed)


```csharp
public override bool Equals(object? obj);
```

Indicates whether this instance and a specified object are equal.

- **`obj`** — The object to compare with the current instance.

**Returns:** `true` if `obj` and this instance are the same type and represent the same value; otherwise, `false`.

<a id="api-ec16d3704992e774"></a>

### [`bool ClosedOpen.Equals(ClosedOpen other)`](#api-ec16d3704992e774)


```csharp
[DebuggerStepThrough]
public bool Equals(ClosedOpen other);
```

Indicates whether the current object is equal to another object of the same type.

- **`other`** — An object to compare with this object.

**Returns:** `true` if the current object is equal to the `other` parameter; otherwise, `false`.

<a id="api-f6636fd184b1dd58"></a>

### [`int ClosedOpen.GetHashCode()`](#api-f6636fd184b1dd58)


```csharp
public override int GetHashCode();
```

Returns the hash code for this instance.

**Returns:** A 32-bit signed integer that is the hash code for this instance.

<a id="api-77c3977f2e2a9582"></a>

### [`ClosedOpen ClosedOpen.Intersect(ClosedOpen other)`](#api-77c3977f2e2a9582)


```csharp
public ClosedOpen Intersect(ClosedOpen other);
```

Set intersection: this ∩ `other`. Returns ∅ if the intervals do not overlap.

<a id="api-dc1a309a9a5ebf8a"></a>

### [`bool ClosedOpen.IsEmpty`](#api-dc1a309a9a5ebf8a)


```csharp
public bool IsEmpty { get; }
```

Whether this interval represents the empty set (Start &gt;= End).

<a id="api-2d7fea8379f43948"></a>

### [`bool ClosedOpen.Overlaps(ClosedOpen other)`](#api-2d7fea8379f43948)


```csharp
[DebuggerStepThrough]
public bool Overlaps(ClosedOpen other);
```

Whether two intervals share any elements (this ∩ other ≠ ∅).

<a id="api-5c2bd746c95f1de1"></a>

### [`T ClosedOpen.Start`](#api-5c2bd746c95f1de1)


```csharp
public T Start;
```

The inclusive lower bound of the interval.

<a id="api-7d6eae583c3d9419"></a>

### [`string ClosedOpen.ToString()`](#api-7d6eae583c3d9419)


```csharp
[DebuggerStepThrough]
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

<a id="api-9ed9e17f6c66a398"></a>

### [`bool ClosedOpen.operator ==(ClosedOpen left, ClosedOpen right)`](#api-9ed9e17f6c66a398)


```csharp
[DebuggerStepThrough]
public static bool operator ==(ClosedOpen left, ClosedOpen right);
```



<a id="api-fe23e9e3339fc868"></a>

### [`ClosedOpen.implicit operator ClosedOpen((T Start, T End) tuple)`](#api-fe23e9e3339fc868)


```csharp
[DebuggerStepThrough]
public static implicit operator ClosedOpen((T Start, T End) tuple);
```

Implicit conversion from a 2-tuple to a half-open interval.

<a id="api-a292ad9dc81d2593"></a>

### [`bool ClosedOpen.operator !=(ClosedOpen left, ClosedOpen right)`](#api-a292ad9dc81d2593)


```csharp
[DebuggerStepThrough]
public static bool operator !=(ClosedOpen left, ClosedOpen right);
```



