-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElement.cs
More file actions
38 lines (29 loc) · 1.32 KB
/
Element.cs
File metadata and controls
38 lines (29 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace ArcOne
{
/// <summary>
/// Represents a fundamental key-value pair stored within the B+ Tree.
/// This structure is designed for fixed-width disk serialization, ensuring
/// predictable offsets during binary I/O operations.
/// </summary>
public struct Element : IComparable<Element>
{
public int Key; // The key of the element
public int Data; // That data that each element contains
/// <summary> Initializes a new empty element with sentinel values. </summary>
public Element() { Key = -1; Data = -1; }
/// <summary> Initializes an element with a specific key and data pair. </summary>
public Element(int key, int data) { Key = key; Data = data; }
/// <summary> Returns a sentinel element representing an empty or null state. </summary>
public static Element GetDefault() => new Element(-1, -1);
/// <summary> Compares elements based solely on their Key property. </summary>
public int CompareTo(Element other)
{
return this.Key.CompareTo(other.Key);
}
/// <summary> Returns a formatted string for debugging: [Key, Data]. </summary>
public override string ToString()
{
return $"[{Key}, {Data}] ";
}
}
}