-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8acf49d
Showing
12 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
cran-comments.md | ||
inst/include/.git | ||
inst/include/.travis.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata | ||
src/*.o | ||
src/*.so | ||
src/*.dll | ||
*.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "inst/include"] | ||
path = inst/include | ||
url = https://github.com/greg7mdp/sparsepp.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Package: sparsepp | ||
Type: Package | ||
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, | ||
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 | ||
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 | ||
BugReports: https://github.com/dselivanov/sparsepp/issues | ||
RoxygenNote: 5.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// ---------------------------------------------------------------------- | ||
// 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. | ||
// ---------------------------------------------------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' sparsepp | ||
#' | ||
#' \code{sparsepp} provides bindings to the | ||
#' \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: | ||
#' \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++). | ||
#'} | ||
"_PACKAGE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# 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 | ||
|
||
```c++ | ||
#include <sparsepp.h> | ||
using spp::sparse_hash_map; | ||
sparse_hash_map<string, int> smap; | ||
``` | ||
# Defining custom hash function | ||
|
||
```c++ | ||
#include <iostream> | ||
#include <functional> | ||
#include <string> | ||
#include "sparsepp.h" | ||
|
||
using std::string; | ||
|
||
struct Person | ||
{ | ||
bool operator==(const Person &o) const | ||
{ return _first == o._first && _last == o._last; } | ||
|
||
string _first; | ||
string _last; | ||
}; | ||
|
||
namespace std | ||
{ | ||
// inject specialization of std::hash for Person into namespace std | ||
// ---------------------------------------------------------------- | ||
template<> | ||
struct hash<Person> | ||
{ | ||
std::size_t operator()(Person const &p) const | ||
{ | ||
std::size_t seed = 0; | ||
spp::hash_combine(seed, p._first); | ||
spp::hash_combine(seed, p._last); | ||
return seed; | ||
} | ||
}; | ||
} | ||
|
||
int main() | ||
{ | ||
// As we have defined a specialization of std::hash() for Person, | ||
// we can now create sparse_hash_set or sparse_hash_map of Persons | ||
// ---------------------------------------------------------------- | ||
spp::sparse_hash_set<Person> persons = { { "John", "Galt" }, | ||
{ "Jane", "Doe" } }; | ||
for (auto& p: persons) | ||
std::cout << p._first << ' ' << p._last << '\n'; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Test environments | ||
|
||
* local OS X install, R 3.3.1 | ||
* win-builder (devel) | ||
|
||
## R CMD check results | ||
|
||
R CMD check results | ||
0 errors | 0 warnings | 0 notes |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source | ||
PackageRoxygenize: rd,collate,namespace,vignette |