Package org.apache.mahout.math.set

Examples of org.apache.mahout.math.set.AbstractIntSet


  }

  @Test
  @Repeat(iterations = 20)
  public void testAgainstReferenceOpenIntHashSet() {
    AbstractIntSet base = new OpenIntHashSet();
    HashSet<Integer> reference = Sets.newHashSet();

    List<Operation> ops = Lists.newArrayList();
    addOp(ops, Operation.ADD, 60);
    addOp(ops, Operation.REMOVE, 30);
    addOp(ops, Operation.INDEXOF, 30);
    addOp(ops, Operation.CLEAR, 5);
    addOp(ops, Operation.ISEMPTY, 2);
    addOp(ops, Operation.SIZE, 2);

    int max = randomIntBetween(1000, 20000);
    for (int reps = 0; reps < max; reps++) {
      // Ensure some collisions among keys.
      int k = randomIntBetween(0, max / 4);
      switch (randomFrom(ops)) {
        case ADD:
          assertEquals(reference.add(k), base.add(k));
          break;

        case REMOVE:
          assertEquals(reference.remove(k), base.remove(k));
          break;

        case INDEXOF:
          assertEquals(reference.contains(k), base.contains(k));
          break;

        case CLEAR:
          reference.clear();
          base.clear();
          break;

        case ISEMPTY:
          assertEquals(reference.isEmpty(), base.isEmpty());
          break;

        case SIZE:
          assertEquals(reference.size(), base.size());
          break;

        default:
          throw new RuntimeException();
      }
View Full Code Here


  /**
   * @see "https://issues.apache.org/jira/browse/MAHOUT-1225"
   */
  @Test
  public void testMahout1225() {
    AbstractIntSet s = new OpenIntHashSet();
    s.clear();
    s.add(23);
    s.add(46);
    s.clear();
    s.add(70);
    s.add(93);
    s.contains(100);
  }
View Full Code Here

  }

  @Test
  @Repeat(iterations = 20)
  public void testAgainstReferenceOpenIntHashSet() {
    AbstractIntSet base = new OpenIntHashSet();
    HashSet<Integer> reference = Sets.newHashSet();

    List<Operation> ops = Lists.newArrayList();
    addOp(ops, Operation.ADD, 60);
    addOp(ops, Operation.REMOVE, 30);
    addOp(ops, Operation.INDEXOF, 30);
    addOp(ops, Operation.CLEAR, 5);
    addOp(ops, Operation.ISEMPTY, 2);
    addOp(ops, Operation.SIZE, 2);

    int max = randomIntBetween(1000, 20000);
    for (int reps = 0; reps < max; reps++) {
      // Ensure some collisions among keys.
      int k = randomIntBetween(0, max / 4);
      switch (randomFrom(ops)) {
        case ADD:
          assertEquals(reference.add(k), base.add(k));
          break;

        case REMOVE:
          assertEquals(reference.remove(k), base.remove(k));
          break;

        case INDEXOF:
          assertEquals(reference.contains(k), base.contains(k));
          break;

        case CLEAR:
          reference.clear();
          base.clear();
          break;

        case ISEMPTY:
          assertEquals(reference.isEmpty(), base.isEmpty());
          break;

        case SIZE:
          assertEquals(reference.size(), base.size());
          break;

        default:
          throw new RuntimeException();
      }
View Full Code Here

  /**
   * @see "https://issues.apache.org/jira/browse/MAHOUT-1225"
   */
  @Test
  public void testMahout1225() {
    AbstractIntSet s = new OpenIntHashSet();
    s.clear();
    s.add(23);
    s.add(46);
    s.clear();
    s.add(70);
    s.add(93);
    s.contains(100);
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.set.AbstractIntSet

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.