/** * Makes a persistently stored (i.e., on disk and ram) hash table using the * supplied parameters * * @param string $fname filename to use when storing the hash table to disk * @param int $num_values number of key value pairs the table can hold * @param int $key_size number of bytes to store a hash table key * @param int $value_size number of bytes to store a hash table value * @param int $save_frequency how many non read operation before saving to * disk */ function __construct($fname, $num_values, $key_size, $value_size, $save_frequency = self::DEFAULT_SAVE_FREQUENCY) { $this->key_size = $key_size; $this->value_size = $value_size; $this->null = pack("x" . $this->key_size); $this->deleted = pack("H2x" . ($this->key_size - 1), "FF"); $this->count = 0; parent::__construct($fname, $num_values, $key_size + $value_size, $save_frequency); }
/** * Makes a priority queue (implemented as an array heap) with the given * operating parameters * * @param string $fname filename to store the data associated with the queue * @param int $num_values number of values the queue can hold * @param int $value_size the size in a bytes of a value * @param string $min_or_max whether this priority queue return least or * most weight values when polled * @param object $notifier object to call when a value changes in the queue * @param int $save_frequency how often the data in the queue should be * save to disk. (It's default location is RAM) */ function __construct($fname, $num_values, $value_size, $min_or_max, $notifier = NULL, $save_frequency = self::DEFAULT_SAVE_FREQUENCY) { $this->num_values = $num_values; $this->value_size = $value_size; $this->min_or_max = $min_or_max; $this->count = 0; $this->notifier = $notifier; parent::__construct($fname, $num_values, $value_size + $this->weight_size, $save_frequency); }