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

com.venky.core.collections.SequenceMap Maven / Gradle / Ivy

There is a newer version: 1.18
Show newest version
package com.venky.core.collections;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;


public class SequenceMap implements Map{
	private HashMap inner = new HashMap();
	private SequenceSet keys = new SequenceSet();

	@Override
	public int size() {
		return inner.size();
	}

	@Override
	public boolean isEmpty() {
		return inner.isEmpty();
	}

	@Override
	public boolean containsKey(Object key) {
		return inner.containsKey(key);
	}

	@Override
	public boolean containsValue(Object value) {
		return inner.containsValue(value);
	}

	@Override
	public V get(Object key) {
		return inner.get(key);
	}

	@Override
	public V put(K key, V value) {
		V old = inner.put(key, value);
		keys.add(key);
		return old;
	}

	@Override
	public V remove(Object key) {
		V v = inner.remove(key);
		keys.remove(key);
		return v;
	}

	@Override
	public void putAll(Map m) {
		for (K k : m.keySet()){
			put(k,m.get(k));
		}
	}

	@Override
	public void clear() {
		inner.clear();
		keys.clear();
	}

	@Override
	public Set keySet() {
		return Collections.unmodifiableSet(keys);
	}

	@Override
	public Collection values() {
		return Collections.unmodifiableCollection(inner.values());
	}

	@Override
	public Set> entrySet() {
		return Collections.unmodifiableSet(inner.entrySet());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy