input
stringlengths
10
828
output
stringlengths
5
107
public void test primary key cache int max 1000 for int i 0 i max i object factory create address new long i commit for int i 0 i 100000 i address finder select by primary key new long i 1000
should hit the cache for pk selects so this should be quick
protected void commit jaxor session commit begin session
commits the context and begins a new session
public boolean is sql server test return jaxor factory get class sql server context testing factory class
the version of sqlserver used for integration testing does not support
public object get property value string property name field adapter adapter get field by property property name if adapter null throw new system exception failed to find property property name return adapter get value
returns a value based upon a property name
public void stop try jaxor context commit finally jaxor context end
commits and closes the jaxor context
public void add error string message errors add message
adds an error to the validation using the specified key to lookup the
public list get messages list messages new array list errors size infos size messages add all errors messages add all infos return messages
returns the list of messages that have been added to this validation
public string to string string buffer result new string buffer result append to string info infos result append to string error errors return result to string
returns the level and messages as a string
public list get field as list if get resolver is unique list result new array list object value get value if value null result add value return result return entity list adapter get value to list
field may resolve to a single entity or an entity list
public list to list return new array list list
a shallow copy of the list
public void test null query with result if jaxor factory get class equals hypersonic context testing factory class contact entity ent contact factory create contact new long 1 ent set email null ent contact factory create contact new long 2 ent set email email commit contact entity contact entity contact finder select by email null assert not null contact entity assert null contact entity get email
only works with hypersonic
public object get mapped sql object if is null return null return mapper map to sql object get value
does a null check first before mapping sql object
public void execute single change connection connection before flush flush connection after flush
used to execute an insert update or delete for a single entity and
public arrow non suspending point debut point fin this start debut this end fin this color color black
creates a new instance of fleche
public string get of what return this of what
le nom de of what de larchitecture
public void set of what string of what this of what of what
le nom de of what de larchitecture
public void test declaration detection system out println declaration detection string nom cfile analyzer instance new cfile analyzer new file f fichier c c int exp result 8 int result instance declaration detection h assert equals exp result result todo review the generated test code and remove the default call to fail fail the test case is a prototype
test of declaration detection method of class org
public void test test system out println test quartus project generator instance new quartus project generator buffered reader in instance test todo review the generated test code and remove the default call to fail fail the test case is a prototype
test of test method of class org
public quadratic probe int table size float c1 float c2 super table size this c1 c1 this c2 c2
construct quadratic probe with given coefficients
public linear probe int table size int delta super table size if delta 1 delta table size throw new illegal argument exception invalid delta delta must be in range 1 table size this delta delta
constructor for linear probe
public int capacity return storage length
return capacity of collection
public int insert e e throws runtime exception compute initial bin location int hash e hash code 0x7 fffffff storage length int h hash for int p 1 p storage length p if storage h null storage h e num return p else if storage h equals e return p advance to next bin h probe next hash p throw new runtime exception unable to insert element num slots taken out of storage length with probe probe
insert element into collection
public void insert string s tree insert s true
insert the string into our collection
public boolean insert e elem boolean b table get elem if b null b false return false return true
insert element into collection
public puzzle evaluator2 int target this target target
evaluator must know the destination target to be able to determine its score
public int eval inode state small puzzle tp small puzzle state manhattan distance to target int diff math abs target 0 tp s 0 math abs target 1 tp s 1 if we have gone too far then double the cost since we have to cut in half and then add back same for both if tp s 0 target 0 diff 2 if tp s 1 target 1 diff 2 return diff
evaluate how far from the solution state is
public void score inode state state score eval state
set the score
public cut in half move
increment move selects the position to be incremented
public small puzzle s new int 2
initialize to empty
public boolean is valid inode state small puzzle tp small puzzle state return tp s 0 2 0 tp s 1 2 0
moves are always valid
public small puzzle int pre s new int 2 s 0 pre 0 s 1 pre 1
initialize to pre existing board state
public inode copy return new small puzzle s
return copy of node
public increment move int pos if pos 0 pos 1 throw new illegal argument exception only two spaces to be incremented this pos pos
increment move selects the position to be incremented
public boolean equivalent inode state return equals state
ensure equivalent method based on equals
public boolean is valid inode state return true
moves are always valid
public void score int s score s
set score for this node
public int score return score
return computed score for this node
public puzzle evaluator1 int target this target target
evaluator must know the destination target to be able to determine its score
public int eval inode state small puzzle tp small puzzle state if tp s 0 target 0 return integer max value if tp s 1 target 1 return integer max value return math abs target 0 tp s 0 math abs target 1 tp s 1
evaluate how far from the solution state is
public int compare to small puzzle tp if s 0 tp s 0 return 1 if s 0 tp s 0 return 1 if s 1 tp s 1 return 1 if s 1 tp s 1 return 1 return 0 must be sasme
needed for nodes to be placed within binary tree
public void window opened window event e system out println loading card images card images card images loader get deck e get window
once opened load up the images
public boolean ready return ready status
determine if cards have been loaded
public int compare to card c if c null return integer max value this takes care of all possibilities return rank c get rank
compares cards based on ranks
public void set node free cell node node key node rawkey force repaint repaint
set the node to be drawn
public string get name return to string rank suit
return a string reflective of this card
protected image cache lookup string key return image image cache get key
the key is the resource name such as 10 h or back
protected void cache store string key image image image cache put key image
the key is the resource name such as 10 h or back
public image get card image int rank int suit if rank suit are invalid the following method will throw illegal argument exception string rep card to string rank suit return cache lookup rep
extracts the card resource based upon the name
public image get card reverse return back image
get the reverse image for a card
public int get height if calculated height 1 if back image null calculated height back image get height null was 96 return calculated height
return the individual height in pixels of each card
public int get overlap if calculated overlap 1 calculated overlap int get height 23 was 22 return calculated overlap
overlap is roughly 23 of the card height
public int get width if calculated width 1 if back image null calculated width back image get width null was 71 return calculated width
return the width of each card
public void set card image card c image img if c null throw new illegal argument exception card images set card image received null card object if img null throw new illegal argument exception card images set card image received null image object string key c get name cache store key img
used by card images loader to set the appropriate image once loaded
public boolean is ace return rank ace
determine whether the card is an ace
public void set card reverse image reverse image cache store back resource name reverse image if reverse image null throw new illegal argument exception card images set card reverse received null image back image reverse image
set the reverse image for a card
public void set name string name if name null throw new illegal argument exception card images set name received null parameter this name name
set name for this deck class
public void set overlap int overlap if overlap 0 throw new illegal argument exception overlap value must be positive calculated overlap overlap
manually set the overlap to use
public boolean is face card return rank jack rank queen rank king
determine whether the card is a face card jack queen king
public boolean has more elements if suit card spades return true return false
returns true if there are more cards in this enumeration
public card next element card c new card rank suit enumerate over each rank and then by suit if rank card king suit rank card ace return c
returns the current card in the enumeration and moves on
public boolean opposite color int other suit if other suit clubs other suit spades throw new illegal argument exception suit suit is an invalid suit for a card same suit can t be opposite color if other suit suit return false switch other suit case clubs if suit spades break return true case diamonds if suit hearts break return true case hearts if suit diamonds break return true case spades if suit clubs break return true if we get here then colors are same return false
determines whether the card has an opposite color than the given suit
public boolean execute inode n if is valid n return false free cell node state free cell node n state detach nth column col state cols nth col remove if col num 0 state sort map state insert free card make auto moves super execute n return true
execute the move on the given board state
public boolean is valid inode n free cell node state free cell node n column col state cols nth if col num 0 return false card short col cards col num 1 return state available free
determine if move is valid for the given state
public boolean undo inode n free cell node state free cell node n undo automoves super undo n state remove free card column col state cols nth col add card return true
assume move had been valid so the undo is a straightforward swap
public boolean opposite color card c if c null return false return opposite color c get suit
determines whether the two cards have opposite colors
public boolean execute inode n if is valid n return false free cell node state free cell node n state detach nth column col state cols nth col remove if col num 0 state sort map state insert foundation card make auto moves super execute n return true
execute the move on the given board state
public boolean is valid inode n free cell node state free cell node n column col state cols nth if col num 0 return false card col cards col num 1 suit short card 1 4 subtract 1 since 0 is invalid card rank short 1 card 1 2 rank extracted this way always move an ace if rank 1 return true else return state foundation encoding suit 1 rank
determine if move is valid for the given state
public boolean same color card c if c null return false return same color c get suit
determine whether the two cards have the same color
public boolean undo inode n free cell node state free cell node n undo automoves super undo n state remove foundation suit column col state cols nth col add card return true
assume move had been valid so the undo is a straightforward swap
public boolean execute inode n if is valid n return false free cell node state free cell node n state remove free card state detach nth column col state cols nth col add card if col num 1 state sort map return true
execute the move on the given board state
public boolean undo inode n free cell node state free cell node n column col state cols nth col remove state insert free card return true
assume move had been valid so the undo is a straightforward swap
public boolean same color int other suit if other suit clubs other suit spades throw new illegal argument exception suit suit is an invalid suit for a card if other suit suit return true switch other suit case clubs if suit spades break return true case diamonds if suit hearts break return true case hearts if suit diamonds break return true case spades if suit clubs break return true if we get here we must not be the same color return false
determines whether the card has the same color as the given suit
public int get next deal number return deal
return the deal that that will be returned upon invoking next
public boolean has next return deal 32000
if the deal has more deals this returns true false otherwise
public free cell node next string line sc next line string tokenizer st new string tokenizer line get task no int val integer value of st next token bypass number if val deal throw new no such element exception deal number deal seems missing from input file for deal iterator construct deal shuffle sequence int deals new int 52 int idx 0 while st has more tokens deals idx integer value of st next token return the deal and prepare for next time deal return deal initialize deals
get the next deal
public boolean same rank card c if c null return false return rank c get rank
determine whether two cards have the same rank
public column to column move int from int to int num this from col from this to col to this num num
person calling this had better ensure descending alternating color of num
public boolean execute inode n if is valid n system err println requested invalid move return false free cell node state free cell node n state detach from col to col int ct num int idx 0 while ct 0 cards idx state cols from col remove while idx 0 state cols to col add cards idx if state cols from col num 0 state cols to col num 1 state sort map make auto moves super execute n return true
execute the move on the given board state
public boolean undo inode n free cell node state free cell node n undo automoves super undo n int ct num int idx 0 while ct 0 cards idx state cols to col remove while idx 0 state cols from col add cards idx return true
assume move had been valid so the undo is a straightforward swap
public boolean same suit card c if c null return false return suit c get suit
determine whether the two cards have the same suit
protected int num auto moves return auto moves size
determine the number of automoves made
public string to string string name to string rank suit return name
return a string reflective of this card
public boolean equals object o if o null return false if o instanceof card card other card o return other rank rank other suit suit return false no good
default equals method
public column short initial num 0 for int i 0 i initial length i cards i initial i num
pre build one
public short remove short card cards num cards num 0 remove return card
remove the topmost card
public string to string if cached null return cached string builder sb new string builder for int i num 1 i 0 i sb append free cell node out cards i cached sb to string return cached
create in reverse order to have keys be different early
public boolean execute inode n if is valid n return false free cell node state free cell node n state remove free card state insert foundation card make auto moves super execute n return true
execute the move on the given board state
public boolean is valid inode n free cell node state free cell node n if card 0 return false suit short card 1 4 subtract 1 since 0 is invalid card rank short 1 card 1 2 rank extracted this way return state foundation encoding suit 1 rank
determine if move is valid for the given state
public boolean undo inode n free cell node state free cell node n undo automoves super undo n state remove foundation suit state insert free card return true
assume move had been valid so the undo is a straightforward swap
public quality directed staged deepening iscore eval ivisitor visitor super visitor this eval eval
target a specific goal in mind using the provided evaluation score
public quality directed staged deepening iscore eval super null this eval eval
target a specific goal in mind using the provided evaluation score
public goal directed staged deepening inode goal iscore eval ivisitor visitor super visitor this goal goal this eval eval
target a specific goal in mind using the provided evaluation score
public int remove free int card if card free encoding 3 free encoding 3 free encoding 2 free encoding 2 free encoding 1 free encoding 1 free encoding 0 free encoding 0 0 return card if card free encoding 2 free encoding 2 free encoding 1 free encoding 1 free encoding 0 free encoding 0 0 return card if card free encoding 1 free encoding 1 free encoding 0 free encoding 0 0 return card free encoding 0 0 return card
remove the card should it exist within the free location
public goal directed staged deepening inode goal iscore eval super null this goal goal this eval eval
target a specific goal in mind using the provided evaluation score
ivisitor visitor new ivisitor public void visit edge int parent int child public void visit node inode n int id
visitor for nodes and edges
public dfs
construct dfs agent with default visitor
public dfs ivisitor visitor if visitor null this visitor visitor
construct dfs agent with given behavior for visiting nodes and edges
public void set depth limit int limit depth limit limit
set the depth limit beyond which no search can continue
public int get counter return ctr
for debugging return the total count of nodes searched
public boolean search complete inode n return n equals goal
determines if the search is successful