mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-04 22:17:22 +08:00
22 lines
3.8 KiB
Go
22 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 (_bf NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_bf )-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 _bf [i ],nil ;};func Sign (v float32 )float32 {if v >=0.0{return 1.0;};return -1.0;};func (_ff IntSlice )Size ()int {return len (_ff )};type Stack struct{Data []interface{};Aux *Stack ;};func NewIntSlice (i int )*IntSlice {_cba :=IntSlice (make ([]int ,i ));
|
|
return &_cba };func NewNumSlice (i int )*NumSlice {_bc :=NumSlice (make ([]float32 ,i ));return &_bc };func (_c IntsMap )Get (key uint64 )(int ,bool ){_cb ,_ce :=_c [key ];if !_ce {return 0,false ;};if len (_cb )==0{return 0,false ;};return _cb [0],true ;
|
|
};func (_ggg *Stack )Len ()int {return len (_ggg .Data )};func (_gg *IntSlice )Add (v int )error {if _gg ==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");
|
|
};*_gg =append (*_gg ,v );return nil ;};func (_ggb NumSlice )GetIntSlice ()[]int {_fc :=make ([]int ,len (_ggb ));for _gda ,_be :=range _ggb {_fc [_gda ]=int (_be );};return _fc ;};type IntSlice []int ;type IntsMap map[uint64 ][]int ;func (_gee *Stack )Pop ()(_e interface{},_da bool ){_e ,_da =_gee .peek ();
|
|
if !_da {return nil ,_da ;};_gee .Data =_gee .Data [:_gee .top ()];return _e ,true ;};func Max (x ,y int )int {if x > y {return x ;};return y ;};func (_af NumSlice )GetInt (i int )(int ,error ){const _gd ="\u0047\u0065\u0074\u0049\u006e\u0074";if i < 0||i > len (_af )-1{return 0,_d .Errorf (_gd ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );
|
|
};_gb :=_af [i ];return int (_gb +Sign (_gb )*0.5),nil ;};func (_dc *Stack )Push (v interface{}){_dc .Data =append (_dc .Data ,v )};func (_ca *IntSlice )Copy ()*IntSlice {_dd :=IntSlice (make ([]int ,len (*_ca )));copy (_dd ,*_ca );return &_dd ;};func (_f IntsMap )GetSlice (key uint64 )([]int ,bool ){_cc ,_ge :=_f [key ];
|
|
if !_ge {return nil ,false ;};return _cc ,true ;};func (_afb *Stack )top ()int {return len (_afb .Data )-1};type NumSlice []float32 ;func (_ag IntSlice )Get (index int )(int ,error ){if index > len (_ag )-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 _ag [index ],nil ;};func (_g IntsMap )Add (key uint64 ,value int ){_g [key ]=append (_g [key ],value )};func (_cf *Stack )Peek ()(_gbb interface{},_df bool ){return _cf .peek ()};func (_b IntsMap )Delete (key uint64 ){delete (_b ,key )};func (_gc *NumSlice )AddInt (v int ){*_gc =append (*_gc ,float32 (v ))};
|
|
func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_eb *Stack )peek ()(interface{},bool ){_fd :=_eb .top ();if _fd ==-1{return nil ,false ;};return _eb .Data [_fd ],true ;};func (_cg *NumSlice )Add (v float32 ){*_cg =append (*_cg ,v )};func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;
|
|
};return (numerator /denominator )+1;};func Min (x ,y int )int {if x < y {return x ;};return y ;}; |