Synthia
Generic and flexible data structure generator
Shrinkable.java
Go to the documentation of this file.
1
/*
2
Synthia, a data structure generator
3
Copyright (C) 2019-2021 Laboratoire d'informatique formelle
4
Université du Québec à Chicoutimi, Canada
5
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Lesser General Public License as published
8
by the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
package
ca.uqac.lif.synthia;
20
21
/**
22
* Interface signaling that a picker can be shrunk. In the context,
23
* <em>shrinking</em> means that given an element e, the picker produces a
24
* new picker instance producing only values that are "smaller" than e.
25
* <p>
26
* The interface defines two versions of <tt>shrink</tt>: the first takes
27
* only a reference object, while the second also accepts a source of
28
* randomness and a "magnitude" parameter.
29
*
30
* @author Sylvain Hallé
31
*
32
* @param <T> The type of the objects to return
33
* @see SequenceShrinkable
34
* @ingroup API
35
*/
36
public
interface
Shrinkable
<T>
extends
Picker
<T>
37
{
38
/**
39
* Shrinks a picker. The method adds two arguments with respect to
40
* {@link #shrink(Object)}: a source of randomness and a magnitude parameter.
41
* A picker may use the magnitude to determine how "aggressive" is the
42
* shrinking process. A value of 1 is expected to produce a picker with
43
* the broadest set, and may return all possible objects that are smaller
44
* than the reference. Lower values (all the way down to 0) instruct
45
* the picker to exclude further objects, and typically to only produce
46
* objects that are relatively "much smaller" than the reference.
47
*
48
* @param o The reference object. The picker must guarantee that the returned
49
* picker instance only produces objects that are smaller than o, according
50
* to an implicit ordering relation that is specific to each object type and
51
* each picker.
52
* @param d A source of randomness. Some pickers must make choices when
53
* producing shrunk objects, and this parameter is used as an external source
54
* for these choices.
55
* @param m A magnitude parameter, which must be between 0 and 1.
56
* @return The returned picker instance. This object may be of a different
57
* class from the object on which the method is called.
58
*/
59
/*@ non_null @*/
public
Shrinkable<T>
shrink
(T o,
Picker<Float>
d,
float
m);
60
61
/**
62
* Shrinks a picker with default parameters. For any picker <tt>p</tt> that
63
* implements the {@link Shrinkable} interface, a call to <tt>p.shrink(o)</tt>
64
* <em>should</em> be the same as a call to
65
* <tt>p.shrink(o, RandomFloat.instance, 1)</tt>.
66
*
67
* @param o The reference object. The picker must guarantee that the returned
68
* picker instance only produces objects that are smaller than o, according
69
* to an implicit ordering relation that is specific to each object type and
70
* each picker.
71
* @return The returned picker instance. This object may be of a different
72
* class from the object on which the method is called.
73
* @see #shrink(Object, Picker, float)
74
*/
75
/*@ non_null @*/
public
Shrinkable<T>
shrink
(T o);
76
}
ca.uqac.lif.synthia.Picker
Picks an object.
Definition:
Picker.java:36
ca.uqac.lif.synthia.Shrinkable
Interface signaling that a picker can be shrunk.
Definition:
Shrinkable.java:36
ca.uqac.lif.synthia.Shrinkable.shrink
Shrinkable< T > shrink(T o, Picker< Float > d, float m)
Shrinks a picker.
Source
Core
src
ca
uqac
lif
synthia
Shrinkable.java
Generated by
1.8.17