8000 GitHub - renkun-ken/collections: High-performance container datatypes for R
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

renkun-ken/collections

 
 

Repository files navigation

High Performance Container Data Types

Github Action codecov CRAN_Status_Badge

Documentation: http://randy3k.github.io/collections

Provides high performance container data types such as queues, stacks, deques, dicts and ordered dicts. Benchmarks https://randy3k.github.io/collections/articles/benchmark.html have shown that these containers are asymptotically more efficient than those offered by other packages.

Installation

You can install the released version of collections from CRAN with:

install.packages("collections")

Install the latest development version using

devtools::install_github("randy3k/collections")

Example

library(collections, warn.conflicts = FALSE)

Queue

q <- queue()
q$push(1)$push(2)
q$pop()
#> [1] 1

Stack

s <- stack()
s$push(1)$push(2)
s$pop()
#> [1] 2

Deque

dq <- deque()
dq$push(1)$pushleft(2)
dq$pop()
#> [1] 1

Priority Queue

pq <- priority_queue()
pq$push("not_urgent")
pq$push("urgent", priority = 2)
pq$push("not_as_urgent", priority = 1)
pq$pop()
#> [1] "urgent"
pq$pop()
#> [1] "not_as_urgent"
pq$pop()
#> [1] "not_urgent"

Dictionary. Comparing to R envrionments, dict() does not leak memory and supports hashing functions and environments.

d <- dict()
e <- new.env()
d$set(e, 1)$set(sum, 2)
d$get(e)
#> [1] 1

Ordered Dictionary

d <- ordered_dict()
d$set("b", 1)$set("a", 2)
d$as_list()
#> $b
#> [1] 1
#> 
#> $a
#> [1] 2

About

High-performance container datatypes for R

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 85.5%
  • R 11.9%
  • Objective-C 2.4%
  • C++ 0.2%
0