Skip to content

Commit af079bd

Browse files
author
patched.codes[bot]
committed
Patched tests/cicd/generate_docstring/usage_example.py
1 parent c953072 commit af079bd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.function.Function;
2+
3+
public class Main {
4+
public static void main(String[] args) {
5+
// Example usage of a_plus_b with integers
6+
System.out.println("Sum of 5 and 3: " + Test.a_plus_b(5, 3));
7+
8+
// Example usage of a_plus_b with keymap functionality
9+
Function<Object, Comparable> lengthKeyMap = obj -> ((String)obj).length();
10+
String str1 = "apple";
11+
String str2 = "banana";
12+
System.out.println("Comparison of 'apple' and 'banana': " + Test.a_plus_b(lengthKeyMap, str1, str2));
13+
}
14+
}
15+
16+
class Test {
17+
public static int a_plus_b(Integer a, Integer b) {
18+
return a + b;
19+
}
20+
21+
public static int a_plus_b(Function<Object, Comparable> keymap, Object a, Object b) {
22+
if (keymap.apply(a).compareTo(keymap.apply(b)) < 0) {
23+
return -1;
24+
} else if (keymap.apply(a).compareTo(keymap.apply(b)) > 0) {
25+
return 1;
26+
} else {
27+
return 0;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)