22
22
* You also may specify fragmenting indexes, that define an additional filter
23
23
* that then is applied on inserting a value. The value will then only be added
24
24
* 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.
26
30
*/
27
31
@ Accessors (fluent = true )
28
32
public class DataTable <T > {
@@ -50,6 +54,12 @@ public <K> DataTable<T> addIndex(final String name, final Function<T, K> keySupp
50
54
return addIndex (name , keySupplier , null );
51
55
}
52
56
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
+ */
53
63
public <K > DataTable <T > addMultiIndex (final String name , final Function <T , K > keySupplier ) {
54
64
return addMultiIndex (name , keySupplier , null );
55
65
}
@@ -64,6 +74,12 @@ public <K> DataTable<T> addIndex(final String name, final Function<T, K> keySupp
64
74
return this ;
65
75
}
66
76
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
+ */
67
83
@ SuppressWarnings ("unchecked" )
68
84
public <K > DataTable <T > addMultiIndex (final String name , final Function <T , K > keySupplier ,
69
85
final Function <T , Boolean > filter ) {
@@ -118,6 +134,10 @@ public synchronized <K> T get(final String name, final K key) {
118
134
return maps .get (name ).get (key );
119
135
}
120
136
137
+ public synchronized <K > T remove (final String name , final K key ) {
138
+ return maps .get (name ).remove (key );
139
+ }
140
+
121
141
/**
122
142
* Gets elements by a specified multi-index.
123
143
*
@@ -130,6 +150,10 @@ public synchronized <K> Collection<T> multiGet(final String name, final K key) {
130
150
return multiMaps .get (name ).get (key );
131
151
}
132
152
153
+ public synchronized <K > Collection <T > multiRemove (final String name , final K key ) {
154
+ return multiMaps .get (name ).remove (key );
155
+ }
156
+
133
157
/**
134
158
* Adds one or more elements to the DataTable.
135
159
* <p>
0 commit comments