Ejemplo n.º 1
0
		@Override public boolean containsKey(Object o) {
			switch (inc) {
			case EQUAL: return m0.containsKey(o) && m1.containsKey(o);
			case SUB0SUP1: return m0.containsKey(o);
			case SUB1SUP0: return m1.containsKey(o);
			}
			throw new AssertionError();
		}
Ejemplo n.º 2
0
		@Override public X2<V0, V1> remove(Object o) {
			if (containsKey(o)) {
				return Tuple.X2(m0.remove(o), m1.remove(o));
			} else {
				m0.remove(o);
				m1.remove(o);
				return null;
			}
		}
Ejemplo n.º 3
0
		/**
		** {@inheritDoc}
		**
		** This will add {@code key} to both maps, even if one of the values
		** of the tuple is {@code null}.
		*/
		@Override public X2<V0, V1> put(K key, X2<V0, V1> x) {
			if (containsKey(key)) {
				return Tuple.X2(m0.put(key, x._0), m1.put(key, x._1));
			} else {
				m0.put(key, x._0);
				m1.put(key, x._1);
				return null;
			}
		}
Ejemplo n.º 4
0
		@Override public int size() {
			int s0 = m0.size(), s1 = m1.size();
			switch (inc) {
			case EQUAL: assert s0 == s1; return s0;
			case SUB0SUP1: assert s0 <= s1; return s0;
			case SUB1SUP0: assert s0 >= s1; return s1;
			}
			throw new AssertionError();
		}
Ejemplo n.º 5
0
		@Override public void clear() {
			m0.clear();
			m1.clear();
		}
Ejemplo n.º 6
0
		@Override public X2<V0, V1> get(Object o) {
			return containsKey(o)? Tuple.X2(m0.get(o), m1.get(o)): null;
		}
Ejemplo n.º 7
0
		@Override public void putAll(Map<? extends U2<K0, K1>, ? extends V> map) {
			if (!(map instanceof U2Map)) { super.putAll(map); return; }
			@SuppressWarnings("unchecked") U2Map<K0, K1, V> umap = (U2Map<K0, K1, V>)(U2Map)map;
			m0.putAll(umap.K0Map());
			m1.putAll(umap.K1Map());
		}
Ejemplo n.º 8
0
		@Override public V remove(Object o) {
			if (!(o instanceof U2)) { return null; }
			@SuppressWarnings("unchecked") U2<K0, K1> u = (U2<K0, K1>)o;
			return (u == null)? null: (u.type == 0)? m0.remove(u.getT0()): m1.remove(u.getT1());
		}
Ejemplo n.º 9
0
		@Override public V put(U2<K0, K1> u, V val) {
			return (u.type == 0)? m0.put(u.getT0(), val): m1.put(u.getT1(), val);
		}
Ejemplo n.º 10
0
		@Override public boolean containsValue(Object o) {
			return m0.containsValue(o) || m1.containsValue(o);
		}
Ejemplo n.º 11
0
		@Override public boolean containsKey(Object o) {
			if (!(o instanceof U2)) { return false; }
			@SuppressWarnings("unchecked") U2<K0, K1> u = (U2<K0, K1>)o;
			return u.type == 0? m0.containsKey(u.getT0()): m1.containsKey(u.getT1());
		}
Ejemplo n.º 12
0
		@Override public int size() {
			return m0.size() + m1.size();
		}