ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > Downloads > Commands
Downloads

Latest Files
Latest Files
Most Popular Files
Most Popular Files
Top Contributors
Top Contributors
Tom David 47
Tyson Nordgren 35
Paul Toone 31
Matt Long 29
Phil BoBo 18
Regan Blackett 16
Cliff King 14
Cameron Pluim 11
Alex Christensen 8
Brandon Peterson 6

Uploaded files must be in one of the following formats: zip rar jpg jpeg jpg2 gif png pdf fsm xls xlsx doc docx ppt pptx

Please no copyrighted material without author's permission!!
  
Navigation
Main | Category Tree | Stats
Downloads [Download swapnodes]
File Name: swapnodes (814 Bytes) Download
Author: Alex Christensen)
Date Added: 07-08-2008
Downloads: 2001
Grade: Not Rated
Description
This is a command for manipulating tree data. It is automatically installed with the library.

Name: swapnodes
Parameters: (treenode tn1, treenode tn2)
Descriptrion: Swaps tn1 and tn2 in the tree. Children of tn1 and tn2 are also moved. Locations in memory are unchanged (a global variable set to point to tn1 will stay pointing to tn1, same with tn2)
Example: swapnodes(last(model()),prev(last(model())));
Code:
treenode tn1=parnode(1);
treenode tn2=parnode(2);
int rank1=getrank(tn1);
int rank2=getrank(tn2);
if(up(tn1)==up(tn2)){
    if(rank1>rank2){
        setrank(tn1,rank2);
        setrank(tn2,rank1);
    }
    else{
        setrank(tn2,rank1);
        setrank(tn1,rank2);
    }
}
else{
    treenode temp=up(tn2);
    transfernode(tn2,up(tn1));
    transfernode(tn1,temp);
    setrank(tn1,rank2);
    setrank(tn2,rank1);
}
Images
None
Downloads [Download swapnodes]


Comments

DownloadsII 5.1.2 by CyberRanger & Jelle
Based on ecDownloads 4.1 © Ronin

All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.