How to traverse level by level in tree
Wondering if there were any suggestions on how to efficiently traverse through a tree level by level.
Here is my code for creating the tree.
public static void main(String[] args)
String userInput = "";
StringTokenizer tokenizedUserInput;
int numAdd = 0;
STree<Integer> completeTree = new STree<Integer>();
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter values for tree: ");
userInput = keyboard.nextLine();
tokenizedUserInput = new StringTokenizer(userInput, ", ");
while (tokenizedUserInput.hasMoreTokens())
numAdd = Integer.parseInt(tokenizedUserInput.nextToken());
completeTree.add(numAdd);
}
I have found a method to traverse through the tree level by level but it takes in a parameter of a node. I'm
not sure how to take my tree and pass it through the method. Here is the method:
public static <T> String levelByLevel(TNode<T> t)
LinkedQueue<TNode<T>> q = new LinkedQueue<TNode<T>>();
TNode<T> p;
String s = "";
q.push(t);
while(!q.isEmpty())
p = q.pop();
s += p.nodeValue + " ";
if(p.left != null)
q.push(p.left);
if(p.right != null)
q.push(p.right);
return s;
}
Similar Messages
-
How to get sequence number for tree level in tree table
Hi,
User would like to add a column as "Sequence" in the beginning of tree table. The tree table look like as following:
Sequence Tasks Date
1 ItemA
subItem1 12/31/12
subItem2 12/31/13
subItem3 12/31/14
2 ItemB
subItem1 12/31/12
subItem2 12/31/13
subitem3 12/13/14
How to add this sequence column in tree table?
Thanks!
SusanCheck this sample:
<af:form id="f1">
<af:treeTable value="#{bindings.Departments.treeModel}" var="node" styleClass="AFStretchWidth"
columnStretching="last" selectionListener="#{bindings.Departments.treeModel.makeCurrent}"
rowSelection="single" id="tt1">
<f:facet name="nodeStamp">
<af:column id="c1" headerText="Department Name" width="200">
<af:outputText value="#{node.index + 1} #{node.DepartmentName}" id="ot1"
visible="#{bindings.Departments.treeModel.depth == 0}"/>
</af:column>
</f:facet>
<f:facet name="pathStamp"></f:facet>
<af:column id="c2" headerText="Employee Name">
<af:outputText id="ot4" value="#{node.FirstName} #{node.LastName}"/>
</af:column>
</af:treeTable>
</af:form>Thanks,
Navaneeth -
How to find Level 1, Leve 2, Level 3 reporting manager
Hi Experts,
How to find Level 1, Level2, Level 3 reporting manager for an employee.
pernr--> leve1 manager --> leve2 manager --> leve3 manager .
Thanks in Advance.
Regards,
IFFHi,
For fetching Level 1 manaer, there are 2 options:
1.You can use FM RH_GET_LEADER for PERNR,Position or User
2.Use FM RH_READ_INFTY with Subtype = A008.
For Fetching level2 manager,
1. fetch Level 1 manager.
2. Get Level1 manager's Org.
3. Get Level2 manager using FM RH_GET_LEADER.
Thanks,
Dharitree -
How to make "Levels" in simple java game
I just wanted to know if anybody knew how to make "Levels" in a java game. In my case, it is to change two polygons that are used in the background. I think you have to use an array of some kind, but i dont really know.
Here is my source, the polygons are by the massive ///////// areas.
I cut out the majority of the program, because it was too long.
public class collision extends Applet implements MouseListener,MouseMotionListener
private Image rickImage,mazeImage;
Image Buffer;
Graphics gBuffer;
int x, y;
int[] LeftWallX = {0,204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,0};
int[] LeftWallY = {500,499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1};
//int[] PlayAreaX = {204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
// int[] PlayAreaY = {499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
int[] RightWallX = {500,500,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
int[] RightWallY = {500,0,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
boolean mouseInside, collide;
boolean rolled = false;
boolean msg = true;
int sX=204,sY=490,sW=12,sH=9;
//Declare the rectangles
Rectangle movingRect,finshBloc,startBloc,oopsBloc;
//Declare the polygons
Polygon leftWall,playerArea,rightWall;
///Initiate
public void init()
rickImage = getImage(getDocumentBase(), "rick.jpg");
mazeImage = getImage(getDocumentBase(), "maze1.jpg");
collide=false;
Buffer=createImage(getSize().width,getSize().height);
gBuffer=Buffer.getGraphics();
rightWall=new Polygon(RightWallX,RightWallY,18);
playerArea= new Polygon(PlayAreaX,PlayAreaY,31);
leftWall= new Polygon(LeftWallX,LeftWallY,17);
public void paint(Graphics g)
drawStuff();
g.drawImage (Buffer,0,0, this);
*/I'm not exactly sure in your case what you are trying to accomplish. If all you want to do is make new polygons for your levels then you will simply need a Vector of type level (or polygon). Store multiple levels/polygons in that vector. This can be done many ways, probably the most efficient way would be to create a class Level of sorts and create each level object from there. This way you have all your levels stored into that vector.
I have made programs where the levels/mazes are randomly generated based on certain parameters (this way you would not need to define any specific level). This can be done inside the Level class and added to the vector so that when a level is randomly generated there are literally infinite possibilities. I would suggest posting all your code or at least a breakdown UML diagram of what is going on in your entire program. -
How check page level permission on SharePoint pages library using JSOM
Hi,
Can anyone tell me how check page level permission on SharePoint pages library using JSOM.
Tanks in advance .
Regards,
Hari
Regards, HariHi,
According to your post, my understanding is that you want to check the page level permission on SharePoint Pages library via JSOM.
I have made a simple code demo to check whether current user has edit permission for the pages in Pages library, it works like a charm.
You can re-write it to fit your environment.
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
var web;
var list;
$(function(){
$("#Button1").click(function()
console.log(1);
getListItems('Pages',success_Items,error_Items);
console.log(2);
function getListItems(listTitle,success,error)
var context = SP.ClientContext.get_current();
this.web = context.get_web();
this.list = context.get_web().get_lists().getByTitle(listTitle);
this.items = list.getItems(SP.CamlQuery.createAllItemsQuery());
this._currentUser = web.get_currentUser();
context.load(this._currentUser);
context.load(web,'EffectiveBasePermissions');
context.load(items);
context.executeQueryAsync(
function() {
success(items);
error
function success_Items(items){
var e = items.getEnumerator();
while (e.moveNext()) {
this.item = e.get_current();
console.log(this.item.get_item('FileLeafRef')); //print File or Folder Name
console.log(this.item.get_item('FileRef')); //print File or Folder Url
if (this.web.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems)) {
console.log('Nice, edit list item permissions!');
else {
console.log('Boo, no edit list item permissions!');
function error_Items(sender,args){
console.log(args.get_message());
</script>
<input id="Button1" type="button" value="Check Permissions"/>
Thanks & Regards,
Jason
Jason Guo
TechNet Community Support -
How many dunning levels can be defined ?
< MODERATOR: Message locked. Please read the [Rules of Engagement|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement] before posting next time. Suspected points abuse. >Hello friends
Could u tell me,how many dunning levels can be defined ?
regards
AAhi anu
Insap provides max 9 levels but all companies use 4 levels only.If u want use 9 levels also.
At the time of FBMP configuration u cen give Dunning levels field 9.and then save.U cen run 9 levels inDUNNING RUN F150.
Deifference is one level to another level DUNNING TEXT.
Dunning text determines URGENCY OF DUNNING NOTICE.
U cen give 9 levels dunning text also at the time of fbmp configaration
Edited by: prasad k on Jul 11, 2008 3:14 PM -
Can anybody tell me how connect by level works
Hi ,
Can anybody tell me how connect by level works
select level
from dual
connect by level <= 10 ;Yes, fully agreed, but still:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:40476301944675#51121960168460
That might be an old example, but dual's behaviour changes often whenever a new database version gets shipped, like FAST DUALwas 'invented' for Optimizer since 10G.
Oh well, I know you know all that ;)
though of course any one row table could be usedTrue and interesting, but would you dare to replace all references to dual on a production system to another one row table?
Theoretically you're right, but imo (and others) Oracle keeps on doing stuff for dual 'under the hood'.
It is a totally different 'table'.
That's my point to OP.
Maybe I was and am only nitpicking, I now realize, so I'll go get me some coffee ;) -
How to traverse the XML tree.
hi ,
i would like to know if there is a sample code snippet
showing how to walk through the Document object tree
generated by the DOM parser for a given XML input.
Thanks.
Sandeep.
nullsandeep (guest) wrote:
: hi,
: can you please tell as to where is the selectNodes() method
: defined. I could not locate it.
: Thanks.
: Sandeep.
: Oracle XML Team wrote:
: : Sandeep (guest) wrote:
: : : hi ,
: : : i would like to know if there is a sample code snippet
: : : showing how to walk through the Document object tree
: : : generated by the DOM parser for a given XML input.
: : : Thanks.
: : : Sandeep.
: : Take a look at the selectNodes() method. It takes XPath
syntax
: : to navigate through the XML document.
: : Oracle XML Team
: : http://technet.oracle.com
: : Oracle Technology Network
selectNodes() is part of oracle.xml.parser.v2.XMLNode. You can
find any method by opening AllNames.html in the doc directory.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
How to traverse repository nodes in weblogic 8.1
hi ,
like binary search tree , how to traverse all node in repository .(can have many hierarchy node or content node ) .
i have to traverse all content and hierarchy node .hi raj ,
actually i have to traverse a node in repository 8.1 ,(like binary search tree).
like u got a node then u have to check that how many content node /or hierarchy node it have , then check each of its content node/hierarchy node , then again check its child status (content/or hierarchy )same like binary search tree traversal .
i try to make recursive code for that but not working properly , its searching at 2/3 levels , not at all levels .
so if u can make recursive method for that i 'll appreciate u .
thanks
attaching my code for little help :
public static void searchNode(Node node){
if(node.getType()==Node.HIERARCHY){
try{
System.out.println( " Hierarchy content +node.getName());
n=node.getChildren();
for(int i=0;i<n.length;i++){
System.out.println("child "+n.getName());
searchNode(n[i]);
catch(Exception e)
System.out.println("");
else //node.getType()==Node.CONTENT
try{
Property p[]=node.getProperties();
for(int i=0;i<p.length;i++)
if(p[i].getValue() !=null && p[i].getType() == Property.BINARY )
System.out.println(" got property file " + p[i].getValue());
fname=p[i].getValue().toString();
System.out.println(" adding "+fname+" these file to array list " );
al.add(fname);
System.out.println(" file added ");
catch(Exception e) -
How to not display nodes in a tree if Oracle roles are NOT used?
How to not display nodes in a tree if Oracle roles are NOT used?
We don't use Oracle DB roles to grant users access to Forms from the menu. We use a template and role system of our own. Basically a few tables with templates and roles.
We want to convert our normal Forms menu to a tree menu and one of our key requirements is that when the tree is populated ONLY nodes with programs (i.e. forms) he has been granted to execute is shown.
Since we don't use Oracle Roles how to do this in a tree?
I created a function to show/hide LEAF nodes, BUT problem is that there are sub-menu nodes showing even if the leaf-nodes under it has not being displayed. My function has suppressed it.
My tree query is like this:
SELECT
t.status, LEVEL, t.label, t.icon, t.node VALUE
FROM
tma_tree_menu t
WHERE
tma_authenticate_sys_chk_role(USER, t.node) = 1
CONNECT BY
PRIOR t.node = t.master
START WITH
t.MASTER IS NULL
ORDER SIBLINGS BY
t.position
The tma_authenticate_sys_chk_role will return 1 only if the user has access to the form under that node.
I tried the FTree functions in Forms but even that has nothing.
Any help would be greatly appreciated.
Edited by: Channa on Mar 17, 2010 6:49 AMWould you share the source code? I guess what I need is how exactly you retreive the user credentials from the DB table and set that boolean variable.
and then how to condition it in UIX? -
hello everyone,
can anybody help me how to traverse folders using scripting?
I want to compress a folder to a zip file using scripting.
thanksThis will leg a list of all files in each folder and sub folders...
var folders =[];
var topLevel = Folder.selectDialog("Please select top level folder");
//get a list of all sub folders
folders = FindAllFolders(topLevel, folders);
folders.unshift(topLevel);
for(var a in folders){
//get a list of all files in each folder in turn
var folderList = folders[a].getFiles();
//do whatever to each file list
function FindAllFolders( srcFolderStr, destArray) {
var fileFolderArray = Folder( srcFolderStr ).getFiles();
for ( var i = 0; i < fileFolderArray.length; i++ ) {
var fileFoldObj = fileFolderArray[i];
if ( fileFoldObj instanceof File ) {
} else {
destArray.push( Folder(fileFoldObj) );
FindAllFolders( fileFoldObj.toString(), destArray );
return destArray;
To get all files in one folder it would be ...
var topLevel = Folder.selectDialog("Please select top level folder");
topLevel.getFiles(); -
How to Purchase group configer in dev system and how to traverse quality
Hi All
I need ur help regarding for how to configer the Purchaseing group in dev system and how to traverse to Quality and production.
Thanks
HappyHi,
You can create the Purchasing Groups using the following settings.
SPRO-MM-Purchasing-Create Purchasing Groups.
Create a new entry for Purchasing group & save it in a Transport request & transport it to QAS & PRD.
Note: We define the Purchasing Groups @ client level
Thanks & Regards, -
hi ,
how to traverse repository .i got one node and i have to traverse all node and child node(hierarchy node and content node), like binary search in tree .Here's some utiltity code we used in GroupSpace:
INodeManager nodeManager = ContentManagerFactory.getNodeManager();
Set<Node> set = new TreeSet<Node>();
int limit = 1000; // stop after 1000 nodes, can be anything
ContentContext context = new ContentContext();
String path = "/" + repositoryName; // whatever that is for you
// Recurse -- see method below
recurseRepository(context, path, set, limit);
// Look at contents
for (Node node:set)
System.err.println(node.getPath()); // or whatever
* Recurse the repository but stop after N nodes
public static void recurseRepository(ContentContext cc, String path, Set set, int limit) throws Exception
if (set.size() <= limit)
Node inNode = nodeManager.getNode(cc, path);
Node [] nodes = inNode.getChildren();
for (int i=0; i<nodes.length;i++)
Node node = nodes;
set.add(node);
recurseRepository(cc,node.getPath(),set, limit);
Hope that helps. -
How to hide a list from SharePoint tree view pro grammatically.
Hi,
I have enabled tree view for a SharePoint 2013 site pro grammatically.
I want hide some specific lists from that tree view like Documents, Workflow, Task List, Calender
Lists which are created default when we create a site.
How could i do that?I know how to hide Quick launch and Enable Tree view with properties in C#.
My question is
hide some specific lists from that tree view like Documents,
Workflow, Task List, Calender
Lists which are created default when we create a site. -
How to get Text for nodes in Tree Structure
Hi Friends,
How to get Text for nodes in Tree Structure
REPORT YFIIN_REP_TREE_STRUCTURE no standard page heading.
I N I T I A L I Z A T I O N
INITIALIZATION.
AUTHORITY-CHECK OBJECT 'ZPRCHK_NEW' :
ID 'YFIINICD' FIELD SY-TCODE.
IF SY-SUBRC NE 0.
MESSAGE I000(yFI02) with SY-TCODE .
LEAVE PROGRAM.
ENDIF.
class screen_init definition create private.
Public section
public section.
class-methods init_screen.
methods constructor.
Private section
private section.
data: container1 type ref to cl_gui_custom_container,
container2 type ref to cl_gui_custom_container,
tree type ref to cl_gui_simple_tree.
methods: fill_tree.
endclass.
Class for Handling Events
class screen_handler definition.
Public section
public section.
methods: constructor importing container
type ref to cl_gui_custom_container,
handle_node_double_click
for event node_double_click
of cl_gui_simple_tree
importing node_key .
Private section
private section.
endclass.
*& Classes implementation
class screen_init implementation.
*& Method INIT_SCREEN
method init_screen.
data screen type ref to screen_init.
create object screen.
endmethod.
*& Method CONSTRUCTOR
method constructor.
data: events type cntl_simple_events,
event like line of events,
event_handler type ref to screen_handler.
create object: container1 exporting container_name = 'CUSTOM_1',
tree exporting parent = container1
node_selection_mode =
cl_gui_simple_tree=>node_sel_mode_multiple.
create object: container2 exporting container_name = 'CUSTOM_2',
event_handler exporting container = container2.
event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
event-appl_event = ' '. "system event, does not trigger PAI
append event to events.
call method tree->set_registered_events
exporting events = events.
set handler event_handler->handle_node_double_click for tree.
call method: me->fill_tree.
endmethod.
*& Method FILL_TREE
method fill_tree.
data: node_table type table of abdemonode,
node type abdemonode.
types: begin of tree_node,
folder(50) type c,
tcode(60) type c,
tcode1(60) type c,
tcode2(60) type c,
text(60) type c,
text1(60) type c,
text2(60) type c,
end of tree_node.
data: wa_tree_node type tree_node,
t_tree_node type table of tree_node.
wa_tree_node-folder = text-001.
wa_tree_node-tcode = text-002.
wa_tree_node-text = 'Creditors ageing'.
wa_tree_node-tcode1 = text-003.
wa_tree_node-text1 = 'GR/IR aging'.
wa_tree_node-tcode2 = text-004.
wa_tree_node-text2 = 'Bank Balance'.
append wa_tree_node to t_tree_node.
clear wa_tree_node .
wa_tree_node-folder = text-005.
wa_tree_node-tcode = text-006.
wa_tree_node-text = 'Creditors ageing'.
wa_tree_node-tcode1 = text-007.
wa_tree_node-text1 = 'Creditors ageing'.
wa_tree_node-tcode2 = text-008.
wa_tree_node-text2 = 'Creditors ageing'.
append wa_tree_node to t_tree_node.
clear wa_tree_node .
wa_tree_node-folder = text-009.
wa_tree_node-tcode = text-010.
wa_tree_node-text = 'Creditors ageing'.
wa_tree_node-tcode1 = text-011.
wa_tree_node-text1 = 'Creditors ageing'.
wa_tree_node-tcode2 = text-012.
wa_tree_node-text2 = 'Creditors ageing'.
append wa_tree_node to t_tree_node.
clear wa_tree_node .
node-hidden = ' '. " All nodes are visible,
node-disabled = ' '. " selectable,
node-isfolder = 'X'. " a folder,
node-expander = ' '. " have no '+' sign forexpansion.
loop at t_tree_node into wa_tree_node.
at new folder.
node-isfolder = 'X'. " a folder,
node-node_key = wa_tree_node-folder.
clear node-relatkey.
clear node-relatship.
node-text = wa_tree_node-folder.
node-n_image = ' '.
node-exp_image = ' '.
append node to node_table.
endat.
at new tcode .
node-isfolder = ' '. " a folder,
node-n_image = '@CS@'. "AV is the internal code
node-exp_image = '@CS@'. "for an airplane icon
node-node_key = wa_tree_node-tcode.
node-text = wa_tree_node-text .
node-relatkey = wa_tree_node-folder.
node-relatship = cl_gui_simple_tree=>relat_last_child.
endat.
append node to node_table.
at new tcode1 .
node-isfolder = ' '. " a folder,
node-n_image = '@CS@'. "AV is the internal code
node-exp_image = '@CS@'. "for an airplane icon
node-node_key = wa_tree_node-tcode1.
node-relatkey = wa_tree_node-folder.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = wa_tree_node-text1.
endat.
append node to node_table.
at new tcode2 .
node-isfolder = ' '. " a folder,
node-n_image = '@CS@'. "AV is the internal code
node-exp_image = '@CS@'. "for an airplane icon
node-node_key = wa_tree_node-tcode2.
node-relatkey = wa_tree_node-folder.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = wa_tree_node-text2.
endat.
append node to node_table.
endloop.
call method tree->add_nodes
exporting table_structure_name = 'ABDEMONODE'
node_table = node_table.
endmethod.
endclass.
*& Class implementation
class screen_handler implementation.
*& Method CONSTRUCTOR
method constructor.
create object: HTML_VIEWER exporting PARENT = CONTAINER,
LIST_VIEWER exporting I_PARENT = CONTAINER.
endmethod.
*& Method HANDLE_NODE_DOUBLE_CLICK
method handle_node_double_click.
case node_key(12).
when 'Creditors'.
submit YFIIN_REP_CREADITORS_AGING via selection-screen and return.
when 'Vendor'.
submit YFIIN_REP_VENDOR_OUTSTANDING via selection-screen and return.
when 'Customer'.
submit YFIIN_REP_CUSTOMER_OUTSTANDING via selection-screen and
return.
when 'GR/IR'.
submit YFIIN_REP_GRIR_AGING via selection-screen and return.
when 'Acc_Doc_List'.
submit YFIIN_REP_ACCOUNTINGDOCLIST via selection-screen and return.
when 'Bank Bal'.
submit YFIIN_REP_BANKBALANCE via selection-screen and return.
when 'Ven_Cus_Dtl'.
submit YFIIN_REP_VENDORCUST_DETAIL via selection-screen and return.
when 'G/L_Open_Bal'.
submit YFIIN_REP_OPENINGBALANCE via selection-screen and return.
when 'Usr_Authn'.
submit YFIIN_REP_USERAUTHRIZATION via selection-screen and return.
endcase.
endmethod.
endclass.
Program execution ************************************************
load-of-program.
call screen 9001.
at selection-screen.
Dialog Modules PBO
*& Module STATUS_9001 OUTPUT
text
module status_9001 output.
set pf-status 'SCREEN_9001'.
set titlebar 'TIT_9001'.
call method screen_init=>init_screen.
endmodule. " STATUS_9001 OUTPUT
Dialog Modules PAI
*& Module USER_COMMAND_9001 INPUT
text
module user_command_9001 input.
endmodule. " USER_COMMAND_9001 INPUT
*& Module exit_9001 INPUT
text
module exit_9001 input.
case sy-ucomm.
when 'EXIT'.
set screen 0.
endcase.
endmodule.
exit_9001 INPUTyou can read the table node_table with nody key value which imports when docubble click the the tree node (Double clifk event).
Regards,
Gopi .
Reward points if helpfull.
Maybe you are looking for
-
Error: Microsoft word web app -Sorry we ran into a problem - IE 11
Hi, I am using Windows 8\Office 2013 32bit\IE 11. When opening word docs in SharePoint 2013, the Word Web App shows the error "Microsoft word web app -Sorry we ran into a problem" and does not open the file. SharePoint site is a http one. The docume
-
Reporting CLOB columns in Analysis
Hi, I've created a view in the database which has a CLOB column. For this column I've use the DBMS_LOB.SUBSTR(<Clob column>) as detailed in the following forum note Reporting on CLOB not working in OBIEE The CLOB column in the RDP Physical and BMM la
-
Issue in installing Oracle !! root.sh giving problem
I am trying to install Oracle RAC on Linux and I am facing one issue at root.sh. Introduction to hardware: H/W :- Intel Xeon Dual core CPU 2.0 GHz x 2 Nos / 4 GB RAM /6 NIC with 3 bond(0,1,2) / 2 FC port to access SAN /SWAP =8 GB SAN = EMC CX3-80 SAN
-
Open first item in detailed navigation
Hello, When I click on a navigation element in the 2nd level I would like to automatically open the first element of the detailed navigation. My problem is that if the element of the detailed navigation is a folder it doesn't open the first subelemen
-
I've got a custom-written wallboard to monitor agents and traffic real-time. When I change a competance level or remove a skill, the agent's records are no longer available in the AgentStateDetail table. Because of this, the agent's status is unknown