Example usage for org.apache.commons.collections4.multimap ArrayListValuedHashMap ArrayListValuedHashMap

List of usage examples for org.apache.commons.collections4.multimap ArrayListValuedHashMap ArrayListValuedHashMap

Introduction

In this page you can find the example usage for org.apache.commons.collections4.multimap ArrayListValuedHashMap ArrayListValuedHashMap.

Prototype

public ArrayListValuedHashMap() 

Source Link

Document

Creates an empty ArrayListValuedHashMap with the default initial map capacity (16) and the default initial list capacity (3).

Usage

From source file:mase.me.MESubpopulation.java

@Override
public void setup(EvolutionState state, Parameter base) {
    super.setup(state, base);
    this.batchSize = super.individuals.length;

    int initial = state.parameters.getInt(base.push(P_INITIAL_BATCH), defaultBase().push(P_INITIAL_BATCH));
    this.individuals = new Individual[initial]; // the super resize method is bugged

    this.behaviourIndex = state.parameters.getInt(base.push(P_BEHAVIOUR_INDEX),
            defaultBase().push(P_BEHAVIOUR_INDEX));
    this.resolution = state.parameters.getDouble(base.push(P_RESOLUTION), defaultBase().push(P_RESOLUTION));

    this.map = new ArrayListValuedHashMap<>();
    this.inverseHash = new HashMap<>();
    this.hits = new HashMap<>();
}

From source file:de.tud.inf.db.sparqlytics.repository.AbstractRepository.java

@Override
public MetricRegistry getStatistics() {
    MetricRegistry registry = new MetricRegistry();
    final Set<Cube> cubes = getCubes();
    registry.register("#cubes", new Gauge<Integer>() {
        @Override//from ww  w . jav a 2s  .c  o m
        public Integer getValue() {
            return cubes.size();
        }
    });
    final Set<Dimension> allDimensions = getDimensions();
    registry.register("#dimensions", new Gauge<Integer>() {
        @Override
        public Integer getValue() {
            return allDimensions.size();
        }
    });
    final Set<Measure> allMeasures = getMeasures();
    registry.register("#measures", new Gauge<Integer>() {
        @Override
        public Integer getValue() {
            return allMeasures.size();
        }
    });
    Histogram levelsPerDimension = registry.register("levels/dimension",
            new Histogram(new SlidingWindowReservoir(cubes.size())));
    for (Dimension dimension : getDimensions()) {
        levelsPerDimension.update(dimension.getLevels().size() - 1);
    }
    Histogram dimensionsPerCube = registry.register("dimensions/cube",
            new Histogram(new SlidingWindowReservoir(cubes.size())));
    Histogram measuresPerCube = registry.register("measures/cube",
            new Histogram(new SlidingWindowReservoir(cubes.size())));
    MultiValuedMap<Dimension, Cube> dimensionMap = new ArrayListValuedHashMap<>();
    MultiValuedMap<Measure, Cube> measureMap = new ArrayListValuedHashMap<>();
    for (Cube cube : cubes) {
        Set<Dimension> dimensions = cube.getDimensions();
        dimensionsPerCube.update(dimensions.size());
        for (Dimension dimension : dimensions) {
            dimensionMap.put(dimension, cube);
        }
        Set<Measure> measures = cube.getMeasures();
        measuresPerCube.update(measures.size());
        for (Measure measure : measures) {
            measureMap.put(measure, cube);
        }
    }
    Histogram cubesPerDimension = registry.register("cubes/dimension",
            new Histogram(new SlidingWindowReservoir(cubes.size())));
    for (Collection<Cube> values : dimensionMap.asMap().values()) {
        cubesPerDimension.update(values.size());
    }
    Histogram cubesPerMeasure = registry.register("cubes/measure",
            new Histogram(new SlidingWindowReservoir(cubes.size())));
    for (Collection<Cube> values : measureMap.asMap().values()) {
        cubesPerMeasure.update(values.size());
    }
    return registry;
}

From source file:com.o2o.util.WebUtils.java

/**
 * ?? //from   ww  w .j ava 2s.  co m
 * @param url
 * @return
 */
public static String generateShortUrl(String url) {
    MultiValuedMap<String, Object> params = new ArrayListValuedHashMap<String, Object>();
    params.put("url", url);
    String jsonStr = HttpUtil.doPost("http://dwz.cn/create.php", params);

    JSONObject object = JSON.parseObject(jsonStr);
    String shortUrl = object.getString("tinyurl");
    if (StringUtils.isEmpty(shortUrl))
        return url;
    return shortUrl;
}

From source file:fr.cph.chicago.util.Util.java

@NonNull
public static MultiValuedMap<String, String> getFavoritesTrainParams(@NonNull final Context context) {
    final MultiValuedMap<String, String> paramsTrain = new ArrayListValuedHashMap<>();
    final List<Integer> favorites = Preferences.getTrainFavorites(context, App.PREFERENCE_FAVORITES_TRAIN);
    Stream.of(favorites).forEach(
            favorite -> paramsTrain.put(context.getString(R.string.request_map_id), favorite.toString()));
    return paramsTrain;
}

From source file:fr.cph.chicago.util.Util.java

@NonNull
public static MultiValuedMap<String, String> getFavoritesBusParams(@NonNull final Context context) {
    final MultiValuedMap<String, String> paramsBus = new ArrayListValuedHashMap<>();
    final List<String> busFavorites = Preferences.getBusFavorites(context, App.PREFERENCE_FAVORITES_BUS);
    Stream.of(busFavorites).map(Util::decodeBusFavorite).forEach(fav -> {
        paramsBus.put(context.getString(R.string.request_rt), fav[0]);
        paramsBus.put(context.getString(R.string.request_stop_id), fav[1]);
    });//from   w  w  w  .  j  a  va2s .c  o m
    return paramsBus;
}

From source file:com.evolveum.midpoint.task.quartzimpl.work.workers.WorkersManager.java

private MultiValuedMap<String, WorkerKey> createWorkerKeys(Task task,
        Map<WorkerKey, WorkerTasksPerNodeConfigurationType> perNodeConfigurationMap, OperationResult opResult)
        throws SchemaException {
    TaskWorkManagementType wsCfg = task.getWorkManagement();
    WorkersManagementType workersCfg = wsCfg.getWorkers();
    if (workersCfg == null) {
        throw new IllegalStateException("Workers configuration is missing: " + task);
    }/*from w ww  . j  a v  a 2s  .  c om*/
    MultiValuedMap<String, WorkerKey> rv = new ArrayListValuedHashMap<>();
    for (WorkerTasksPerNodeConfigurationType perNodeConfig : getWorkersPerNode(workersCfg)) {
        for (String nodeIdentifier : getNodeIdentifiers(perNodeConfig, opResult)) {
            int count = defaultIfNull(perNodeConfig.getCount(), 1);
            for (int index = 1; index <= count; index++) {
                WorkerKey key = createWorkerKey(nodeIdentifier, index, perNodeConfig, workersCfg, task);
                rv.put(key.group, key);
                perNodeConfigurationMap.put(key, perNodeConfig);
            }
        }
    }
    return rv;
}

From source file:com.evolveum.midpoint.prism.schema.SchemaRegistryImpl.java

private void parsePrismSchemas(List<SchemaDescription> schemaDescriptions, boolean allowDelayedItemDefinitions)
        throws SchemaException {
    List<SchemaDescription> prismSchemaDescriptions = schemaDescriptions.stream()
            .filter(sd -> sd.isPrismSchema()).collect(Collectors.toList());
    Element schemaElement = DOMUtil.createElement(DOMUtil.XSD_SCHEMA_ELEMENT);
    schemaElement.setAttribute("targetNamespace", "http://dummy/");
    schemaElement.setAttribute("elementFormDefault", "qualified");

    // These fragmented namespaces should not be included in wrapper XSD because they are defined in multiple XSD files.
    // We have to process them one by one.
    MultiValuedMap<String, SchemaDescription> schemasByNamespace = new ArrayListValuedHashMap<>();
    prismSchemaDescriptions.forEach(sd -> schemasByNamespace.put(sd.getNamespace(), sd));
    List<String> fragmentedNamespaces = schemasByNamespace.keySet().stream()
            .filter(ns -> schemasByNamespace.get(ns).size() > 1).collect(Collectors.toList());
    LOGGER.trace("Fragmented namespaces: {}", fragmentedNamespaces);

    List<SchemaDescription> wrappedDescriptions = new ArrayList<>();
    for (SchemaDescription description : prismSchemaDescriptions) {
        String namespace = description.getNamespace();
        if (!fragmentedNamespaces.contains(namespace)) {
            Element importElement = DOMUtil.createSubElement(schemaElement, DOMUtil.XSD_IMPORT_ELEMENT);
            importElement.setAttribute(DOMUtil.XSD_ATTR_NAMESPACE.getLocalPart(), namespace);
            description.setSchema(new PrismSchemaImpl(prismContext));
            wrappedDescriptions.add(description);
        }//  w  w w  .java  2s.c o  m
    }
    if (LOGGER.isTraceEnabled()) {
        String xml = DOMUtil.serializeDOMToString(schemaElement);
        LOGGER.trace("Wrapper XSD:\n{}", xml);
    }

    long started = System.currentTimeMillis();
    LOGGER.trace("Parsing {} schemas wrapped in single XSD", wrappedDescriptions.size());
    PrismSchemaImpl.parseSchemas(schemaElement, entityResolver, wrappedDescriptions,
            allowDelayedItemDefinitions, getPrismContext());
    LOGGER.trace("Parsed {} schemas in {} ms", wrappedDescriptions.size(),
            System.currentTimeMillis() - started);

    for (SchemaDescription description : wrappedDescriptions) {
        detectExtensionSchema(description.getSchema());
    }

    for (String namespace : fragmentedNamespaces) {
        Collection<SchemaDescription> fragments = schemasByNamespace.get(namespace);
        LOGGER.trace("Parsing {} schemas for fragmented namespace {}", fragments.size(), namespace);
        for (SchemaDescription schemaDescription : fragments) {
            parsePrismSchema(schemaDescription, allowDelayedItemDefinitions);
        }
    }
}

From source file:com.evolveum.midpoint.testing.story.TestStrings.java

private ArrayListValuedHashMap<String, Message> sortByRecipients(Collection<Message> messages) {
    ArrayListValuedHashMap<String, Message> rv = new ArrayListValuedHashMap<>();
    messages.forEach(m -> m.getTo().forEach(to -> rv.put(to, m)));
    return rv;/*from  w  w  w  .ja v  a2s. c om*/
}

From source file:org.apache.poi.xssf.usermodel.XSSFWorkbook.java

/**
 * Create a new CTWorkbook with all values set to default
 *//*from   w  ww  . ja va 2s .com*/
private void onWorkbookCreate() {
    workbook = CTWorkbook.Factory.newInstance();

    // don't EVER use the 1904 date system
    CTWorkbookPr workbookPr = workbook.addNewWorkbookPr();
    workbookPr.setDate1904(false);

    CTBookViews bvs = workbook.addNewBookViews();
    CTBookView bv = bvs.addNewWorkbookView();
    bv.setActiveTab(0);
    workbook.addNewSheets();

    POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties();
    expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR);

    sharedStringSource = (SharedStringsTable) createRelationship(XSSFRelation.SHARED_STRINGS,
            XSSFFactory.getInstance());
    stylesSource = (StylesTable) createRelationship(XSSFRelation.STYLES, XSSFFactory.getInstance());
    stylesSource.setWorkbook(this);

    namedRanges = new ArrayList<XSSFName>();
    namedRangesByName = new ArrayListValuedHashMap<String, XSSFName>();
    sheets = new ArrayList<XSSFSheet>();
    pivotTables = new ArrayList<XSSFPivotTable>();
}

From source file:org.apache.poi.xssf.usermodel.XSSFWorkbook.java

private void reprocessNamedRanges() {
    namedRangesByName = new ArrayListValuedHashMap<String, XSSFName>();
    namedRanges = new ArrayList<XSSFName>();
    if (workbook.isSetDefinedNames()) {
        for (CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameArray()) {
            createAndStoreName(ctName);/*from  w ww  . j  av  a  2s.  co  m*/
        }
    }
}