Rcpp Version 1.0.14
Loading...
Searching...
No Matches
Comparator_With_One_Value.h
Go to the documentation of this file.
1
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2
//
3
// LessThan.h: Rcpp R/C++ interface class library -- vector operators
4
//
5
// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
6
//
7
// This file is part of Rcpp.
8
//
9
// Rcpp is free software: you can redistribute it and/or modify it
10
// under the terms of the GNU General Public License as published by
11
// the Free Software Foundation, either version 2 of the License, or
12
// (at your option) any later version.
13
//
14
// Rcpp is distributed in the hope that it will be useful, but
15
// WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
18
//
19
// You should have received a copy of the GNU General Public License
20
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21
22
#ifndef Rcpp__sugar__Comparator_With_One_Value_h
23
#define Rcpp__sugar__Comparator_With_One_Value_h
24
25
namespace
Rcpp
{
26
namespace
sugar{
27
28
template
<
int
RTYPE,
typename
Operator,
bool
NA,
typename
T>
29
class
Comparator_With_One_Value
:
public
::Rcpp::VectorBase
< LGLSXP, true, Comparator_With_One_Value<RTYPE,Operator,NA,T> > {
30
public
:
31
typedef
typename
Rcpp::VectorBase<RTYPE,NA,T>
VEC_TYPE
;
32
typedef
typename
traits::storage_type<RTYPE>::type
STORAGE
;
33
typedef
int
(
Comparator_With_One_Value
::*
METHOD
)(
int
)
const
;
34
35
Comparator_With_One_Value
(
const
VEC_TYPE
&
lhs_
,
STORAGE
rhs_
) :
36
lhs
(
lhs_
),
rhs
(
rhs_
),
m
(),
op
() {
37
38
m
= Rcpp::traits::is_na<RTYPE>(
rhs
) ?
39
&
Comparator_With_One_Value::rhs_is_na
:
40
&
Comparator_With_One_Value::rhs_is_not_na
;
41
42
}
43
44
inline
int
operator[]
(
R_xlen_t
i )
const
{
45
return
(this->*
m
)(i) ;
46
}
47
48
inline
R_xlen_t
size
()
const
{
return
lhs
.
size
() ; }
49
50
private
:
51
const
VEC_TYPE
&
lhs
;
52
STORAGE
rhs
;
53
METHOD
m
;
54
Operator
op
;
55
56
inline
int
rhs_is_na
(
int
i)
const
{
return
rhs
; }
57
inline
int
rhs_is_not_na
(
int
i)
const
{
58
STORAGE
x =
lhs
[i] ;
59
return
Rcpp::traits::is_na<RTYPE>(x) ? x :
op
( x,
rhs
) ;
60
}
61
62
} ;
63
64
65
template
<
int
RTYPE,
typename
Operator,
typename
T>
66
class
Comparator_With_One_Value
<RTYPE,
Operator
,
false
,T> :
67
public
::Rcpp::VectorBase
< RTYPE, true, Comparator_With_One_Value<LGLSXP,Operator,false,T> > {
68
69
public
:
70
typedef
typename
Rcpp::VectorBase<RTYPE,false,T>
VEC_TYPE
;
71
typedef
typename
traits::storage_type<RTYPE>::type
STORAGE
;
72
typedef
int
(
Comparator_With_One_Value
::*
METHOD
)(
int
)
const
;
73
74
Comparator_With_One_Value
(
const
VEC_TYPE
&
lhs_
,
STORAGE
rhs_
) :
75
lhs
(
lhs_
),
rhs
(
rhs_
),
m
(),
op
() {
76
77
m
= Rcpp::traits::is_na<RTYPE>(
rhs
) ?
78
&
Comparator_With_One_Value::rhs_is_na
:
79
&
Comparator_With_One_Value::rhs_is_not_na
;
80
81
}
82
83
inline
int
operator[]
(
R_xlen_t
i )
const
{
84
return
(this->*
m
)(i) ;
85
}
86
87
inline
R_xlen_t
size
()
const
{
return
lhs
.
size
() ; }
88
89
private
:
90
const
VEC_TYPE
&
lhs
;
91
STORAGE
rhs
;
92
METHOD
m
;
93
Operator
op
;
94
95
inline
int
rhs_is_na
(
int
i)
const
{
return
rhs
; }
96
inline
int
rhs_is_not_na
(
int
i)
const
{
97
return
op
(
lhs
[i],
rhs
) ;
98
}
99
100
} ;
101
102
103
}
// sugar
104
}
// Rcpp
105
106
107
108
109
110
#endif
Rcpp::VectorBase
Definition
VectorBase.h:29
Rcpp::VectorBase::size
R_xlen_t size() const
Definition
VectorBase.h:49
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::operator[]
int operator[](R_xlen_t i) const
Definition
Comparator_With_One_Value.h:83
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::size
R_xlen_t size() const
Definition
Comparator_With_One_Value.h:87
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::lhs
const VEC_TYPE & lhs
Definition
Comparator_With_One_Value.h:90
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::rhs
STORAGE rhs
Definition
Comparator_With_One_Value.h:91
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::Comparator_With_One_Value
Comparator_With_One_Value(const VEC_TYPE &lhs_, STORAGE rhs_)
Definition
Comparator_With_One_Value.h:74
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::rhs_is_not_na
int rhs_is_not_na(int i) const
Definition
Comparator_With_One_Value.h:96
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::STORAGE
traits::storage_type< RTYPE >::type STORAGE
Definition
Comparator_With_One_Value.h:71
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::m
METHOD m
Definition
Comparator_With_One_Value.h:92
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::VEC_TYPE
Rcpp::VectorBase< RTYPE, false, T > VEC_TYPE
Definition
Comparator_With_One_Value.h:70
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::op
Operator op
Definition
Comparator_With_One_Value.h:93
Rcpp::sugar::Comparator_With_One_Value< RTYPE, Operator, false, T >::rhs_is_na
int rhs_is_na(int i) const
Definition
Comparator_With_One_Value.h:95
Rcpp::sugar::Comparator_With_One_Value
Definition
Comparator_With_One_Value.h:29
Rcpp::sugar::Comparator_With_One_Value::op
Operator op
Definition
Comparator_With_One_Value.h:54
Rcpp::sugar::Comparator_With_One_Value::size
R_xlen_t size() const
Definition
Comparator_With_One_Value.h:48
Rcpp::sugar::Comparator_With_One_Value::rhs
STORAGE rhs
Definition
Comparator_With_One_Value.h:52
Rcpp::sugar::Comparator_With_One_Value::VEC_TYPE
Rcpp::VectorBase< RTYPE, NA, T > VEC_TYPE
Definition
Comparator_With_One_Value.h:31
Rcpp::sugar::Comparator_With_One_Value::m
METHOD m
Definition
Comparator_With_One_Value.h:53
Rcpp::sugar::Comparator_With_One_Value::rhs_is_not_na
int rhs_is_not_na(int i) const
Definition
Comparator_With_One_Value.h:57
Rcpp::sugar::Comparator_With_One_Value::operator[]
int operator[](R_xlen_t i) const
Definition
Comparator_With_One_Value.h:44
Rcpp::sugar::Comparator_With_One_Value::STORAGE
traits::storage_type< RTYPE >::type STORAGE
Definition
Comparator_With_One_Value.h:32
Rcpp::sugar::Comparator_With_One_Value::Comparator_With_One_Value
Comparator_With_One_Value(const VEC_TYPE &lhs_, STORAGE rhs_)
Definition
Comparator_With_One_Value.h:35
Rcpp::sugar::Comparator_With_One_Value::rhs_is_na
int rhs_is_na(int i) const
Definition
Comparator_With_One_Value.h:56
Rcpp::sugar::Comparator_With_One_Value::METHOD
int(Comparator_With_One_Value::* METHOD)(int) const
Definition
Comparator_With_One_Value.h:33
Rcpp::sugar::Comparator_With_One_Value::lhs
const VEC_TYPE & lhs
Definition
Comparator_With_One_Value.h:51
Rcpp
Rcpp API.
Definition
algo.h:28
Rcpp::as
T as(SEXP x)
Definition
as.h:151
Rcpp::traits::storage_type::type
SEXP type
Definition
storage_type.h:36
inst
include
Rcpp
sugar
operators
Comparator_With_One_Value.h
Generated on Sun Jan 12 2025 11:21:43 for Rcpp Version 1.0.14 by
1.9.8