Skip to content

Commit 3cfc29b

Browse files
committed
PQ_Compare required
1 parent b9de093 commit 3cfc29b

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

R/RcppExports.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
22
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
33

4-
### Efficient log-linear cumulative median.
4+
#' Efficient log-linear cumulative median.
55
cum_median_interface <- function(data_vec, weight_vec) {
66
.Call(`_binsegRcpp_cum_median_interface`, data_vec, weight_vec)
77
}
88

9-
### Use depth first search to compute a data.frame
10-
### with one row for each segment, and columns
11-
### splits and depth, number/depth of candidate
12-
### splits that need to be
13-
### computed after splitting that segment.
9+
#' Use depth first search to compute a data.frame
10+
#' with one row for each segment, and columns
11+
#' splits and depth, number/depth of candidate
12+
#' splits that need to be
13+
#' computed after splitting that segment.
1414
depth_first_interface <- function(n_data, min_segment_length) {
1515
.Call(`_binsegRcpp_depth_first_interface`, n_data, min_segment_length)
1616
}
1717

18-
### Compute a data.frame with one row for each distribution
19-
### implemented in the C++ code, and columns distribution.str,
20-
### parameters, description.
18+
#' Compute a data.frame with one row for each distribution
19+
#' implemented in the C++ code, and columns distribution.str,
20+
#' parameters, description.
2121
get_distribution_info <- function() {
2222
.Call(`_binsegRcpp_get_distribution_info`)
2323
}
2424

25-
### Low-level interface to binary segmentation algorithm.
25+
#' Low-level interface to binary segmentation algorithm.
2626
binseg_interface <- function(data_vec, weight_vec, max_segments, min_segment_length, distribution_str, container_str, is_validation_vec, position_vec) {
2727
.Call(`_binsegRcpp_binseg_interface`, data_vec, weight_vec, max_segments, min_segment_length, distribution_str, container_str, is_validation_vec, position_vec)
2828
}

src/binseg.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ container_umap_type* get_container_umap(void){
401401
return &container_umap;
402402
}
403403

404-
#define CMAKER(CONTAINER, INSERT, SET_IT, GET_SEG, ERASE) \
405-
class CONCAT(CONTAINER,Wrapper) : public MyContainer< std::CONTAINER<Segment> > { \
404+
#define CMAKER(CONTAINER, STRUCT, INSERT, SET_IT, GET_SEG, ERASE) \
405+
class CONCAT(CONTAINER,Wrapper) : public MyContainer< STRUCT > { \
406406
public: \
407407
void insert(Segment& new_seg){ \
408408
segment_container.INSERT(new_seg); \
@@ -423,14 +423,25 @@ container_umap_type* get_container_umap(void){
423423
static ContainerFactory CONCAT(CONTAINER,_instance) \
424424
( #CONTAINER, CONCAT(CONTAINER,construct), CONCAT(CONTAINER,destruct) );
425425

426-
#define CIT(CONTAINER, INSERT, BEST) \
427-
CMAKER(CONTAINER, INSERT, std::CONTAINER<Segment>::iterator it = BEST, *it, segment_container.erase(it))
426+
#define CIT(CONTAINER, INSERT, BEST) \
427+
CMAKER(CONTAINER, std::CONTAINER<Segment>, INSERT, std::CONTAINER<Segment>::iterator it = BEST, *it, segment_container.erase(it))
428428

429429
CIT(multiset, insert, segment_container.begin())
430430

431431
CIT(list, push_back, std::min_element(segment_container.begin(),segment_container.end()))
432432

433-
CMAKER(priority_queue, push, , segment_container.top(), segment_container.pop())
433+
class PQ_Compare {
434+
public:
435+
bool operator()(Segment a, Segment b){
436+
return !(a < b);
437+
}
438+
};
439+
#define PQ_STRUCT std::priority_queue<Segment,std::vector<Segment>,PQ_Compare>
440+
CMAKER(priority_queue, PQ_STRUCT, push, , segment_container.top(), segment_container.pop())
441+
//template <class T, class Container = vector<T>, class Compare = less<typename Container::value_type> >
442+
//template < class T, // multiset::key_type/value_type class Compare = less<T>, // multiset::key_compare/value_compare class Alloc = allocator<T> > // multiset::allocator_type > class multiset;
443+
444+
434445

435446
class Candidates {
436447
public:

0 commit comments

Comments
 (0)