The NetBSD's constant database (cdb) library provides a space efficient key-value database based on perfect hashing, thus guaranteeing the O(1) lookup time. The database preserves the key order.