mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-07 19:29:16 +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 _d "github.com/unidoc/unipdf/v3/internal/jbig2/errors";func (_dbf IntSlice )Get (index int )(int ,error ){if index > len (_dbf )-1{return 0,_d .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 _dbf [index ],nil ;};type IntSlice []int ;func (_b IntsMap )Get (key uint64 )(int ,bool ){_g ,_be :=_b [key ];if !_be {return 0,false ;};if len (_g )==0{return 0,false ;};return _g [0],true ;};func (_dc IntsMap )GetSlice (key uint64 )([]int ,bool ){_bb ,_db :=_dc [key ];
|
|
if !_db {return nil ,false ;};return _bb ,true ;};func Max (x ,y int )int {if x > y {return x ;};return y ;};func (_ae *Stack )peek ()(interface{},bool ){_af :=_ae .top ();if _af ==-1{return nil ,false ;};return _ae .Data [_af ],true ;};func NewIntSlice (i int )*IntSlice {_gf :=IntSlice (make ([]int ,i ));
|
|
return &_gf };func (_cg IntsMap )Delete (key uint64 ){delete (_cg ,key )};func (_fdg *Stack )Len ()int {return len (_fdg .Data )};type IntsMap map[uint64 ][]int ;func (_a *NumSlice )AddInt (v int ){*_a =append (*_a ,float32 (v ))};type Stack struct{Data []interface{};
|
|
Aux *Stack ;};func (_f IntsMap )Add (key uint64 ,value int ){_f [key ]=append (_f [key ],value )};func (_ef IntSlice )Size ()int {return len (_ef )};func Min (x ,y int )int {if x < y {return x ;};return y ;};func (_bg *IntSlice )Copy ()*IntSlice {_df :=IntSlice (make ([]int ,len (*_bg )));
|
|
copy (_df ,*_bg );return &_df ;};func (_e *IntSlice )Add (v int )error {if _e ==nil {return _d .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");
|
|
};*_e =append (*_e ,v );return nil ;};func (_gd *Stack )top ()int {return len (_gd .Data )-1};func NewNumSlice (i int )*NumSlice {_beg :=NumSlice (make ([]float32 ,i ));return &_beg };func (_fd NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_fd )-1{return 0,_d .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 _fd [i ],nil ;};func (_dg NumSlice )GetIntSlice ()[]int {_cb :=make ([]int ,len (_dg ));for _fg ,_bec :=range _dg {_cb [_fg ]=int (_bec );};return _cb ;};func (_egb *Stack )Push (v interface{}){_egb .Data =append (_egb .Data ,v )};func (_fc *Stack )Pop ()(_cd interface{},_gg bool ){_cd ,_gg =_fc .peek ();
|
|
if !_gg {return nil ,_gg ;};_fc .Data =_fc .Data [:_fc .top ()];return _cd ,true ;};func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;};return (numerator /denominator )+1;};func (_da *Stack )Peek ()(_ea interface{},_dfg bool ){return _da .peek ()};
|
|
func (_fb *NumSlice )Add (v float32 ){*_fb =append (*_fb ,v )};func Sign (v float32 )float32 {if v >=0.0{return 1.0;};return -1.0;};func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_de NumSlice )GetInt (i int )(int ,error ){const _eg ="\u0047\u0065\u0074\u0049\u006e\u0074";
|
|
if i < 0||i > len (_de )-1{return 0,_d .Errorf (_eg ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );};_ac :=_de [i ];return int (_ac +Sign (_ac )*0.5),nil ;};
|
|
type NumSlice []float32 ; |