-
Notifications
You must be signed in to change notification settings - Fork 2
/
DemoApplication.java
49 lines (36 loc) · 1.81 KB
/
DemoApplication.java
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
package com.example.demo;
import com.googlecode.concurrenttrees.common.PrettyPrinter;
import com.googlecode.concurrenttrees.radix.node.concrete.DefaultCharArrayNodeFactory;
import com.googlecode.concurrenttrees.radix.node.util.PrettyPrintable;
import com.googlecode.concurrenttrees.radixreversed.ConcurrentReversedRadixTree;
import com.googlecode.concurrenttrees.radixreversed.ReversedRadixTree;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.stream.StreamSupport;
@SpringBootApplication
public class DemoApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
ReversedRadixTree<Integer> tree = new ConcurrentReversedRadixTree<Integer>(new DefaultCharArrayNodeFactory());
tree.put("springboot", 1);
tree.put("springcloud", 2);
tree.put("springmvc", 3);
tree.put("sports", 77);
PrettyPrinter.prettyPrint((PrettyPrintable) tree, System.out);
//Exact 매칭
System.out.println("#1. Exact 매칭 테스트");
System.out.println("springboot (exact match): " + tree.getValueForExactKey("springboot"));
System.out.println("springcloud (exact match): " + tree.getValueForExactKey("springcloud"));
System.out.println("springmvc (exact match): " + tree.getValueForExactKey("springmvc"));
System.out.println("sports (exact match): " + tree.getValueForExactKey("sports"));
//Reverse 매칭
System.out.println("#2. Reverse Suffix 매칭 테스트");
System.out.println("(reverse suffix match): ");
StreamSupport.stream(tree.getKeyValuePairsForKeysEndingWith("boot").spliterator(), false)
.forEach(System.out::println);
}
}