Package it.unimi.dsi.fastutil.ints

Examples of it.unimi.dsi.fastutil.ints.Int2IntMap


    // make sure this does nothing
    m1.decode();

    assertEquals(0, m1.size());

    Int2IntMap m2 = Int2IntOpenHashMapWritable.create(m1.serialize());

    assertEquals(0, m2.size());
  }
View Full Code Here


  public void testBasic1() {
    int size = 100000;
    Random r = new Random();
    int[] ints = new int[size];

    Int2IntMap map = new Int2IntOpenHashMapWritable();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(size);
      map.put(i, k);
      ints[i] = k;
    }

    for (int i = 0; i < size; i++) {
      assertEquals(ints[i], map.get(i));
      assertTrue(map.containsKey(i));
    }
  }
View Full Code Here

  public void testUpdate() {
    int size = 100000;
    Random r = new Random();
    int[] ints = new int[size];

    Int2IntMap map = new Int2IntOpenHashMapWritable();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(size);
      map.put(i, k);
      ints[i] = k;
    }

    assertEquals(size, map.size());

    for (int i = 0; i < size; i++) {
      map.put(i, ints[i] + 1);
    }

    assertEquals(size, map.size());

    for (int i = 0; i < size; i++) {
      assertEquals(ints[i] + 1, map.get(i));
      assertTrue(map.containsKey(i));
    }
  }
View Full Code Here

     * @param uidx User index.
     * @param iidx Item index.
     * @param idx  Global index.
     */
    public void putIndex(int uidx, int iidx, int idx) {
        Int2IntMap imap = null;
        while (uidx >= mapping.size()) {
            imap = new Int2IntOpenHashMap();
            imap.defaultReturnValue(-1);
            mapping.add(imap);
        }
        if (imap == null) {
            imap = mapping.get(uidx);
        }
        imap.put(iidx, idx);
    }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.ints.Int2IntMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.