### Question:
InMemoryLeaf extends AbstractPage<K, V> { public InsertResult<K, V> insert( K key, V value, long revision ) throws IOException { int pos = findPos( key ); if ( pos < 0 ) { int index = -( pos + 1 ); InsertResult<K, V> result = replaceElement( revision, key, value, index ); return result; } if ( nbElems < btree.getPageSize() ) { Page<K, V> modifiedPage = addElement( revision, key, value, pos ); InsertResult<K, V> result = new ModifyResult<K, V>( modifiedPage, null ); result.addCopiedPage( this ); return result; } else { InsertResult<K, V> result = addAndSplit( revision, key, value, pos ); result.addCopiedPage( this ); return result; } } InMemoryLeaf( BTree<K, V> btree ); @SuppressWarnings("unchecked")  InMemoryLeaf( BTree<K, V> btree, long revision, int nbElems ); InsertResult<K, V> insert( K key, V value, long revision ); V get( K key ); @Override ValueCursor<V> getValues( K key ); boolean hasKey( K key ); @Override boolean contains( K key, V value ); TupleCursor<K, V> browse( K key, ReadTransaction<K, V> transaction, ParentPos<K, V>[] stack, int depth ); TupleCursor<K, V> browse( ReadTransaction<K, V> transaction, ParentPos<K, V>[] stack, int depth ); KeyCursor<K> browseKeys( ReadTransaction<K, K> transaction, ParentPos<K, K>[] stack, int depth ); Tuple<K, V> findLeftMost(); Tuple<K, V> findRightMost(); boolean isLeaf(); boolean isNode(); String toString(); String dumpPage( String tabs );  }### Answer:
@Test public void testFindPos() throws Exception { InMemoryLeaf<Long, String> leaf = new InMemoryLeaf<Long, String>( btree ); for ( long i = 0; i < 8; i++ ) { long value = i + i + 1; leaf = ( InMemoryLeaf<Long, String> ) ( ( ModifyResult<Long, String> ) leaf.insert( value, "V" + value, 0L ) ) .getModifiedPage(); } for ( long i = 0; i < 17; i++ ) { if ( i % 2 == 1 ) { assertEquals( -( i / 2 + 1 ), leaf.findPos( i ) ); } else { assertEquals( i / 2, leaf.findPos( i ) ); } } }