Package it.unimi.dsi.fastutil.ints

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


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

    assertEquals(0, m1.size());

    Int2FloatMap m2 = Int2FloatOpenHashMapWritable.create(m1.serialize());

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


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

    Int2FloatMap map = new Int2FloatOpenHashMapWritable();
    for (int i = 0; i < size; i++) {
      float k = r.nextFloat() * size;
      map.put(i, k);
      floats[i] = k;
    }

    for (int i = 0; i < size; i++) {
      assertEquals(floats[i], map.get(i), 10e-6);
      assertTrue(map.containsKey(i));
    }

  }
View Full Code Here

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

    Int2FloatMap map = new Int2FloatOpenHashMapWritable();
    for (int i = 0; i < size; i++) {
      float k = r.nextFloat() * size;
      map.put(i, k);
      floats[i] = k;
    }

    assertEquals(size, map.size());

    for (int i = 0; i < size; i++) {
      map.put(i, floats[i] + 1.0f);
    }

    assertEquals(size, map.size());

    for (int i = 0; i < size; i++) {
      assertEquals(floats[i] + 1.0f, map.get(i), 10e-6);
      assertTrue(map.containsKey(i));
    }

  }
View Full Code Here

TOP

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

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.