input stringlengths 10 828 | output stringlengths 5 107 |
|---|---|
public void storage type int type closed storage type | determine structure to use for storing closed set |
public inode remove return stack pop | remove takes the topmost element from the stack |
public astar search iscore sf this scoring function sf | prepare an a search using the given scoring function |
public inode contains inode n for int i 0 i stack size i if stack element at i equals n return stack element at i return null | a costly operation in a stack typically not required |
public boolean remove inode n for int i 0 i stack size i if stack element at i equals n stack remove i return true return false | remove actual value from the list |
public boolean remove e e if e null return false if head value e remove first return true if last value e remove last return true not in the list if head next null return false double node e prev head double node e n head next find it in the list and remove while n null if n value e prev next n next if prev next null prev next prev prev size return true n n next prev prev next return false | this will remove given element known to already be in the list |
public state hash table new hashtable inode inode initial capacity | construct hash to store inode objects |
public void insert inode n tree insert n n | insert the board state into the tree |
public void insert inode n table put n n | insert a node into the hash |
public inode remove throw new unsupported operation exception remove operation not supported by state hash | not supported since it makes no sense in this context |
public inode remove return tree minimum | return inode with minimum score value since tree was constructed using |
private string format node binary node t node binary node t n string builder response new string builder if n node get left son null response append format node n response append node to string if n node get right son null response append format node n response append flatten return response to string | format the node recursively |
public boolean set allow duplicates boolean b if size 0 return false allow duplicates b return true | determine if this tree should allow entries with duplicate keys |
public e remove first if head null throw new no such element exception nothing in list e value head value head head next if head null head prev null else last null emptied out the list size return value | remove first element without altering sort order |
public inode contains inode n return table get n | locate element stored in set that equals n |
public boolean remove inode n return table remove n null | remove actual entry from the set |
public void insert inode n list insert n | insert the board state into the set |
public inode contains inode n balanced binary node inode inode entry tree get entry n if entry null return null return entry value | locate element within the set whose score is the same |
public boolean remove inode n return tree remove n null | remove actual value from the set whose score is the same |
public inode remove return list remove first | remove board state with lowest evaluated score |
public e remove last if head null throw new no such element exception nothing in list e value last value last last prev if last null last next null else head null emptied out the list size return value | remove last element without altering sort order |
public void insert inode n queue insert n | insert node places at end of queue |
public inode contains inode n double node inode dn list first while dn null if dn value equals n return dn value dn dn next return null | determine if contained within the set |
public inode remove return queue remove first | remove a node by taking the first one from the queue |
public boolean remove inode n inode state contains n if state null return false return list remove state | remove from the set |
public inode contains inode n return closed contains n | determine if the given state is contained |
public void insert inode n closed insert n | insert the board state into the open states |
public boolean remove inode n must get actual inode via contains which operates on equals since remove only operates on inode state contains n if state null return false return queue remove state | remove actual value from the set |
public boolean is empty return closed is empty | determine if open states is empty |
public int size return closed size | determine number of states in the set |
public inode remove throw new illegal state exception no semantic meaning associated with default remove operation on closed states | not expected to be called since this is the closed list |
public idebug search debug idebug search debugger idebug search old debug debug debugger return old | set the debugger to use when searching or null to turn off |
public depth first search this integer max value | construct a depth first search entity with no fixed depth |
public transition imove move inode prev this move move this prev prev | record the move and previous state of this transition |
public depth first search int bound this depth bound bound | construct a depth fixed search entity |
public solution inode initial inode goal idebug search debug this initial initial this goal goal this debug debug solve this success true | build the solution and work backwards with a debugger |
public void use legend boolean b legend on b | use or disuse legend |
public solution inode initial inode goal this initial goal null | build the solution and work backwards without a debugger |
public solution inode initial inode goal boolean success this initial goal null this success success | build the solution and work backwards without a debugger |
public solution inode initial inode goal idebug search debug boolean success this initial goal debug this success success | build solution with success or not |
public boolean succeeded return success | was this a successful solution |
public int num moves return moves size | number of moves in the solution |
public v search k k balanced binary node k v p root while p null int cmp compare k p key if cmp 0 return p value else if cmp 0 p p left else p p right not found return null | returns value associated with given key or tt null tt if the map |
private string format node right threaded binary node t node right threaded binary node t n string builder response new string builder if n node get left son null response append format node n response append node to string if n node get right son null response append format node n response append flatten return response to string | format the node recursively |
public dimensional comparator int d if d 1 throw new illegal argument exception dimensional comparator must have d 1 this d d | construct with the given dimensional index d 1 |
public string to string string builder sb new string builder double node imove node moves first boolean ends with comma false while node null sb append node value node node next ends with comma true if ends with comma sb delete char at sb length 1 return sb to string | return solution as a string |
public int compare imulti point o1 imulti point o2 return floating point compare o1 get coordinate d o2 get coordinate d | compare the two points against a given dimension |
public two dnode double coord ipoint point this coord coord this point point this region new two drectangle double negative infinity double negative infinity double positive infinity double positive infinity | stores the coordinate value to be used for dividing the plane either vertically |
private void solve inode n goal regenerate the trail of nodes into a double linked list double linked list imove list new double linked list imove work our way backwards until we terminate at the initial state while n null transition trans transition n stored data gone to the end if trans null break if debug null debug mark edge trans prev n list insert trans move n trans prev list is now the reverse of the solution path so we reverse it here moves new double linked list imove while list is empty moves insert list remove last | generate the solution for the search by working backwards to initial |
public void set root vertical node node root node | set the root of the two dtree |
public two dnode construct ipoint value return new horizontal node value | this method constructs the node of the appropriate class based upon the |
public two dnode get below return below | return node below this one |
public boolean is boundless for int i 1 i max i if double is infinite region get left i return false if double is infinite region get right i return false return true | determine if node has a boundless region associated with it |
public ipoint nearest ipoint target if root null target null return null find parent node to which target would have been inserted this is our best shot at locating closest point compute best distance guess so far two dnode parent parent target ipoint result parent point double smallest distance target result now start back at the root and check all rectangles that potentially overlap this smallest distance if better one is found return it double best new double smallest computed best distance ipoint better one root nearest target best if better one null return better one return result | find the nearest point in the two dtree to the given point |
public two dnode get above return above | return node above this one |
public boolean is leaf if below null return false if above null return false return true | determines if node is a leaf node i |
public void accept ivisitor t visitor if root null return accept null root visitor | accept a visitor for a inorder traversal |
protected void traverse two dnode node two dnode next node get below if next null traverse next visit node next node get above if next null traverse next | traverse starting at this given node |
public void traverse if tree null return two dnode node tree get root if node null return traverse node | control the traversal of the entire tree |
public irectangle get region return region | return region associated with this node |
public dimensional node get below return below | return node below this one |
public string to string if root null return string builder sb new string builder build string sb root return sb to string | reasonable to string to aid debugging |
public int next dimension dimensional node node return next dimension node dimension | helper method to always determine the next dimensionality given a node |
public void set below two dnode node if node null this below null return if node is vertical is vertical throw new illegal argument exception can only set as children nodes whose is vertical is different this below node split this below false | set the node below this one |
public void update rectangles vertical node vn get root vn region new two drectangle double negative infinity double negative infinity double positive infinity double positive infinity vn special update rectangle | propagate all rectangles down to leaves |
public int next dimension int d if d max dimension return 1 return d 1 | helper method to always determine the next dimensionality given an integer |
public void set above two dnode node if node null this above null return if node is vertical is vertical throw new illegal argument exception can only set as children nodes whose is vertical is different this above node split this above true | set node above this one |
public ihypercube region return region | return region being managed |
public void remove all root null | empty the kdtree of all of its internal points |
public v remove k key balanced binary node k v p get entry key if p null return null v old value p value delete entry p return old value | removes the mapping for this key from this tree map if present |
private void traverse dimensional node node dimensional node next node get below if next null traverse next visit node next node get above if next null traverse next | traverse starting at this given node |
public dimensional node get above return above | return node above this one |
public void traverse if cursor null return traverse cursor | control the traversal of the entire tree |
public void set below dimensional node node if node null this below null return node belongs here and we update node s region accordingly if this dimension max node dimension 1 this dimension 1 node dimension this below node we close off the above right area since node is below node region new hypercube region node region set right dimension coord return throw new illegal argument exception can only set as children nodes whose dimensionality is one greater | set the node below this one |
public void reset number 0 | reset the counter |
public int get count return number | retrieve the counter value |
public boolean has next return cur artificial root | as long as we havent hit the sentinel |
public void set above dimensional node node if node null this above null return node belong here and we update node s region accordingly if this dimension max node dimension 1 this dimension 1 node dimension this above node we close off the below left area since node is above node region new hypercube region node region set left dimension coord return throw new illegal argument exception can only set as children nodes whose dimensionality is one greater | set the node above this one |
public int get count long n array list long times timings get n if times null return 0 if times size 2 return times size return times size 2 | return the number of entries for given row |
public dimensional node get root return root | return the root of the kdtree |
public boolean is below imulti point pt return pt get coordinate dimension coord | returns whether the point is below the line represented by this node |
public void clear size 0 root null | empty out the tree |
protected void special update rectangle if below null split below false below special update rectangle if above null split above true above special update rectangle | called once the node has its region properly set and it must propagate |
protected dimensional node construct imulti point value if this dimension max return new dimensional node 1 value else return new dimensional node dimension 1 value | this method constructs the node of the appropriate class based upon the |
public t next t val t cur get value move on to the next one if no thread then find right child and get its left most descendant if cur is thread cur cur thread else cur cur get right son right threaded binary node t n if cur null throw new no such element exception next invoked after all elements have been returned if cur left son last then we need to pursue further while n cur get left son null cur n return val | return next in the chain |
public void set root dimensional node new root root new root if root null return construct initial region which will be partitioned by nodes as we recurse through tree double lows new double max dimension double highs new double max dimension for int i 0 i max dimension i lows i double negative infinity highs i double positive infinity hypercube region new hypercube lows highs root propagate region | set the root of the kdtree |
public string get average long n string row build row n string tokenizer st new string tokenizer row st next token skip n return st next token got average | return a single average if it exists in the table |
public string get maximum long n string row build row n string tokenizer st new string tokenizer row st next token skip n st next token skip avg st next token skip min return st next token got average | return maximum value for entry if it exists in the table |
protected double shorter double raw target double min we compare distance by subtracting squares from the current min if we ever fall below zero then we are too far otherwise we return sqrt double minsq min min double max v minsq for int i 0 i this max i double d raw target i cached i if max v d d 0 return 1 leave now can t be shorter return math sqrt minsq max v | given the target in optimized form determine if node is closer than min |
public string get minimum long n string row build row n string tokenizer st new string tokenizer row st next token skip n st next token skip avg return st next token got average | return minimum value for entry if it exists in the table |
public string get deviation long n string row build row n string tokenizer st new string tokenizer row st next token skip n st next token skip avg st next token skip min st next token skip max return st next token got average | return a single standard deviation if it exists in the table |
public void search ihypercube space ivisit kdnode visitor if root null return search visiting those nodes that are identified rather than storing root search space visitor | locate all points within the two dtree that fall within the given |
public void remove throw new unsupported operation exception thread until end is not mutable through the iterator | deny attempts to remove |
public string get row long n iterator long it timings key set iterator while it has next long existing it next if existing n return build row n nothing to return return | return a single row if it exists in the table |
public void search ihypercube space array list imulti point results wholly contained take all descendant points if space contains region this drain results return ok is our point at least contained if space intersects cached results add point recursively progress along both ancestral trees if demanded note that the cost in manipulating space to be cropped to the proper structure is excessive and leaving it alone has no bearing on the computation if space get left dimension coord if below null below search space results if coord space get right dimension if above null above search space results | locate all points within the kdtree that fall within the given hypercube |
public string compute table string builder sb new string builder sb append build header sb append n iterator long it timings key set iterator while it has next long n it next sb append build row n sb append n return sb to string | produce full table of information |
private void build string string builder sb dimensional node node if node null return dimensional node left node get below dimensional node right node get above if left null build string sb left sb append node to string if right null build string sb right | helper method for to string |
public string histogram string builder sb new string builder sb append build header sb append n iterator long it timings key set iterator while it has next long n it next sb append table for n append n sb append histogram separator append n sb append build table n sb append histogram separator append n n return sb to string | generate full histogram of unique values within the trial suite divided by n |
public string to string string pre h if is vertical pre v return pre point region region | reasonable to string method |
public int validate artificial root return artificial root value compare to null | placed here for the purpose of testing |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.