コード例 #1
0
 public void testHashcodeUsedAsIndex() {
   HashedTripleBunch htb = new HTB(emptyBunch);
   int limit = htb.currentCapacity();
   for (int i = 0; i < limit; i += 1) {
     TripleWithHash t = TripleWithHash.create(i, "s p o");
     htb.add(t);
     assertSame(t, htb.getItemForTestingAt(i));
   }
 }
コード例 #2
0
 private void testRemovePerformsShift(int most, int capacity) {
   int next = most - 1;
   if (next < 0) next += capacity;
   int least = most - 2;
   if (least < 0) least += capacity;
   TripleWithHash t1 = TripleWithHash.create(most, "s p o");
   TripleWithHash t2 = TripleWithHash.create(next, "a b c");
   TripleWithHash t3 = TripleWithHash.create(most, "x y z");
   htb.add(t1);
   htb.add(t2);
   htb.add(t3);
   assertSame(t1, htb.getItemForTestingAt(most));
   assertSame(t2, htb.getItemForTestingAt(next));
   assertSame(t3, htb.getItemForTestingAt(least));
   //
   htb.remove(t1);
   assertSame(t3, htb.getItemForTestingAt(most));
   assertSame(t2, htb.getItemForTestingAt(next));
   assertSame(null, htb.getItemForTestingAt(least));
 }