A detailed vignette is provided that motivates the package. In
applications such as the mvp or clifford packages,
the user will not need to even think about the disordR
package: it works in the background. The purpose of the package is to
trap plausible idiom that is ill-defined (implementation-specific) and
return an informative error, rather than returning a possibly
incorrect result.
The package provides a single S4 class, disord
,
which has two slots, .Data
and hash
.
Function disord()
takes an R object such as a vector or list
and returns a disord
object, which is useful in the context of
the STL
map class.
Function hash()
returns the hash of an object (compare
hashcal()
which is used to actually calculate the hash code).
The package detects acceptable and forbidden operations using hash
codes: function consistent()
checks for its arguments having
the same hash code, and thus their elements can be paired up
(e.g. added). Idiomatically, a %~% b
is equivalent to
consistent(a,b)
.
Function elements()
takes a disord
and returns a regular
R object, typically a vector or a list.