input
stringlengths
10
828
output
stringlengths
5
107
public void multiply with shift int p scalar x int long x p scalar math utils shift count y int long y p scalar math utils shift count
prevents integer overflow
public void multiply with shift int p scalar int p shift count x int long x p scalar math utils shift count p shift count y int long y p scalar math utils shift count p shift count
prevents integer overflow
public void add dynamic body soft body p to add if object pools inited tmp dynamic bodies add element p to add return ifdef debug if dynamic bodies len max dynamic bodies system out println aioob add dynamic body endif p to add properties soft body mask visible default value p to add id dynamic bodies len dynamic bodies dynamic bodies len p to add if ig dynamic bodies null ig dynamic bodies set object dynamic bodies len 1 p to add get aabb
adds a soft body to the simulation
public void divide int p scalar x p scalar y p scalar
divides this vector datas by scalar
public void divide with shift int p scalar x int long x math utils shift count p scalar y int long y math utils shift count p scalar
performs a shift to the left before division
public void divide with shift long p scalar x int long x math utils shift count p scalar y int long y math utils shift count p scalar
performs a shift to the left before division
public void divide with shift int p scalar int p shift count x int long x math utils shift count p shift count p scalar y int long y math utils shift count p shift count p scalar
performs more shifts before division
public vector2 plus vector2 p other return new vector2 x p other x y p other y
creates new vector which is this p other
public vector2 minus vector2 p other return new vector2 x p other x y p other y
just like plus
public void add external mass point mass point p point tmp mass points add element p point
adds a mass point connected to this body by a spring chain
public vector2 times int p scalar return new vector2 x p scalar y p scalar
creates a new vector which is this scalar
public vector2 times with shift int p scalar return new vector2 int long x p scalar math utils shift count int long y p scalar math utils shift count
just like times but it shifts the result
public void add neighbour soft body p body if p body null tmp objects contains p body tmp objects add element p body
adds a body connected to this body by a spring chain
public vector2 times with shift int p scalar int p num shifts return new vector2 int long x p scalar math utils shift count p num shifts int long y p scalar math utils shift count p num shifts
just like times with shift
public vector2 divided int p scalar return new vector2 x p scalar y p scalar
creates a new vector which equals this scalar
public void add static body static body p to add if object pools inited tmp static bodies add element p to add return ifdef debug if static bodies len max static bodies system out println aioob add static body endif static bodies static bodies len p to add p to add id static bodies len 1 if ig static bodies null ig static bodies set object p to add id p to add get aabb
adds a static body to the simulation
public vector2 divided with shift int p scalar return new vector2 int long x math utils shift count p scalar int long y math utils shift count p scalar
shifts the new vector before division
public void pre collision init coll info 0 erase information from previous frame int len points length for int k 0 k len k points k info mass point mask was colliding mass point mask was colliding with world mass point mask was colliding with movables erase old info
for internal use clears info about collision
public int dot product vector2 p other return x p other x y p other y
calculates a dotproduct of this and p other vectors
public int dot product with shift vector2 p other return int long x p other x long y p other y math utils shift count
just like dot product but it shifts the result and prevents overflow
public int cross product vector2 p other return x p other y y p other x
calculates cross product of this and p other vectors
public int cross product with shift vector2 p other return int long x p other y long y p other x math utils shift count
just like cross product but it shifts the result and prevents overflow
public void remove static body int p index ig static bodies unset object p index static bodies p index get aabb static bodies len if static bodies len p index ig static bodies unset object static bodies len static bodies static bodies len get aabb static bodies p index static bodies static bodies len ig static bodies set object p index static bodies p index get aabb static bodies p index id p index static bodies static bodies len null maybe we should update visible static objects too
removes a static body from the simulation
public void copy vector2 p other x p other x y p other y
sets this vectors data to p others data
public void build structural springs2 int p k int p break len int len tmp mass points size int len2 len 1 for int i 0 i len2 i spring spr new spring mass point tmp mass points element at i mass point tmp mass points element at len2 i p k p break len 1 add spring spr
adds a spring from each point to his opposite point
public void remove dynamic body soft body p to remove for int i 0 i dynamic bodies len i if dynamic bodies i p to remove remove dynamic body i break
removes a soft body from the simulation
public int normalise with shift int len length if len math utils shift koef return len x int long x math utils shift count len y int long y math utils shift count len return len
normalises this vector and shifts the result data
public void build structural springs3 int p k int p break len int len tmp mass points size for int i 0 i len i for int j i 2 j len j spring spr new spring mass point tmp mass points element at i mass point tmp mass points element at j p k p break len 1 add spring spr
adds a spring from each point to each other
public int length int x x 0 x x absolute values int y y 0 y y if x 0 return y if y 0 return x if x y swap x and y if x y see wyvill g1 436 x y y x x y int t y y 1 return x x 5 x 7 t 2 t 6
lineary approximates the length of this vector
public void build structural springs4 int p k int p break len build structural springs2 p k 6 p break len int len tmp mass points size for int i 0 j len 1 k len 2 i len k j j i i spring spr new spring mass point tmp mass points element at i mass point tmp mass points element at k p k p break len 1 add spring spr
creates springs similar to the gish game
public int length squared with shift return int long x x long y y math utils shift count
returns length of this vector squared
public long length squared return long x x long y y
returns length of this vector squared
public void d print out string name system out println name x math utils shift count 1 y math utils shift count 1 x y
prints info held by this vector into the console
public void add particle particle p to add if object pools inited tmp particles add element p to add return ifdef debug if particles len max particles system out println aioob add particle endif particles particles len p to add p to add id particles len 1 if ig particles null ig particles set object particles len 1 p to add get aabb system out println add partcle particles len max particles
removes a particle from the simulation
public boolean is sticked return sticky springs len 0
true if this object is sticked to something
public boolean is sticked to world for int i 0 i sticky springs len i if sticky springs i p2 pos null return true return false
true if this object is sticked to the static world
public void remove particle mass point p point for int i 0 i particles len i if particles i point equals p point remove particle i break
removes a particle from the simulation
public void unstick for int i 0 i sticky springs len i sticky springs i notify points to unstick sticky springs i null sticky springs len 0
call this to unstick this object of everything
public void integrate update mass points of a spring chain attached to this body if external mass points null for int i 0 i external mass points length i if external mass points i null if external mass points i info mass point mask dead 0 external mass points i null delete dead points else external mass points i integrate invalidate visual data so the body know it must be updated invalidate visual data integrate for int i 0 i points length i points i integrate if center point null center point integrate
integrates motion equations to get new position of points
public void apply external springs for int i 0 i external springs length i if external springs i null external springs i apply true external springs i die external springs i null
applies springs attached to this body
public void apply sticky springs spring spr for int i 0 i sticky springs len i spr sticky springs i if spr apply true if i sticky springs len 1 sticky springs i sticky springs sticky springs len 1 sticky springs len sticky springs sticky springs len null i spr notify points to unstick spr p1 null this will signal to all objects using this spring that it s broken spr null
applies springs used for sticking
public void accumulate forces invalidate visible objects update visibile objects accumulate forces vector2 gravity vec new vector2 0 gravity int len visible dynamic bodies 0 for int i 1 i len i soft body body dynamic bodies visible dynamic bodies i body accumulate internal forces body add force times mass gravity vec if body external mass points null body add force times mass to external mass points gravity vec len visible particles 0 for int i 1 i len i particles visible particles i point add force times mass gravity vec
accumulates forces of all objects in the simulation
public int compute perimeter int res 0 for int i 0 j points length 1 i points length j i i res points i pos minus points j pos length return res
computes perimeter of the polygon determined by masspoints creating this body
public void integrate update visibile objects integrate int len visible dynamic bodies 0 for int i 1 i len i dynamic bodies visible dynamic bodies i integrate len visible particles 0 for int i 1 i len i particles visible particles i point integrate
integrates motion of all objects in the simulation
public void clamp velocities of colliding update visibile objects int len visible dynamic bodies 0 for int i 1 i len i soft body body dynamic bodies visible dynamic bodies i if body coll info soft body mask was colliding 0 body clamp point velocities
clamps velocity of all mass points in the simulation to max velocity
public void accumulate internal forces if gas pressure 0 accumulate gas pressure force
accumulates internal forces like the gas pressure force
public void add force vector2 p force inlined for better performance for int i 0 i points length i points i add force p force if center point null center point add force p force for int i 0 i points length i if points i mass math utils infinity inlined for better performance points i force x p force x points i force y p force y if center point null center point mass math utils infinity inlined for better performance center point force x p force x center point force y p force y
adds a force to the accumulator
public void preserve volume update visibile objects preserve volume int len visible dynamic bodies 0 for int i 1 i len i dynamic bodies visible dynamic bodies i preserve volume
runs the preservation volume algorithms on all objects in the simulation
public void add force to non colliding vector2 p force for int i 0 i points length i mass point pt points i if pt info mass point mask was colliding mass point mask is sticked 0 pt add force p force
adds a force to mass points which didnt collide last frame
public void add force times mass vector2 p force for int i 0 i points length i points i add force times mass p force if center point null center point add force times mass p force
adds a force after multiplying by the mass to the accumulator
public void pre collision init update visibile objects int len visible dynamic bodies 0 for int l 1 l len l soft body b dynamic bodies visible dynamic bodies l b pre collision init b update aabb ig dynamic bodies len visible particles 0 for int l 1 l len l particle p particles visible particles l p pre collision init p update aabb ig particles
clears collision information of all objects in the simulation
public vector2 get center pos if center pos null center pos new vector2 arithmetic mean int len points length int num 0 for int i 0 i len i mass point pt points i if pt info mass point mask dead 0 center pos x pt pos x center pos y pt pos y num center pos x num center pos y num return center pos
gets the average center position of this body
public vector2 get linear velocity vector2 v new vector2 int len points length for int i 0 i len i mass point pt points i v x pt pos x pt last pos x v y pt pos y pt last pos y v divide points length return v
estimates linear velocity of the body
public boolean check convexity int len points length vector2 pt j points len 1 pos vector2 pt k points len 2 pos for int i 0 i len i vector2 pt i points i pos long edge1 x pt j x pt k x edge1 y pt j y pt k y long edge2 x pt i x pt j x edge2 y pt i y pt j y if int edge1 x edge2 y edge1 y edge2 x math utils shift count 0 return false pt k pt j pt j pt i return true
true if this object is convex
public void clean springs null points null center point null center pos null ground dir null sticky springs null external mass points null external springs null neighbours null draw points null fixed center pos null
cleans up all data thus releasing memory
private void read more lines throws ioexception while true string line client read line if line starts with lines add line substring 1 else if line equals break else lines add line
reads multiple lines until we meet a single
public string get textual information string buffer sb new string buffer string sep for string line lines sb append sep sb append line sep n return sb to string
get the textual information the lines following the first as a single
protected response send string command throws ioexception dict exception send line command return new response this
sends a command and returns its complete response
private void parse capabilities string s throws dict exception if s starts with s ends with throw new dict exception invalid server connect string string tokenizer st new string tokenizer s substring 1 s length 1 while st has more tokens capabilities add st next token
parse the capabilities parameter
public boolean has capability string cap return capabilities contains cap
whether the specified capability is present
public string get msg id return msg id
get the servers initial msgid
private void init throws ioexception dict exception socket new socket host port out new print writer new output stream writer socket get output stream utf 8 true in new buffered reader new input stream reader socket get input stream utf 8 response tmp new response this server caps connect response tmp get response status success hello send user agent
open the socket and prepare the reader and writer
public void remove it remove
removes the current token
private void check throws dict error if socket null throw new dict error resource bundle get bundle mt rcasha dict client dict messages get string connection closed
checks that the socket is open etc
public void close throws dict exception ioexception if socket null return send quit socket close socket null
close the connection to the dict server
private void set method java lang string method if method starts with throw new runtime exception invalid method this method method substring 1 to lower case
setter for property method
private void set host java lang string host this host host
setter for property host
public response auth string user string shared secret throws ioexception dict exception return send auth user hash server caps get msg id shared secret
authenticate the user
private string hash string s throws dict exception try message digest md message digest get instance md5 md update s get bytes utf 8 byte checksum md digest string buffer sb new string buffer for int i 0 i checksum length i string hs integer to hex string char checksum i 0x ff if hs length 2 sb append 0 sb append hs return sb to string catch exception e throw new dict exception e
return the md5 hash as a hex string
private void set database java lang string database this database database
setter for property database
private void set strategy java lang string strategy if strategy null strategy equals strategy dict client strategy default this strategy strategy
setter for property strategy
private void set word java lang string word this word word
setter for property word
public string get status throws dict exception ioexception response res send status single response sr res get response status success status return sr get first line
gets information about the dict server status as a single line string
public int get def num return def num
getter for property def num
private void set def num string tmp if tmp length 0 def num integer parse int tmp
setter for property def num
public string get database info string db throws ioexception dict exception response res send show info db single response sr res get response status info database return sr get textual information
gets information about the specified database as freeform text in a multiline string
public boolean get throw exceptions return throw exceptions
what to do in the event of a command returning an error status
public void set throw exceptions boolean throw exceptions this throw exceptions throw exceptions
what to do in the event of a command returning an error status
public tci module id get defining module return null
returns b null b if type is a ttcn 3 base type
public integer value yatr add op object o integer value yatr i new integer value yatr o i set integer this m value i m value return i
returns new instance for the mod operator
public void set root module module root module this root module root module
set the root module of a ats called in tci root module
public tri component id start control assert runtime control null callable info ci root module get callable control if ci null throw new runtime exception module root module get module name have no control part component c root module create control this ro ci c start test component req ci null tci chprovided control runtime control c return c get component id
create a new control component and run it
private void choose file todo choose file by a filename if new file get path file separator application myfuses application file is file set file new file get path file separator application myfuses application file if new file get path file separator application fusebox application file is file set file new file get path file separator application fusebox application file
choose the application file
private void set path string path this path path
set application path
private menu show menu final menu res new menu fill menu res cur get class return res
create a menu with all the get methods
public void set auto commit final boolean auto commit if this auto commit auto commit commit null this auto commit auto commit
sets this maps auto commit state to the given state
private void return to pool if pool null try pool return object this catch exception e1 log error exception e1 this pool null
returns the thread to the pool
private void reset this runnable null this sync object null
reset the memebers to service next request
public void commit if auto commit return commit get current thread id
commits the changes to the map so that all threads
public void test size map m make map assert equals 0 m size local test node nodes make local nodes for int k 0 k nodes length k m put nodes k get key nodes k get value assert equals k 1 m size int count m size for int k 0 k nodes length k m remove nodes k get key count assert equals count m size failed remove should not affect size m remove nodes k get key assert equals count m size
test size method
public void test contains key map m make map assert true m contains key foo local test node nodes make local nodes for int k 0 k nodes length k m put nodes k get key nodes k assert true m contains key nodes k get key assert true m contains key new integer 1 assert true m contains key foo for int k 0 k nodes length k m remove nodes k get key assert true m contains key nodes k get key
test contains key method
public void test put map m make map local test node nodes make local nodes for int k 0 k nodes length k assert null m put nodes k get key nodes k get value assert not null m put nodes k get key foo assert null m put new integer integer nodes k get key int value 1 nodes k get value
test put method
protected string get current thread id string attach id string thread session get value get thread session key if attach id null return attach id thread thread thread current thread return thread to string thread hash code
retrieve the current thread id for use by the
private boolean valid node final node k v node final string thread id if auto commit node null return node null return node is node deleted thread id node is node added null node is node no change thread id
checks that this node is valid for the current thread
public void test hash code map m transactional hash map make map local test node nodes make local nodes for int k 0 k nodes length k m put nodes k get key nodes k map m1 transactional hash map make map for int k nodes length 1 k 0 k m1 put nodes k get key nodes k assert equals m hash code m1 hash code
test hash code method
public int compare to object o local test node other local test node o int rval get key compare to other get key if rval 0 rval get value compare to other get value return rval
method compare to
private object do get final object o final int index check non null comparable o index node k v node lookup valid o index get current thread id return node null null node get data opposite index index
common get logic used to get by key or get by value
private int compare final int o1 status final object o1 final int o2 status final object o2 final int index if comparators index null if o1 instanceof transactional comparable return transactional comparable o1 compare to o1 status o2 o2 status else return comparable o1 compare to o2 else return comparators index compare o1 o2
compare two objects
private void check key final object key check non null comparable key key
check a key for validity
private void check value final object value check non null comparable value value
check a value for validity