Nothing
## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
if(requireNamespace("pkgload", quietly = TRUE)) {
pkgload::load_all(".", quiet = TRUE)
} else if(requireNamespace("Immutables", quietly = TRUE)) {
library(Immutables)
} else {
stop("Need either installed 'Immutables' or the 'pkgload' package to render this vignette.")
}
## -----------------------------------------------------------------------------
s <- flexseq("a", "b", "c", "d")
s |> push_front("z") |> push_back("e")
pop_front(s)$remaining
## -----------------------------------------------------------------------------
s[[3]]
peek_back(s)
insert_at(s, 3, c("x", "y"))
## -----------------------------------------------------------------------------
fapply(s, toupper)
c(s, as_flexseq(letters[10:12]))
loop(for (el in s) print(el))
## -----------------------------------------------------------------------------
q <- priority_queue(a = "task_a", b = "task_b", c = "task_c", priorities = c(3, 1, 2)) |>
insert("task_d", priority = 1, name = "d")
## -----------------------------------------------------------------------------
peek_min(q)
pop_max(q)$value
pop_all_min(q)$elements
## -----------------------------------------------------------------------------
min_priority(q); max_priority(q)
merge(q, priority_queue("task_e", priorities = 0))
## -----------------------------------------------------------------------------
xs <- ordered_sequence("a1", "b1", "b2", "c1", keys = c(1, 2, 2, 3))
peek_key(xs, 2)
peek_all_key(xs, 2)
## -----------------------------------------------------------------------------
count_between(xs, 1, 2)
elements_between(xs, 2, 3, include_to = FALSE)
lower_bound(xs, 2)$index
## -----------------------------------------------------------------------------
min_key(xs); max_key(xs)
merge(xs, ordered_sequence("d1", keys = 4))
## -----------------------------------------------------------------------------
ix <- interval_index("A", "B", "C", start = c(1, 2, 4), end = c(3, 4, 5))
peek_point(ix, 2)
## -----------------------------------------------------------------------------
peek_all_overlaps(ix, start = 2, end = 5)
peek_all_containing(ix, start = 2, end = 3)
peek_all_point(ix, point = 3, match_at = "end")
## -----------------------------------------------------------------------------
min_endpoint(ix); max_endpoint(ix)
merge(ix, interval_index("D", start = 6, end = 8))
## -----------------------------------------------------------------------------
sum_monoid <- measure_monoid(f = `+`, i = 0, measure = function(el) el)
x <- as_flexseq(c(3, 1, 4, 1, 5, 9, 2, 6)) |>
add_monoids(list(sum = sum_monoid))
get_measure(x, "sum")
## -----------------------------------------------------------------------------
locate_by_predicate(x, function(v) v > 10, "sum")
split_around_by_predicate(x, function(v) v > 10, "sum")$value
validate_tree(x)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.