Skip to content

Commit

Permalink
Moved to RObjects instead of SEXPs <3
Browse files Browse the repository at this point in the history
  • Loading branch information
dirmeier committed Aug 16, 2018
1 parent d4aa988 commit 0f25583
Show file tree
Hide file tree
Showing 19 changed files with 215 additions and 123 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -36,6 +36,7 @@ NeedsCompilation: yes
Collate:
'checks.R'
'datastructures-package.R'
'methods_clear.R'
'methods_insert.R'
'methods_size.R'
'methods_pop.R'
Expand All @@ -49,7 +50,6 @@ Collate:
'ds_heap.R'
'ds_heap_binomial.R'
'ds_heap_fibonacci.R'
'methods_clear.R'
'methods_remove.R'
'methods_head.R'
'ds_map.R'
Expand Down
14 changes: 12 additions & 2 deletions R/ds_deque.R
Expand Up @@ -22,6 +22,7 @@
#' @include methods_pop.R
#' @include methods_size.R
#' @include methods_insert.R
#' @include methods_clear.R
NULL


Expand All @@ -42,6 +43,12 @@ setClass(
)


.clear.deque <- function(obj)
{
obj@.deque$clear()
obj
}

#' @noRd
.peek.deque <- function(obj)
{
Expand All @@ -67,7 +74,6 @@ setClass(
{
cat(paste0("An object of class ", class(object)[1], "<SEXP>\n\n"))
li <- peek(object)
if (is.null(li)) li <- "NULL"
cat(paste0("Peek: ", class(li), ", ...\n"))
}

Expand All @@ -83,7 +89,6 @@ setClass(
.insert.deque <- function(obj, x)
{
obj@.deque$insert(x)

obj
}

Expand All @@ -110,6 +115,7 @@ setMethod(
function(obj, x) .insert.deque(obj, list(x))
)


#' @rdname insert-methods
setMethod(
"insert",
Expand All @@ -120,3 +126,7 @@ setMethod(
.insert.deque(obj, x)
}
)


#' @rdname clear-methods
setMethod("clear", "deque", .clear.deque)
16 changes: 15 additions & 1 deletion R/ds_heap.R
Expand Up @@ -25,6 +25,7 @@
#' @include methods_handle.R
#' @include methods_decrease.R
#' @include methods_values.R
#' @include methods_clear.R
NULL


Expand Down Expand Up @@ -99,6 +100,14 @@ setClass(
}


#' @noRd
.clear.heap <- function(obj)
{
obj@.heap$clear()
obj
}


#' @noRd
#' @importFrom purrr map
.handle <- function(obj, key, value)
Expand Down Expand Up @@ -169,6 +178,7 @@ setMethod(
}
)


#' @rdname insert-methods
setMethod(
"insert",
Expand All @@ -182,7 +192,6 @@ setMethod(
)



#' @rdname insert-methods
setMethod(
"insert",
Expand Down Expand Up @@ -328,6 +337,7 @@ setMethod("peek", "heap", .peek.heap)
#' @rdname pop-methods
setMethod("pop", "heap", .pop.heap)


#' @noRd
setMethod("show", "heap", .show.heap)

Expand All @@ -338,3 +348,7 @@ setMethod("size", "heap", .size.heap)

#' @rdname values-methods
setMethod("values", "heap", .heap_values)


#' @rdname clear-methods
setMethod("clear", "heap", .clear.heap)
3 changes: 2 additions & 1 deletion R/ds_map.R
Expand Up @@ -103,9 +103,10 @@ setMethod(
)


#' @rdname size-methods
#' @rdname clear-methods
setMethod("clear", "map", .clear.map)


#' @noRd
setMethod("show", "map", .show.map)

Expand Down
80 changes: 47 additions & 33 deletions docs/articles/datastructures.html

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

13 changes: 11 additions & 2 deletions docs/reference/clear-methods.html

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

2 changes: 1 addition & 1 deletion docs/reference/index.html

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

3 changes: 0 additions & 3 deletions docs/reference/size-methods.html

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

0 comments on commit 0f25583

Please sign in to comment.