Package edu.umd.cloud9.io.pair

Examples of edu.umd.cloud9.io.pair.PairOfIntLong


  public PairOfIntLong getStats(String term) {
    int index = prefixSet.getId(term);
    LOG.info("index of " + term + ": " + index);
    if (index < 0)
      return null;
    PairOfIntLong p = new PairOfIntLong();
    p.set(df[index], cf[index]);
    return p;
  }
View Full Code Here


  }
 
  public PairOfIntLong getStats(int index) {
    if (index < 0)
      return null;
    PairOfIntLong p = new PairOfIntLong();
    p.set(df[index], cf[index]);
    return p;
  }
View Full Code Here

public class PairOfIntLongTest {

  @Test
  public void testBasic() throws IOException {
    PairOfIntLong pair = new PairOfIntLong(1, 2L);

    assertEquals(1L, pair.getLeftElement());
    assertEquals(2L, pair.getRightElement());
  }
View Full Code Here

    assertEquals(2L, pair.getRightElement());
  }

  @Test
  public void testSerialize() throws IOException {
    PairOfIntLong origPair = new PairOfIntLong(1, 2L);

    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    DataOutputStream dataOut = new DataOutputStream(bytesOut);

    origPair.write(dataOut);

    PairOfIntLong pair = new PairOfIntLong();

    pair.readFields(new DataInputStream(new ByteArrayInputStream(bytesOut.toByteArray())));

    assertEquals(1L, pair.getLeftElement());
    assertEquals(2L, pair.getRightElement());
  }
View Full Code Here

    assertEquals(2L, pair.getRightElement());
  }

  @Test
  public void testComparison1() throws IOException {
    PairOfIntLong pair1 = new PairOfIntLong(1, 2L);
    PairOfIntLong pair2 = new PairOfIntLong(1, 2L);
    PairOfIntLong pair3 = new PairOfIntLong(1, 1L);
    PairOfIntLong pair4 = new PairOfIntLong(0, 9L);
    PairOfIntLong pair5 = new PairOfIntLong(9, 0L);

    assertTrue(pair1.equals(pair2));
    assertFalse(pair1.equals(pair3));

    assertTrue(pair1.compareTo(pair2) == 0);
View Full Code Here

  @Test
  public void testComparison2() throws IOException {
    WritableComparator comparator = new PairOfIntLong.Comparator();

    PairOfIntLong pair1 = new PairOfIntLong(1, 2L);
    PairOfIntLong pair2 = new PairOfIntLong(1, 2L);
    PairOfIntLong pair3 = new PairOfIntLong(1, 1L);
    PairOfIntLong pair4 = new PairOfIntLong(0, 9L);
    PairOfIntLong pair5 = new PairOfIntLong(9, 0L);

    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair2) == 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair3) > 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair4) > 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair5) < 0);
View Full Code Here

    }

    assertEquals(6, list.size());

    Iterator<PairOfIntLong> iter = list.iterator();
    PairOfIntLong e = iter.next();
    assertEquals(1, e.getLeftElement());
    assertEquals(1, e.getRightElement());
    e = iter.next();
    assertEquals(2, e.getLeftElement());
    assertEquals(4, e.getRightElement());
    e = iter.next();
    assertEquals(3, e.getLeftElement());
    assertEquals(2, e.getRightElement());
    e = iter.next();
    assertEquals(4, e.getLeftElement());
    assertEquals(3, e.getRightElement());
    e = iter.next();
    assertEquals(5, e.getLeftElement());
    assertEquals(7, e.getRightElement());
    e = iter.next();
    assertEquals(6, e.getLeftElement());
    assertEquals(9, e.getRightElement());
  }
View Full Code Here

   */
  public Iterator<PairOfIntLong> iterator() {
    return new Iterator<PairOfIntLong>() {
      private Iterator<MapIL.Entry> iter =
        Int2LongFrequencyDistributionEntry.this.counts.entrySet().iterator();
      private final PairOfIntLong pair = new PairOfIntLong();

      @Override
      public boolean hasNext() {
        return iter.hasNext();
      }

      @Override
      public PairOfIntLong next() {
        if (!hasNext()) {
          return null;
        }

        MapIL.Entry entry = iter.next();
        pair.set(entry.getKey(), entry.getValue());
        return pair;
      }

      @Override
      public void remove() {
View Full Code Here

  private List<PairOfIntLong> getEntriesSorted(Comparator<PairOfIntLong> comparator) {
    List<PairOfIntLong> list = Lists.newArrayList();

    for (MapIL.Entry e : counts.entrySet()) {
      list.add(new PairOfIntLong(e.getKey(), e.getValue()));
    }

    Collections.sort(list, comparator);
    return list;
  }
View Full Code Here

   */
  public Iterator<PairOfIntLong> iterator() {
    return new Iterator<PairOfIntLong>() {
      private Iterator<Int2LongMap.Entry> iter =
        Int2LongFrequencyDistributionFastutil.this.counts.int2LongEntrySet().iterator();
      private final PairOfIntLong pair = new PairOfIntLong();

      @Override
      public boolean hasNext() {
        return iter.hasNext();
      }

      @Override
      public PairOfIntLong next() {
        if (!hasNext()) {
          return null;
        }

        Int2LongMap.Entry entry = iter.next();
        pair.set(entry.getIntKey(), entry.getLongValue());
        return pair;
      }

      @Override
      public void remove() {
View Full Code Here

TOP

Related Classes of edu.umd.cloud9.io.pair.PairOfIntLong

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.