File: rcpp_radix.R

package info (click to toggle)
r-cran-triebeard 0.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 392 kB
  • sloc: cpp: 1,095; sh: 13; makefile: 2; ansic: 1
file content (61 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
## //[[Rcpp::depends(triebeard)]]

## #include <radix.h>


## radix_tree<type1, type2> radix;


## radix_tree<std::string, std::string> radix;

## radix["turnin"] = "entry the first";

## radix["turin"] = "entry the second";

## 
## radix_tree<std::string, std::string>::iterator it;

## 
## it = radix.longest_match("turing");

## 
## if(it = radix.end()){

##   printf("No match was found :(");

## } else {

##   std::string result = "Key of longest match: " + it->first + " , value of longest match: " + it->second;

## }


## radix_tree<std::string, std::string> radix;

## radix["turnin"] = "entry the first";

## radix["turin"] = "entry the second";

## 
## std::vector<radix_tree<std::string, std::string>::iterator> vec;

## std::vector<radix_tree<std::string, std::string>::iterator>::iterator it;

## 
## it = radix.prefix_match("tur");

## 
## if(it == vec.end()){

##   printf("No match was found :(");

## } else {

##   for (it = vec.begin(); it != vec.end(); ++it) {

##     std::string result = "Key of a prefix match: " + it->first + " , value of a prefix match: " + it->second;

##   }

## }