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

com.almondtools.util.collections.HashMaps Maven / Gradle / Ivy

Go to download

Regular expression matchers, searcher, lexers based on deterministic finite automata

There is a newer version: 0.3.3
Show newest version
package com.almondtools.util.collections;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class HashMaps {

	private HashMap map;

	private HashMaps(boolean linked) {
		if (linked) {
			this.map = new LinkedHashMap();
		} else {
			this.map = new HashMap();
		}
	}

	private HashMaps(HashMap map) {
		this.map = new HashMap(map);
	}

	public HashMaps put(K key, V value) {
		map.put(key, value);
		return this;
	}

	public static  HashMaps linked() {
		return new HashMaps(true);
	}

	public static  HashMaps hashed() {
		return new HashMaps(false);
	}

	public static  HashMaps invert(Map toinvert) {
		HashMaps maps = new HashMaps(false);
		for (Map.Entry entry: toinvert.entrySet()) {
			maps.put(entry.getValue(), entry.getKey());
		}
		return maps;
	}

	public HashMap build() {
		return map;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy