Search Results

Search found 4088 results on 164 pages for 'avl tree'.

Page 28/164 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Tree deletion with NHibernate

    - by Tigraine
    Hi, I'm struggling with a little problem and starting to arrive at the conclusion it's simply not possible. I have a Table called Group. As with most of these systems Group has a ParentGroup and a Children collection. So the Table Group looks like this: Group -ID (PK) -Name -ParentId (FK) I did my mappings using FNH AutoMappings, but I had to override the defaults for this: p.References(x => x.Parent) .Column("ParentId") .Cascade.All(); p.HasMany(x => x.Children) .KeyColumn("ParentId") .ForeignKeyCascadeOnDelete() .Cascade.AllDeleteOrphan() .Inverse(); Now, the general idea was to be able to delete a node and all of it's children to be deleted too by NH. So deleting the only root node should basically clear the whole table. I tried first with Cascade.AllDeleteOrphan but that works only for deletion of items from the Children collection, not deletion of the parent. Next I tried ForeignKeyCascadeOnDelete so the operation gets delegated to the Database through on delete cascade. But once I do that MSSql2008 does not allow me to create this constraint, failing with : Introducing FOREIGN KEY constraint 'FKBA21C18E87B9D9F7' on table 'Group' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Well, and that's it for me. I guess I'll just loop through the children and delete them one by one, thus doing a N+1. If anyone has a suggestion on how do that more elegantly I'd be eager to hear it.

    Read the article

  • jquery tree traversing help

    - by rod
    Hi All, Given simple DOM: <form id="form1">...</form> <div> <div> <a href="#" id="export">Export</a> </div> </div> Starting with id=export, is there a way to go up a variable amount of divs and then get the closest form id? Thanks, rodchar

    Read the article

  • heirarchial data from self referencing table in tree form

    - by Beta033
    Ii looks like this has been asked and answered in all the simple cases, excluding the one that i'm having trouble with. I've tried using a recursive CTE to generate this, however maybe a cursor would be better? or maybe a set of recursive functions will do the trick? Can this be done in a cte? consider the following table PrimaryKey ParentKey 1 NULL 2 1 3 6 4 7 5 2 6 1 7 NULL should yield PK 1 -2 --5 -6 --3 7 -4 where the number of - marks equal the depth, my primary difficulty is the ordering.

    Read the article

  • RubyMine Folder Tree doesn't refresh

    - by user336514
    Hi Using RubyMine 2.0.2 for the first time today, on Mac OSX Leopard. If I create files in the filesystem (with, say, script/generate) those new files do not appear in rubymine. I have had limited success with restarting the program, in that the files in the db/ folder are added and removed, but unfortunately new folders in the views directory are not shown. Pardon my french, but wtf? Thanks

    Read the article

  • Balanced Search Tree Query, Asymtotic Analysis..

    - by AGeek
    Hi, The situation is as follows:- We have n number and we have print them in sorted order. We have access to balanced dictionary data structure, which supports the operations serach, insert, delete, minimum, maximum each in O(log n) time. We want to retrieve the numbers in sorted order in O(n log n) time using only the insert and in-order traversal. The answer to this is:- Sort() initialize(t) while(not EOF) read(x) insert(x,t); Traverse(t); Now the query is if we read the elements in time "n" and then traverse the elements in "log n"(in-order traversal) time,, then the total time for this algorithm (n+logn)time, according to me.. Please explain the follow up of this algorithm for the time calculation.. How it will sort the list in O(nlogn) time?? Thanks.

    Read the article

  • findNode in binary search tree

    - by Weadadada Awda
    Does this look right? I mean I am trying to implement the delete function. Node* BST::findNode(int tofind) { Node* node = new Node; node = root; while (node != NULL) { if (node->val == tofind) { return node; } else if (tofind < node->val) { node = node->left; } else { node = node->right; } } } Here is the delete, it's not even close to done but, void BST::Delete(int todelete) { // bool found = false; Node* toDelete = new Node(); toDelete=findNode(todelete); if(toDelete->val!=NULL) { cout << toDelete->val << endl; } } This causes a segmentation fault just running that, any ideas?

    Read the article

  • How to parse a directory tree in python?

    - by chutsu
    I have a directory called "notes" within the notes I have categories which are named "science", "maths" ... within those folder are sub-categories, such as "Quantum Mechanics", "Linear Algebra". ./notes --> ./notes/maths ------> ./notes/maths/linear_algebra --> ./notes/physics/ ------> ./notes/physics/quantum_mechanics My problem is that I don't know how to put the categories and subcategories into TWO SEPARATE list/array.

    Read the article

  • XSLT: Transform XML files tree

    - by Myniva
    I have the following file structure (XML files 'index.xml' in nested folders): index.xml foo/index.xml foo/sub/index.xml foo/.../index.xml bar/.../index.xml Now I have to transform each of this XML files with a given XSL stylesheet. The result should be the same folder structure (overwriting would be OK). What would be your approach to achieve this? My system: OS X 10.6, Saxon XSLT processor

    Read the article

  • How to use C# nested structures to access tree of data

    - by zotty
    I'm importing some XML to C#, and want to be able to access data from the XML in the form of what I think is a nested structure. (I may be wrong!) What I have in my XML is in the following form: <hardwareSettings initial="true> <cameraSettings width="1024" height="768" depth="8" /> <tiltSettings theta="35" rho="90"> </hardwareSettings> I can import each setting alright, so I have them all in individual ints, but I would like to be able to access it in the form int x=hardwaresettings.camerasettings.width; int rho=hardwaresettings.tiltsettings.rho; I've tried various arrangements of structs within structs, but I don't seem able to cast a new object (hardwaresettings) that contains the appropriate children (camerasettings.width & tiltsettings.rho). Sorry if I'm not using the right lingo... I'm reading myself in circles here!

    Read the article

  • Tree + Recursion..

    - by RBA
    Hi.. I came across an article on Binary Trees Search . It uses intensive Recursive Algorithms.. I am just so confused with these stuff.. Please guide my path so as I understand these problems at ease, or any good website to read about recursion first and then solving these problems.. Please share your experience on it.. Its very urgent, and I want to learn these concepts as soon as possible.. Thankss... Regards.

    Read the article

  • php $_SESSION[document_root] too far down the tree

    - by Idealflip
    Hi, I have multiple sub-domains within the document_root. And multiple folders/classes within those sub-domain folders. I need something that will help me with my include_once paths, but $_SESSION[DOCUMENT_ROOT] goes too far down. And if I were to use this, and transfer the website folder later, all my include_once paths will/might break. Hope my question is clear... Any recommendations?

    Read the article

  • get attributes from xml tree using linq

    - by nelsonwebs
    I'm working with an xml file that looks like this: <?xml version="1.0" encoding="UTF-8"?> <element1 xmlns="http://namespace1/"> <element2> <element3> <element4 attr1="2009-11-09"> <element5 attr2="NAME1"> <element6 attr3="1"> <element7 attr4="1" attr5="5.5" attr6="3.4"/> </element6> </element5> <element5 attr2="NAME2"> <element6 attr3="1"> <element7 attr4="3" attr5="4" attr6="4.5"/> </element6> </element5> </element4> </element3> </element2> </element1> Where I need to loop through element5 and retrieve the attributes in an Ienumberable like this: attr1, attr2, attr3, attr4, attr5, attr6 using linq to xml and c#. I can loop through the element5 and get all the attribute2 info using but I can't figure out how to get the parent or child attributes I need. UPDATE: Thanks for the feeback thus far. For clarity, I need to do a loop through attribute5. So basically, what I have right now (which isn't much) is . . . XElement xel = XElement.Load(xml); IEnumberable<XElement> cList = from el in xel.Elements(env + "element2").Element (n2 + "element3").Elements(n2 + "element4").Elements(ns + "element5") select el; foreach (XElement e in cList) Console.WriteLine(e.Attribute("attr2").Value.ToString()); This will give me the value all the attr 2 in the loop but I could be going about this all wrong for what I'm trying to acheive. I also need to collect the other attributes mentioned above in a collection (the Console reference is just me playing with this right now but the end result I need is a collection). So the end results would be a collection like attr1, attr2, attr3, attr4, attr5, attr6 2009-11-09, name1, 1, 1, 5.5, 3.4 2009-11-09, name2, 1, 3, 4, 4.5 Make Sense?

    Read the article

  • hierarchical data from self referencing table in tree form

    - by Beta033
    It looks like this has been asked and answered in all the simple cases, excluding the one that I'm having trouble with. I've tried using a recursive CTE to generate this; however maybe a cursor would be better? Or maybe a set of recursive functions will do the trick? Can this be done in a cte? consider the following table PrimaryKey ParentKey 1 NULL 2 1 3 6 4 7 5 2 6 1 7 NULL should yield PK 1 -2 --5 -6 --3 7 -4 where the number of - marks equal the depth, my primary difficulty is the ordering.

    Read the article

  • How to create and Expression tree to do the same as "StartsWith"

    - by Jonathan
    Hi to all. Currently, I have this method to compare two numbers Private Function ETForGreaterThan(ByVal query As IQueryable(Of T), ByVal propertyValue As Object, ByVal propertyInfo As PropertyInfo) As IQueryable(Of T) Dim e As ParameterExpression = Expression.Parameter(GetType(T), "e") Dim m As MemberExpression = Expression.MakeMemberAccess(e, propertyInfo) Dim c As ConstantExpression = Expression.Constant(propertyValue, propertyValue.GetType()) Dim b As BinaryExpression = Expression.GreaterThan(m, c) Dim lambda As Expression(Of Func(Of T, Boolean)) = Expression.Lambda(Of Func(Of T, Boolean))(b, e) Return query.Where(lambda) End Function It works fine and is consumed in this way query = ETForGreaterThan(query, Value, propertyInfo) As you can see, I give it an IQueryable collection and it add a where clause to it, base on a property and a value. Y can construct Lessthan, LessOrEqualThan etc equivalents as Expression has this operators predefined. ¿How can I transform this code to do the same with strings? Expression don't give me a predefined operator like "contains" or "startwith" and I'm really noob with Expression trees. Thanks, and please Post your answer in C#/VB. Choose the one that make you feel more confortable.

    Read the article

  • Converting keys of an array/object-tree to lowercase

    - by tstenner
    Im currently optimizing a PHP application and found one function being called around 10-20k times, so I'd thought I'd start optimization there. function keysToLower($obj) { if(!is_object($obj) && !is_array($obj)) return $obj; foreach($obj as $key=>$element) { $element=keysToLower($element); if(is_object($obj)) { $obj->{strtolower($key)}=$element; if(!ctype_lower($key)) unset($obj->{$key}); } else if(is_array($obj) && ctype_upper($key)) { $obj[strtolower($key)]=$element; unset($obj[$key]); } } return $obj; } Most of the time is spent in recursive calls (which are quite slow in PHP), but I don't see any way to convert it to a loop. What would you do?

    Read the article

  • What is the most efficient approach to fetch category tree, products, brands, counts by subcategory

    - by alex227
    Symfony 1.4 + Doctrine 1.2. What is the best way to minimize the number of queries to retrieve products, subcategories of current category, product counts by subcategory and brand for the result set of the query below? Categories are a nested set. Here is my query: $q = Doctrine_Query::create() ->select('c.*, p.product,p.price, b.brand') ->from('Category c') ->leftJoin('c.Product p') ->leftJoin('p.Brand b') ->where ('c.root_id = ?', $this->category->getRootId()) ->andWhere('c.lft >= ?', $this->category->getLft()) ->andWhere('c.rgt <= ?', $this->category->getRgt()) ->setHydrationMode(Doctrine_Core::HYDRATE_ARRAY); $treeObject = Doctrine::getTable('Category')->getTree(); $treeObject->setBaseQuery($q); $this->treeObject = $treeObject; $treeObject->resetBaseQuery(); $this->products = $q->execute();

    Read the article

  • Storing tree data in Javascript

    - by Ozh
    I need to store data to represent this: Water + Fire = Steam Water + Earth = Mud Mud + Fire = Rock The goal is the following: I have draggable HTML divs, and when <div id="Fire"> and <div id="Mud"> overlap, I add <div id="Rock"> to the screen. Ever played Alchemy on iPhone or Android? Same stuff Right now, the way I'm doing this is a JS object : var stuff = { 'Steam' : { needs: [ 'Water', 'Fire'] }, 'Mud' : { needs: [ 'Water', 'Earth'] }, 'Rock' : { needs: [ 'Mud', 'Fire'] }, // etc... }; and every time a div overlaps with another one, I traverse the object keys and check the 'needs' array. I can deal with that structure but I was wondering if I could do any better? Edit: I should add that I also need to store a few other things, like a short description or an icon name. So typicall I have Steam: { needs: [ array ], desc: "short desc", icon:"steam.png"},

    Read the article

  • How to hide some nodes in Richfaces Tree (do not render nodes by condition)?

    - by VestniK
    I have a tree of categories and courses in my SEAM application. Courses may be active and inactive. I want to be able to show only active or all courses in my tree. I've decided to always build complete tree in my PAGE scope component since building this tree is quite expensive operation. I have boolean flag courseActive in the data wrapped by TreeNode<T>. Now I can't find the way to show courses node only if this flag is true. The best result I've achieved with the following code: <h:outputLabel for="showInactiveCheckbox" value="show all courses: "/> <h:selectBooleanCheckbox id="showInactiveCheckbox" value="#{categoryTreeEditorModel.showAllCoursesInTree}"> <a4j:support event="onchange" reRender="categoryTree"/> </h:selectBooleanCheckbox> <rich:tree id="categoryTree" value="#{categoryTree}" var="item" switchType="ajax" ajaxSubmitSelection="true" reRender="categoryTree,controls" adviseNodeOpened="#{categoryTreeActions.adviseRootOpened}" nodeSelectListener="#{categoryTreeActions.processSelection}" nodeFace="#{item.typeName}"> <rich:treeNode type="Category" icon="..." iconLeaf="..."> <h:outputText value="#{item.title}"/> </rich:treeNode> <rich:treeNode type="Course" icon="..." iconLeaf="..." rendered="#{item.courseActive or categoryTreeEditorModel.showAllCoursesInTree}"> <h:outputText rendered="#{item.courseActive}" value="#{item.title}"/> <h:outputText rendered="#{not item.courseActive}" value="#{item.title}" style="color:#{a4jSkin.inactiveTextColor}"/> </rich:treeNode> </rich:tree> the only problem is if some node is not listed in any rich:treeNode it just still shown with title obtained by Object.toString() method insted of being hidden. Does anybody know how to not show some nodes in the Richfases tree according to some condition?

    Read the article

  • How hide some nodes in Richfaces Tree (do not render nodes by condition)?

    - by VestniK
    I have a tree of categories and courses in my SEAM application. Courses may be active and inactive. I want to be able to show only active or all courses in my tree. I've decided to always build complete tree in my PAGE scope component since building this tree is quite expensive operation. I have boolean flag courseActive in the data wrapped by TreeNode<T>. Now I can't find the way to show courses node only if this flag is true. The best result I've achieved with the following code: <h:outputLabel for="showInactiveCheckbox" value="show all courses: "/> <h:selectBooleanCheckbox id="showInactiveCheckbox" value="#{categoryTreeEditorModel.showAllCoursesInTree}"> <a4j:support event="onchange" reRender="categoryTree"/> </h:selectBooleanCheckbox> <rich:tree id="categoryTree" value="#{categoryTree}" var="item" switchType="ajax" ajaxSubmitSelection="true" reRender="categoryTree,controls" adviseNodeOpened="#{categoryTreeActions.adviseRootOpened}" nodeSelectListener="#{categoryTreeActions.processSelection}" nodeFace="#{item.typeName}"> <rich:treeNode type="Category" icon="..." iconLeaf="..."> <h:outputText value="#{item.title}"/> </rich:treeNode> <rich:treeNode type="Course" icon="..." iconLeaf="..." rendered="#{item.courseActive or categoryTreeEditorModel.showAllCoursesInTree}"> <h:outputText rendered="#{item.courseActive}" value="#{item.title}"/> <h:outputText rendered="#{not item.courseActive}" value="#{item.title}" style="color:#{a4jSkin.inactiveTextColor}"/> </rich:treeNode> </rich:tree> the only problem is if some node is not listed in any rich:treeNode it just still shown with title obtained by Object.toString() method insted of being hidden. Does anybody know how to not show some nodes in the Richfases tree according to some condition?

    Read the article

  • c++ templates and inheritance

    - by Armen Ablak
    Hey, I'm experiencing some problems with breaking my code to reusable parts using templates and inheritance. I'd like to achieve that my tree class and avltree class use the same node class and that avltree class inherits some methods from the tree class and adds some specific ones. So I came up with the code below. Compiler throws an error in tree.h as marked below and I don't really know how to overcome this. Any help appreciated! :) node.h: #ifndef NODE_H #define NODE_H #include "tree.h" template <class T> class node { T data; ... node() ... friend class tree<T>; }; #endif tree.h #ifndef DREVO_H #define DREVO_H #include "node.h" template <class T> class tree { public: //signatures tree(); ... void insert(const T&); private: node<T> *root; //missing type specifier - int assumed. Note: C++ does not support default-int }; //implementations #endif avl.h #ifndef AVL_H #define AVL_H #include "tree.h" #include "node.h" template <class T> class avl: public tree<T> { public: //specific int findMin() const; ... protected: void rotateLeft(node<T> *)const; private: node<T> *root; }; #endif avl.cpp (I tried separating headers from implementation, it worked before I started to combine avl code with tree code) #include "drevo" #include "avl.h" #include "vozlisce.h" template class avl<int>; //I know that only avl with int can be used like this, but currently this is doesn't matter :) //implementations ...

    Read the article

  • Efficient representation of Hierarchies in Hibernate.

    - by Alison G
    I'm having some trouble representing an object hierarchy in Hibernate. I've searched around, and haven't managed to find any examples doing this or similar - you have my apologies if this is a common question. I have two types which I'd like to persist using Hibernate: Groups and Items. * Groups are identified uniquely by a combination of their name and their parent. * The groups are arranged in a number of trees, such that every Group has zero or one parent Group. * Each Item can be a member of zero or more Groups. Ideally, I'd like a bi-directional relationship allowing me to get: * all Groups that an Item is a member of * all Items that are a member of a particular Group or its descendants. I also need to be able to traverse the Group tree from the top in order to display it on the UI. The basic object structure would ideally look like this: class Group { ... /** @return all items in this group and its descendants */ Set<Item> getAllItems() { ... } /** @return all direct children of this group */ Set<Group> getChildren() { ... } ... } class Item { ... /** @return all groups that this Item is a direct member of */ Set<Group> getGroups() { ... } ... } Originally, I had just made a simple bi-directional many-to-many relationship between Items and Groups, such that fetching all items in a group hierarchy required recursion down the tree, and fetching groups for an Item was a simple getter, i.e.: class Group { ... private Set<Item> items; private Set<Group> children; ... /** @return all items in this group and its descendants */ Set<Item> getAllItems() { Set<Item> allItems = new HashSet<Item>(); allItems.addAll(this.items); for(Group child : this.getChildren()) { allItems.addAll(child.getAllItems()); } return allItems; } /** @return all direct children of this group */ Set<Group> getChildren() { return this.children; } ... } class Item { ... private Set<Group> groups; /** @return all groups that this Item is a direct member of */ Set<Group> getGroups() { return this.groups; } ... } However, this resulted in multiple database requests to fetch the Items in a Group with many descendants, or for retrieving the entire Group tree to display in the UI. This seems very inefficient, especially with deeper, larger group trees. Is there a better or standard way of representing this relationship in Hibernate? Am I doing anything obviously wrong or stupid? My only other thought so far was this: Replace the group's id, parent and name fields with a unique "path" String which specifies the whole ancestry of a group, e.g.: /rootGroup /rootGroup/aChild /rootGroup/aChild/aGrandChild The join table between Groups and Items would then contain group_path and item_id. This immediately solves the two issues I was suffering previously: 1. The entire group hierarchy can be fetched from the database in a single query and reconstructed in-memory. 2. To retrieve all Items in a group or its descendants, we can select from group_item where group_path='N' or group_path like 'N/%' However, this seems to defeat the point of using Hibernate. All thoughts welcome!

    Read the article

  • How can I create a new branch in git from an existing file tree?

    - by pkaeding
    I am looking to add an existing file tree to a git repository as a new branch (I can't just copy the existing tree into my git tree, since the existing tree is versioned under a different VCS, and I am trying to sync them up). Is this possible? EDIT: Would setting up a new git repository, that is connected to the existing remote repository, and then moving the resulting .git folder work? That seems really hackish, but if that's the way to do it...

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >