Passed
Push — master ( d0ebb7...0d8755 )
by Rudi
03:39
created

Deque   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 13
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldIncreaseCapacity() 0 4 1
1
<?php
2
namespace Ds;
3
4
/**
5
 * A Deque (pronounced "deck") is a sequence of values in a contiguous buffer
6
 * that grows and shrinks automatically. The name is a common abbreviation of
7
 * "double-ended queue".
8
 *
9
 * While a Deque is very similar to a Vector, it offers constant time operations
10
 * at both ends of the buffer, ie. shift, unshift, push and pop are all O(1).
11
 *
12
 * @package Ds
13
 */
14
final class Deque implements Sequence
15
{
16
    use Traits\GenericCollection;
17
    use Traits\GenericSequence;
18
    use Traits\SquaredCapacity;
19
20
    const MIN_CAPACITY = 8;
21
22
    protected function shouldIncreaseCapacity(): bool
23
    {
24
        return count($this) >= $this->capacity;
25
    }
26
}
27