1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace drupol\phpartition; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Interface PartitionAlgorithmInterface. |
7
|
|
|
* |
8
|
|
|
* @package drupol\phpartition |
9
|
|
|
*/ |
10
|
|
|
interface PartitionAlgorithmInterface |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Set the number of partition to use. |
15
|
|
|
* |
16
|
|
|
* @param int $size |
17
|
|
|
* The number of partition. |
18
|
|
|
*/ |
19
|
|
|
public function setSize($size); |
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Get the size, the number of partition to use. |
23
|
|
|
* |
24
|
|
|
* @return int |
25
|
|
|
* The number of partition. |
26
|
|
|
*/ |
27
|
|
|
public function getSize(); |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Get the partition container object. |
31
|
|
|
* |
32
|
|
|
* @return PartitionContainer |
33
|
|
|
* The partition container object. |
34
|
|
|
*/ |
35
|
|
|
public function getPartitionContainer(); |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Set the original data. |
39
|
|
|
* |
40
|
|
|
* @param mixed[] $data |
41
|
|
|
* The original data. |
42
|
|
|
*/ |
43
|
|
|
public function setData(array $data = array()); |
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Get the original data. |
47
|
|
|
* |
48
|
|
|
* @return mixed[] |
49
|
|
|
* The original data. |
50
|
|
|
*/ |
51
|
|
|
public function getData(); |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get the result as array chunks. |
55
|
|
|
* |
56
|
|
|
* @return array |
57
|
|
|
* The result array. |
58
|
|
|
*/ |
59
|
|
|
public function getResult(); |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Set the function used to compute the value of an item. |
63
|
|
|
* |
64
|
|
|
* @param callable $callable |
|
|
|
|
65
|
|
|
* The function. |
66
|
|
|
*/ |
67
|
|
|
public function setItemAccessCallback(callable $callable = null); |
|
|
|
|
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get the function used to compute the value of an item. |
71
|
|
|
* |
72
|
|
|
* @return callable |
73
|
|
|
* The function. |
74
|
|
|
*/ |
75
|
|
|
public function getItemAccessCallback(); |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Get the weight of a partition. |
79
|
|
|
* |
80
|
|
|
* @param \drupol\phpartition\Partition $partition |
81
|
|
|
* The partition to get the weight from. |
82
|
|
|
* |
83
|
|
|
* @return int|float |
84
|
|
|
* The weight. |
85
|
|
|
*/ |
86
|
|
|
public function getPartitionWeight(Partition $partition); |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Get the original set of data as a partition. |
90
|
|
|
* |
91
|
|
|
* @return Partition |
92
|
|
|
* A single partition containing the original items. |
93
|
|
|
*/ |
94
|
|
|
public function getDataPartition(); |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Set the original set of data partition. |
98
|
|
|
* |
99
|
|
|
* @param Partition $partition |
100
|
|
|
* The partition. |
101
|
|
|
*/ |
102
|
|
|
public function setDataPartition(Partition $partition); |
|
|
|
|
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Generate the original data partition. |
106
|
|
|
* |
107
|
|
|
* @param mixed[] $items |
108
|
|
|
* The original items. |
109
|
|
|
* |
110
|
|
|
* @return Partition |
111
|
|
|
* The partition. |
112
|
|
|
*/ |
113
|
|
|
public function generateDataPartition(array $items = array()); |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Create and return a new partition, ready to use. |
117
|
|
|
* |
118
|
|
|
* @return Partition |
119
|
|
|
* A new partition. |
120
|
|
|
*/ |
121
|
|
|
public function getPartition(); |
122
|
|
|
} |
123
|
|
|
|
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@return
doc comment to communicate to implementors of these methods what they are expected to return.