Пример #1
0
 public static void main(String[] args) throws IOException {
   OutputStream outputStream = System.out;
   in = System.in;
   out = new PrintWriter(outputStream);
   M1 a = new M1();
   a.solve();
   out.close();
 }
Пример #2
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();
		}
Пример #3
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;
			}
		}
Пример #4
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;
			}
		}
 @Override
 public <T extends M2> Collection<T> getMany(M1 one, Class<T> manySide) {
   if (manySide == M2.class) {
     return (Collection<T>) one.getBs();
   } else if (manySide == M3.class) {
     return (Collection<T>) one.getCs();
   } else if (manySide == M4.class) {
     return (Collection<T>) one.getDs();
   } else {
     throw new AssertionError();
   }
 }
Пример #6
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();
		}
Пример #7
0
  public static void main(String[] args) {
    final M1 m1 = new M1();
    m1.start();

    new Thread() {
      @Override
      public void run() {
        for (; ; ) {
          long c = m1.getCount();
          try {
            Thread.sleep(2000L);
          } catch (InterruptedException e) {
            continue;
          }
          System.out.println("tps:" + (m1.getCount() - c) / 2);
          System.out.println("  x:" + m1.getX().size());
          System.out.println("  y:" + m1.getY().size());
          System.out.println("==============");
        }
      }
    }.start();
  }
Пример #8
0
		@Override public void clear() {
			m0.clear();
			m1.clear();
		}
Пример #9
0
		@Override public X2<V0, V1> get(Object o) {
			return containsKey(o)? Tuple.X2(m0.get(o), m1.get(o)): null;
		}
Пример #10
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());
		}
Пример #11
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());
		}
Пример #12
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);
		}
Пример #13
0
		@Override public boolean containsValue(Object o) {
			return m0.containsValue(o) || m1.containsValue(o);
		}
Пример #14
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());
		}
Пример #15
0
		@Override public int size() {
			return m0.size() + m1.size();
		}