-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make rbind_all stricter (only accepting lists of data frames). closes #…
- Loading branch information
1 parent
79c4d3d
commit d9c2d8e
Showing
7 changed files
with
81 additions
and
3 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
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,31 @@ | ||
#ifndef dplyr_tools_FilteredListOf_H | ||
#define dplyr_tools_FilteredListOf_H | ||
|
||
namespace Rcpp { | ||
|
||
template <typename T> | ||
class FilteredListOf { | ||
public: | ||
|
||
FilteredListOf(SEXP data_) : data(data_){ | ||
int n = data.size() ; | ||
for( int i=0; i<n; i++){ | ||
indices.push_back(i) ; | ||
} | ||
} | ||
|
||
T operator[](int i) const { | ||
return as<T>( data[indices[i]]) ; | ||
} | ||
|
||
int size() const { | ||
return indices.size() ; | ||
} | ||
|
||
private: | ||
List data ; | ||
std::vector<int> indices ; | ||
} ; | ||
} | ||
|
||
#endif |
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,37 @@ | ||
#ifndef dplyr_tools_FilteredListOf_H | ||
#define dplyr_tools_FilteredListOf_H | ||
|
||
namespace Rcpp { | ||
|
||
template <typename T> | ||
class StrictListOf { | ||
public: | ||
|
||
StrictListOf(SEXP data_) : data(data_){ | ||
int n = data.size() ; | ||
for( int i=0; i<n; i++){ | ||
if( !is<T>(data[i]) ){ | ||
std::stringstream s ; | ||
s << "object at index " | ||
<< i | ||
<< " not compatible with class " | ||
<< DEMANGLE(T) ; | ||
stop( s.str() ) ; | ||
} | ||
} | ||
} | ||
|
||
T operator[](int i) const { | ||
return as<T>( data[i] ) ; | ||
} | ||
|
||
int size() const { | ||
return data.size() ; | ||
} | ||
|
||
private: | ||
List data ; | ||
} ; | ||
} | ||
|
||
#endif |
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
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
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
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