Package org.apache.lucene.util.collections

Examples of org.apache.lucene.util.collections.IntHashSet$IndexIterator


  }

  @Test
  public void test2() {
    IntHashSet set0 = new IntHashSet();

    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());
    for (int i = 0; i < 1000; ++i) {
      set0.add(1);
      set0.add(-382);
    }
    assertEquals(2, set0.size());
    assertFalse(set0.isEmpty());
    set0.remove(-382);
    set0.remove(1);
    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());

  }
View Full Code Here


  }

  @Test
  public void test3() {
    IntHashSet set0 = new IntHashSet();

    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());
    for (int i = 0; i < 1000; ++i) {
      set0.add(i);
    }

    for (int i = 0; i < 1000; i += 2) {
      set0.remove(i);
    }

    assertEquals(500, set0.size());
    for (int i = 0; i < 1000; ++i) {
      if (i % 2 == 0) {
        assertFalse(set0.contains(i));
      } else {
        assertTrue(set0.contains(i));
      }
    }

  }
View Full Code Here

  }

  @Test
  public void test4() {
    IntHashSet set1 = new IntHashSet();
    HashSet<Integer> set2 = new HashSet<Integer>();
    for (int i = 0; i < ArrayHashMapTest.RANDOM_TEST_NUM_ITERATIONS; ++i) {
      int value = random.nextInt() % 500;
      boolean shouldAdd = random.nextBoolean();
      if (shouldAdd) {
        set1.add(value);
        set2.add(value);
      } else {
        set1.remove(value);
        set2.remove(value);
      }
    }
    assertEquals(set2.size(), set1.size());
    for (int value : set2) {
      assertTrue(set1.contains(value));
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testMySet() {
    IntHashSet set = new IntHashSet();
    for (int j = 0; j < 100; ++j) {
      for (int i = 0; i < ArrayHashMapTest.RANDOM_TEST_NUM_ITERATIONS; ++i) {
        int value = random.nextInt() % 5000;
        boolean shouldAdd = random.nextBoolean();
        if (shouldAdd) {
          set.add(value);
        } else {
          set.remove(value);
        }
      }
      set.clear();
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testToArray() {
    IntHashSet set = new IntHashSet();
    for (int j = 0; j < 100; ++j) {
      for (int i = 0; i < ArrayHashMapTest.RANDOM_TEST_NUM_ITERATIONS; ++i) {
        int value = random.nextInt() % 5000;
        boolean shouldAdd = random.nextBoolean();
        if (shouldAdd) {
          set.add(value);
        } else {
          set.remove(value);
        }
      }
      int[] vals = set.toArray();
      assertEquals(set.size(), vals.length);

      int[] realValues = new int[set.size()];
      int[] unrealValues = set.toArray(realValues);
      assertEquals(realValues, unrealValues);
      for (int value : vals) {
        assertTrue(set.remove(value));
      }
      for (int i = 0; i < vals.length; ++i) {
        assertEquals(vals[i], realValues[i]);
      }
    }
View Full Code Here

    }
  }

  @Test
  public void testZZMySet() {
    IntHashSet set = new IntHashSet();
    for (int j = 0; j < 100; ++j) {
      for (int i = 0; i < ArrayHashMapTest.RANDOM_TEST_NUM_ITERATIONS; ++i) {
        int value = random.nextInt() % 5000;
        boolean shouldAdd = random.nextBoolean();
        if (shouldAdd) {
          set.add(value);
        } else {
          set.remove(value);
        }
      }
      set.clear();
    }
  }
View Full Code Here

                                  ? section.getRange(rangeIdx++)
                                  : new Range(0, 0);
        Range         yRange    = section.getRange(rangeIdx++);
        Range         xRange    = section.getRange(rangeIdx);

        IndexIterator ii        = dataArray.getIndexIterator();

        // loop over ens
        for (int ensIdx = ensRange.first(); ensIdx <= ensRange.last();
                ensIdx += ensRange.stride()) {
            //loop over time
View Full Code Here

              ? 1
              : nk); k++) {
            origin[0] = i;
            origin[1] = j;
            origin[2] = k;
            IndexIterator it = array.section(origin,
                eshape).getIndexIterator();
            for (int l = 0; l < n; l++) {
              d[l] = it.getDoubleNext()//get the original values
            }
            double[] d2 = extrapinterpolate(d)//compute new values
            //define slice of new array to write into
            IndexIterator newit =
                newArray.section(origin,
                    neweshape).getIndexIterator();
            for (int l = 0; l < n + 1; l++) {
              newit.setDoubleNext(d2[l]);
            }
          }
        }
      }
    } catch (InvalidRangeException e) {
View Full Code Here

  static public void compareData(Array data1, Array data2) {
    assert data1.getSize() == data2.getSize();
    assert data1.getElementType() == data2.getElementType() : data1.getElementType()+"!="+ data2.getElementType();
    DataType dt = DataType.getType( data1.getElementType());

    IndexIterator iter1 = data1.getIndexIterator();
    IndexIterator iter2 = data2.getIndexIterator();

    if (dt == DataType.DOUBLE) {
      while (iter1.hasNext()) {
          double v1 = iter1.getDoubleNext();
          double v2 = iter2.getDoubleNext();
          if (!Double.isNaN(v1) || !Double.isNaN(v2))
            assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
      }
    }

    else if (dt == DataType.FLOAT) {
      while (iter1.hasNext()) {
          float v1 = iter1.getFloatNext();
          float v2 = iter2.getFloatNext();
          if (!Float.isNaN(v1) || !Float.isNaN(v2))
            assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
      }
    }

    else if (dt == DataType.INT) {
      while (iter1.hasNext()) {
          int v1 = iter1.getIntNext();
          int v2 = iter2.getIntNext();
          assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
      }
    }

    else if (dt == DataType.SHORT) {
      while (iter1.hasNext()) {
          short v1 = iter1.getShortNext();
          short v2 = iter2.getShortNext();
          assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
      }
    }

    else if (dt == DataType.BYTE) {
      while (iter1.hasNext()) {
          byte v1 = iter1.getByteNext();
          byte v2 = iter2.getByteNext();
          assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
      }
    }
  }
View Full Code Here

     // Range scanRange = section.getRange(0);
     // Range radialRange = section.getRange(1);
     // Range gateRange = section.getRange(2);

      Array data = Array.factory(v2.getDataType().getPrimitiveClassType(), section.getShape());
      IndexIterator ii = data.getIndexIterator();

      List groups = null;
      String shortName = v2.getShortName();
      if( shortName.startsWith("Reflectivity"))
        groups = volScan.getReflectivityGroups();
View Full Code Here

TOP

Related Classes of org.apache.lucene.util.collections.IntHashSet$IndexIterator

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.