Index

Domain

MMO.math · 1 symbol · generated 30 Sep 2026

class

Domain

Domain.js:14

A set of numbers, held as a sorted list of disjoint MMO.math.Interval

class MMO.math.Domain
Namespace
MMO.math
Adding an interval MERGES it into the ones already there, so the content stays normalised: no overlap, no touching pair left unmerged, and always in order. A Domain and an Interval expose the same predicates (contains, overlap, isEqual, intervals, limit...), so either can be handed to the other's methods.
new MMO.math.Domain([0,10], [20,30]).toString();//'[0,10]u[20,30]'

Index

constructor(intervals)
From(domains) staticCopy another domain, or promote an interval into one.
FromValue(value, isIncluded) staticThe domain holding exactly one value.
Infinity() static
toString()
clone()PHP clone $domain + __clone (each interval is cloned)
clear()Empty the domain.
indexOf(interval)PHP returns int|false; this returns the JS convention -1 when not found.
Columns(lines) staticFind the common columns between a list of domains.
intervals()PHP arrays are value types, so PHP returns a copy here; callers (see Columns) rely on being able to mutate the returned array without touching the Domain.
limit()The single interval spanning from the first bound to the last one, holes included.
set(domains)Replace the whole content.
add(values)
remove(values)
getStart()On an EMPTY domain these four return null here.
includeStart()
getEnd()
includeEnd()
size()
contains(value)Test whether a value lies entirely inside this domain.
overlap(value)Test whether a value shares any point with this domain.
isEmpty()
isEqual(value)Test whether a value covers exactly the same points.
union(value)Create a new Domain of the union of this one and the given values
exclude(value)Create a new Domain from this one and remove the given values
intersect(value)Create a new Domain of the intersection of this one and the given values
inverse(limit)Create a new Domain of the inverse of this one
addStorage(storage)
attach(object, info)Attach an object to EVERY interval of the domain.
freeStorage()Detach every object from every interval.
computeLeft(operator, value)Do an arithmetic operation on the start and end of all the intervals using the value at the start of the computing (value * this).
computeRight(operator, value)Do an arithmetic operation on the start and end of all the intervals using the value at the end of the computing (this * value).
offsetBy(offset)
[Symbol.iterator]() generatorJS has no operator overloading for $domain[$i], so the four ArrayAccess methods become plain methods: $d[$i] -> d.at(i) $d[$i] = $v -> d.setAt(i, $v) $d[] = $v -> d.add($v) unset($d[$i]) -> d.del…
deleteAt(offset)PHP \ArrayAccess::offsetUnset
at(offset)PHP \ArrayAccess::offsetGet (PHP returns by reference; JS cannot)
setAt(offset, value)PHP \ArrayAccess::offsetSet - note it removes then re-adds (so it re-sorts)
hasAt(offset)PHP \ArrayAccess::offsetExists

Methods38

constructor(intervals)

Domain.js:16
constructor(...intervals)
...intervals...(number | Array | Interval)

FromValue(value, isIncluded)

staticDomain.js:36

The domain holding exactly one value.

static FromValue(value, isIncluded = true)
valuenumber
isIncluded = truebooleanfalse yields an EMPTY domain
returnsMMO.math.Domain

toString()

Domain.js:50
toString()
returnsstringthe intervals joined by 'u' (union) @example '[0,10]u[20,30]'

clone()

Domain.js:55

PHP clone $domain + __clone (each interval is cloned)

clone()

indexOf(interval)

Domain.js:72

PHP returns int|false; this returns the JS convention -1 when not found.

indexOf(interval)
interval
returnsnumberindex, or -1

Columns(lines)

staticDomain.js:84

Find the common columns between a list of domains.

static Columns(...lines)
...lines...Domainthe lines with various columns on them
returnsDomain

intervals()

Domain.js:181

PHP arrays are value types, so PHP returns a copy here; callers (see Columns) rely on being able to mutate the returned array without touching the Domain.

intervals()
returnsInterval[]a shallow copy of the content

limit()

Domain.js:189

The single interval spanning from the first bound to the last one, holes included.

limit()
returnsMMO.math.Intervalan empty interval when the domain is empty

add(values)

Domain.js:212
add(...values)
...values...(number | Array | Interval)

remove(values)

Domain.js:262
remove(...values)
...values...(number | Array | Interval)

getStart()

Domain.js:307

On an EMPTY domain these four return null here. Verified difference with the PHP: getStart()/getEnd() are declared ?float and also return null there, but includeStart()/includeEnd() are declared : bool, so PHP raises "Return value must be of type bool, null returned" (TypeError) instead.

getStart()Add an explicit guard here if you relied on that failure.

includeStart()

Domain.js:314
includeStart()
returnsbooleanwhether the domain's lower bound is part of it

getEnd()

Domain.js:321
getEnd()
returnsnumberthe domain's upper bound, Infinity when unbounded

includeEnd()

Domain.js:328
includeEnd()
returnsbooleanwhether the domain's upper bound is part of it

size()

Domain.js:335
size()
returnsnumberthe total length of the intervals, EXCLUDING the holes between them

isEmpty()

Domain.js:403
isEmpty()
returnsbooleantrue when the domain holds no value at all

union(value)

Domain.js:430

Create a new Domain of the union of this one and the given values

union(value)
value

exclude(value)

Domain.js:439

Create a new Domain from this one and remove the given values

exclude(value)
value

intersect(value)

Domain.js:448

Create a new Domain of the intersection of this one and the given values

intersect(value)
value

inverse(limit)

Domain.js:483

Create a new Domain of the inverse of this one

inverse(limit = false)
limit = falsebooleanif true, will preserve the domain's limit

addStorage(storage)

Domain.js:494
addStorage(storage)
storageMap<object, any>

attach(object, info)

Domain.js:505

Attach an object to EVERY interval of the domain.

attach(object, info = null)
objectObject
info = null*anything to remember alongside it

freeStorage()

Domain.js:514

Detach every object from every interval.

freeStorage()

computeLeft(operator, value)

Domain.js:528

Do an arithmetic operation on the start and end of all the intervals using the value at the start of the computing (value * this).

computeLeft(operator, value)
operator(a: number, b: number) => number | null
valuenumber | Interval | Domain

computeRight(operator, value)

Domain.js:545

Do an arithmetic operation on the start and end of all the intervals using the value at the end of the computing (this * value).

computeRight(operator, value)
operator(a: number, b: number) => number | null
valuenumber | Interval | Domain

[Symbol.iterator]()

generatorDomain.js:677

JS has no operator overloading for $domain[$i], so the four ArrayAccess methods become plain methods: $d[$i] -> d.at(i) $d[$i] = $v -> d.setAt(i, $v) $d[] = $v -> d.add($v) unset($d[$i]) -> d.deleteAt(i) isset($d[$i]) -> d.hasAt(i)

*[Symbol.iterator]()

deleteAt(offset)

Domain.js:682

PHP \ArrayAccess::offsetUnset

deleteAt(offset)
offset

at(offset)

Domain.js:689

PHP \ArrayAccess::offsetGet (PHP returns by reference; JS cannot)

at(offset)
offset

setAt(offset, value)

Domain.js:695

PHP \ArrayAccess::offsetSet - note it removes then re-adds (so it re-sorts)

setAt(offset, value)
offset
value

hasAt(offset)

Domain.js:704

PHP \ArrayAccess::offsetExists

hasAt(offset)
offset