[context] min cleanup

This commit is contained in:
xdrm-brackets 2018-04-22 01:05:51 +02:00
parent 91512adbb2
commit 544ee489a4
1 changed files with 13 additions and 15 deletions

View File

@ -30,47 +30,45 @@ type T struct {
* @return outName<outType> outDesc
*
---------------------------------------------------------*/
func Create(win float64, optional... uint16) (*T, error) {
var instance = new(T);
var inst = new(T);
/* (1) Window size error */
if win < 0 { return nil, errors.New("Window size must be positive and is negative") }
instance.win = win;
inst.win = win;
/* (2) Default values */
instance.min = DefaultMin
instance.thr = DefaultThr
instance.max = DefaultMax
inst.min = DefaultMin
inst.thr = DefaultThr
inst.max = DefaultMax
/* (3) Optional 'min' */
if len(optional) > 0 {
if optional[0] < 0x0f { return nil, errors.New("Minimum depth must be greater than 0x0f (decimal 15) for consistency issues") }
instance.min = optional[0];
if optional[0] < 0x0f {
return nil, errors.New("Minimum depth must be greater than 0x0f (decimal 15) for consistency issues")
}
inst.min = optional[0];
}
/* (4) Optional 'thr' */
if len(optional) > 1 {
instance.thr = optional[1];
inst.thr = optional[1];
}
/* (5) Optional 'max' */
if len(optional) > 2 {
if optional[2] <= instance.min+instance.thr {
if optional[2] <= inst.min+inst.thr {
return nil, errors.New("Minimum depth must be greater than 0x0f (decimal 15) for consistency issues")
}
instance.max = optional[2];
inst.max = optional[2];
}
return instance, nil
return inst, nil
}
/* (4) Getters */