/** * Compares the specified object with this set for equality. * * For the time being, this just checks the hashcodes to make sure they are equivalent */ public function equals(Object $o) { if ($o instanceof AbstractSet) { if ($o->hashCode() == $this->hashCode()) { return true; } } return false; }
/** * Compares the specified object with this map for equality. */ public function equals(Object $o) { if ($o instanceof AbstractCollection) { foreach ($this->map as $key => $value) { if (!$o->containsKey($key) || !$o->containsValue($value)) { return false; } } return true; } return false; }
/** * Compares the specified object with this list for equality. Returns * <tt>true</tt> if and only if the specified object is also a list, both * lists have the same size, and all corresponding pairs of elements in * the two lists are <i>equal</i>. (Two elements <tt>e1</tt> and * <tt>e2</tt> are <i>equal</i> if <tt>(e1==null ? e2==null : * e1.equals(e2))</tt>.) In other words, two lists are defined to be * equal if they contain the same elements in the same order.<p> * * This implementation first checks if the specified object is this * list. If so, it returns <tt>true</tt>; if not, it checks if the * specified object is a list. If not, it returns <tt>false</tt>; if so, * it iterates over both lists, comparing corresponding pairs of elements. * If any comparison returns <tt>false</tt>, this method returns * <tt>false</tt>. If either iterator runs out of elements before the * other it returns <tt>false</tt> (as the lists are of unequal length); * otherwise it returns <tt>true</tt> when the iterations complete. * * @param object The object to be compared for equality with this list. * @return boolean <tt>true</tt> if the specified object is equal to this list. * @access public */ public function equals(Object $object) { if (!$object instanceof AbstractList) { return false; } if ($object->size() != $this->size()) { return false; } for ($i = 0; $i < $this->size(); $i++) { if ($object->list[$i] != $this->list[$i]) { return false; } } return true; }
/** * Compares two dates for equality. * * Compares the toString() quanitity for each object */ public function equals(Object $obj) { if ($obj->toString() == $this->toString()) { return true; } return false; }
public function isInstance(Object $obj) { $className = $obj->getClass()->getName(); if (is_string($this->_class)) { return is_subclass_of($obj, get_parent_class($this->_class)); } if ($inst instanceof $className) { return true; } return false; }
/** * Removes the first occurrence of the specified element in this list. */ public function remove1(Object $o) { if ($o == null) { for ($e = $this->header->next; $e != $this->header; $e = $e->next) { if ($e->element == null) { $this->remove($e); return true; } } } else { for ($e = $this->header->next; $e != $this->header; $e = $e->next) { if ($o->equals($e->element)) { $this->remove($e); return true; } } } return false; }