A Bound
describes the to bounds of a Range.
A Bound
describes the to bounds of a Range. For example the range
(4,7]
has the two (finite) bounds "open" 4 and 7 "closed". A bound is
either a FiniteBound[T]
with a value of type T
and a BoundType or
an InifinteBound
. An InifinteBound
is used to describe unbounded ranges
as for example [a..+∞)
0.8
Indicates whether an endpoint of some range is contained in the range itself ("closed") or not ("open").
Indicates whether an endpoint of some range is contained in the range itself ("closed") or not ("open"). If a range is unbounded on a side, it is neither open nor closed on that side; the bound simply does not exist.
0.8 (copied from Guava-libraries)
A descriptor for a discrete domain such as all
Int
instances.
A descriptor for a discrete domain such as all
Int
instances. A discrete domain is one that supports the three basic
operations: #next
, #previous
and #distance
, according
to their specifications. The methods #minValue
and #maxValue
should also be overridden for bounded types.
A discrete domain always represents the entire set of values of its type; it cannot represent partial domains such as "prime integers" or "strings of length 5."
See the Guava User Guide section on
DiscreteDomain
.
0.8 (copied from Guava-libraries)
A range (or "interval") defines the boundaries around a contiguous span of values of some
type which an Ordering
exists; for example, "integers from 1 to 100 inclusive." Note that it is not
possible to iterate over these contained values.
A range (or "interval") defines the boundaries around a contiguous span of values of some
type which an Ordering
exists; for example, "integers from 1 to 100 inclusive." Note that it is not
possible to iterate over these contained values. To do so, pass this range instance and
an appropriate DiscreteDomain
to ContiguousSet#create
.
Each end of the range may be bounded or unbounded. If bounded, there is an associated
endpoint value, and the range is considered to be either open (does not include the
endpoint) or closed (includes the endpoint) on that side. With three possibilities on each
side, this yields nine basic types of ranges, enumerated below. (Notation: a square bracket
[ ]
indicates that the range is closed on that side; a parenthesis ( )
means
it is either open or unbounded. The construct {x | statement}
is read "the set of all
x such that statement.")
Notation Definition Factory method (a..b) {x | a < x < b} Range#open [a..b] {x | a <= x <= b} Range#closed (a..b] {x | a < x <= b} Range#openClosed [a..b) {x | a <= x < b} Range#closedOpen (a..+inf) {x | x > a} Range#greaterThan [a..+inf) {x | x >= a} Range#atLeast (-inf..b) {x | x < b} Range#lessThan (-inf..b] {x | x <= b} Range#atMost (-inf..+inf) {x} Range#all
When both endpoints exist, the upper endpoint may not be less than the lower. The endpoints may be equal only if at least one of the bounds is closed:
[a..a]
: a singleton range[a..a); (a..a]
: empty ranges; also valid(a..a)
: invalid; an exception will be thrownOrdering#compare
returns zero, not whether equals returns true
.c1 <= c2 <= c3
of type C
,
r.contains(c1) && r.contains(c3)
implies r.contains(c2)
). This means that a
Range[Int,Ordering[Int]
can never be used to represent, say, "all prime numbers from 1 to
100."#contains
.a
is said to be the maximal range having property
P if, for all ranges b
also having property P, a.encloses(b)
.
Likewise, a
is minimal when b.encloses(a)
for all b
having
property P. See, for example, the definition of intersection
.Extractors are defined for general ranges with finite and infinite bounds.
Usage example:
val range = Range.atLeast(6) // Range[Int,math.Ordering.Int.type] = [6..inf) range match { case Range(FiniteBound(lower, lowerType),InfiniteBound) => // matches lower = 6 // lowerType = Closed }
Since most Scala classes don't implement Ordered
a Range of type T
needs a "companion" type
class of Ordering[T]
.
See the Guava User Guide article on Range.
0.8 (copied from Guava-libraries)
A base trait for all RangeMap
, mutable as well as immutable
A base trait for all RangeMap
, mutable as well as immutable
A mapping from disjoint nonempty ranges to non-null values. Queries look up the value associated with the range (if any) that contains a specified key.
In contrast to RangeSet, no "coalescing" is done of connected ranges, even if they are mapped to the same value.
Usage example:
import org.feijoas.mango.common.collect.mutable import org.feijoas.mango.common.collect.Range import math.Ordering.Int // mutable range map val rangeMap = mutable.RangeMap(Range.open(3, 7) -> "1") //Map((3..7) -> 1) rangeMap += Range.closed(9, 10) -> "2" // Map((3..7) -> 1, [9..10] -> 2) rangeMap += Range.closed(12, 16) -> "3" // Map((3..7) -> 1, [9..10] -> 2, [12..16] -> 3) val sub = rangeMap.subRangeMap(Range.closed(5, 11)) // Map([5..7) -> 1, [9..10] -> 2) sub.put(Range.closed(7, 9), "4") // sub = Map([5..7) -> 1, [7..9] -> 4, (9..10] -> 2) // rangeMap = Map((3..7) -> 1, [7..9] -> 4, (9..10] -> 2, [12..16] -> 3)
0.9
Factory for RangeMap implementations
Factory for RangeMap implementations
0.9
Implementation trait for RangeMap
Implementation trait for RangeMap
A mapping from disjoint nonempty ranges to non-null values. Queries look up the value associated with the range (if any) that contains a specified key.
In contrast to RangeSet, no "coalescing" is done of connected ranges, even if they are mapped to the same value.
Usage example:
import org.feijoas.mango.common.collect.mutable import org.feijoas.mango.common.collect.Range import math.Ordering.Int // mutable range map val rangeMap = mutable.RangeMap(Range.open(3, 7) -> "1") //Map((3..7) -> 1) rangeMap += Range.closed(9, 10) -> "2" // Map((3..7) -> 1, [9..10] -> 2) rangeMap += Range.closed(12, 16) -> "3" // Map((3..7) -> 1, [9..10] -> 2, [12..16] -> 3) val sub = rangeMap.subRangeMap(Range.closed(5, 11)) // Map([5..7) -> 1, [9..10] -> 2) sub.put(Range.closed(7, 9), "4") // sub = Map([5..7) -> 1, [7..9] -> 4, (9..10] -> 2) // rangeMap = Map((3..7) -> 1, [7..9] -> 4, (9..10] -> 2, [12..16] -> 3)
0.9
A base trait for all RangeSet
, mutable as well as immutable
A base trait for all RangeSet
, mutable as well as immutable
A range set is a set comprising zero or more nonempty, disconnected ranges of type C
for which an Ordering[C]
is defined.
Note that the behavior of Range#isEmpty()
and Range#isConnected(Range)
may
not be as expected on discrete ranges. See the Scaladoc of those methods for details.
For a Set
whose contents are specified by a Range, see ContiguousSet.
Usage example:
import org.feijoas.mango.common.collect.Bound._ import org.feijoas.mango.common.collect._ import math.Ordering.Int // immutable range set: val rangeSet = RangeSet(Range.open(1, 3), Range.closed(4, 9)) // {(1,3), [4,9]} val subSet = rangeSet.subRangeSet(Range.closed(2, 6)) // union view {[2,3), [4,6]} // mutable range set: val mutableRangeSet = mutable.RangeSet(Range.closed(1, 10)) // {[1, 10]} mutableRangeSet += Range.closedOpen(11, 15) // disconnected range: {[1, 10], [11, 15)} mutableRangeSet += Range.closedOpen(15, 20) // connected range; {[1, 10], [11, 20)} mutableRangeSet += Range.openClosed(0, 0) // empty range; {[1, 10], [11, 20)} mutableRangeSet -= Range.open(5, 10) // splits [1, 10]; {[1, 5], [10, 10], [11, 20)}
0.8
Factory for RangeSet implementations
Factory for RangeSet implementations
0.8
Implementation trait for RangeSet
Implementation trait for RangeSet
A range set is a set comprising zero or more nonempty, disconnected ranges of type C
for which an Ordering[C]
is defined.
Note that the behavior of Range#isEmpty()
and Range#isConnected(Range)
may
not be as expected on discrete ranges. See the Scaladoc of those methods for details.
For a Set
whose contents are specified by a Range, see ContiguousSet.
Usage example:
import org.feijoas.mango.common.collect.Bound._ import org.feijoas.mango.common.collect._ import math.Ordering.Int // immutable range set: val rangeSet = RangeSet(Range.open(1, 3), Range.closed(4, 9)) // {(1,3), [4,9]} val subSet = rangeSet.subRangeSet(Range.closed(2, 6)) // union view {[2,3), [4,6]} // mutable range set: val mutableRangeSet = mutable.RangeSet(Range.closed(1, 10)) // {[1, 10]} mutableRangeSet += Range.closedOpen(11, 15) // disconnected range: {[1, 10], [11, 15)} mutableRangeSet += Range.closedOpen(15, 20) // connected range; {[1, 10], [11, 20)} mutableRangeSet += Range.openClosed(0, 0) // empty range; {[1, 10], [11, 20)} mutableRangeSet -= Range.open(5, 10) // splits [1, 10]; {[1, 5], [10, 10], [11, 20)}
0.8
A Bound
describes the to bounds of a Range.
A Bound
describes the to bounds of a Range. For example the range
(4,7]
has the two (finite) bounds "open" 4 and 7 "closed". A bound is
either a FiniteBound[T]
with a value of type T
and a BoundType or
an InifinteBound
. An InifinteBound
is used to describe unbounded ranges
as for example [a..+∞)
0.8
Indicates whether an endpoint of some range is contained in the range itself ("closed") or not ("open").
Indicates whether an endpoint of some range is contained in the range itself ("closed") or not ("open"). If a range is unbounded on a side, it is neither open nor closed on that side; the bound simply does not exist.
0.8 (copied from Guava-libraries)
A range (or "interval") defines the boundaries around a contiguous span of values of some
type which an Ordering
exists; for example, "integers from 1 to 100 inclusive." Note that it is not
possible to iterate over these contained values.
A range (or "interval") defines the boundaries around a contiguous span of values of some
type which an Ordering
exists; for example, "integers from 1 to 100 inclusive." Note that it is not
possible to iterate over these contained values. To do so, pass this range instance and
an appropriate DiscreteDomain
to ContiguousSet#create
.
Each end of the range may be bounded or unbounded. If bounded, there is an associated
endpoint value, and the range is considered to be either open (does not include the
endpoint) or closed (includes the endpoint) on that side. With three possibilities on each
side, this yields nine basic types of ranges, enumerated below. (Notation: a square bracket
[ ]
indicates that the range is closed on that side; a parenthesis ( )
means
it is either open or unbounded. The construct {x | statement}
is read "the set of all
x such that statement.")
Notation Definition Factory method (a..b) {x | a < x < b} Range#open [a..b] {x | a <= x <= b} Range#closed (a..b] {x | a < x <= b} Range#openClosed [a..b) {x | a <= x < b} Range#closedOpen (a..+inf) {x | x > a} Range#greaterThan [a..+inf) {x | x >= a} Range#atLeast (-inf..b) {x | x < b} Range#lessThan (-inf..b] {x | x <= b} Range#atMost (-inf..+inf) {x} Range#all
When both endpoints exist, the upper endpoint may not be less than the lower. The endpoints may be equal only if at least one of the bounds is closed:
[a..a]
: a singleton range[a..a); (a..a]
: empty ranges; also valid(a..a)
: invalid; an exception will be thrownOrdering#compare
returns zero, not whether equals returns true
.c1 <= c2 <= c3
of type C
,
r.contains(c1) && r.contains(c3)
implies r.contains(c2)
). This means that a
Range[Int,Ordering[Int]
can never be used to represent, say, "all prime numbers from 1 to
100."#contains
.a
is said to be the maximal range having property
P if, for all ranges b
also having property P, a.encloses(b)
.
Likewise, a
is minimal when b.encloses(a)
for all b
having
property P. See, for example, the definition of intersection
.Extractors are defined for general ranges with finite and infinite bounds. For example:
val range = Range.atLeast(6) // Range[Int,math.Ordering.Int.type] = [6..inf) range match { case Range(FiniteBound(lower, lowerType),InfiniteBound) => // matches lower = 6 // lowerType = Closed }
Since most Scala classes don't implement Ordered
a Range of type T
needs a "companion" type
class of Ordering[T]
.
See the Guava User Guide article on
Range
.
0.8 (copied from Guava-libraries)
Factory for immutable RangeMap
Factory for immutable RangeSet
This package contains generic collection traits and implementations for working with Guava collections.
0.8