elect
08/01/2022, 7:57 AMi-2..i+2 in wd.indices
ephemient
08/01/2022, 1:20 PMthis.start <= other.endInclusive && this.endInclusive >= other.start
this.start >= other.start && this.endInclusive <= other.endInclusive
plus additional considerations around what the result should be with empty rangeselect
08/01/2022, 1:23 PMRuckus
08/01/2022, 2:48 PMI - 2 in wd.indices && I + 2 in wd.indices
elect
08/01/2022, 2:49 PMlhwdev
08/08/2022, 7:41 AMin
is implemented in Kotlin, it seems to imply that some element is contained in some *set*(collection), not subset. In java, there is containsAll
, not contains
.Klitos Kyriacou
08/08/2022, 8:03 AMwd.indices.toSet().containsAll((i-2..i+2).toSet())
That's only because toSet() creates a LinkedHashSet. Perhaps it could be optimized to create a specialized Set that just keeps the range as its only property and whose contains
method just forwards to the range, and defines a suitably specialized containsAll
. Then the above code would have good performance.
Or perhaps just a new containsAll
method on ranges.lhwdev
08/08/2022, 8:05 AMcontains
(which corresponds to in
) does not work for set-to-set. (like Set.contains(Set)
)