外文分享

Confused - Height of Binary tree

ⅰ亾dé卋堺 提交于 2021-02-20 06:47:11
问题 I'm somewhat confused between the logic of calculating the height of binary tree. Code 1 public static int findHeight(Tree node) { if(node == null) return 0; else { return 1+Math.max(findHeight(node.left), findHeight(node.right)); } } Code 2 public static int findHeight(Tree node) { if(node == null) return -1; else { return 1+Math.max(findHeight(node.left), findHeight(node.right)); } } I think, the second one is correct, since it gives the correct answer for below code :- Tree t4 = new Tree(4

Add external javascript file in wordpress

元气小坏坏 提交于 2021-02-20 06:47:09
问题 I want to add more than one external javascript files in wordpress theme, I have found code for adding one file, but I need to add more javascript files. How can I do it? function wpTan_scripts() { wp_register_script('app', '/js/app.js', false); wp_enqueue_script( 'app' ); } add_action('wp_enqueue_scripts', 'wpTan_scripts'); 回答1: you can add as many scripts as you want. function themeslug_enqueue_script() { wp_enqueue_script( 'jquery-v-2', 'http://code.jquery.com/jquery-2.1.3.min.js', false )

Stop windows service before perform the uninstallation

假装没事ソ 提交于 2021-02-20 06:47:05
问题 I have an installer that installs few components including windows service, after it installed it'll start the service that installed onto the system using CustomAction. The problem when I uninstall the application, the installer asks to close the application before continue. I created a custom action that will stop the service, and I scheduled it with Uninstall actions. But its not executed until I press OK for the error dialog after manually stop the service. It failed on Win7, but I tested

Emacs rearrange split panes

本小妞迷上赌 提交于 2021-02-20 06:46:08
问题 If I'm working in (terminal) Emacs and have 2 buffers on screen using a horizontal split: +--------------------------+ | | | | | | | | +--------------------------+ | | | | | | | | +--------------------------+ Then I decide to open the slime repl, Emacs will split one of those horizontal panes vertically: +--------------------------+ | | | | | | | | +-------------+------------+ | | | | | slime | | | | | | | +-------------+------------+ But what I want is to have slime on the right, using the

Cyclic dependency of modules

点点圈 提交于 2021-02-20 06:45:48
问题 I want to write a parser in F# and because of reasons I have to use Antlr. This means I have to define a Visitor class for every AST node I want to parse. Now I have the problem that there are some rules with cyclic dependencies like: boolExpr : boolTerm 'or' boolTerm ; boolTerm : boolAtom 'and' boolAtom ; boolAtom : '(' boolExpr ')' | ... ; which means I need 3 visitor classes that have the same cyclic dependency and I want to have each of them in their own file //BoolExprVisitor.fs let

JWT-based authentication for <img> tags?

我怕爱的太早我们不能终老 提交于 2021-02-20 06:45:13
问题 Supposed I have a single page application that uses JWT tokens to authenticate against a backend REST api. I transfer the JWT token inside the http header when doing a REST request. So far, so good. Now, supposed I want to download an image from the server, and I want the image only to be accessible for authenticated users. On the server, this is no problem: Simply define a route that delivers the image, and in that route verify the JWT token. But: How do I transfer the token from the client

tkinter resize frame and contents with main window

£可爱£侵袭症+ 提交于 2021-02-20 06:45:09
问题 I am trying to work out how to control resizing of the window containing a frame. In the code I have three buttons across the top that should to stay exactly where they are. When I drag the window to expand it, I want the frame and the text box it contains to expand with the master window. I have read that columnconfigure and rowconfigure can be used but not sure how to implement it. from tkinter import * from tkinter import scrolledtext master_window = Tk() # Create the buttons btn_Image =

EqualsIgnoreCase() not working as intended.

家住魔仙堡 提交于 2021-02-20 06:44:22
问题 When i run the following program it prints only equals says they are equal However From equalsIgnoreCase docs in java 8 we have : Two characters c1 and c2 are considered the same ignoring case if at least one of the following is true: • Applying the method java.lang.Character.toUpperCase(char) to each character produces the same result public class Test { public static void main(String[] args) { String string1 = "abc\u00DF"; String string2 = string1.toUpperCase(); if (string1.equalsIgnoreCase

ambiguous call to overloaded function

六月ゝ 毕业季﹏ 提交于 2021-02-20 06:44:07
问题 I have two functions: void DoSomething( const tchar* apsValue ) void DoSomething( size_t aiValue ) Now I want to pass '0' as a size_t: DoSomething(0); The compiler throws an error: "ambiguous call to overloaded function" To solve this, I can use static_cast, for instance: DoSomething(static_cast<size_t>(0)); Or simple: DoSomething(size_t(0)); Is one of them better than the other? Are there any other approaches to solve this? 回答1: It's ambiguous because 0 has type int , not size_t . It can

ambiguous call to overloaded function

百般思念 提交于 2021-02-20 06:44:05
问题 I have two functions: void DoSomething( const tchar* apsValue ) void DoSomething( size_t aiValue ) Now I want to pass '0' as a size_t: DoSomething(0); The compiler throws an error: "ambiguous call to overloaded function" To solve this, I can use static_cast, for instance: DoSomething(static_cast<size_t>(0)); Or simple: DoSomething(size_t(0)); Is one of them better than the other? Are there any other approaches to solve this? 回答1: It's ambiguous because 0 has type int , not size_t . It can