-
-
Save arnaud-lb/ef1ef37d3c981015b722089b7652bff5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'DateTimeMap.php'; | |
for ($i = 0; $i < 100; $i++) { | |
$map = new DateTimeMap(); | |
for ($j = 0; $j < 100; $j++) { | |
$map->set($j, new DateTime()); | |
$map->get($j); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'GenericMap.php'; | |
for ($i = 0; $i < 100; $i++) { | |
$map = new GenericMap<DateTime>(); | |
for ($j = 0; $j < 100; $j++) { | |
$map->set($j, new DateTime()); | |
$map->get($j); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'UntypedMap.php'; | |
for ($i = 0; $i < 100; $i++) { | |
$map = new UntypedMap(); | |
for ($j = 0; $j < 100; $j++) { | |
$map->set($j, new DateTime()); | |
$map->get($j); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use DateTime; | |
final class DateTimeMap | |
{ | |
private array $elems; | |
public function __construct() | |
{ | |
$this->elems = []; | |
} | |
public function get(string $key): DateTime | |
{ | |
return $this->elems[$key]; | |
} | |
public function set(string $key, DateTime $value): void | |
{ | |
$this->elems[$key] = $value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
final class GenericMap<T> | |
{ | |
private array $elems; | |
public function __construct() | |
{ | |
$this->elems = []; | |
} | |
public function get(string $key): T | |
{ | |
return $this->elems[$key]; | |
} | |
public function set(string $key, T $value): void | |
{ | |
$this->elems[$key] = $value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
final class UntypedMap | |
{ | |
private array $elems; | |
public function __construct() | |
{ | |
$this->elems = []; | |
} | |
public function get(string $key) | |
{ | |
return $this->elems[$key]; | |
} | |
public function set(string $key, $value): void | |
{ | |
$this->elems[$key] = $value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment