Skip to content

Commit

Permalink
Remove now-conflicting __generic member
Browse files Browse the repository at this point in the history
Left-over from first generic implementation, see xp-framework/rfc#193,
which was dropped around three years ago and removed back in Nov 2013
  • Loading branch information
thekid committed Aug 13, 2014
1 parent 0fb21bc commit 0481e68
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 30 deletions.
13 changes: 4 additions & 9 deletions src/main/php/util/collections/HashSet.class.php
Expand Up @@ -203,11 +203,7 @@ public function hashCode() {
* @return bool
*/
public function equals($cmp) {
return (
$cmp instanceof self &&
$this->__generic === $cmp->__generic &&
$this->_hash === $cmp->_hash
);
return $cmp instanceof self && $this->_hash === $cmp->_hash;
}

/**
Expand All @@ -217,13 +213,12 @@ public function equals($cmp) {
*/
public function toString() {
$s= $this->getClassName().'['.sizeof($this->_elements).'] {';
if (0 == sizeof($this->_elements)) return $s.' }';
if (empty($this->_elements)) return $s.' }';

$s.= "\n";
foreach (array_keys($this->_elements) as $key) {
$s.= ' '.\xp::stringOf($this->_elements[$key]).",\n";
foreach ($this->_elements as $e) {
$s.= ' '.\xp::stringOf($e).",\n";
}
return substr($s, 0, -2)."\n}";
}

}
12 changes: 4 additions & 8 deletions src/main/php/util/collections/HashTable.class.php
Expand Up @@ -222,11 +222,7 @@ public function hashCode() {
* @return bool
*/
public function equals($cmp) {
return (
$cmp instanceof self &&
$this->__generic === $cmp->__generic &&
$this->_hash === $cmp->_hash
);
return $cmp instanceof self && $this->_hash === $cmp->_hash;
}

/**
Expand Down Expand Up @@ -264,11 +260,11 @@ public function values() {
*/
public function toString() {
$s= $this->getClassName().'['.sizeof($this->_buckets).'] {';
if (0 == sizeof($this->_buckets)) return $s.' }';
if (empty($this->_buckets)) return $s.' }';

$s.= "\n";
foreach (array_keys($this->_buckets) as $key) {
$s.= ' '.\xp::stringOf($this->_buckets[$key][0]).' => '.\xp::stringOf($this->_buckets[$key][1]).",\n";
foreach ($this->_buckets as $b) {
$s.= ' '.\xp::stringOf($b[0]).' => '.\xp::stringOf($b[1]).",\n";
}
return substr($s, 0, -2)."\n}";
}
Expand Down
6 changes: 1 addition & 5 deletions src/main/php/util/collections/Queue.class.php
Expand Up @@ -163,10 +163,6 @@ public function hashCode() {
* @return bool
*/
public function equals($cmp) {
return (
$cmp instanceof self &&
$this->__generic === $cmp->__generic &&
$this->_hash === $cmp->_hash
);
return $cmp instanceof self && $this->_hash === $cmp->_hash;
}
}
6 changes: 1 addition & 5 deletions src/main/php/util/collections/Stack.class.php
Expand Up @@ -144,10 +144,6 @@ public function hashCode() {
* @return bool
*/
public function equals($cmp) {
return (
$cmp instanceof self &&
$this->__generic === $cmp->__generic &&
$this->_hash === $cmp->_hash
);
return $cmp instanceof self && $this->_hash === $cmp->_hash;
}
}
6 changes: 3 additions & 3 deletions src/main/php/util/collections/Vector.class.php
Expand Up @@ -272,8 +272,8 @@ public function lastIndexOf(\lang\Generic $element) {
*/
public function toString() {
$r= $this->getClassName().'['.$this->size."]@{\n";
for ($i= 0; $i < $this->size; $i++) {
$r.= ' '.$i.': '.\xp::stringOf($this->elements[$i], ' ')."\n";
foreach ($this->elements as $e) {
$r.= ' '.$i.': '.\xp::stringOf($e, ' ')."\n";
}
return $r.'}';
}
Expand All @@ -285,7 +285,7 @@ public function toString() {
* @return bool
*/
public function equals($cmp) {
if (!($cmp instanceof self) || $this->size !== $cmp->size || $this->__generic !== $cmp->__generic) return false;
if (!($cmp instanceof self) || $this->size !== $cmp->size) return false;

// Compare element by element
for ($i= 0; $i < $this->size; $i++) {
Expand Down

0 comments on commit 0481e68

Please sign in to comment.