Java 类com.google.common.collect.Ordering.ArbitraryOrdering 实例源码

项目:guava-mock    文件:OrderingTest.java   
public void testArbitrary_withCollisions() {
  List<Integer> list = Lists.newArrayList();
  for (int i = 0; i < 50; i++) {
    list.add(i);
  }

  Ordering<Object> arbitrary = new ArbitraryOrdering() {
    @Override int identityHashCode(Object object) {
      return ((Integer) object) % 5; // fake tons of collisions!
    }
  };

  // Don't let the elements be in such a predictable order
  list = shuffledCopy(list, new Random(1));

  Collections.sort(list, arbitrary);

  // Now we don't care what order it's put the list in, only that
  // comparing any pair of elements gives the answer we expect.
  Helpers.testComparator(arbitrary, list);
}
项目:googles-monorepo-demo    文件:OrderingTest.java   
public void testArbitrary_withCollisions() {
  List<Integer> list = Lists.newArrayList();
  for (int i = 0; i < 50; i++) {
    list.add(i);
  }

  Ordering<Object> arbitrary = new ArbitraryOrdering() {
    @Override int identityHashCode(Object object) {
      return ((Integer) object) % 5; // fake tons of collisions!
    }
  };

  // Don't let the elements be in such a predictable order
  list = shuffledCopy(list, new Random(1));

  Collections.sort(list, arbitrary);

  // Now we don't care what order it's put the list in, only that
  // comparing any pair of elements gives the answer we expect.
  Helpers.testComparator(arbitrary, list);
}
项目:guava-libraries    文件:OrderingTest.java   
public void testArbitrary_withCollisions() {
  List<Integer> list = Lists.newArrayList();
  for (int i = 0; i < 50; i++) {
    list.add(i);
  }

  Ordering<Object> arbitrary = new ArbitraryOrdering() {
    @Override int identityHashCode(Object object) {
      return ((Integer) object) % 5; // fake tons of collisions!
    }
  };

  // Don't let the elements be in such a predictable order
  list = shuffledCopy(list, new Random(1));

  Collections.sort(list, arbitrary);

  // Now we don't care what order it's put the list in, only that
  // comparing any pair of elements gives the answer we expect.
  Helpers.testComparator(arbitrary, list);
}
项目:guava-libraries    文件:OrderingTest.java   
public void testArbitrary_withCollisions() {
  List<Integer> list = Lists.newArrayList();
  for (int i = 0; i < 50; i++) {
    list.add(i);
  }

  Ordering<Object> arbitrary = new ArbitraryOrdering() {
    @Override int identityHashCode(Object object) {
      return ((Integer) object) % 5; // fake tons of collisions!
    }
  };

  // Don't let the elements be in such a predictable order
  list = shuffledCopy(list, new Random(1));

  Collections.sort(list, arbitrary);

  // Now we don't care what order it's put the list in, only that
  // comparing any pair of elements gives the answer we expect.
  Helpers.testComparator(arbitrary, list);
}
项目:guava    文件:OrderingTest.java   
public void testArbitrary_withCollisions() {
  List<Integer> list = Lists.newArrayList();
  for (int i = 0; i < 50; i++) {
    list.add(i);
  }

  Ordering<Object> arbitrary =
      new ArbitraryOrdering() {
        @Override
        int identityHashCode(Object object) {
          return ((Integer) object) % 5; // fake tons of collisions!
        }
      };

  // Don't let the elements be in such a predictable order
  list = shuffledCopy(list, new Random(1));

  Collections.sort(list, arbitrary);

  // Now we don't care what order it's put the list in, only that
  // comparing any pair of elements gives the answer we expect.
  Helpers.testComparator(arbitrary, list);
}
项目:guava    文件:OrderingTest.java   
public void testArbitrary_withCollisions() {
  List<Integer> list = Lists.newArrayList();
  for (int i = 0; i < 50; i++) {
    list.add(i);
  }

  Ordering<Object> arbitrary =
      new ArbitraryOrdering() {
        @Override
        int identityHashCode(Object object) {
          return ((Integer) object) % 5; // fake tons of collisions!
        }
      };

  // Don't let the elements be in such a predictable order
  list = shuffledCopy(list, new Random(1));

  Collections.sort(list, arbitrary);

  // Now we don't care what order it's put the list in, only that
  // comparing any pair of elements gives the answer we expect.
  Helpers.testComparator(arbitrary, list);
}