<p dir="ltr">Hello! <br>
Thanks for your comments, they are valuable to me. I indeed intended to make Range immutable, if you noticed, in potential methods I listed extendTo and shrinkTo, which is kind of modified with-ers. But, it's indeed better to convert range to class and expose some methods to create bounded and unbounded ones.</p>
<p dir="ltr">The range pattern would be great to have, but unless there is some way to ger range object, there will not me a way to create range arithmetics. It would be better, in my opinion, to create member pattern inside Range class that can match it's type params. This may eliminate need for new syntax for range litterals and make feature more versatile.</p>
<p dir="ltr">Regarding the array return types, I specifically mentioned that this is the first thing up to change. Your point is completely valid, I will look into this issue as soon as possible.</p>
<p dir="ltr"> I don't really understand the point about coupling different parts with an interface (future class I guess). Do you say that it is not desirable to have specialized versions of range such as timespan, and would prefer just one generic Range?</p>
<p dir="ltr">I appreciate all feedback you give. I will address your comments as soon as possible. I am new to API design, so I guess people won't go to hard on me. I hope that, iteratively, I could workout the API that would be a good match for JDK quality level.</p>
<p dir="ltr">Best regards</p>
<br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Sep 22, 2024, 23:17 Remi Forax <<a href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:#000000"><div>Hello,<br></div><div>if we introduce a Range object, it will have to be an immutable class because otherwise any API that takes an interface Range as parameter will have to copy it into an immutable subclass first;<br></div><div><br></div><div>In term of design, coupling different parts of the JDK with an interface is not appealing to me, especially given that a Range is a very small object.<br></div><div><br></div><div>We (the amber EG) have talked about adding a way to do pattern matching using a Range with a special syntax like 1 .. 3, if we introduce such syntax, the runtime representation will be an immutable class an not an interface (think java.lang.String).<br></div><div><br></div><div>Your API is unsafe, you can not have a method that creates a Range<T>[] in a safe way, the combination of erasure + array covariant is nasty (at least until we have a way to create a read-only arrays).</div><div><br></div><div>regards,<br></div><div>Rémi<br></div><div><br></div><hr id="m_1110753311284118601zwchr"><div><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>From: </b>"Olexandr Rotan" <<a href="mailto:rotanolexandr842@gmail.com" target="_blank" rel="noreferrer">rotanolexandr842@gmail.com</a>><br><b>To: </b>"core-libs-dev" <<a href="mailto:core-libs-dev@openjdk.org" target="_blank" rel="noreferrer">core-libs-dev@openjdk.org</a>><br><b>Sent: </b>Sunday, September 22, 2024 9:01:47 PM<br><b>Subject: </b>Range API<br></blockquote></div><div><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr">Hello everyone! I am writing here today to invite everyone to participate in the discussion regarding the Range APi proposal I have made into JDK. Here is the pull request link: <a href="https://github.com/openjdk/jdk/pull/21122" target="_blank" rel="noreferrer">https://github.com/openjdk/jdk/pull/21122</a>, and PR text:<div><br><p dir="auto" style="box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;margin-top:0px"><span style="background-color:rgb(255,255,255)"><font color="#000000">This pull request describes the methods of the <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Range<T></code> interface. The <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Range<T></code> interface represents a bounded or unbounded range. (From now on, range, span and interval are used interchangeably, but docs only use "range")</font></span></p><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Goals:</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Main goal. Standardization of the Range/Interval API:</strong> The primary objective of this effort is to provide a standardized interface for working with ranges or spans of time (or any ordered types). Many existing libraries offer their own custom implementations of ranges, and they differ in significant ways, making it harder to use and combine across different codebases. Standardization will ensure consistency, interoperability, and a more predictable interface across various contexts.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Versatile range operations:</strong> provide a comprehensive API for manipulating and querying ranges, especially those representing time periods or numerical intervals. The API simplifies common tasks like checking containment, overlaps, or adjacency between ranges.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Support for unbounded ranges:</strong> Unlike many existing libraries, which assume intervals are always bounded, this API aims to fully support unbounded intervals. Users will be able to define ranges with open starts or ends, making it suitable for temporal data that spans indefinitely in one direction, such as future projections or historical data with unknown starting points.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Performance efficiency:</strong> The API aims to provide optimized for performance implementation, that takes advantage of all possible simplifications and short-circuits.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Consistency with existing libraries:</strong> To aid adoption, the API should be familiar to developers who have used popular libraries like NodaTime, Joda-Time, Three-Ten Extra, and Boost Date_Time, but with enhancements for unbounded intervals, negative ranges (?), and optional return types instead of null values.</font></span></p></li></ul><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Non-Goals:</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Handling complex data structures beyond smple ranges:</strong> This API is not intended to manage or represent complex data structures beyond ranges. For example, ranges that involve intricate internal states, like non-contiguous ranges (?) or ranges with multiple gaps, are out of scope.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Overly simplifying range types:</strong> While ease of use is a goal, its is not an aim to remove support for advanced cases like unbounded or negative ranges, even if this results in slightly more complex implementations. The API should not be skewed towards being purely a simple data structure for bounded ranges.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Application-specific logic:</strong> The API is meant to be domain-agnostic and general-purpose. It is not intended to allow to embed application-specific logic, such as calendar-based date manipulations or domain-specific business rules for interval comparison.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Replacing existing libraries:</strong> The goal is not to replace established libraries like Joda-Time or ThreeTen-Extra, but rather to augment these ideas with support for unbounded ranges and additional arithmetic operations. Although, it is a goal to provide interface that could exisiting libraries could easily retrofit into.</font></span></p></li></ul><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Motivation</font></span></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">The primary motivation behind standardizing the <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Range</code> API is the <strong style="box-sizing:border-box">lack of an established, universal interface</strong> for handling ranges or spans across various domains. Developers are often forced to work with different, incompatible range implementations across libraries or to re-implement common functionality themselves. This leads to redundant code, increased dependencies, and greater chances for errors.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">In many software systems—whether in scheduling, auditing, access control, or financial services—ranges are used to represent periods of time, numerical intervals, or validity spans. Without a standardized API, developers must contend with diverse implementations that often differ in naming conventions, behavior, and supported features. These variations create unnecessary complexity, as developers must:</font></span></p><ol dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Introduce additional dependencies</strong>: Many libraries provide similar functionality for ranges, but since they are not interchangeable, developers must often add extra dependencies to cover edge cases or specific use cases that are not available in a single library. This bloats the codebase and creates maintenance overhead.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Re-implement common logic</strong>: In cases where no single library meets the required needs, developers are forced to write their own range-handling logic. This reinvention of basic operations such as intersection, union, or containment leads to redundancy, increased likelihood of bugs, and inconsistency in how ranges are handled across different parts of the code.</font></span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Fragmentation across domains</strong>: Different libraries often define their own range concepts (e.g., for date-times, numbers, or general comparisons), which are rarely compatible with one another. This lack of compatibility makes integration between systems difficult, requiring custom adapters or conversions.</font></span></p></li></ol><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">By defining a standard <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Range</code> API, the goal is to:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Reduce the dependency footprint:</strong> A common, well-designed API for ranges would eliminate the need to import multiple libraries just to handle different types of ranges, reducing dependencies in projects and enhancing maintainability.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Simplify code and increase reusability:</strong> With a standardized interface, developers can write range-related code once and reuse it across projects and libraries, confident that the same semantics and operations will apply consistently.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Minimize developer errors:</strong> By providing a predictable and well-documented interface, the likelihood of misunderstandings or incorrect use of range operations will decrease. Developers can trust that operations like intersections, unions, and comparisons will behave consistently, regardless of the context.</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">In essence, the lack of standardization in range operations creates unnecessary complexity, fragmentation, and redundant effort. A standardized <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Range</code> API would provide clarity, reduce the need for additional dependencies, and enable more efficient, reusable, and error-free code across different projects and domains.</font></span></p><h1 dir="auto" style="box-sizing:border-box;margin-right:0px;margin-left:0px;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Key API points</font></span></h1><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Support of unbounded intervals</font></span></h2><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">API supports both one- and two-sided. Provided sample (draft) implementation for<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px"> ChronoDateTime</code> has 4 separate implementation for each type of ranges.</font></span></p><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Alternatives</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Many Libraries, like Luxon, C++ boost, NodaTime and many others, arguably the most, fo not explicitly support unbounded intervals. This reduces complexity of implementation, but takes away many possible optimization for edge-cases. Alternative they propose is to use Instant.MIN and Instant.MAX or similar to create unbounded-like intervals.</font></span></li></ul><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Support for negative intervals,</font></span></h2><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">API supports both positive and negative and positive ranges. This is questionable and discussion is encouraged.</font></span></p><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Advantages</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Allows more flexible usage of API, which would be helpful for use cases like diagrams visualization.</font></span></li></ul><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Disadvantages</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Dramatically increases amount of boilerplate code inside the implementations.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">Makes behaviour of potential methods like <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">boolean endsBefore(T t) </code>unintuitive. Does this mean that end() is before that provided parameter, or latter of bounds (i.e. <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">start()</code> for negative range and <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">end()</code> for positive).</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">Limited usability scope. Most use cases would not benefit from possibility of negative ranges creation, but would have to suffer performance decrease.</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">In general, either there should be support for negative ranges, or ranges might be end-exclusve, but not two at the same time, as having them both together dramatically increases complexity.</font></span></p><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000"><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px">Range</code> is not <code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px">Serializable</code></font></span></h2><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">Currently ranges are not<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px"> Serializable</code>. This is due to difficulties regarding using non-serializable interfaces, like <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">ChronoDateTIme </code> in sample implementation.</font></span></p><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Alternatives</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Restrict range type variable to implement <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Serializable</code>. I see this option as undesiarable bacause of how much it narrows use of interface.</font></span></li></ul><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Current interface methods list is minimal</font></span></h2><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">For now, API proposed contains minimal amount of methods that are used in range arithmetics. List of methods is supposed to change as discussion moves on.</font></span></p><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Generic Range class vs Rnage interface + specific inmplementations</font></span></h2><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">Currently, approach is to define interface and list of implementations.</font></span></p><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Advantages</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Ability to introduce specialized for type of range methods. For example, <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Timespan</code> could have <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Duration toDuration()</code> method, potential <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">IntegerRange</code> could have something like <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">LongRange toLongRange()</code> dur to limitations of comparability between classes. This would be impossible with structural class Range without declaring additional static utility methods.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">Enhanced validation of annotaion targets as classes, unlike generics, arent erased.</font></span></li></ul><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Disadvantages</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Increased amount of classes to maintain.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">Additional considerations would be required before extending Range interface in case if hierarchy non-sealed to ensure backward compatibility.</font></span></li></ul><h1 dir="auto" style="box-sizing:border-box;margin-right:0px;margin-left:0px;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">API Description</font></span></h1><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">NB: Since date ranges is supposed to be one of the most popular if not the most popular use case for range, date-time libraries were main reference for interface design.</font></span></h3><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Section: Bounds</font></span></h2><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">General notes</font></span></h3><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">In <strong style="box-sizing:border-box">Boost Date_Time</strong> (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">time_period.begin()</code>), the start and end are always defined, meaning there is no concept of unbounded intervals. Similarly, some libraries like <strong style="box-sizing:border-box">Chrono</strong> in Rust assume bounded intervals by default. In fact, only a few libraries expose trully unbound ranges. Although, while complexity of implementation is increased by this corner cases, thier performance also vastly increased by cutting amount of operations in each method at least in half (For two-way unbound interval, almost all operations return constnat value).</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">T start()</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description:</strong><br style="box-sizing:border-box">Returns the start of the range. If the range is unbounded at the start, this method throws an <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">UnsupportedOperationException</code>. This can be preemptively checked using <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBoundedAtStart()</code>.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Alternatives:</font></strong></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Method could return <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Optional<T></code> instead of throwing an exception. I see this two approaches roughly identical in terms of pros/cons score, so suggestions are much appreciated.</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">T end()</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns the end of the range. If the range is unbounded at the end, this method throws an <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">UnsupportedOperationException</code>. Use <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBoundedAtEnd()</code> to check if the range is bounded.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Alternatives:</font></strong></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Simallarly to start(), method could return <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Optional<T></code> instead of throwing an exception. I see this two approaches roughly identical in terms of pros/cons score, so suggestions are much appreciated.</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean isBoundedAtStart()</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">true</code> if the range is bounded at the start. If unbounded, it returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">false</code>, meaning calling <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">start()</code> will throw an <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">UnsupportedOperationException</code>.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Alternatives</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Joda-Time</strong>, <strong style="box-sizing:border-box">NodaTime</strong>, <strong style="box-sizing:border-box">Luxon</strong>, and <strong style="box-sizing:border-box">Moment.js</strong> do not explicitly support unbounded intervals by default but can use <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">null</code> or special values to represent unbounded starts.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Boost Date_Time</strong> and <strong style="box-sizing:border-box">Chrono</strong> don’t support unbounded ranges directly, so this method is unnecessary.</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean isBoundedAtEnd()</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">true</code> if the range is bounded at the end. A false value means the range is unbounded at the end, and calling <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">end()</code> will throw an <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">UnsupportedOperationException</code>.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Alternatives</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Similar to <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBoundedAtStart()</code>, most libraries don’t have built-in unbounded intervals, but the concept can be simulated using <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">null</code>, minimal/maximal possible value etc. Pros and cons were described in API notes.</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Section: boolean operations</font></span></h2><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean contains(T instant)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">true</code> if the given <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">instant</code> falls within the start and end bounds of the range, otherwise returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">false</code>.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Similar Methods in other libraries</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">NodaTime (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.Contains</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Joda-Time (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.contains</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Luxon (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.contains</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Boost Date_Time (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">time_period.contains()</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">And many others...</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Differences with existing APIs</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Moment.js</strong> doesn’t provide a direct <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">contains</code> method but the <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">moment-range</code> plugin adds this functionality with <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">range.contains()</code>.</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Note</strong>: this method is present in most interval implementations. Terefore, I concider as basic and unremovable from the API.</font></span></p><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean overlaps(Range<? extends T> other)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Checks if the current range overlaps with another range. Returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">true</code> if the two ranges overlap, otherwise returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">false</code>.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Similar Methods in other libraries</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">NodaTime (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.Overlaps</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Joda-Time (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.overlaps</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Luxon (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.overlaps</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Boost Date_Time (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">time_period.intersects()</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">And many others...</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Differences with existing APIs</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Moment.js</strong>: The <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">moment-range</code> plugin provides a similar <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">overlaps()</code> method to check overlap.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Chrono</strong> relies on custom interval intersection logic.</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Note</strong>: this method is present in most interval implementations. Terefore, I concider as basic and unremovable from the API.</font></span></p><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">General notes on next two methods</font></span></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">Most of the libraries propose API like <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore(T point)</code> or do not provide methods like this at all. Since current implementation throws an exception if interval is not bounded, trivial check for <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore</code> could become 4-6 lines long. The question basically comes down to whether the Range class should be more data-structure-like or object-like. I would argue that at least <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore(T moment)</code> is required, especially since ranges can be negative currently. Existence of boolean isBefore(Range<? extends T> other)<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">and similar</code>isAfter` is up to discussion.</font></span></p><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean isBefore(Range<? extends T> other)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">true</code> if the current range is strictly before another range (i.e., ends before the other range starts).</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Differences with other libraries</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">NodaTime</strong>: You’d manually compare <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">End</code> of one interval with the <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Start</code> of another.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Joda-Time</strong>: Manual comparison with <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.getEnd()</code> and <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.getStart()</code>.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Boost Date_Time</strong> and <strong style="box-sizing:border-box">Chrono</strong> would use custom logic to compare <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">time_period</code> or ranges of time, since they don’t have a direct equivalent of <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore()</code>.</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Alternatives</font></strong></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Most of the libraries propose API like <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore(T point)</code> or do not provide methods like this at all. Since current implementation throws an exception if interval is not bounded, trivial check for <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore</code> could become 4-6 lines long. The question basically comes down to whether the Range class should be more data-structure-like or object-like. I would argue that at least <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore(T moment)</code> is required, especially since ranges can be negative currently</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean isAfter(Range<? extends T> other)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">true</code> if the current range is strictly after another range (i.e., starts after the other range ends).</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Similar Methods</strong>:</font></span><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;margin-bottom:0px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Similar to <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore()</code>, manual comparisons are used in <strong style="box-sizing:border-box">NodaTime</strong>, <strong style="box-sizing:border-box">Joda-Time</strong>, and <strong style="box-sizing:border-box">Luxon</strong> an others.</font></span></li></ul></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean isBefore(T point)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description:</strong><br style="box-sizing:border-box">Determines if the span ends before the given point. This is useful when you need to check whether a time span occurs entirely before a specific point.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Alternatives</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Method could be removed from APi at all, if Range is desired to be skewed towards being data structure.</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean isAfter(T point)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description:</strong><br style="box-sizing:border-box">Determines if the span starts after the given point. This is useful when you need to check whether a time span occurs entirely after a specific point.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Alternatives</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Similarly to <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">boolean isBefore(T point)</code>, method could be removed from APi at all, if Range is desired to be skewed towards being data structure.</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean isNegative()</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">true</code> if the start of the range is after the end, indicating a "negative" range.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Alternatives:</font></strong></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">if concidered too niche, negatie timespans could be removed from model.</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Note:</strong> this one is most questionable for me. Do we really need negative ranges? This is most entirely required in numeric ranges and diagrams, while introdcues huge complexity overhead for majority that doesnt need this feature. Negativity might be confusing for users. Would love to hear thoughs on this matter</font></span></p><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Section: Range arithmetics</font></span></h2><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">Optional<Range<T>> intersection(Range<? extends T> other)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns the intersection of the current range with another range. If the ranges do not overlap, the result is an empty <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Optional</code>. If they overlap, the intersection is returned.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Similar Methods</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">NodaTime (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.Intersection()</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Moment.js (via <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">moment-range</code>, <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">range.intersect()</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Joda-Time (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.overlap()</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">And many others...</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Differences with existing APIs</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Boost Date_Time</strong> returns an empty <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">time_period</code> if no overlap exists, instead of an <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Optional</code>. Some libraries return <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">null</code> (e.g., <strong style="box-sizing:border-box">NodaTime</strong>).</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">Other libraries return null if intervals arent overlapping. This is undesrable, so optional returned instead.</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Note</strong>: this method is present in most interval implementations. Terefore, I concider as basic and unremovable from the API.</font></span></p><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">Range<T>[] union(Range<? extends T> other)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns the union of two ranges. If the ranges overlap, the result is a single combined range. If they do not overlap, the result is an array of two separate ranges.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Differences with existing APIs</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">NodaTime</strong> and <strong style="box-sizing:border-box">Joda-Time</strong> support similar logic using custom union handling.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Boost Date_Time</strong> has no built-in <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">union()</code> function but you can write custom logic to combine or separate intervals.</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Note</strong>: Behaviour of this method is up to change. Currently, it returns array for maximal performance, but it can (and most likely should) be wrapped in some monadic class. As an alternative, there may be support for non-continuous ranges (ones with gaps inside them), then this method should return thise kind of range.</font></span></p><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">Optional<Range<T>> gap(Range<? extends T> other)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns the gap between two ranges, if they do not overlap. If they overlap, the result is an empty <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Optional</code>.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Differences with existing APIs</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">NodaTime</strong> and <strong style="box-sizing:border-box">Joda-Time</strong> support custom logic to calculate the gap using <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isBefore()</code>, <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">isAfter()</code>, and manual calculations of the gap.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">Other libraries return null if intervals are overlapping. This is undesrable, so optional returned instead.</font></span></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h2 dir="auto" style="box-sizing:border-box;line-height:1.25;padding-bottom:0.3em;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Section: potential methods</font></span></h2><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean isEmpty()</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description:</strong><br style="box-sizing:border-box">Determines if the range is "empty,"</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">Empty range is its own, separate type of range (basically opposite of unbounded range). There are many questions regrading this type of range. Is it bounded at start or end? If so, what should <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">start()</code> or <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">end()</code> return. Them throwing an exception would violate current contract between <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">IsBoundedAtX()</code> and 'x()` methods.</font></span></p><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Advantages</font></strong></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Returning empty range instead of Optional might be more user-friendly</font></span></li></ul><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Disadvantages</font></strong></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">One more concept in the API model</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000">Corner case in <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">IsBoundedAtX()</code> and 'x()` contract.</font></span></li></ul><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><span style="background-color:rgb(255,255,255)"><font color="#000000">Potential Methods for API Enhancement</font></span></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000">In this section, we explore methods that could be added to the API, comparing them with similar functionality in popular time-related libraries. These methods enhance the versatility and clarity of the <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Range<T></code> implementation, especially in the context of temporal, numeric, and other domain-specific ranges. Some of these methods are inspired by well-established libraries, while others are novel suggestions.</font></span></p><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean encloses(Range<? extends T> other)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Checks whether the current range completely encloses another range, i.e., the other range starts after or at the start of the current range and ends before or at the end of the current range.</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Similar Methods in Other Libraries</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;margin-bottom:0px"><li style="box-sizing:border-box"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">NodaTime (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.ContainedBy</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Joda-Time (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.contains</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Luxon (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.contains</code>)</font></strong></li><li style="box-sizing:border-box;margin-top:0.25em"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">Boost Date_Time (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">time_period.contains()</code>)</font></strong></li></ul></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Differences with Existing APIs</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;margin-bottom:0px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Some libraries handle <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">encloses()</code> and <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">contains()</code> in the same method. For clarity, this API can separate the two, where <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">contains()</code> is used for checking individual points and <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">encloses()</code> is for range-level comparison.</font></span></li></ul></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">boolean abuts(Range<? extends T> other)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">true</code> if the current range abuts (i.e., touches but does not overlap) with another range. This method is useful when determining whether two ranges are adjacent but do not overlap.</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Similar Methods in Other Libraries</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;margin-bottom:0px"><li style="box-sizing:border-box"><strong style="box-sizing:border-box;background-color:rgb(255,255,255)"><font color="#000000">NodaTime (<code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">Interval.Abuts</code>)</font></strong></li></ul></li><li style="box-sizing:border-box;margin-top:0.25em"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Alternatives</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;margin-bottom:0px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000">Instead of this method, users could manually compare the <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">end</code> of one range and the <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">start</code> of another, but including <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">abuts()</code> in the API simplifies the logic and reduces error-prone comparisons.</font></span></li></ul></li></ul><hr style="box-sizing:content-box;height:0.25em;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;border:0px;padding:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><h3 dir="auto" style="box-sizing:border-box;font-size:1.25em;line-height:1.25;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji""><code style="box-sizing:border-box;font-size:inherit;padding:0px 0.2em;margin:0px;border-radius:6px;background-color:rgb(255,255,255)"><font color="#000000">Range<T> extendTo(T point)</font></code></h3><p dir="auto" style="box-sizing:border-box;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Description</strong>:<br style="box-sizing:border-box">Returns a new range that extends the current range to include the given point. If the point is already within the range, it returns the current range. Otherwise, it extends either the start or end, depending on the point's position relative to the range.</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><li style="box-sizing:border-box"><p dir="auto" style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Similar Methods in Other Libraries</strong>:</font></span></p><ul dir="auto" style="box-sizing:border-box;padding:0px;margin-top:0px;margin-bottom:0px"><li style="box-sizing:border-box"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">NodaTime</strong> and <strong style="box-sizing:border-box">Joda-Time</strong> do not have explicit methods for this, but users can manipulate intervals manually.</font></span></li><li style="box-sizing:border-box;margin-top:0.25em"><span style="background-color:rgb(255,255,255)"><font color="#000000"><strong style="box-sizing:border-box">Moment.js</strong>: The <code style="box-sizing:border-box;font-size:11.9px;padding:0.2em 0.4em;margin:0px;border-radius:6px">moment-ran</code></font></span></li></ul></li></ul></div></div></blockquote></div></div></div></blockquote></div>