Skip to content

Commit 19bc403

Browse files
committed
Implement Integer Binary Min Heap
1 parent bf2be8e commit 19bc403

File tree

5 files changed

+526
-4
lines changed

5 files changed

+526
-4
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ Library Dependencies:
1818

1919
## Usage
2020

21-
### Maven
21+
### Setup
22+
23+
#### Maven
2224

2325
Include the following `repository` to your project pom. This is required since releases are currently published to
2426
GitHub Packages. You would also need to set the environment variables `GITHUB_USER` and `GITHUB_PAT` which are your
@@ -45,12 +47,27 @@ Include the following `dependency` to the `dependencies` section of your project
4547
</dependency>
4648
```
4749

50+
#### Logger Adapter
51+
4852
Additionally, include any [SLF4J supported logger implementation](http://www.slf4j.org/faq.html#where_is_binding)
4953
dependencies for output. The tests here use [logback](https://mvnrepository.com/artifact/ch.qos.logback/logback-classic)
5054
with [this configuration](./src/test/resources/logback.xml)
5155

5256
With the above configuration, you should be able to run individual tests easily via your favorite IDEs like IntelliJ,
53-
Eclipse, etc
57+
Eclipse, etc. Checkout JUnit documentation for running tests via Maven (Surefire plugin and JUnit Platform & Engine).
58+
59+
#### Java 9 Modules
60+
61+
If you are using Java 9 Modules, then you can `requires` the module "org.codi.LeetCodeTester". Also, you would need to
62+
add `opens` for all test classes since the test executor makes heavy use of Java Reflection to run the tests. For
63+
simplicity, you could define your module as `open`.
64+
65+
```java
66+
// module-info.java
67+
open module MyModule {
68+
requires org.codi.LeetCodeTestre;
69+
}
70+
```
5471

5572
### Examples
5673

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package org.codi.lct.core;
2+
3+
import java.util.Arrays;
4+
import java.util.Collection;
5+
import java.util.Map;
6+
import lombok.experimental.UtilityClass;
7+
import org.codi.lct.ds.ListNode;
8+
import org.codi.lct.ds.TreeNode;
9+
import org.codi.lct.ds.extra.ArrayTree;
10+
import org.codi.lct.ds.extra.BinaryHeap;
11+
import org.codi.lct.ds.extra.CircularArray;
12+
import org.codi.lct.ds.extra.Pair;
13+
import org.codi.lct.ds.extra.UnionFind;
14+
15+
@UtilityClass
16+
public class LCPrinter {
17+
18+
// Printers
19+
20+
public void print(Object o) {
21+
System.out.println(o);
22+
}
23+
24+
public void print(String s) {
25+
print((Object) s);
26+
}
27+
28+
public void print(Collection<?> collection) {
29+
print(collection.toString());
30+
}
31+
32+
public void print(Map<?, ?> map) {
33+
print(map.toString());
34+
}
35+
36+
public void print(int[] arr) {
37+
print(Arrays.toString(arr));
38+
}
39+
40+
public void print(char[] arr) {
41+
print(new String(arr));
42+
}
43+
44+
public <T> void print(T[] arr) {
45+
print(Arrays.toString(arr));
46+
}
47+
48+
public void print(ArrayTree tree) {
49+
print(tree.toString());
50+
}
51+
52+
public void print(CircularArray arr) {
53+
print(arr.toString());
54+
}
55+
56+
public void print(BinaryHeap heap) {
57+
print(heap.heap());
58+
}
59+
60+
public void print(ListNode list) {
61+
print(LCUtil.serialize(list));
62+
}
63+
64+
public void print(Pair<?, ?> pair) {
65+
print(pair.toString());
66+
}
67+
68+
public void print(TreeNode tree) {
69+
print(LCUtil.visualize(tree));
70+
}
71+
72+
public void print(UnionFind uf) {
73+
print(uf.toString());
74+
}
75+
}

0 commit comments

Comments
 (0)