Functions to query some index attributes

# S3 method for class 'hi'
length(x)
# S3 method for class 'hi'
maxindex(x, ...)
# S3 method for class 'hi'
poslength(x, ...)

Arguments

x

an object of class hi

...

further arguments (not used)

Details

length.hi returns the number of the subsript elements in the index (even if they are negative). By contrast poslength returns the number of selected elements (which for negative indices is maxindex(x) - length(unique(x))). maxindex returns the highest possible index position.

Value

an integer scalar

Author

Jens Oehlschlägel

Note

duplicated negative indices are removed

Examples

  length(as.hi(-1, maxindex=12))
#> [1] 1
  poslength(as.hi(-1, maxindex=12))
#> [1] 11
  maxindex(as.hi(-1, maxindex=12))
#> [1] 12
  message("note that")
#> note that
  length(as.hi(c(-1, -1), maxindex=12))
#> [1] 1
  length(as.hi(c(1,1), maxindex=12))
#> [1] 2