Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^.*\.Rcheck/$
^.*\.Rproj$
^\.Rproj\.user$
^_pkgdown\.yml$
Expand All @@ -22,3 +23,4 @@
^Makefile$
^codecov\.yml$
^pkgdown$
^cran-comments\.md$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ docs/
/doc/
/Meta/
..Rcheck/
*.Rcheck/
.claude
.codex
.agents
Expand Down
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Immutables
Type: Package
Title: Fast and Functional Data Structures
URL: https://oneilsh.github.io/immutables, https://github.com/oneilsh/immutables
URL: https://oneilsh.github.io/immutables/, https://github.com/oneilsh/immutables
BugReports: https://github.com/oneilsh/immutables/issues
Version: 1.0.0
Authors@R: c(
Expand All @@ -12,6 +12,8 @@ Description: Provides fast, side-effect free data structures, including
sequences, and interval indices.
License: MIT + file LICENSE
Encoding: UTF-8
Depends:
R (>= 4.1.0)
Imports:
coro,
Rcpp,
Expand All @@ -38,4 +40,4 @@ Suggests:
Config/testthat/edition: 3
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# immutables 1.0.0
# Immutables 1.0.0

* First release.
* First CRAN submission.
* `flexseq`s: list-like sequences with push/pop/peek from either end, indexed and named access, insertion, splitting, and concatenation.
* `priority_queue`s, `ordered_sequence`s, `interval_index`es: finger-tree-backed structures for min/max-by-priority, sorted-by-key, and interval-overlap queries.
* Developer API for building custom structures via monoid/measure combinations.
* Core operations implemented in C++ via Rcpp, with matching pure-R reference implementations using `lambda.r`.
8 changes: 5 additions & 3 deletions R/30-api-flexseq-core.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ merge.flexseq <- function(x, y, ...) {
#' x <- flexseq("a", "b", "c")
#' if(requireNamespace("igraph", quietly = TRUE)) plot(x)
#'
#' \dontrun{
#' if (requireNamespace("igraph", quietly = TRUE)) {
#' \donttest{
#' # Label every node with its subtree size (leaves contribute 1).
#' plot_structure(as_flexseq(1:10), node_label = function(node) {
#' paste0(node$type, "\n.size=", node$measures$.size)
Expand All @@ -296,8 +297,8 @@ merge.flexseq <- function(x, y, ...) {
#' xs <- add_monoids(as_flexseq(c(3, 1, 4, 1, 5, 9, 2, 6)),
#' list(sum = sum_monoid))
#' plot_structure(xs, node_label = function(node) {
#' if(node$type == "Element") sprintf("%g\=%g", node$element, node$measures$sum)
#' else sprintf("%s\=%g", node$type, node$measures$sum)
#' if(node$type == "Element") sprintf("%g\nsum=%g", node$element, node$measures$sum)
#' else sprintf("%s\nsum=%g", node$type, node$measures$sum)
#' })
#'
#' # List-valued built-in measure: priority_queue's .pq_min tracks the min
Expand All @@ -315,6 +316,7 @@ merge.flexseq <- function(x, y, ...) {
#' }
#' })
#' }
#' }
#' @export
# Runtime: O(n) to build plot graph data.
plot.flexseq <- function(x, ...) {
Expand Down
8 changes: 5 additions & 3 deletions R/70-plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ NULL
#' @return Invoked for its side effect (draws to the active graphics
#' device). Returns `NULL` invisibly.
#' @examples
#' \dontrun{
#' if (requireNamespace("igraph", quietly = TRUE)) {
#' \donttest{
#' t <- as_flexseq(letters[1:8])
#' plot_structure(t, title = "Finger tree")
#'
Expand All @@ -277,10 +278,11 @@ NULL
#' xs <- add_monoids(as_flexseq(c(3, 1, 4, 1, 5, 9, 2, 6)),
#' list(sum = sum_monoid))
#' plot_structure(xs, node_label = function(node) {
#' if(node$type == "Element") sprintf("%g\=%g", node$element, node$measures$sum)
#' else sprintf("%s\=%g", node$type, node$measures$sum)
#' if(node$type == "Element") sprintf("%g\nsum=%g", node$element, node$measures$sum)
#' else sprintf("%s\nsum=%g", node$type, node$measures$sum)
#' })
#' }
#' }
#' @seealso [plot.flexseq()], [measure_monoid()], [add_monoids()]
#' @export
# Runtime: O(n) to build graph structures prior to plotting.
Expand Down
24 changes: 12 additions & 12 deletions R/immutables-package.R
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
#' immutables
#'
#' The `immutables` R package implements several immutable, or persistent, data
#' Immutables: Fast and Functional Data Structures
#'
#' The `Immutables` R package implements several immutable, or persistent, data
#' structures: operations return modified copies while remaining fast and true
#' to R's side-effect-free functional nature.
#'
#' - `flexseq`s provide list-like operations including indexed and named element
#' access, push/pop/peek from either end for double-ended queue behavior,
#' insertion, splitting, and concatenation.
#' - `priority_queues` associate items with priority values and provide
#' - `flexseq`s provide list-like operations: indexed and named element access;
#' push/pop/peek from either end for double-ended queue behavior; insertion,
#' splitting, and concatenation.
#' - `priority_queue`s associate items with priority values and provide
#' min and max peek/pop by priority and fast insertion.
#' - `ordered_sequences` associate items with key values and keep the elements in
#' - `ordered_sequence`s associate items with key values and keep the elements in
#' sorted order by key. These may be similarly be inserted/popped/peeked by key
#' value as well as position. Keys may be duplicated, with first-in-first-out order within key groups.
#' - `interval_indexes` store items associated with interval ranges, supporting
#' - `interval_index`es store items associated with interval ranges, supporting
#' point as well as interval overlaps/contains/within queries. Items are kept
#' in start-order enabling ordered sequence operations and sweep-line
#' algorithms.
#'
#' Backed by monoid-annotated 2-3 fingertrees as described by
#' [Hinze and Paterson](https://doi.org/10.1017/S0956796805005769), most operations are constant time, amortized constant time, or $O(\\log(n))$ (indexing $k$ elements is $O(k \\log(n))$). Core functions are implemented in C++ (via Rcpp) for speed, with matching pure-R reference implementations using `lambda.r` syntax to match the paper.
#' Hinze and Paterson, most operations are constant time, amortized constant time, or $O(\\log(n))$. Core functions are implemented in C++ (via Rcpp) for speed, with matching pure-R reference implementations using `lambda.r` syntax to match the paper.
#'
#' Finally, the developer API supports the addition of custom structures via combinations of monoids and measures; see vignettes for details.
#' Finally, the developer API supports the addition of custom structures via combinations of monoids and measures.
#'
#' - Hinze, R. and Paterson, R. (2006), *Finger trees: a simple general-purpose data structure*.
#' - Hinze, R. and Paterson, R. (2006), *Finger trees: a simple general-purpose data structure*. \doi{10.1017/S0956796805005769}
#'
#' @keywords internal
#' @import lambda.r
Expand Down
19 changes: 19 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## R CMD check results

0 errors | 0 warnings | 1 note

The NOTE has two components:

* "New submission" is expected
* "catenable" is flagged as a possibly misspelled word but is standard
terminology in functional data structures literature

## Test environments

- local macOS (aarch64), R 4.5.3
- win-builder R-devel (R 4.6.0 RC, x86_64-w64-mingw32)
- GitHub Actions: ubuntu-latest, macos-latest, windows-latest

## Notes

This is a new submission.
24 changes: 12 additions & 12 deletions man/Immutables-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/plot.flexseq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/plot_structure.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading