Skip to content

Commit 2bcae06

Browse files
committed
Merge branch 'develop'
2 parents f0b9d13 + dfcabf4 commit 2bcae06

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>jre-utils</artifactId>
13-
<version>0.3.14</version>
13+
<version>0.3.15</version>
1414
<name>JreUtils</name>
1515
<packaging>jar</packaging>
1616

src/main/java/info/unterrainer/commons/jreutils/collections/DataTable.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
* You also may specify fragmenting indexes, that define an additional filter
2323
* that then is applied on inserting a value. The value will then only be added
2424
* to a specific index, if the filter is satisfied. This allows for
25-
* runtime-efficient table-fragmentation.
25+
* runtime-efficient table-fragmentation.<br>
26+
* You may add multi-indexes. Those indexes don't reference a unique item, but
27+
* rather a list of items. You have to keep in mind which kind of index it was
28+
* when you added it and you have to use the proper accessors and mutators
29+
* respective to the kind of index you're manipulating.
2630
*/
2731
@Accessors(fluent = true)
2832
public class DataTable<T> {
@@ -50,6 +54,12 @@ public <K> DataTable<T> addIndex(final String name, final Function<T, K> keySupp
5054
return addIndex(name, keySupplier, null);
5155
}
5256

57+
/**
58+
* Adds a multi-indexes. Those indexes don't reference a unique item, but rather
59+
* a list of items.<br>
60+
* Be sure to manipulate these indexes using the appropriate accessors or
61+
* mutators.
62+
*/
5363
public <K> DataTable<T> addMultiIndex(final String name, final Function<T, K> keySupplier) {
5464
return addMultiIndex(name, keySupplier, null);
5565
}
@@ -64,6 +74,12 @@ public <K> DataTable<T> addIndex(final String name, final Function<T, K> keySupp
6474
return this;
6575
}
6676

77+
/**
78+
* Adds a multi-indexes. Those indexes don't reference a unique item, but rather
79+
* a list of items.<br>
80+
* Be sure to manipulate these indexes using the appropriate accessors or
81+
* mutators.
82+
*/
6783
@SuppressWarnings("unchecked")
6884
public <K> DataTable<T> addMultiIndex(final String name, final Function<T, K> keySupplier,
6985
final Function<T, Boolean> filter) {
@@ -118,6 +134,10 @@ public synchronized <K> T get(final String name, final K key) {
118134
return maps.get(name).get(key);
119135
}
120136

137+
public synchronized <K> T remove(final String name, final K key) {
138+
return maps.get(name).remove(key);
139+
}
140+
121141
/**
122142
* Gets elements by a specified multi-index.
123143
*
@@ -130,6 +150,10 @@ public synchronized <K> Collection<T> multiGet(final String name, final K key) {
130150
return multiMaps.get(name).get(key);
131151
}
132152

153+
public synchronized <K> Collection<T> multiRemove(final String name, final K key) {
154+
return multiMaps.get(name).remove(key);
155+
}
156+
133157
/**
134158
* Adds one or more elements to the DataTable.
135159
* <p>

0 commit comments

Comments
 (0)