All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.neko233.toolchain.memoryDatabase.indexer.RowIndexer Maven / Gradle / Ivy

package com.neko233.toolchain.memoryDatabase.indexer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 行数据库 索引
 *
 * @author SolarisNeko
 */
public class RowIndexer {

    private final Map>> index;

    public RowIndexer(List> data, String key) {
        index = new HashMap<>();
        for (Map item : data) {
            Object value = item.get(key);
            if (value != null) {
                String indexKey = value.toString();
                if (!index.containsKey(indexKey)) {
                    index.put(indexKey, new ArrayList<>());
                }
                index.get(indexKey).add(item);
            }
        }
    }

    public List> get(String key) {
        return index.get(key);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy