Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package info.unterrainer.commons.jreutils.collections;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Function;
import lombok.Getter;
import lombok.experimental.Accessors;
/**
* A synchronized data-structure acting as a table. You may create indexes for
* various columns and later on retrieve sets of index-keys or the indexed
* values.
* You also may specify fragmenting indexes, that define an additional filter
* that then is applied on inserting a value. The value will then only be added
* to a specific index, if the filter is satisfied. This allows for
* runtime-efficient table-fragmentation.
*/
@Accessors(fluent = true)
public class DataTable {
private Class clazz;
private int maxEntries;
@Getter
private DataQueue queue;
private HashMap> keySuppliers = new HashMap<>();
private HashMap> filters = new HashMap<>();
private HashMap> maps = new HashMap<>();
public DataTable(final Class clazz, final int maxEntries) {
this.clazz = clazz;
this.maxEntries = maxEntries;
queue = new DataQueue<>(maxEntries);
}
public DataTable addIndex(final String name, final Function keySupplier) {
return addIndex(name, keySupplier, null);
}
@SuppressWarnings("unchecked")
public DataTable addIndex(final String name, final Function keySupplier,
final Function filter) {
keySuppliers.put(name, (Function) keySupplier);
if (filter != null)
filters.put(name, filter);
maps.put(name, new DataMap