Search Results

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

Page 57/164 | < Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >

  • XML: When to use attributes instead of child nodes?

    - by Rosarch
    For tree leaves in XML, when is it better to use attributes, and when is it better to use descendant nodes? For example, in the following XML document: <?xml version="1.0" encoding="utf-8" ?> <savedGame> <links> <link rootTagName="zombies" packageName="zombie" /> <link rootTagName="ghosts" packageName="ghost" /> <link rootTagName="players" packageName="player" /> <link rootTagName="trees" packageName="tree" /> </links> <locations> <zombies> <zombie> <positionX>41</positionX> <positionY>100</positionY> </zombie> <zombie> <positionX>55</positionX> <positionY>56</positionY> </zombie> </zombies> <ghosts> <ghost> <positionX>11</positionX> <positionY>90</positionY> </ghost> </ghosts> </locations> </savedGame> The <link> tag has attributes, but it could also be written as: <link> <rootTagName>trees</rootTagName> <packageName>tree</packageName> </link> Similarly, the location tags could be written as: <zombie positionX="55" positionY="56" /> instead of: <zombie> <positionX>55</positionX> <positionY>56</positionY> </zombie> What reasons are there to prefer one over the other? Is it just a stylistic issue? Any performance considerations?

    Read the article

  • How to find NSOutlineView row index when using NSTreeController

    - by velocityb0y
    I'm using an NSTreeController to manage nodes for an NSOutlineView. When the user adds a new item, I create a new object and insert it: EntityViewEntityNode *newNode = [EntityViewEntityNode nodeWithName:@"New entity" entity:newObject]; // Insert at end of group // NSIndexPath *insertAt = [pathOfGroupNode indexPathByAddingIndex:[selected.children count]]; [entityCollectionTreeController insertObject:newNode atArrangedObjectIndexPath:insertAt]; Now I'd like to open the table column for edit so the user can name the new item. This seems logical: NSInteger row = [entityCollectionOutlineView rowForItem:newNode]; [entityCollectionOutlineView editColumn:0 row:row withEvent:nil select:YES]; However, row is always -1 indicating the object isn't found. Poking around reveals that the tree controller is not actually putting my objects directly in the tree, but is wrapping them in a node object of its own. Anyone have insight into how I would go about getting a row index relative to the outline view, so I can do this (without, hopefully, enumerating everything in the outline view and figuring out the mapping back to my node?)

    Read the article

  • C++ Unlocking a std::mutex before calling std::unique_lock wait

    - by Sant Kadog
    I have a multithreaded application (using std::thread) with a manager (class Tree) that executes some piece of code on different subtrees (embedded struct SubTree) in parallel. The basic idea is that each instance of SubTree has a deque that store objects. If the deque is empty, the thread waits until a new element is inserted in the deque or the termination criteria is reached. One subtree can generate objects and push them in the deque of another subtree. For convenience, all my std::mutex, std::locks and std::variable_condition are stored in a struct called "locks". The class Tree creates some threads that run the following method (first attempt) : void Tree::launch(SubTree & st, Locks & locks ) { /* some code */ std::lock_guard<std::mutex> deque_lock(locks.deque_mutex_[st.id_]) ; // lock the access to the deque of subtree st if (st.deque_.empty()) // check that the deque is still empty { // some threads are still running, wait for them to terminate std::unique_lock<std::mutex> wait_lock(locks.restart_mutex_[st.id_]) ; locks.restart_condition_[st.id_].wait(wait_lock) ; } /* some code */ } The problem is that "deque_lock" is still locked while the thread is waiting. Hence no object can be added in the deque of the current thread by a concurrent one. So I turned the lock_guard into a unique_lock and managed the lock/unlock manually : void launch(SubTree & st, Locks & locks ) { /* some code */ std::unique_lock<std::mutex> deque_lock(locks.deque_mutex_[st.id_]) ; // lock the access to the deque of subtree st if (st.deque_.empty()) // check that the deque is still empty { deque_lock.unlock() ; // unlock the access to the deque to enable the other threads to add objects // DATA RACE : nothing must happen to the unprotected deque here !!!!!! // some threads are still running, wait for them to terminate std::unique_lock<std::mutex> wait_lock(locks.restart_mutex_[st.id_]) ; locks.restart_condition_[st.id_].wait(wait_lock) ; } /* some code */ } The problem now, is that there is a data race, and I would like to make sure that the "wait" instruction is performed directly after the "deque_lock.unlock()" one. Would anyone know a way to create such a critical instruction sequence with the standard library ? Thanks in advance.

    Read the article

  • How to structure class to support imported 3d model ?

    - by brainydexter
    Hello, I've written a C++ library that reads in this 3d model file (collada DAE). uptil now, I would output a list of triangles and handle each at rendering stage. But now, I need to attach some Bounding sphere information with the imported model. I need some advice on how should I organize this in code. Here are some specs of the 3D file format: - 3D model is represented as a Tree consisting of nodes - each node can contain other nodes, geometry information, transformation etc My requirements: - a bounding sphere associated with each node, thereby yielding a tree of bounding sphere hierarchy for the model itself. - actual vertex information What would be the recommended way to deal with this situation? Thanks

    Read the article

  • Best way to Fingerprint and Verify html structure.

    - by Lukas Šalkauskas
    Hello there, I just want to know what is your opinion about how to fingerprint/verify html/links structure. The problem I want to solve is: fingerprint for example 10 different sites, html pages. And after some time I want to have possibility to verify them, so is, if site has been changed, links changed, verification fails, othervise verification success. My base Idea is to analyze link structure by splitting it in some way, doing some kind of tree, and from that tree generate some kind of code. But I'm still in brainstorm stage, where I need to discuss this with someone, and know other ideas. So any ideas, algos, and suggestions would be usefull.

    Read the article

  • Difference between halo and mx namespace

    - by Andree
    Hi there ! As far as I know, the support for library://ns.adobe.com/flex/halo namespace has been dropped, and now we have to use library://ns.adobe.com/flex/mx instead (reference). Can someone provide if there's any difference between the two namespaces? I am just starting to learn Flex and this change make me confused. For example, if I have an <mx:Tree> tag in my mxml document, the compiler complains that <mx:Tree> could not be resolved to a component implementation. But if I change my mx namespace to use the old one instead (halo), it successfully compiled without error. Thanks. Andree Updated: By the way, I use Flex SDK command line compiler in Windows. mxmlc --version Version 4.0.0 build 10485

    Read the article

  • String of KML needs to be converted to java objects

    - by spartikus
    I have a string of kml coming in on a request object. I have used xjc to create the kml java objects. I am looking for an easy way to create the kml nested java objects from this string. I could parse the string and create each object in the tree by hand but wouldn't it be cool if there was a library or something that would create the java objects for me? Something like KmlType type = parseKML(mykmlStringFromTheRequest); Then type would be a Tree of kml objects. Thanks for the help all.

    Read the article

  • python lxml problem

    - by David ???
    I'm trying to print/save a certain element's HTML from a web-page. I've retrieved the requested element's XPath from firebug. All I wish is to save this element to a file. I don't seem to succeed in doing so. (tried the XPath with and without a /text() at the end) I would appreciate any help, or past experience. 10x, David import urllib2,StringIO from lxml import etree url='http://www.tutiempo.net/en/Climate/Londres_Heathrow_Airport/12-2009/37720.htm' seite = urllib2.urlopen(url) html = seite.read() seite.close() parser = etree.HTMLParser() tree = etree.parse(StringIO.StringIO(html), parser) xpath = "/html/body/table/tbody/tr/td[2]/div/table/tbody/tr[6]/td/table/tbody/tr/td[3]/table/tbody/tr[3]/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/text()" elem = tree.xpath(xpath) print elem[0].strip().encode("utf-8")

    Read the article

  • TreeNodes don't get collected with weakevent solution

    - by Marcus
    Hi, When I use this method http://stackoverflow.com/questions/1089309/weak-events-in-net (by Egor) to hook up a event i a inherited treenode, the tree node never gets collected, is there any speciall case with tree nodes and GC? public class MyTreeNode : TreeNode { public MyTreeNode(Entity entity) { entity.Children.ListChanged += new ListChangedEventHandler(entityChildren_ListChanged).MakeWeak(eh => entity.Children.ListChanged -= eh); } } Entity.Children is a bindinglist. I made tests with a destructor on MyTreeNode and invoking GC.Collect(), with the weak eventhandler the treenode never gets collected but i DOES get collected WIHTOUT the weak eventhandler.

    Read the article

  • Learning Algorithms and Data Structures Fundamentals

    - by valya
    Can you recommend me a book or (better!) a site with many hard problems and exercises about data structures? I'm already answering project Euler questions, but these questions are about interesting, but uncommon algorithms. I hardly used even a simple tree. Maybe there is a site with exercises like: hey, you need to calculate this: ... . Do it using a tree. Now do it using a zipper. Upload your C (Haskell, Lisp, even Pascal or Fortress go) solution. Oh, your solution is so slow! Self-education is very hard then you trying to learn very common, fundamental things. How can I help myself with them without attending to courses or whatever?

    Read the article

  • etree.findall: 'OR'-lookup?

    - by piquadrat
    I want to find all stylesheet definitions in a XHTML file with lxml.etree.findall. This could be as simple as elems = tree.findall('link[@rel="stylesheet"]') + tree.findall('style') But the problem with CSS style definitions is that the order matters, e.g. <link rel="stylesheet" type="text/css" href="/media/css/first.css" /> <style>body:{font-size: 10px;}</style> <link rel="stylesheet" type="text/css" href="/media/css/second.css" /> if the contents of the style tag is applied after the rules in the two link tags, the result may be completely different from the one where the rules are applied in order of definition. So, how would I do a lookup that inlcudes both link[@rel="stylesheet"] and style?

    Read the article

  • An Efficient data structure for Sorted List

    - by holydiver
    I want to save my objects according to a key in the attributes of my object in a sorted fashion. Later on I'll access these objects sequentially from max key to min key. I'll do some search tasks as well. I consider to use either AVL tree or RB Tree. As far as i know they are nearly equivalent in theory(Both have O(logn)). But in practice which one might be better in performance in my situation. And is there a better alternative than those, considering that I'll mostly do insert and sequentially access to the ds.

    Read the article

  • Programatically Drop an External Div in JSTree

    - by Ted Mosbey
    I have a grid (slickgrid) which creates and destroys rows on the fly. I know jstree uses .jstree-draggable to find the external drag targets, but applying them to the grid rows doesn't work - such that I've thought of using the grid drag, and on finish of the grid drag I want to call the jstree "drag_finish": function (data) jQuery.jstree._reference($("#Tree")).dnd_finish(); The problem is that there is some null data. How would I Programatically Drop an External Div? How does jstree apply the .jstree-draggable targets? I could add the .jstree-draggable class to the grid drag helper, but it doesnt seem to fire when dropped on the tree although it clearly has the class. Any guidance would be greatly appreciated. Regards.

    Read the article

  • How to unit test internals (organization) of a data structure?

    - by Herms
    I've started working on a little ruby project that will have sample implementations of a number of different data structures and algorithms. Right now it's just for me to refresh on stuff I haven't done for a while, but I'm hoping to have it set up kind of like Ruby Koans, with a bunch of unit tests written for the data structures but the implementations empty (with full implementations in another branch). It could then be used as a nice learning tool or code kata. However, I'm having trouble coming up with a good way to write the tests. I can't just test the public behavior as that won't necessarily tell me about the implementation, and that's kind of important here. For example, the public interfaces of a normal BST and a Red-Black tree would be the same, but the RB Tree has very specific data organization requirements. How would I test that?

    Read the article

  • Why does IE prompt a security warning when viewing an XML file?

    - by Tav
    Opening an XML file in Internet explorer gives a security warning. IE has a nice collapsible tree view for viewing XML, but it's disabled by default and you get this scary error message about a potential security hole. http://www.leonmeijer.nl/archive/2008/04/27/106.aspx But why? How can simply viewing an XML file (not running any embedded macros in it or anything) possibly be a security hole? Sure, I get that running XSLT could potentially do some bad stuff, but we're not talking about executing anything. We're talking about viewing. Why can't IE simply display the XML file as text (plus with the collapsible tree viewer)? So why did they label this as a security hole? Can someone describe how simply viewing an XML document could be used as an attack document?

    Read the article

  • Swing: what to do when a GUI update takes too long and freezes other GUI elements?

    - by java.is.for.desktop
    Hello, everyone! I know that GUI code in Java Swing must be put inside SwingUtilities.invokeAndWait or SwingUtilities.invokeLater. This way threading works fine. Sadly, in my situation, the GUI update it that thing which takes much longer than background thread(s). More specific: I update a JTree with about just 400 entries, nesting depth is maximum 4, so should be nothing scary, right? But it takes sometimes one second! I need to ensure that the user is able to type in a JTextPane without delays. Well, guess what, the slow JTree updates do cause delays for JTextPane during input. It refreshes only as soon as the tree gets updated. I am using Netbeans and know empirically that a Java app can update lots of information without freezing the rest of the UI. How can it be done? NOTE 1: All those DefaultMutableTreeNodes are prepared outside the invokeAndWait. NOTE 2: When I replace invokeAndWait with invokeLater the tree doesn't get updated.

    Read the article

  • Understanding run time code interpretation and execution

    - by Bob
    I'm creating a game in XNA and was thinking of creating my own scripting language (extremely simple mind you). I know there's better ways to go about this (and that I'm reinventing the wheel), but I want the learning experience more than to be productive and fast. When confronted with code at run time, from what I understand, the usual approach is to parse into a machine code or byte code or something else that is actually executable and then execute that, right? But, for instance, when Chrome first came out they said their JavaScript engine was fast because it compiles the JavaScript into machine code. This implies other engines weren't compiling into machine code. I'd prefer not compiling to a lower language, so are there any known modern techniques for parsing and executing code without compiling to low level? Perhaps something like parsing the code into some sort of tree, branching through the tree, and comparing each symbol and calling some function that handles that symbol? (Wild guessing and stabbing in the dark)

    Read the article

  • Freezable DataContext

    - by grid-wpf-architect
    Hi, I have a customControl like ListView and I need to bind the sub property of my Custom Control to the visual tree element like below, <StackPanel> <TextBlock Text="Test" x:Name="txtBlock" /> <local:MyControl> <local:MyControl.Items> <local:MyControlItem Value ="{Binding ElementName=txtBlock, Path=Text}" /> </local:MyControl.Items> </local:MyControl> </StackPanel> I can access the object using Freezable object as the resource, but i want to inherit Freezable in my MyControlItem and access the Visual Tree.

    Read the article

  • Ant - using vssadd to add multiple file

    - by mamendex
    Hi, I'm trying to use vssadd task to add a tree of source files to a recent created project on VSS. But it happens to be adding only the folder tree, all files missing. <vsscp vsspath="$/DEV/APL_${version}" ssdir="${vssapl}" serverPath="${vsssvr}"/> The vssadd task displays the name of the folders it's creating: ... (vssadd) $/DEV/APL_0.0.10c/src/domain: (vssadd) $/DEV/APL_0.0.10c/src/mbeans: (vssadd) $/DEV/APL_0.0.10c/src/service: ... The script runs successfully but the files never get in the repository. Trying to use wilcards are no good, the task says it found no matching files and ss returns with a code of 100: <vssadd ssdir="${vssapl}" localPath="C:\Workspace\APL_Build*.*" recursive="true" serverPath="${vsssvr}" comment="Build ${versao} at ${to.timestamp}"/ I've noticed that vssadd does not accept fileset tag either, so I'm kind of lost here. Any tips? tks

    Read the article

  • Reverse Bredth First Search in C#

    - by Ngu Soon Hui
    Anyone has a ready implementation of the Reverse Bredth First Search algorithm in C#? By Reverse Bredth First Search, I mean instead of searching a tree starting from a common node, I want to search the tree from the bottom and gradually converged to a common node. Let's see the below figure, this is the output of a Bredth First Search: In my reverse bredth first search, 9,10,11 and 12 will be the first few nodes found ( the order of them are not important as they are all first order). 5, 6, 7 and 8 are the second few nodes found, and so on. 1 would be the last node found. Any ideas or pointers?

    Read the article

  • Reverse Breadth First traversal in C#

    - by Ngu Soon Hui
    Anyone has a ready implementation of the Reverse Breadth First traversal algorithm in C#? By Reverse Breadth First traversal , I mean instead of searching a tree starting from a common node, I want to search the tree from the bottom and gradually converged to a common node. Let's see the below figure, this is the output of a Breadth First traversal : In my reverse breadth first traversal , 9,10,11 and 12 will be the first few nodes found ( the order of them are not important as they are all first order). 5, 6, 7 and 8 are the second few nodes found, and so on. 1 would be the last node found. Any ideas or pointers? Edit: Change "Breadth First Search" to "Breadth First traversal" to clarify the question

    Read the article

  • How to print an Objectified Element?

    - by BeeBand
    I have xml of the format: <channel> <games> <game slot='1'> <id>Bric A Bloc</id> <title-text>BricABloc Hoorah</title-text> <link>Fruit Splat</link> </game> </games> </channel> I've parsed this xml using lxml.objectify, via: tree = objectify.parse(file) There will potentially be a number of <game>s underneath <games>. I understand that I can generate a list of <game> objects via: [ tree.games[0].game[0:4] ] My question is, what class are those objects and is there a function to print any object of whatever class these objects belong to?

    Read the article

  • Reverse Breath First Search in C#

    - by Ngu Soon Hui
    Anyone has a ready implementation of the Reverse Breath First Search algorithm in C#? By Reverse Breath First Search, I mean instead of searching a tree starting from a common node, I want to search the tree from the bottom and gradually converged to a common node. Let's see the below figure, this is the output of a Breath First Search: In my reverse breath first search, 9,10,11 and 12 will be the first few nodes found ( the order of them are not important as they are all first order). 5, 6, 7 and 8 are the second few nodes found, and so on. 1 would be the last node found. Any ideas or pointers?

    Read the article

< Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >