mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +08:00
23 lines
3.8 KiB
Go
23 lines
3.8 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
package basic ;import _ef "github.com/unidoc/unipdf/v3/internal/jbig2/errors";func (_bd *NumSlice )AddInt (v int ){*_bd =append (*_bd ,float32 (v ))};func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_d IntSlice )Size ()int {return len (_d )};
|
|
type NumSlice []float32 ;func (_fc *Stack )Peek ()(_ga interface{},_da bool ){return _fc .peek ()};func Max (x ,y int )int {if x > y {return x ;};return y ;};func NewIntSlice (i int )*IntSlice {_ce :=IntSlice (make ([]int ,i ));return &_ce };func Sign (v float32 )float32 {if v >=0.0{return 1.0;
|
|
};return -1.0;};func (_bf *IntSlice )Copy ()*IntSlice {_ee :=IntSlice (make ([]int ,len (*_bf )));copy (_ee ,*_bf );return &_ee ;};type IntsMap map[uint64 ][]int ;func (_eg IntSlice )Get (index int )(int ,error ){if index > len (_eg )-1{return 0,_ef .Errorf ("\u0049\u006e\u0074S\u006c\u0069\u0063\u0065\u002e\u0047\u0065\u0074","\u0069\u006e\u0064\u0065x:\u0020\u0025\u0064\u0020\u006f\u0075\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006eg\u0065",index );
|
|
};return _eg [index ],nil ;};func (_bb NumSlice )GetInt (i int )(int ,error ){const _gf ="\u0047\u0065\u0074\u0049\u006e\u0074";if i < 0||i > len (_bb )-1{return 0,_ef .Errorf (_gf ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );
|
|
};_ff :=_bb [i ];return int (_ff +Sign (_ff )*0.5),nil ;};func NewNumSlice (i int )*NumSlice {_fg :=NumSlice (make ([]float32 ,i ));return &_fg };func (_cb *NumSlice )Add (v float32 ){*_cb =append (*_cb ,v )};func (_ed NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_ed )-1{return 0,_ef .Errorf ("\u004e\u0075\u006dS\u006c\u0069\u0063\u0065\u002e\u0047\u0065\u0074","\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );
|
|
};return _ed [i ],nil ;};func (_bc *IntSlice )Add (v int )error {if _bc ==nil {return _ef .Error ("\u0049\u006e\u0074S\u006c\u0069\u0063\u0065\u002e\u0041\u0064\u0064","\u0073\u006c\u0069\u0063\u0065\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064");
|
|
};*_bc =append (*_bc ,v );return nil ;};func (_c IntsMap )Get (key uint64 )(int ,bool ){_ca ,_a :=_c [key ];if !_a {return 0,false ;};if len (_ca )==0{return 0,false ;};return _ca [0],true ;};func (_db *Stack )peek ()(interface{},bool ){_ecb :=_db .top ();
|
|
if _ecb ==-1{return nil ,false ;};return _db .Data [_ecb ],true ;};func (_cf *Stack )Push (v interface{}){_cf .Data =append (_cf .Data ,v )};func (_fe NumSlice )GetIntSlice ()[]int {_af :=make ([]int ,len (_fe ));for _caa ,_de :=range _fe {_af [_caa ]=int (_de );
|
|
};return _af ;};func (_ec IntsMap )Add (key uint64 ,value int ){_ec [key ]=append (_ec [key ],value )};func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;};return (numerator /denominator )+1;};func (_fb *Stack )top ()int {return len (_fb .Data )-1};
|
|
type Stack struct{Data []interface{};Aux *Stack ;};func (_cg *Stack )Len ()int {return len (_cg .Data )};func (_eef *Stack )Pop ()(_cc interface{},_ea bool ){_cc ,_ea =_eef .peek ();if !_ea {return nil ,_ea ;};_eef .Data =_eef .Data [:_eef .top ()];return _cc ,true ;
|
|
};type IntSlice []int ;func Min (x ,y int )int {if x < y {return x ;};return y ;};func (_g IntsMap )Delete (key uint64 ){delete (_g ,key )};func (_b IntsMap )GetSlice (key uint64 )([]int ,bool ){_f ,_fd :=_b [key ];if !_fd {return nil ,false ;};return _f ,true ;
|
|
}; |