|
@@ 121-135 (lines=15) @@
|
| 118 |
|
$this->assertTrue($this->tree->empty()); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
public function testDeleteMin() { |
| 122 |
|
$this->tree->put(1, "one"); |
| 123 |
|
$this->tree->put(2, "two"); |
| 124 |
|
$this->tree->put(3, "three"); |
| 125 |
|
$this->assertEquals(1, $this->tree->deleteMin()->key); |
| 126 |
|
$this->assertEquals(2, $this->tree->size()); |
| 127 |
|
$this->assertEquals(2, $this->tree->deleteMin()->key); |
| 128 |
|
$this->assertEquals(1, $this->tree->size()); |
| 129 |
|
$this->tree->put(100, "hundred"); |
| 130 |
|
$this->assertEquals(2, $this->tree->size()); |
| 131 |
|
$this->assertEquals(3, $this->tree->deleteMin()->key); |
| 132 |
|
$this->assertEquals(1, $this->tree->size()); |
| 133 |
|
$this->assertEquals(100, $this->tree->deleteMin()->key); |
| 134 |
|
$this->assertEquals(0, $this->tree->size()); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
public function testDeleteMax() { |
| 138 |
|
$this->tree->put(1, "one"); |
|
@@ 137-151 (lines=15) @@
|
| 134 |
|
$this->assertEquals(0, $this->tree->size()); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
public function testDeleteMax() { |
| 138 |
|
$this->tree->put(1, "one"); |
| 139 |
|
$this->tree->put(2, "two"); |
| 140 |
|
$this->tree->put(3, "three"); |
| 141 |
|
$this->assertEquals(3, $this->tree->deleteMax()->key); |
| 142 |
|
$this->assertEquals(2, $this->tree->size()); |
| 143 |
|
$this->assertEquals(2, $this->tree->deleteMax()->key); |
| 144 |
|
$this->assertEquals(1, $this->tree->size()); |
| 145 |
|
$this->tree->put(100, "hundred"); |
| 146 |
|
$this->assertEquals(2, $this->tree->size()); |
| 147 |
|
$this->assertEquals(100, $this->tree->deleteMax()->key); |
| 148 |
|
$this->assertEquals(1, $this->tree->size()); |
| 149 |
|
$this->assertEquals(1, $this->tree->deleteMax()->key); |
| 150 |
|
$this->assertEquals(0, $this->tree->size()); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
public function testPreorder() { |
| 154 |
|
$this->tree->put(2, "two"); |