Esempio n. 1
0
    $testPriorityQueuePass = new Types\PriorityQueue(array($testPriority0, 'huh?'));
    $fail = false;
} catch (\Exception $e) {
}
if ($fail) {
    echo "Failure!\n";
} else {
    echo "Success...\n";
}
echo "Instantiate and Pass (Data) with Custom Restrictions -> ";
$success = true;
$testPriorityQueueRestrictions = $testRestrictions = $testStack = null;
try {
    $testStack = new Types\Stack();
    $testRestrictions = new Types\Restrictions(array(Type::TYPED_OBJECT), array('Falcraft\\Data\\Types\\Stack'));
    $testPriorityQueueRestrictions = new Types\PriorityQueue(array(), $testRestrictions, array('strict' => true));
    $testPriorityQueueRestrictions->push($testStack);
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n";
} else {
    echo "Failure...\n";
}
echo "Priority Queue Operations -- \n\n";
echo "    Population -> ";
$success = true;
try {
    $testPriorityQueue->push(new Types\Priority('towel', 7), new Types\Priority('gas mask', 50), new Types\Priority('cooler', 2));
} catch (\Exception $e) {
Esempio n. 2
0
 /**
  * The Handler Priority Queue Constructor
  * 
  * This takes an array of Handlers, which is enforced by the restrictions
  * and puts them in a sorted priority queue.  This is why the handler
  * class is inherited from the priority class.
  * 
  * @param array $data An array of handler objects
  * @param array $options Options to pass on to the priority queue
  * 
  */
 public function __construct($data = null, array $options = array())
 {
     if (is_array($options)) {
         $options = array_change_key_case($options);
     }
     $options = array_merge(array('strict' => true), $options);
     $this->configure($options);
     $setRestrictions = new Types\Restrictions(array(Type::BASIC_NULL, Type::TYPED_OBJECT), array('Falcraft\\Patterns\\Resource\\PublisherInterface'), array('strict' => $this->conf->strict));
     $this->subject = new Types\RestrictedSet(array(), $setRestrictions, array('strict' => $this->conf->strict));
     $queueRestrictions = new Types\Restrictions(array(Type::TYPED_OBJECT), array('Falcraft\\Event\\Handler'), array('strict' => $this->conf->strict));
     parent::__construct($data, $queueRestrictions, $options);
 }