Skip to content

Commit bc6f6ee

Browse files
author
Gerald Unterrainer
committed
Merge branch 'develop'
2 parents cea1e70 + c10d3b4 commit bc6f6ee

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,69 @@
99

1010
A library to help with JRE stuff like `shutdownhooks` or reading resources.
1111

12+
13+
14+
## Collections
15+
16+
This package contains several collections I've come across and used in some programs.
17+
18+
### DataQueue
19+
20+
A synchronized, size-limited FIFO-queue.
21+
22+
### SizeLimitedHashMap
23+
24+
A normal HashMap, but limited in size.
25+
If there is a size-overflow, the oldest value will be discarded.
26+
27+
### DataMap
28+
29+
A synchronized, size-limited HashMap.
30+
31+
### DataTable
32+
33+
This is a data-structure that holds arbitrary objects in a DataQueue and you may or may not add one or many `indexes`, which will generate a DataMap for each index, using the given keySupplier to generate the key for each entry.
34+
35+
When you add a new element, delete an element or clear the list, all indexes will be automatically equally affected.
36+
37+
The indexes use minimal memory, since the references to the corresponding values is shared.
38+
39+
```java
40+
DataTable<String> dt = new DataTable<>(String.class, 10);
41+
dt.addIndex("index1", e -> e);
42+
dt.addIndex("index2", e -> e);
43+
dt.add("test");
44+
assertThat(dt.get("index1", "test")).isEqualTo("test");
45+
assertThat(dt.get("index2", "test")).isEqualTo("test");
46+
```
47+
48+
49+
50+
51+
52+
## DoubleBufferedFile
53+
54+
This is a data-structure that is thread-safe and uses two files to persist itself.
55+
This way you have a file left, if something happens during persisting.
56+
57+
```java
58+
DoubleBufferedFile dbf = new DoubleBufferedFile(Path.of("new"), "txt");
59+
dbf.write(w -> w.write("test_old"));
60+
dbf.write(w -> w.write("test_new"));
61+
String value = dbf.read() // is equal to "test_new"
62+
dbf.delete();
63+
```
64+
65+
The above example generates two files: `new1.txt` and `new2.txt` and the accessors always give the correct file-handle to read or write-to.
66+
67+
68+
69+
## DateUtils
70+
71+
Offers some often used date-time conversions including UTC and ISO8601.
72+
73+
74+
1275
## ForName
1376

1477
This helps you to load and instantiate classes that haven't already been loaded using a given class-loader. This is of great help to strip boilerplate code when doing stuff like plugin-systems or the like.
@@ -26,7 +89,7 @@ The special thing about these is, that they work in JAR-files AND server-deploym
2689
## ShutdownHook
2790

2891
If you'd like some code running before the Java-VM shuts down, then this is the way to go.
29-
I use it shutting down the EntityManagerFactory for some programs as gracefully as it gets.
92+
I use it for shutting down the EntityManagerFactory in some programs as gracefully as it gets.
3093

3194
### Example
3295

0 commit comments

Comments
 (0)