interval_set 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/interval_set/version.rb +1 -1
- data/lib/interval_set.rb +26 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a613b54e3bb21ed54db8f0a61a6649d872a9be5
|
4
|
+
data.tar.gz: e0b2f5995b8a3de7b12bae21e24ed0012ef313bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84359b40ffc3b226a319b729375826dffa0029ec92034bbba21754e681575769c0d58a67f31f0f25243dbe8aeaac7a1f38be41a042341ed96425ba5891c82fc6
|
7
|
+
data.tar.gz: 9ffb727f9161abcfa62c47e2ef913d18edc0f1da2ba107628701467e91b5a0f43eb59d3c53af33eaa857612b1ae818721c1d5f8356644e1f5cd546f5aa001115
|
data/Gemfile.lock
CHANGED
data/lib/interval_set/version.rb
CHANGED
data/lib/interval_set.rb
CHANGED
@@ -129,6 +129,32 @@ class IntervalSet
|
|
129
129
|
|
130
130
|
alias_method :===, :include?
|
131
131
|
|
132
|
+
# Returns +true+ if the closure of this IntervalSet contains the given element.
|
133
|
+
#
|
134
|
+
# The closure of a set +S+ is defined as the set containing all elements of +S+
|
135
|
+
# but also its limit points.
|
136
|
+
#
|
137
|
+
# It will always return +true+ if #include? returns +true+ but in addition it
|
138
|
+
# will also return +true+ if the exclusive end of a range is included.
|
139
|
+
#
|
140
|
+
# i = IntervalSet[0...1] # -> [0...1]
|
141
|
+
#
|
142
|
+
# i.include_or_limit?(0) # -> true
|
143
|
+
# i.include_or_limit?(0.5) # -> true
|
144
|
+
# i.include_or_limit?(1) # -> true
|
145
|
+
#
|
146
|
+
# Note that the given element must be comparable to elements already in this
|
147
|
+
# set. Otherwise, the behavior is undefined.
|
148
|
+
#
|
149
|
+
# @param element [Object]
|
150
|
+
def include_or_limit?(element)
|
151
|
+
return false if element.nil?
|
152
|
+
|
153
|
+
floor_entry = @range_map.floor_entry(element)
|
154
|
+
|
155
|
+
!floor_entry.nil? && floor_entry.value.last >= element
|
156
|
+
end
|
157
|
+
|
132
158
|
# Returns +true+ if this IntervalSet includes all elements
|
133
159
|
# of the other object.
|
134
160
|
#
|