, providing a common way to build and manipulate a tree structure.TreeNode method, which is used to access the information of the node of the treeThe Mutabletreenode method is used on a variable tree (ability to add or remove child nodes)The TreeModel method is used to create and manage tree-related data models.Next, we will create a class that inherits JTree, providing the ability to parse XML documents and display nodes with visual JTree components.Creating
current node. p represents the current node 34 insertSubTree: function (xTree) {35 var s, q; 36 // x is the left subtree of p 37 if (this. leftTag = THREAD) {38 s = this. leftChild; // s is the precursor of p 39 this. leftTag = LINK; 40 this. leftChild = xTree; 41 q = xTree; 42 43 While (q. leftChild q. leftTag = LINK) q = q. leftChild; 44 // locate the leftmos
Using namespace STD;
This code is written in imitation books. However, compilation and translation fail. There are a lot of compilation errors. The compilation errors are as follows:
1> ------ build started: Project: dialogtest, configuration: Debug Win32 ------
1> compiling...
1> dialogtestdlg. cpp
1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator
1> C:/program files/Microsoft Visual Studio 9.0/VC/include/
current interval.
The code is implemented recursively:
voidQueryintk) { if(xTREE[K].R) {ans+=tree[k].sum; return ; } if(TREE[K].F) down (k);//It's good to omit it first. Long LongMid= (TREE[K].L+TREE[K].R) >>1; if(x1); if(y>mid) query (k1|1);}
Here's the point: Lazy sign
For the interval modification, we waste a lot of time on one of the changes, and modify it is not necessarily to check this point, in order to solve this problem, we
. This is a key point. For simple presentation, it is easier to retrieve data and place it in the shape of a tree. However, it is not easy to add, delete, modify, or delete a tree menu like desktop programming. In fact, I spent a lot of energy here. The first consideration is to implement these functions on your own, but I immediately rejected this stupid idea-now is not an era of "making wheels". I must learn to stand on the shoulders of giants.
Therefore, we decided to select a mature JS tree
Simple parameter configuration for flexible functions
1 DtreeDtree is a JS open-source tree component, use is particularly simple, you can open new links according to the tag, custom display icons and so on. The advantage is that the function is simple and practical, but does not support checkbox, does not support dynamic increment, delete node, move node. Of course, if you can use other things like jquery can be added dynamically, but this adds more code. References:A official website
Simple parameter configuration for flexible functions
1 DtreeDtree is a JS open-source tree component, use is particularly simple, you can open new links according to the tag, custom display icons and so on. The advantage is that the function is simple and practical, but does not support checkbox, does not support dynamic increment, delete node, move node. Of course, if you can use other things like jquery can be added dynamically, but this adds more code. References:A official website
idea of ①② CodeSUM (int k) { if(tree[k].l>=xtree[k].ry) { ans+ =tree[k].w; return ; } int m= (TREE[K].L+TREE[K].R)/2; if (x2); if (y>m) sum (k*2+1);}③ Correctness AnalysisSituation 1,3 Needless to say, for Case 2, the worst case is to search the leaf node, at this time must meet the situation 15, the interval modification, the time reason, later to fill upNow go back to the question in the exampleFirst, enter N,
Use hibernate to implement unlimited CLASSIFICATION OF TREE STRUCTURES
In the system, infinite tree structure classification is often used, such as Organization Management and Product/Region Classification. Generally, the following two methods are used:One is similar to Struts-menu (http://struts-menu.sourceforge.net) XML file management method, configuration is more convenient, but it is difficult to integrate with other applications in the system;The second is to use databas
Vulnerability file webmedia/common/function/xtree. aspINode_ID = Request. QueryString ("id ")If Len (Session ("SuperAdmin")> 0 or Len (Session ("LIVEAdmin")> 0 or Len (Session ("VODAdmin")> 0 thenSzSQL = "SELECT Type_ID, ParentID, TypeName FROM TypeInfo WHERE Type_ID> = 20 AND ParentID =" iNode_IDElseSzSQL = "SELECT Type_ID, ParentID, TypeName FROM TypeInfo WHERE Type_ID> 20 AND ParentID =" iNode_IDEnd ifRsData. Open szSQL, con, 1, 3SzRetVar = "Do w
js| algorithm
It's a bit of a hassle to implement a tree structure on a Web page.In the recent development of an MIS system, our project team has used a lot of tree structure: for example, the choice of personnel, the choice of units to wait.The database used by this MIS system is Oracle 9i. Oracle 9i SQL supports iterative queries. Our tree is written by the Ox, butAlso refer to the network of more famous XTree (can be downloaded here: http://webfx.
Another LCT template problem.How to find out if it's on the same tree? Just find the smallest point of depth is not the same point.That's the point at the far left of Splay.#include #include#include#include#defineMAXV 10050#defineMaxe 20050using namespacestd;intn,m,fath[maxv],size[maxv],tree[maxv][3],X,Y,REV[MAXV];intstack[maxv],top=0;Chars[ -];BOOLIsRootintx) { returntree[fath[x]][1]!=xtree[fath[x]][2]!=x;}voidPushdown (intx) { if(Rev[x]) {intl
, 1SourceObviously directly LCT on the line ... You can lay the mark on the Add and multiply.Remember to split instead of cut when calculating ... Do not delete the edges!!!I am a fool to add and multiply the mark as a bool ... WA's 4 rounds, 233.#include #include #include #include #include #define MAXN 100010#define LL unsigned int#define P 51061usingnamespace Std;Charch[3];intU,v,w;intN,m;intSta[maxn],top;structsplay{intfa,ch[2],size;BOOLRev; LL Sum,w,time,plus;} TREE[MAXN];void inch(intAMP;X)
Statistics count of the original treeLCT Dynamic Maintenance tree information. Better than the chain, but speed really does not have the advantage ...#include #include #include #include #include #define LL Long Long#define MAXN 50010#define MAXINT 0x7fffffffusing namespace STD;structsplay{intfa,ch[2]; LL sum,maxn,w;BOOLRev;} TREE[MAXN];intQ[maxn],top;Charch[Ten];voidPrint ();Long LongU,V,N,M,U[MAXN],V[MAXN];inline voidInLong LongAMP;X) {intflag=1;CharCh=getchar (); x=0; while(! (ch>=' 0 'ch' 9 '
The following figure shows how to use Struts-menu in my actual project.
1.
Copy necessary jar library files to dbmenu \ WEB-INF \ Lib
Log4j-
1.2.8
. Jar
Struts-menu-2.3.jar
Copy the menu-config.xml to the struts-menu.tld directory,
And some necessary images and jscripts, CSS to the corresponding directory
Images /*.*
Scripts/menuexpandable. js xtree. js
Styles/menuexpandable.css global.css xtree.css
2.
Modify the struts-config.xml file, add the fo
to see and is a compiler bug.
Fix to xstring
The string in P. J. STL adopts the copy on write and reference counting technologies. For the following code:String S1 = "ABC"; // Statement 1
String S2 = S1; // Statement 2
S2 = "123"; // Statement 3
When Statement 2 is executed, there will be no two "ABC" copies. Instead, S2 shares the memory with S1.
When Statement 3 is executed, the S2 value is rewritten, and memory is allocated separately.
The method to implement this is to reference the count.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.