/** * @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; }
/** 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); }
/** 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(); }