mirror of
https://github.com/bdelespierre/php-kmeans.git
synced 2025-01-17 04:28:18 +01:00
PHP 5.3 compatibility.
This commit is contained in:
parent
6a2a38f64f
commit
3dc32e4ef4
@ -44,14 +44,14 @@ class Cluster extends Point implements IteratorAggregate, Countable
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
$points = [];
|
||||
$points = array();
|
||||
foreach ($this->points as $point)
|
||||
$points[] = $point->toArray();
|
||||
|
||||
return [
|
||||
return array(
|
||||
'centroid' => parent::toArray(),
|
||||
'points' => $points,
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
public function attach(Point $point)
|
||||
@ -103,4 +103,4 @@ class Cluster extends Point implements IteratorAggregate, Countable
|
||||
{
|
||||
return count($this->points);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ class Point implements ArrayAccess
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
return array(
|
||||
'coordinates' => $this->coordinates,
|
||||
'data' => isset($this->space[$this]) ? $this->space[$this] : null,
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
public function getDistanceWith(self $point)
|
||||
@ -117,4 +117,4 @@ class Point implements ArrayAccess
|
||||
{
|
||||
unset($this->coordinates[$offset]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ class Space extends SplObjectStorage
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
$points = [];
|
||||
$points = array();
|
||||
foreach ($this as $point)
|
||||
$points[] = $point->toArray();
|
||||
|
||||
return ['points' => $points];
|
||||
return array('points' => $points);
|
||||
}
|
||||
|
||||
public function newPoint(array $coordinates)
|
||||
@ -98,7 +98,7 @@ class Space extends SplObjectStorage
|
||||
}
|
||||
}
|
||||
|
||||
return [$min, $max];
|
||||
return array($min, $max);
|
||||
}
|
||||
|
||||
public function getRandomPoint(Point $min, Point $max)
|
||||
@ -229,4 +229,4 @@ class Space extends SplObjectStorage
|
||||
|
||||
return $continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user