Skip to content

Commit

Permalink
following CRAN team suggestions - adjust description here and there
Browse files Browse the repository at this point in the history
  • Loading branch information
dselivanov committed Dec 30, 2016
1 parent 8acf49d commit 5c6be11
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ src/*.o
src/*.so
src/*.dll
*.DS_Store
inst/doc
13 changes: 6 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
Package: sparsepp
Type: Package
Title: Rcpp Interface to Sparsepp
Title: 'Rcpp' Interface to 'sparsepp'
Version: 0.1.0
Date: 2016-12-29
Authors@R: c(
person("Gregory", "Popovitch", role = c("aut", "cph"), email = "[email protected]"),
person("Google Inc", role = c("aut", "cph")),
person("Dmitriy", "Selivanov", role = "cre", email = "[email protected]")
)
Description: Provides interface to sparsepp - fast, memory efficient hash map.
It is derived from Google's excellent sparsehash implementation.
We believe Sparsepp provides an unparalleled combination of performance and memory usage,
Description: Provides interface to 'sparsepp' - fast, memory efficient hash map.
It is derived from Google's excellent 'sparsehash' implementation.
We believe 'sparsepp' provides an unparalleled combination of performance and memory usage,
and will outperform your compiler's unordered_map on both counts.
Only Google's dense_hash_map is consistently faster, at the cost of much greater
Only Google's 'dense_hash_map' is consistently faster, at the cost of much greater
memory usage (especially when the final size of the map is not known in advance).
License: BSD_3_clause + file LICENSE
Encoding: UTF-8
URL: https://github.com/dselivanov/sparsepp, https://github.com/greg7mdp/
sparsepp
URL: https://github.com/greg7mdp/sparsepp, https://github.com/dselivanov/sparsepp
BugReports: https://github.com/dselivanov/sparsepp/issues
RoxygenNote: 5.0.1
39 changes: 3 additions & 36 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
// ----------------------------------------------------------------------
// Copyright (c) 2016, Gregory Popovitch - [email protected]
// All rights reserved.
//
// This work is derived from Google's sparsehash library
//
// Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------

YEAR: 2005, 2016
COPYRIGHT HOLDER: Google Inc., Gregory Popovitch <[email protected]>
ORGANIZATION: Google Inc.
38 changes: 36 additions & 2 deletions R/package-sparsepp.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
#' sparsepp
#'
#' \code{sparsepp} provides bindings to the
#' \href{https://github.com/greg7mdp/sparsepp}{sparsepp} - fast, memory efficient hash map for C++
#' \href{https://github.com/greg7mdp/sparsepp}{sparsepp} - fast, memory efficient hash map for C++.
#' \code{sparsepp} is an open source C++ library derived from Google's
#' excellent sparsehash implementation. It aims to achieve the following objectives:
#' excellent sparsehash implementation, but considerably outperform it - \url{https://github.com/greg7mdp/sparsepp/blob/master/bench.md}.
#' It aims to achieve the following objectives:
#' \itemize{
#' \item A drop-in alternative for unordered_map and unordered_set.
#' \item Extremely low memory usage (typically about one byte overhead per entry).
#' \item Very efficient, typically faster than your compiler's unordered map/set or Boost's.
#' \item C++11 support (if supported by compiler).
#' \item Single header implementation - just copy sparsepp.h to your project and include it.
#' \item Tested on Windows (vs2010-2015, g++), linux (g++, clang++) and MacOS (clang++).
#' }
#' @examples
#' \dontrun{
#' library(Rcpp)
#' code = "
#' #include <Rcpp.h>
#' using namespace std;
#' using namespace Rcpp;
#' // drop-in replacement for unordered_map
#' //#include <unordered_map>
#' #include <sparsepp.h>
#' using spp::sparse_hash_map;
#' // @export
#' // [[Rcpp::export]]
#' IntegerVector word_count(CharacterVector v) {
#' //unordered_map<string, int> smap;
#' sparse_hash_map<string, int> smap;
#' for(auto x: v) {
#' smap[as<string>(x)] ++;
#' }
#' IntegerVector res(smap.size());
#' int i = 0;
#' for(auto s:smap) {
#' res[i]=s.second;
#' i++;
#' }
#' return(res);
#' }"
#' f = tempfile(, fileext = ".cpp")
#' writeLines(code, f)
#' sourceCpp(f)
#' unlink(f)
#' word_count(sample(letters, 100, T))
#'}
"_PACKAGE"
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
# Use `sparsepp` from another package
## Benchmarks

Check original [sparsepp](https://github.com/greg7mdp/sparsepp) repository and [write-up](https://github.com/greg7mdp/sparsepp/blob/master/bench.md) which compares hashmap implementations.

![insert-benchmark](https://raw.githubusercontent.com/greg7mdp2/img/master/sparsepp/insert_large_0.PNG)

## Use sparsepp from another package
To use C++ code from `sparsepp`:

1. In DESCRIPTION, add `LinkingTo: sparsepp`.
1. In the C++ file, add:
`#include <sparsepp.h>`

# Simple example
## Simple example

```c++
#include <sparsepp.h>
using spp::sparse_hash_map;
sparse_hash_map<string, int> smap;
```
# Defining custom hash function
## Defining custom hash function

```c++
#include <iostream>
#include <functional>
#include <string>
#include "sparsepp.h"
#include <sparsepp.h>

using std::string;

Expand Down
8 changes: 8 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Resubmission
This is a resubmission. In this version:

* Put single quote around package names in Title and Description fields.
* Fixed URLs
* Added example to doc

## Test environments

* local OS X install, R 3.3.1
Expand All @@ -7,3 +14,4 @@

R CMD check results
0 errors | 0 warnings | 0 notes

39 changes: 37 additions & 2 deletions man/sparsepp-package.Rd

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

0 comments on commit 5c6be11

Please sign in to comment.