示例#1
0
  /**
   * @return an iterator over all tuples on this page (calling remove on this iterator throws an
   *     UnsupportedOperationException) (note that this iterator shouldn't return tuples in empty
   *     slots!)
   */
  public Iterator<Tuple> iterator() {
    // hdj
    final BitSet bitset = BitSet.valueOf(header);
    Iterator<Tuple> it =
        new Iterator<Tuple>() {
          int currentIndex = -1;

          public boolean hasNext() {
            if (bitset.nextSetBit(currentIndex + 1) == -1) return false;
            else return true;
          }

          public Tuple next() {
            currentIndex = bitset.nextSetBit(currentIndex + 1);
            return tuples[currentIndex];
          }

          public void remove() {
            throw new UnsupportedOperationException();
          }
        };

    return it;
  }
示例#2
0
 /** Returns true if associated slot on this page is filled. */
 public boolean isSlotUsed(int i) {
   // hdj
   BitSet bitset = BitSet.valueOf(header);
   return bitset.get(i);
 }
示例#3
0
 /** Returns the number of empty slots on this page. */
 public int getNumEmptySlots() {
   // hdj:!!! use getNumTuples instead of bitset.size() or bitset.length()
   BitSet bitset = BitSet.valueOf(header);
   return getNumTuples() - bitset.cardinality();
 }