/** * Compares already saved nodes with new node, in order to find duplicates. * Returns true if duplicate was found. * * @param HeaderNode $node New node * * @return bool Returns true if duplicate was found. */ protected function isUnique(HeaderNode $node) { $checksum = $node->getChecksum(); foreach ($this->nodes as $node) { if ($node->getChecksum() === $checksum) { return false; } } return true; }
/** * Compares two header nodes concerning their priority. * * @param HeaderNode $a The first node. * @param HeaderNode $b The second node. * * @return int The comparison result. * * @author Christian Achatz * @version * Version 0.1, 10.05.2011<br /> */ private function compare(HeaderNode $a, HeaderNode $b) { if ($a->getPriority() == $b->getPriority()) { return $a->getPriority() == 0 ? 0 : 1; // sort equals again to preserve order! } return $a->getPriority() > $b->getPriority() ? -1 : 1; }